blob: 169b3837af52b6ae098dfd5df559cfcf0abc8309 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
31#include "hda_codec.h"
32#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090033#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Kailang Yangccc656c2006-10-17 12:32:26 +020035#define ALC880_FRONT_EVENT 0x01
36#define ALC880_DCVOL_EVENT 0x02
37#define ALC880_HP_EVENT 0x04
38#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40/* ALC880 board config type */
41enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 ALC880_3ST,
43 ALC880_3ST_DIG,
44 ALC880_5ST,
45 ALC880_5ST_DIG,
46 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020047 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020048 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020049 ALC880_6ST_DIG,
50 ALC880_F1734,
51 ALC880_ASUS,
52 ALC880_ASUS_DIG,
53 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010054 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010055 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020056 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020057 ALC880_UNIWILL,
58 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010059 ALC880_CLEVO,
60 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010061 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010062 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020063 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020064#ifdef CONFIG_SND_DEBUG
65 ALC880_TEST,
66#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010067 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020068 ALC880_MODEL_LAST /* last tag */
69};
70
71/* ALC260 models */
72enum {
73 ALC260_BASIC,
74 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020075 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010076 ALC260_HP_3013,
77 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010078 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020079 ALC260_WILL,
80 ALC260_REPLACER_672V,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010081#ifdef CONFIG_SND_DEBUG
82 ALC260_TEST,
83#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010084 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020085 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070086};
87
Kailang Yangdf694da2005-12-05 19:42:22 +010088/* ALC262 models */
89enum {
90 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020091 ALC262_HIPPO,
92 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010093 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020094 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010095 ALC262_HP_BPC_D7000_WL,
96 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010097 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +010098 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +020099 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200100 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200101 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200102 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100103 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200104 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200105 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200106 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000107 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100108 ALC262_AUTO,
109 ALC262_MODEL_LAST /* last tag */
110};
111
Kailang Yanga361d842007-06-05 12:30:55 +0200112/* ALC268 models */
113enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200114 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200115 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200116 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200117 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100118 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200119 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100120 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100121 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100122#ifdef CONFIG_SND_DEBUG
123 ALC268_TEST,
124#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200125 ALC268_AUTO,
126 ALC268_MODEL_LAST /* last tag */
127};
128
Kailang Yangf6a92242007-12-13 16:52:54 +0100129/* ALC269 models */
130enum {
131 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200132 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200133 ALC269_ASUS_EEEPC_P703,
134 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100135 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000136 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100137 ALC269_AUTO,
138 ALC269_MODEL_LAST /* last tag */
139};
140
Kailang Yangdf694da2005-12-05 19:42:22 +0100141/* ALC861 models */
142enum {
143 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200144 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100145 ALC861_3ST_DIG,
146 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200147 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200148 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200149 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100150 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100151 ALC861_AUTO,
152 ALC861_MODEL_LAST,
153};
154
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100155/* ALC861-VD models */
156enum {
157 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200158 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100159 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160 ALC861VD_3ST,
161 ALC861VD_3ST_DIG,
162 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200163 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200164 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200165 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100166 ALC861VD_AUTO,
167 ALC861VD_MODEL_LAST,
168};
169
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200170/* ALC662 models */
171enum {
172 ALC662_3ST_2ch_DIG,
173 ALC662_3ST_6ch_DIG,
174 ALC662_3ST_6ch,
175 ALC662_5ST_DIG,
176 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200177 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100178 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200179 ALC663_ASUS_M51VA,
180 ALC663_ASUS_G71V,
181 ALC663_ASUS_H13,
182 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200183 ALC662_ECS,
184 ALC663_ASUS_MODE1,
185 ALC662_ASUS_MODE2,
186 ALC663_ASUS_MODE3,
187 ALC663_ASUS_MODE4,
188 ALC663_ASUS_MODE5,
189 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200190 ALC662_AUTO,
191 ALC662_MODEL_LAST,
192};
193
Kailang Yangdf694da2005-12-05 19:42:22 +0100194/* ALC882 models */
195enum {
196 ALC882_3ST_DIG,
197 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200198 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200199 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200200 ALC882_TARGA,
201 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200202 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100203 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200204 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200205 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200206 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100207 ALC882_MODEL_LAST,
208};
209
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200210/* ALC883 models */
211enum {
212 ALC883_3ST_2ch_DIG,
213 ALC883_3ST_6ch_DIG,
214 ALC883_3ST_6ch,
215 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200216 ALC883_TARGA_DIG,
217 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200218 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200219 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800220 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200221 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200222 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100223 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200224 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200225 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200226 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200227 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200228 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200229 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100230 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100231 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100232 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100233 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800234 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200235 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200236 ALC888_ASUS_M90V,
237 ALC888_ASUS_EEE1601,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100238 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200239 ALC883_AUTO,
240 ALC883_MODEL_LAST,
241};
242
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200243/* styles of capture selection */
244enum {
245 CAPT_MUX = 0, /* only mux based */
246 CAPT_MIX, /* only mixer based */
247 CAPT_1MUX_MIX, /* first mux and other mixers */
248};
249
Kailang Yangdf694da2005-12-05 19:42:22 +0100250/* for GPIO Poll */
251#define GPIO_MASK 0x03
252
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253struct alc_spec {
254 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100255 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100257 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100258 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
Kailang Yangdf694da2005-12-05 19:42:22 +0100260 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200261 * don't forget NULL
262 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200263 */
264 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
Takashi Iwai16ded522005-06-10 19:58:24 +0200266 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 struct hda_pcm_stream *stream_analog_playback;
268 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100269 struct hda_pcm_stream *stream_analog_alt_playback;
270 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200272 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 struct hda_pcm_stream *stream_digital_playback;
274 struct hda_pcm_stream *stream_digital_capture;
275
276 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200277 struct hda_multi_out multiout; /* playback set-up
278 * max_channels, dacs must be set
279 * dig_out_nid and hp_nid are optional
280 */
Takashi Iwai63300792008-01-24 15:31:36 +0100281 hda_nid_t alt_dac_nid;
Takashi 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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Iwaic8b6bf92005-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-02-09 12:01:26 +01005733#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005734 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Woithe7cf51e482006-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 Iwaic8b6bf92005-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 Iwai96fe7cc82007-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 Iwai96fe7cc82007-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 Iwai96fe7cc82007-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 Iwaib3bdb302009-02-18 13:16:26 +01008548 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC883_AUTO),
Takashi Iwai94683502009-02-13 09:31:20 +01008549 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC883_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01008550 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
8551 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008552 /* default Acer */
8553 SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER),
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008554 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008555 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008556 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8557 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008558 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01008559 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008560 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008561 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01008562 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008563 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008564 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008565 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008566 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008567 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008568 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8569 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008570 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008571 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008572 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008573 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8574 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8575 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008576 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008577 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008578 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008579 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8580 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8581 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8582 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8583 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8584 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8585 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8586 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8587 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008588 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8589 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008590 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01008591 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008592 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008593 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008594 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008595 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008596 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008597 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8598 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaidea0a502009-02-09 17:14:52 +01008599 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008600 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008601 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaif67d8172009-02-04 23:30:19 +01008602 SND_PCI_QUIRK(0x1734, 0x1107, "FSC AMILO Xi2550",
8603 ALC883_FUJITSU_PI2515),
Jiang zhefb97dc62008-03-06 11:07:11 +01008604 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008605 SND_PCI_QUIRK(0x1734, 0x113d, "Fujitsu AMILO Xa3530",
8606 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02008607 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008608 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008609 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8610 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008611 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008612 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008613 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008614 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008615 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008616 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8617 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11008618 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Wu Fengguang4b558992009-01-12 09:18:58 +08008619 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008620 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008621 {}
8622};
8623
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008624static hda_nid_t alc1200_slave_dig_outs[] = {
8625 ALC883_DIGOUT_NID, 0,
8626};
8627
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008628static struct alc_config_preset alc883_presets[] = {
8629 [ALC883_3ST_2ch_DIG] = {
8630 .mixers = { alc883_3ST_2ch_mixer },
8631 .init_verbs = { alc883_init_verbs },
8632 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8633 .dac_nids = alc883_dac_nids,
8634 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008635 .dig_in_nid = ALC883_DIGIN_NID,
8636 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8637 .channel_mode = alc883_3ST_2ch_modes,
8638 .input_mux = &alc883_capture_source,
8639 },
8640 [ALC883_3ST_6ch_DIG] = {
8641 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8642 .init_verbs = { alc883_init_verbs },
8643 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8644 .dac_nids = alc883_dac_nids,
8645 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008646 .dig_in_nid = ALC883_DIGIN_NID,
8647 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8648 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008649 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008650 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008651 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008652 [ALC883_3ST_6ch] = {
8653 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8654 .init_verbs = { alc883_init_verbs },
8655 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8656 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008657 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8658 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008659 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008660 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008661 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008662 [ALC883_3ST_6ch_INTEL] = {
8663 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8664 .init_verbs = { alc883_init_verbs },
8665 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8666 .dac_nids = alc883_dac_nids,
8667 .dig_out_nid = ALC883_DIGOUT_NID,
8668 .dig_in_nid = ALC883_DIGIN_NID,
8669 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8670 .channel_mode = alc883_3ST_6ch_intel_modes,
8671 .need_dac_fix = 1,
8672 .input_mux = &alc883_3stack_6ch_intel,
8673 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008674 [ALC883_6ST_DIG] = {
8675 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8676 .init_verbs = { alc883_init_verbs },
8677 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8678 .dac_nids = alc883_dac_nids,
8679 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008680 .dig_in_nid = ALC883_DIGIN_NID,
8681 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8682 .channel_mode = alc883_sixstack_modes,
8683 .input_mux = &alc883_capture_source,
8684 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008685 [ALC883_TARGA_DIG] = {
8686 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8687 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8688 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8689 .dac_nids = alc883_dac_nids,
8690 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008691 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8692 .channel_mode = alc883_3ST_6ch_modes,
8693 .need_dac_fix = 1,
8694 .input_mux = &alc883_capture_source,
8695 .unsol_event = alc883_tagra_unsol_event,
8696 .init_hook = alc883_tagra_automute,
8697 },
8698 [ALC883_TARGA_2ch_DIG] = {
8699 .mixers = { alc883_tagra_2ch_mixer},
8700 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8701 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8702 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008703 .adc_nids = alc883_adc_nids_alt,
8704 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008705 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008706 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8707 .channel_mode = alc883_3ST_2ch_modes,
8708 .input_mux = &alc883_capture_source,
8709 .unsol_event = alc883_tagra_unsol_event,
8710 .init_hook = alc883_tagra_automute,
8711 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008712 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008713 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008714 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8715 * and the headphone jack. Turn this on and rely on the
8716 * standard mute methods whenever the user wants to turn
8717 * these outputs off.
8718 */
8719 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8720 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8721 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008722 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8723 .channel_mode = alc883_3ST_2ch_modes,
8724 .input_mux = &alc883_capture_source,
8725 },
Tobin Davis2880a862007-08-07 11:50:26 +02008726 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008727 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008728 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008729 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8730 .dac_nids = alc883_dac_nids,
8731 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008732 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8733 .channel_mode = alc883_3ST_2ch_modes,
8734 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008735 .unsol_event = alc883_acer_aspire_unsol_event,
8736 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008737 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008738 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008739 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008740 alc883_chmode_mixer },
8741 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8742 alc888_acer_aspire_4930g_verbs },
8743 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8744 .dac_nids = alc883_dac_nids,
8745 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8746 .adc_nids = alc883_adc_nids_rev,
8747 .capsrc_nids = alc883_capsrc_nids_rev,
8748 .dig_out_nid = ALC883_DIGOUT_NID,
8749 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8750 .channel_mode = alc883_3ST_6ch_modes,
8751 .need_dac_fix = 1,
8752 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008753 ARRAY_SIZE(alc888_2_capture_sources),
8754 .input_mux = alc888_2_capture_sources,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008755 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8756 .init_hook = alc888_acer_aspire_4930g_automute,
8757 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008758 [ALC883_MEDION] = {
8759 .mixers = { alc883_fivestack_mixer,
8760 alc883_chmode_mixer },
8761 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008762 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008763 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8764 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008765 .adc_nids = alc883_adc_nids_alt,
8766 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008767 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8768 .channel_mode = alc883_sixstack_modes,
8769 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008770 },
Kailang Yang272a5272007-05-14 11:00:38 +02008771 [ALC883_MEDION_MD2] = {
8772 .mixers = { alc883_medion_md2_mixer},
8773 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8774 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8775 .dac_nids = alc883_dac_nids,
8776 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008777 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8778 .channel_mode = alc883_3ST_2ch_modes,
8779 .input_mux = &alc883_capture_source,
8780 .unsol_event = alc883_medion_md2_unsol_event,
8781 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008782 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008783 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008784 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008785 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8786 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8787 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008788 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8789 .channel_mode = alc883_3ST_2ch_modes,
8790 .input_mux = &alc883_capture_source,
8791 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008792 [ALC883_CLEVO_M720] = {
8793 .mixers = { alc883_clevo_m720_mixer },
8794 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008795 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8796 .dac_nids = alc883_dac_nids,
8797 .dig_out_nid = ALC883_DIGOUT_NID,
8798 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8799 .channel_mode = alc883_3ST_2ch_modes,
8800 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008801 .unsol_event = alc883_clevo_m720_unsol_event,
8802 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008803 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008804 [ALC883_LENOVO_101E_2ch] = {
8805 .mixers = { alc883_lenovo_101e_2ch_mixer},
8806 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8807 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8808 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008809 .adc_nids = alc883_adc_nids_alt,
8810 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008811 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8812 .channel_mode = alc883_3ST_2ch_modes,
8813 .input_mux = &alc883_lenovo_101e_capture_source,
8814 .unsol_event = alc883_lenovo_101e_unsol_event,
8815 .init_hook = alc883_lenovo_101e_all_automute,
8816 },
Kailang Yang272a5272007-05-14 11:00:38 +02008817 [ALC883_LENOVO_NB0763] = {
8818 .mixers = { alc883_lenovo_nb0763_mixer },
8819 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8820 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8821 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008822 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8823 .channel_mode = alc883_3ST_2ch_modes,
8824 .need_dac_fix = 1,
8825 .input_mux = &alc883_lenovo_nb0763_capture_source,
8826 .unsol_event = alc883_medion_md2_unsol_event,
8827 .init_hook = alc883_medion_md2_automute,
8828 },
8829 [ALC888_LENOVO_MS7195_DIG] = {
8830 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8831 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8832 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8833 .dac_nids = alc883_dac_nids,
8834 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008835 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8836 .channel_mode = alc883_3ST_6ch_modes,
8837 .need_dac_fix = 1,
8838 .input_mux = &alc883_capture_source,
8839 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8840 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008841 },
8842 [ALC883_HAIER_W66] = {
8843 .mixers = { alc883_tagra_2ch_mixer},
8844 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8845 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8846 .dac_nids = alc883_dac_nids,
8847 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008848 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8849 .channel_mode = alc883_3ST_2ch_modes,
8850 .input_mux = &alc883_capture_source,
8851 .unsol_event = alc883_haier_w66_unsol_event,
8852 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008853 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008854 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008855 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008856 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008857 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8858 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008859 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8860 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008861 .need_dac_fix = 1,
8862 .input_mux = &alc883_capture_source,
8863 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008864 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008865 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008866 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8867 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8868 .dac_nids = alc883_dac_nids,
8869 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008870 .dig_in_nid = ALC883_DIGIN_NID,
8871 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8872 .channel_mode = alc883_sixstack_modes,
8873 .input_mux = &alc883_capture_source,
8874 .unsol_event = alc888_6st_dell_unsol_event,
8875 .init_hook = alc888_6st_dell_front_automute,
8876 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008877 [ALC883_MITAC] = {
8878 .mixers = { alc883_mitac_mixer },
8879 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8880 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8881 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008882 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8883 .channel_mode = alc883_3ST_2ch_modes,
8884 .input_mux = &alc883_capture_source,
8885 .unsol_event = alc883_mitac_unsol_event,
8886 .init_hook = alc883_mitac_automute,
8887 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008888 [ALC883_FUJITSU_PI2515] = {
8889 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8890 .init_verbs = { alc883_init_verbs,
8891 alc883_2ch_fujitsu_pi2515_verbs},
8892 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8893 .dac_nids = alc883_dac_nids,
8894 .dig_out_nid = ALC883_DIGOUT_NID,
8895 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8896 .channel_mode = alc883_3ST_2ch_modes,
8897 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8898 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8899 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8900 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +08008901 [ALC888_FUJITSU_XA3530] = {
8902 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
8903 .init_verbs = { alc883_init_verbs,
8904 alc888_fujitsu_xa3530_verbs },
8905 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8906 .dac_nids = alc883_dac_nids,
8907 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8908 .adc_nids = alc883_adc_nids_rev,
8909 .capsrc_nids = alc883_capsrc_nids_rev,
8910 .dig_out_nid = ALC883_DIGOUT_NID,
8911 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
8912 .channel_mode = alc888_4ST_8ch_intel_modes,
8913 .num_mux_defs =
8914 ARRAY_SIZE(alc888_2_capture_sources),
8915 .input_mux = alc888_2_capture_sources,
8916 .unsol_event = alc888_fujitsu_xa3530_unsol_event,
8917 .init_hook = alc888_fujitsu_xa3530_automute,
8918 },
Kailang Yange2757d52008-08-26 13:17:46 +02008919 [ALC888_LENOVO_SKY] = {
8920 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8921 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8922 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8923 .dac_nids = alc883_dac_nids,
8924 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008925 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8926 .channel_mode = alc883_sixstack_modes,
8927 .need_dac_fix = 1,
8928 .input_mux = &alc883_lenovo_sky_capture_source,
8929 .unsol_event = alc883_lenovo_sky_unsol_event,
8930 .init_hook = alc888_lenovo_sky_front_automute,
8931 },
8932 [ALC888_ASUS_M90V] = {
8933 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8934 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8935 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8936 .dac_nids = alc883_dac_nids,
8937 .dig_out_nid = ALC883_DIGOUT_NID,
8938 .dig_in_nid = ALC883_DIGIN_NID,
8939 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8940 .channel_mode = alc883_3ST_6ch_modes,
8941 .need_dac_fix = 1,
8942 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8943 .unsol_event = alc883_mode2_unsol_event,
8944 .init_hook = alc883_mode2_inithook,
8945 },
8946 [ALC888_ASUS_EEE1601] = {
8947 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008948 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008949 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8950 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8951 .dac_nids = alc883_dac_nids,
8952 .dig_out_nid = ALC883_DIGOUT_NID,
8953 .dig_in_nid = ALC883_DIGIN_NID,
8954 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8955 .channel_mode = alc883_3ST_2ch_modes,
8956 .need_dac_fix = 1,
8957 .input_mux = &alc883_asus_eee1601_capture_source,
8958 .unsol_event = alc883_eee1601_unsol_event,
8959 .init_hook = alc883_eee1601_inithook,
8960 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01008961 [ALC1200_ASUS_P5Q] = {
8962 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8963 .init_verbs = { alc883_init_verbs },
8964 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8965 .dac_nids = alc883_dac_nids,
8966 .dig_out_nid = ALC1200_DIGOUT_NID,
8967 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +08008968 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +01008969 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8970 .channel_mode = alc883_sixstack_modes,
8971 .input_mux = &alc883_capture_source,
8972 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008973};
8974
8975
8976/*
8977 * BIOS auto configuration
8978 */
8979static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8980 hda_nid_t nid, int pin_type,
8981 int dac_idx)
8982{
8983 /* set as output */
8984 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008985 int idx;
8986
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008987 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008988 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8989 idx = 4;
8990 else
8991 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008992 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8993
8994}
8995
8996static void alc883_auto_init_multi_out(struct hda_codec *codec)
8997{
8998 struct alc_spec *spec = codec->spec;
8999 int i;
9000
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009001 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009002 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009003 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009004 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009005 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02009006 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009007 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009008 }
9009}
9010
9011static void alc883_auto_init_hp_out(struct hda_codec *codec)
9012{
9013 struct alc_spec *spec = codec->spec;
9014 hda_nid_t pin;
9015
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009016 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009017 if (pin) /* connect to front */
9018 /* use dac 0 */
9019 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009020 pin = spec->autocfg.speaker_pins[0];
9021 if (pin)
9022 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009023}
9024
9025#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
9026#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
9027
9028static void alc883_auto_init_analog_input(struct hda_codec *codec)
9029{
9030 struct alc_spec *spec = codec->spec;
9031 int i;
9032
9033 for (i = 0; i < AUTO_PIN_LAST; i++) {
9034 hda_nid_t nid = spec->autocfg.input_pins[i];
9035 if (alc883_is_input_pin(nid)) {
9036 snd_hda_codec_write(codec, nid, 0,
9037 AC_VERB_SET_PIN_WIDGET_CONTROL,
9038 (i <= AUTO_PIN_FRONT_MIC ?
9039 PIN_VREF80 : PIN_IN));
9040 if (nid != ALC883_PIN_CD_NID)
9041 snd_hda_codec_write(codec, nid, 0,
9042 AC_VERB_SET_AMP_GAIN_MUTE,
9043 AMP_OUT_MUTE);
9044 }
9045 }
9046}
9047
Takashi Iwaif511b012008-08-15 16:46:42 +02009048#define alc883_auto_init_input_src alc882_auto_init_input_src
9049
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009050/* almost identical with ALC880 parser... */
9051static int alc883_parse_auto_config(struct hda_codec *codec)
9052{
9053 struct alc_spec *spec = codec->spec;
9054 int err = alc880_parse_auto_config(codec);
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009055 struct auto_pin_cfg *cfg = &spec->autocfg;
9056 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009057
9058 if (err < 0)
9059 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02009060 else if (!err)
9061 return 0; /* no config found */
9062
9063 err = alc_auto_add_mic_boost(codec);
9064 if (err < 0)
9065 return err;
9066
9067 /* hack - override the init verbs */
9068 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02009069
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009070 /* setup input_mux for ALC889 */
9071 if (codec->vendor_id == 0x10ec0889) {
9072 /* digital-mic input pin is excluded in alc880_auto_create..()
9073 * because it's under 0x18
9074 */
9075 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
9076 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
9077 struct hda_input_mux *imux = &spec->private_imux[0];
9078 for (i = 1; i < 3; i++)
9079 memcpy(&spec->private_imux[i],
9080 &spec->private_imux[0],
9081 sizeof(spec->private_imux[0]));
9082 imux->items[imux->num_items].label = "Int DMic";
9083 imux->items[imux->num_items].index = 0x0b;
9084 imux->num_items++;
9085 spec->num_mux_defs = 3;
9086 spec->input_mux = spec->private_imux;
9087 }
9088 }
9089
Takashi Iwai776e1842007-08-29 15:07:11 +02009090 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009091}
9092
9093/* additional initialization for auto-configuration model */
9094static void alc883_auto_init(struct hda_codec *codec)
9095{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009096 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009097 alc883_auto_init_multi_out(codec);
9098 alc883_auto_init_hp_out(codec);
9099 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009100 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009101 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02009102 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009103}
9104
9105static int patch_alc883(struct hda_codec *codec)
9106{
9107 struct alc_spec *spec;
9108 int err, board_config;
9109
9110 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
9111 if (spec == NULL)
9112 return -ENOMEM;
9113
9114 codec->spec = spec;
9115
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02009116 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
9117
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009118 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
9119 alc883_models,
9120 alc883_cfg_tbl);
9121 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009122 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
9123 "trying auto-probe from BIOS...\n");
9124 board_config = ALC883_AUTO;
9125 }
9126
9127 if (board_config == ALC883_AUTO) {
9128 /* automatic parse from the BIOS config */
9129 err = alc883_parse_auto_config(codec);
9130 if (err < 0) {
9131 alc_free(codec);
9132 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009133 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009134 printk(KERN_INFO
9135 "hda_codec: Cannot set up configuration "
9136 "from BIOS. Using base mode...\n");
9137 board_config = ALC883_3ST_2ch_DIG;
9138 }
9139 }
9140
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09009141 err = snd_hda_attach_beep_device(codec, 0x1);
9142 if (err < 0) {
9143 alc_free(codec);
9144 return err;
9145 }
9146
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009147 if (board_config != ALC883_AUTO)
9148 setup_preset(spec, &alc883_presets[board_config]);
9149
Kailang Yang2f893282008-05-27 12:14:47 +02009150 switch (codec->vendor_id) {
9151 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02009152 if (codec->revision_id == 0x100101) {
9153 spec->stream_name_analog = "ALC1200 Analog";
9154 spec->stream_name_digital = "ALC1200 Digital";
9155 } else {
9156 spec->stream_name_analog = "ALC888 Analog";
9157 spec->stream_name_digital = "ALC888 Digital";
9158 }
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009159 if (!spec->num_adc_nids) {
9160 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9161 spec->adc_nids = alc883_adc_nids;
9162 }
9163 if (!spec->capsrc_nids)
9164 spec->capsrc_nids = alc883_capsrc_nids;
9165 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009166 break;
9167 case 0x10ec0889:
9168 spec->stream_name_analog = "ALC889 Analog";
9169 spec->stream_name_digital = "ALC889 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009170 if (!spec->num_adc_nids) {
9171 spec->num_adc_nids = ARRAY_SIZE(alc889_adc_nids);
9172 spec->adc_nids = alc889_adc_nids;
9173 }
9174 if (!spec->capsrc_nids)
9175 spec->capsrc_nids = alc889_capsrc_nids;
9176 spec->capture_style = CAPT_1MUX_MIX; /* 1mux/Nmix-style
9177 capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009178 break;
9179 default:
9180 spec->stream_name_analog = "ALC883 Analog";
9181 spec->stream_name_digital = "ALC883 Digital";
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02009182 if (!spec->num_adc_nids) {
9183 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
9184 spec->adc_nids = alc883_adc_nids;
9185 }
9186 if (!spec->capsrc_nids)
9187 spec->capsrc_nids = alc883_capsrc_nids;
9188 spec->capture_style = CAPT_MIX; /* matrix-style capture */
Kailang Yang2f893282008-05-27 12:14:47 +02009189 break;
9190 }
9191
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009192 spec->stream_analog_playback = &alc883_pcm_analog_playback;
9193 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01009194 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009195
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009196 spec->stream_digital_playback = &alc883_pcm_digital_playback;
9197 spec->stream_digital_capture = &alc883_pcm_digital_capture;
9198
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009199 if (!spec->cap_mixer)
9200 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01009201 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009202
Takashi Iwai2134ea42008-01-10 16:53:55 +01009203 spec->vmaster_nid = 0x0c;
9204
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009205 codec->patch_ops = alc_patch_ops;
9206 if (board_config == ALC883_AUTO)
9207 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02009208
Takashi Iwaicb53c622007-08-10 17:21:45 +02009209#ifdef CONFIG_SND_HDA_POWER_SAVE
9210 if (!spec->loopback.amplist)
9211 spec->loopback.amplist = alc883_loopbacks;
9212#endif
Takashi Iwaidaead532008-11-28 12:55:36 +01009213 codec->proc_widget_hook = print_realtek_coef;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009214
9215 return 0;
9216}
9217
9218/*
Kailang Yangdf694da2005-12-05 19:42:22 +01009219 * ALC262 support
9220 */
9221
9222#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
9223#define ALC262_DIGIN_NID ALC880_DIGIN_NID
9224
9225#define alc262_dac_nids alc260_dac_nids
9226#define alc262_adc_nids alc882_adc_nids
9227#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01009228#define alc262_capsrc_nids alc882_capsrc_nids
9229#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01009230
9231#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01009232#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01009233
Kailang Yang4e555fe2008-08-26 13:05:55 +02009234static hda_nid_t alc262_dmic_adc_nids[1] = {
9235 /* ADC0 */
9236 0x09
9237};
9238
9239static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
9240
Kailang Yangdf694da2005-12-05 19:42:22 +01009241static struct snd_kcontrol_new alc262_base_mixer[] = {
9242 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9243 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9244 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9245 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9246 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9247 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9248 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9249 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009250 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009251 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9252 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009253 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009254 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
9255 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9256 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
9257 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01009258 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01009259};
9260
Kailang Yangccc656c2006-10-17 12:32:26 +02009261static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
9262 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9263 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9264 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9265 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9266 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9267 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9268 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9269 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009270 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009271 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9272 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009273 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009274 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
9275 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9276 { } /* end */
9277};
9278
Takashi Iwaice875f02008-01-28 18:17:43 +01009279/* update HP, line and mono-out pins according to the master switch */
9280static void alc262_hp_master_update(struct hda_codec *codec)
9281{
9282 struct alc_spec *spec = codec->spec;
9283 int val = spec->master_sw;
9284
9285 /* HP & line-out */
9286 snd_hda_codec_write_cache(codec, 0x1b, 0,
9287 AC_VERB_SET_PIN_WIDGET_CONTROL,
9288 val ? PIN_HP : 0);
9289 snd_hda_codec_write_cache(codec, 0x15, 0,
9290 AC_VERB_SET_PIN_WIDGET_CONTROL,
9291 val ? PIN_HP : 0);
9292 /* mono (speaker) depending on the HP jack sense */
9293 val = val && !spec->jack_present;
9294 snd_hda_codec_write_cache(codec, 0x16, 0,
9295 AC_VERB_SET_PIN_WIDGET_CONTROL,
9296 val ? PIN_OUT : 0);
9297}
9298
9299static void alc262_hp_bpc_automute(struct hda_codec *codec)
9300{
9301 struct alc_spec *spec = codec->spec;
9302 unsigned int presence;
9303 presence = snd_hda_codec_read(codec, 0x1b, 0,
9304 AC_VERB_GET_PIN_SENSE, 0);
9305 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9306 alc262_hp_master_update(codec);
9307}
9308
9309static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
9310{
9311 if ((res >> 26) != ALC880_HP_EVENT)
9312 return;
9313 alc262_hp_bpc_automute(codec);
9314}
9315
9316static void alc262_hp_wildwest_automute(struct hda_codec *codec)
9317{
9318 struct alc_spec *spec = codec->spec;
9319 unsigned int presence;
9320 presence = snd_hda_codec_read(codec, 0x15, 0,
9321 AC_VERB_GET_PIN_SENSE, 0);
9322 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
9323 alc262_hp_master_update(codec);
9324}
9325
9326static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9327 unsigned int res)
9328{
9329 if ((res >> 26) != ALC880_HP_EVENT)
9330 return;
9331 alc262_hp_wildwest_automute(codec);
9332}
9333
9334static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9335 struct snd_ctl_elem_value *ucontrol)
9336{
9337 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9338 struct alc_spec *spec = codec->spec;
9339 *ucontrol->value.integer.value = spec->master_sw;
9340 return 0;
9341}
9342
9343static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9344 struct snd_ctl_elem_value *ucontrol)
9345{
9346 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9347 struct alc_spec *spec = codec->spec;
9348 int val = !!*ucontrol->value.integer.value;
9349
9350 if (val == spec->master_sw)
9351 return 0;
9352 spec->master_sw = val;
9353 alc262_hp_master_update(codec);
9354 return 1;
9355}
9356
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009357static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009358 {
9359 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9360 .name = "Master Playback Switch",
9361 .info = snd_ctl_boolean_mono_info,
9362 .get = alc262_hp_master_sw_get,
9363 .put = alc262_hp_master_sw_put,
9364 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009365 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9366 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9367 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009368 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9369 HDA_OUTPUT),
9370 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9371 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009372 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9373 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009374 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009375 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9376 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009377 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009378 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9379 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9380 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9381 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009382 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9383 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9384 { } /* end */
9385};
9386
Kailang Yangcd7509a2007-01-26 18:33:17 +01009387static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009388 {
9389 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9390 .name = "Master Playback Switch",
9391 .info = snd_ctl_boolean_mono_info,
9392 .get = alc262_hp_master_sw_get,
9393 .put = alc262_hp_master_sw_put,
9394 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009395 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9396 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9397 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9398 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009399 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9400 HDA_OUTPUT),
9401 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9402 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009403 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9404 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009405 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009406 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9407 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9408 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9409 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009410 { } /* end */
9411};
9412
9413static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9414 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9415 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009416 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009417 { } /* end */
9418};
9419
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009420/* mute/unmute internal speaker according to the hp jack and mute state */
9421static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9422{
9423 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009424
9425 if (force || !spec->sense_updated) {
9426 unsigned int present;
9427 present = snd_hda_codec_read(codec, 0x15, 0,
9428 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009429 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009430 spec->sense_updated = 1;
9431 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009432 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9433 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009434}
9435
9436static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9437 unsigned int res)
9438{
9439 if ((res >> 26) != ALC880_HP_EVENT)
9440 return;
9441 alc262_hp_t5735_automute(codec, 1);
9442}
9443
9444static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9445{
9446 alc262_hp_t5735_automute(codec, 1);
9447}
9448
9449static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009450 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9451 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009452 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9453 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9454 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9455 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9456 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9457 { } /* end */
9458};
9459
9460static struct hda_verb alc262_hp_t5735_verbs[] = {
9461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9463
9464 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9465 { }
9466};
9467
Kailang Yang8c427222008-01-10 13:03:59 +01009468static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009469 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9470 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009471 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9472 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009473 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9474 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9475 { } /* end */
9476};
9477
9478static struct hda_verb alc262_hp_rp5700_verbs[] = {
9479 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9480 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9481 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9482 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9484 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9486 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9487 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9488 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9489 {}
9490};
9491
9492static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9493 .num_items = 1,
9494 .items = {
9495 { "Line", 0x1 },
9496 },
9497};
9498
Takashi Iwai0724ea22007-08-23 00:31:43 +02009499/* bind hp and internal speaker mute (with plug check) */
9500static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9501 struct snd_ctl_elem_value *ucontrol)
9502{
9503 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9504 long *valp = ucontrol->value.integer.value;
9505 int change;
9506
9507 /* change hp mute */
9508 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9509 HDA_AMP_MUTE,
9510 valp[0] ? 0 : HDA_AMP_MUTE);
9511 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9512 HDA_AMP_MUTE,
9513 valp[1] ? 0 : HDA_AMP_MUTE);
9514 if (change) {
9515 /* change speaker according to HP jack state */
9516 struct alc_spec *spec = codec->spec;
9517 unsigned int mute;
9518 if (spec->jack_present)
9519 mute = HDA_AMP_MUTE;
9520 else
9521 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9522 HDA_OUTPUT, 0);
9523 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9524 HDA_AMP_MUTE, mute);
9525 }
9526 return change;
9527}
Takashi Iwai5b319542007-07-26 11:49:22 +02009528
Kailang Yang272a5272007-05-14 11:00:38 +02009529static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009530 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9531 {
9532 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9533 .name = "Master Playback Switch",
9534 .info = snd_hda_mixer_amp_switch_info,
9535 .get = snd_hda_mixer_amp_switch_get,
9536 .put = alc262_sony_master_sw_put,
9537 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9538 },
Kailang Yang272a5272007-05-14 11:00:38 +02009539 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9540 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9541 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9542 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9543 { } /* end */
9544};
9545
Kailang Yang83c34212007-07-05 11:43:05 +02009546static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9547 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9548 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9549 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9552 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9553 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9554 { } /* end */
9555};
Kailang Yang272a5272007-05-14 11:00:38 +02009556
Tony Vroonba340e82009-02-02 19:01:30 +00009557static struct snd_kcontrol_new alc262_tyan_mixer[] = {
9558 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9559 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
9560 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
9561 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
9562 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9563 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9564 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9565 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9566 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9567 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9568 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9569 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9570 { } /* end */
9571};
9572
9573static struct hda_verb alc262_tyan_verbs[] = {
9574 /* Headphone automute */
9575 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9576 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9577 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9578
9579 /* P11 AUX_IN, white 4-pin connector */
9580 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9581 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
9582 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
9583 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
9584
9585 {}
9586};
9587
9588/* unsolicited event for HP jack sensing */
9589static void alc262_tyan_automute(struct hda_codec *codec)
9590{
9591 unsigned int mute;
9592 unsigned int present;
9593
9594 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9595 present = snd_hda_codec_read(codec, 0x1b, 0,
9596 AC_VERB_GET_PIN_SENSE, 0);
9597 present = (present & 0x80000000) != 0;
9598 if (present) {
9599 /* mute line output on ATX panel */
9600 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9601 HDA_AMP_MUTE, HDA_AMP_MUTE);
9602 } else {
9603 /* unmute line output if necessary */
9604 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9605 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9606 HDA_AMP_MUTE, mute);
9607 }
9608}
9609
9610static void alc262_tyan_unsol_event(struct hda_codec *codec,
9611 unsigned int res)
9612{
9613 if ((res >> 26) != ALC880_HP_EVENT)
9614 return;
9615 alc262_tyan_automute(codec);
9616}
9617
Kailang Yangdf694da2005-12-05 19:42:22 +01009618#define alc262_capture_mixer alc882_capture_mixer
9619#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9620
9621/*
9622 * generic initialization of ADC, input mixers and output mixers
9623 */
9624static struct hda_verb alc262_init_verbs[] = {
9625 /*
9626 * Unmute ADC0-2 and set the default input to mic-in
9627 */
9628 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9629 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9630 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9632 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9633 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9634
Takashi Iwaicb53c622007-08-10 17:21:45 +02009635 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009636 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009637 * Note: PASD motherboards uses the Line In 2 as the input for
9638 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009639 */
9640 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9645 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009646
9647 /*
9648 * Set up output mixers (0x0c - 0x0e)
9649 */
9650 /* set vol=0 to output mixers */
9651 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9652 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9653 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9654 /* set up input amps for analog loopback */
9655 /* Amp Indices: DAC = 0, mixer = 1 */
9656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9657 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9658 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9659 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9660 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9661 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9662
9663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9664 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9665 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9666 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9667 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9668 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9669
9670 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9671 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9672 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9673 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9674 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009675
Kailang Yangdf694da2005-12-05 19:42:22 +01009676 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9677 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009678
Kailang Yangdf694da2005-12-05 19:42:22 +01009679 /* FIXME: use matrix-type input source selection */
9680 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9681 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9682 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9683 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9684 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9685 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9686 /* Input mixer2 */
9687 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9688 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9689 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9690 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9691 /* Input mixer3 */
9692 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9693 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9694 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009695 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009696
9697 { }
9698};
9699
Kailang Yang4e555fe2008-08-26 13:05:55 +02009700static struct hda_verb alc262_eapd_verbs[] = {
9701 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9702 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9703 { }
9704};
9705
Kailang Yangccc656c2006-10-17 12:32:26 +02009706static struct hda_verb alc262_hippo_unsol_verbs[] = {
9707 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9708 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9709 {}
9710};
9711
9712static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9713 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9714 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9715 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9716
9717 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9718 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9719 {}
9720};
9721
Kailang Yang272a5272007-05-14 11:00:38 +02009722static struct hda_verb alc262_sony_unsol_verbs[] = {
9723 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9724 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9725 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9726
9727 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9728 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009729 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009730};
9731
Kailang Yang4e555fe2008-08-26 13:05:55 +02009732static struct hda_input_mux alc262_dmic_capture_source = {
9733 .num_items = 2,
9734 .items = {
9735 { "Int DMic", 0x9 },
9736 { "Mic", 0x0 },
9737 },
9738};
9739
9740static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9741 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9742 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9743 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9744 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9745 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009746 { } /* end */
9747};
9748
9749static struct hda_verb alc262_toshiba_s06_verbs[] = {
9750 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9751 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9752 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9753 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9754 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9755 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9756 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9757 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9758 {}
9759};
9760
9761static void alc262_dmic_automute(struct hda_codec *codec)
9762{
9763 unsigned int present;
9764
9765 present = snd_hda_codec_read(codec, 0x18, 0,
9766 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9767 snd_hda_codec_write(codec, 0x22, 0,
9768 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9769}
9770
9771/* toggle speaker-output according to the hp-jack state */
9772static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9773{
9774 unsigned int present;
9775 unsigned char bits;
9776
9777 present = snd_hda_codec_read(codec, 0x15, 0,
9778 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9779 bits = present ? 0 : PIN_OUT;
9780 snd_hda_codec_write(codec, 0x14, 0,
9781 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9782}
9783
9784
9785
9786/* unsolicited event for HP jack sensing */
9787static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9788 unsigned int res)
9789{
9790 if ((res >> 26) == ALC880_HP_EVENT)
9791 alc262_toshiba_s06_speaker_automute(codec);
9792 if ((res >> 26) == ALC880_MIC_EVENT)
9793 alc262_dmic_automute(codec);
9794
9795}
9796
9797static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9798{
9799 alc262_toshiba_s06_speaker_automute(codec);
9800 alc262_dmic_automute(codec);
9801}
9802
Kailang Yangccc656c2006-10-17 12:32:26 +02009803/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009804static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009805{
9806 struct alc_spec *spec = codec->spec;
9807 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009808 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009809
Takashi Iwai5b319542007-07-26 11:49:22 +02009810 /* need to execute and sync at first */
9811 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9812 present = snd_hda_codec_read(codec, 0x15, 0,
9813 AC_VERB_GET_PIN_SENSE, 0);
9814 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009815 if (spec->jack_present) {
9816 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009817 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9818 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009819 } else {
9820 /* unmute internal speaker if necessary */
9821 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009822 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9823 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009824 }
9825}
9826
9827/* unsolicited event for HP jack sensing */
9828static void alc262_hippo_unsol_event(struct hda_codec *codec,
9829 unsigned int res)
9830{
9831 if ((res >> 26) != ALC880_HP_EVENT)
9832 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009833 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009834}
9835
Takashi Iwai5b319542007-07-26 11:49:22 +02009836static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009837{
Kailang Yangccc656c2006-10-17 12:32:26 +02009838 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009839 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009840
Takashi Iwai5b319542007-07-26 11:49:22 +02009841 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9842 present = snd_hda_codec_read(codec, 0x1b, 0,
9843 AC_VERB_GET_PIN_SENSE, 0);
9844 present = (present & 0x80000000) != 0;
9845 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009846 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009847 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9848 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009849 } else {
9850 /* unmute internal speaker if necessary */
9851 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009852 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9853 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009854 }
9855}
9856
9857/* unsolicited event for HP jack sensing */
9858static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9859 unsigned int res)
9860{
9861 if ((res >> 26) != ALC880_HP_EVENT)
9862 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009863 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009864}
9865
Takashi Iwai834be882006-03-01 14:16:17 +01009866/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009867 * nec model
9868 * 0x15 = headphone
9869 * 0x16 = internal speaker
9870 * 0x18 = external mic
9871 */
9872
9873static struct snd_kcontrol_new alc262_nec_mixer[] = {
9874 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9875 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9876
9877 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9878 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9880
9881 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9883 { } /* end */
9884};
9885
9886static struct hda_verb alc262_nec_verbs[] = {
9887 /* Unmute Speaker */
9888 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9889
9890 /* Headphone */
9891 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9892 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9893
9894 /* External mic to headphone */
9895 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9896 /* External mic to speaker */
9897 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9898 {}
9899};
9900
9901/*
Takashi Iwai834be882006-03-01 14:16:17 +01009902 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009903 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9904 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009905 */
9906
9907#define ALC_HP_EVENT 0x37
9908
9909static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9910 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9911 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009912 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9913 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009914 {}
9915};
9916
Jiang zhe0e31daf2008-03-20 12:12:39 +01009917static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9918 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9919 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9920 {}
9921};
9922
Takashi Iwai834be882006-03-01 14:16:17 +01009923static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009924 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009925 .items = {
9926 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009927 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009928 { "CD", 0x4 },
9929 },
9930};
9931
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009932static struct hda_input_mux alc262_HP_capture_source = {
9933 .num_items = 5,
9934 .items = {
9935 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009936 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009937 { "Line", 0x2 },
9938 { "CD", 0x4 },
9939 { "AUX IN", 0x6 },
9940 },
9941};
9942
zhejiangaccbe492007-08-31 12:36:05 +02009943static struct hda_input_mux alc262_HP_D7000_capture_source = {
9944 .num_items = 4,
9945 .items = {
9946 { "Mic", 0x0 },
9947 { "Front Mic", 0x2 },
9948 { "Line", 0x1 },
9949 { "CD", 0x4 },
9950 },
9951};
9952
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009953/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009954static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9955{
9956 struct alc_spec *spec = codec->spec;
9957 unsigned int mute;
9958
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009959 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009960 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009961 /* need to execute and sync at first */
9962 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009963 /* check laptop HP jack */
9964 present = snd_hda_codec_read(codec, 0x14, 0,
9965 AC_VERB_GET_PIN_SENSE, 0);
9966 /* need to execute and sync at first */
9967 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9968 /* check docking HP jack */
9969 present |= snd_hda_codec_read(codec, 0x1b, 0,
9970 AC_VERB_GET_PIN_SENSE, 0);
9971 if (present & AC_PINSENSE_PRESENCE)
9972 spec->jack_present = 1;
9973 else
9974 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009975 spec->sense_updated = 1;
9976 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009977 /* unmute internal speaker only if both HPs are unplugged and
9978 * master switch is on
9979 */
9980 if (spec->jack_present)
9981 mute = HDA_AMP_MUTE;
9982 else
Takashi Iwai834be882006-03-01 14:16:17 +01009983 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009984 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9985 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009986}
9987
9988/* unsolicited event for HP jack sensing */
9989static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9990 unsigned int res)
9991{
9992 if ((res >> 26) != ALC_HP_EVENT)
9993 return;
9994 alc262_fujitsu_automute(codec, 1);
9995}
9996
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009997static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9998{
9999 alc262_fujitsu_automute(codec, 1);
10000}
10001
Takashi Iwai834be882006-03-01 14:16:17 +010010002/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020010003static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
10004 .ops = &snd_hda_bind_vol,
10005 .values = {
10006 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
10007 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
10008 0
10009 },
10010};
Takashi Iwai834be882006-03-01 14:16:17 +010010011
Jiang zhe0e31daf2008-03-20 12:12:39 +010010012/* mute/unmute internal speaker according to the hp jack and mute state */
10013static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
10014{
10015 struct alc_spec *spec = codec->spec;
10016 unsigned int mute;
10017
10018 if (force || !spec->sense_updated) {
10019 unsigned int present_int_hp;
10020 /* need to execute and sync at first */
10021 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
10022 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
10023 AC_VERB_GET_PIN_SENSE, 0);
10024 spec->jack_present = (present_int_hp & 0x80000000) != 0;
10025 spec->sense_updated = 1;
10026 }
10027 if (spec->jack_present) {
10028 /* mute internal speaker */
10029 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10030 HDA_AMP_MUTE, HDA_AMP_MUTE);
10031 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10032 HDA_AMP_MUTE, HDA_AMP_MUTE);
10033 } else {
10034 /* unmute internal speaker if necessary */
10035 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
10036 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10037 HDA_AMP_MUTE, mute);
10038 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
10039 HDA_AMP_MUTE, mute);
10040 }
10041}
10042
10043/* unsolicited event for HP jack sensing */
10044static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
10045 unsigned int res)
10046{
10047 if ((res >> 26) != ALC_HP_EVENT)
10048 return;
10049 alc262_lenovo_3000_automute(codec, 1);
10050}
10051
Takashi Iwai834be882006-03-01 14:16:17 +010010052/* bind hp and internal speaker mute (with plug check) */
10053static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
10054 struct snd_ctl_elem_value *ucontrol)
10055{
10056 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10057 long *valp = ucontrol->value.integer.value;
10058 int change;
10059
Tony Vroon5d9fab22008-03-14 17:09:18 +010010060 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10061 HDA_AMP_MUTE,
10062 valp ? 0 : HDA_AMP_MUTE);
10063 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10064 HDA_AMP_MUTE,
10065 valp ? 0 : HDA_AMP_MUTE);
10066
Takashi Iwai82beb8f2007-08-10 17:09:26 +020010067 if (change)
10068 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010010069 return change;
10070}
10071
10072static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020010073 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010010074 {
10075 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10076 .name = "Master Playback Switch",
10077 .info = snd_hda_mixer_amp_switch_info,
10078 .get = snd_hda_mixer_amp_switch_get,
10079 .put = alc262_fujitsu_master_sw_put,
10080 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10081 },
10082 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10083 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10084 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10085 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10086 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010087 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10088 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10089 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010010090 { } /* end */
10091};
10092
Jiang zhe0e31daf2008-03-20 12:12:39 +010010093/* bind hp and internal speaker mute (with plug check) */
10094static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
10095 struct snd_ctl_elem_value *ucontrol)
10096{
10097 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10098 long *valp = ucontrol->value.integer.value;
10099 int change;
10100
10101 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
10102 HDA_AMP_MUTE,
10103 valp ? 0 : HDA_AMP_MUTE);
10104
10105 if (change)
10106 alc262_lenovo_3000_automute(codec, 0);
10107 return change;
10108}
10109
10110static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
10111 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10112 {
10113 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10114 .name = "Master Playback Switch",
10115 .info = snd_hda_mixer_amp_switch_info,
10116 .get = snd_hda_mixer_amp_switch_get,
10117 .put = alc262_lenovo_3000_master_sw_put,
10118 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
10119 },
10120 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10121 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10122 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10123 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10124 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10125 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10126 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
10127 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
10128 { } /* end */
10129};
10130
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010131static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
10132 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
10133 {
10134 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10135 .name = "Master Playback Switch",
10136 .info = snd_hda_mixer_amp_switch_info,
10137 .get = snd_hda_mixer_amp_switch_get,
10138 .put = alc262_sony_master_sw_put,
10139 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
10140 },
10141 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10142 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
10143 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10144 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10145 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10146 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10147 { } /* end */
10148};
10149
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010150/* additional init verbs for Benq laptops */
10151static struct hda_verb alc262_EAPD_verbs[] = {
10152 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10153 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
10154 {}
10155};
10156
Kailang Yang83c34212007-07-05 11:43:05 +020010157static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
10158 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10159 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10160
10161 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
10162 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
10163 {}
10164};
10165
Tobin Davisf651b502007-10-26 12:40:47 +020010166/* Samsung Q1 Ultra Vista model setup */
10167static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010168 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10169 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010170 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10171 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
10172 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010173 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020010174 { } /* end */
10175};
10176
10177static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010178 /* output mixer */
10179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10181 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10182 /* speaker */
10183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
10184 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10185 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10186 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
10187 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020010188 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010189 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10190 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10191 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10192 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10193 /* internal mic */
10194 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10195 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10196 /* ADC, choose mic */
10197 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10202 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10203 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10204 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10205 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
10206 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020010207 {}
10208};
10209
Tobin Davisf651b502007-10-26 12:40:47 +020010210/* mute/unmute internal speaker according to the hp jack and mute state */
10211static void alc262_ultra_automute(struct hda_codec *codec)
10212{
10213 struct alc_spec *spec = codec->spec;
10214 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020010215
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010216 mute = 0;
10217 /* auto-mute only when HP is used as HP */
10218 if (!spec->cur_mux[0]) {
10219 unsigned int present;
10220 /* need to execute and sync at first */
10221 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
10222 present = snd_hda_codec_read(codec, 0x15, 0,
10223 AC_VERB_GET_PIN_SENSE, 0);
10224 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
10225 if (spec->jack_present)
10226 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020010227 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010228 /* mute/unmute internal speaker */
10229 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10230 HDA_AMP_MUTE, mute);
10231 /* mute/unmute HP */
10232 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10233 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020010234}
10235
10236/* unsolicited event for HP jack sensing */
10237static void alc262_ultra_unsol_event(struct hda_codec *codec,
10238 unsigned int res)
10239{
10240 if ((res >> 26) != ALC880_HP_EVENT)
10241 return;
10242 alc262_ultra_automute(codec);
10243}
10244
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010245static struct hda_input_mux alc262_ultra_capture_source = {
10246 .num_items = 2,
10247 .items = {
10248 { "Mic", 0x1 },
10249 { "Headphone", 0x7 },
10250 },
10251};
10252
10253static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
10254 struct snd_ctl_elem_value *ucontrol)
10255{
10256 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10257 struct alc_spec *spec = codec->spec;
10258 int ret;
10259
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010260 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010261 if (!ret)
10262 return 0;
10263 /* reprogram the HP pin as mic or HP according to the input source */
10264 snd_hda_codec_write_cache(codec, 0x15, 0,
10265 AC_VERB_SET_PIN_WIDGET_CONTROL,
10266 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
10267 alc262_ultra_automute(codec); /* mute/unmute HP */
10268 return ret;
10269}
10270
10271static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
10272 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
10273 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
10274 {
10275 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10276 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010277 .info = alc_mux_enum_info,
10278 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010279 .put = alc262_ultra_mux_enum_put,
10280 },
10281 { } /* end */
10282};
10283
Kailang Yangdf694da2005-12-05 19:42:22 +010010284/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010285static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
10286 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010010287{
10288 hda_nid_t nid;
10289 int err;
10290
10291 spec->multiout.num_dacs = 1; /* only use one dac */
10292 spec->multiout.dac_nids = spec->private_dac_nids;
10293 spec->multiout.dac_nids[0] = 2;
10294
10295 nid = cfg->line_out_pins[0];
10296 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010297 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10298 "Front Playback Volume",
10299 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
10300 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010301 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010302 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10303 "Front Playback Switch",
10304 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
10305 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010306 return err;
10307 }
10308
Takashi Iwai82bc9552006-03-21 11:24:42 +010010309 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010310 if (nid) {
10311 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010312 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10313 "Speaker Playback Volume",
10314 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10315 HDA_OUTPUT));
10316 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010317 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010318 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10319 "Speaker Playback Switch",
10320 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10321 HDA_OUTPUT));
10322 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010323 return err;
10324 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010325 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10326 "Speaker Playback Switch",
10327 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10328 HDA_OUTPUT));
10329 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010330 return err;
10331 }
10332 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010333 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010334 if (nid) {
10335 /* spec->multiout.hp_nid = 2; */
10336 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010337 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10338 "Headphone Playback Volume",
10339 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
10340 HDA_OUTPUT));
10341 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010342 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010343 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10344 "Headphone Playback Switch",
10345 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
10346 HDA_OUTPUT));
10347 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010348 return err;
10349 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010350 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10351 "Headphone Playback Switch",
10352 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
10353 HDA_OUTPUT));
10354 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010355 return err;
10356 }
10357 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010358 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010010359}
10360
10361/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010362#define alc262_auto_create_analog_input_ctls \
10363 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010010364
10365/*
10366 * generic initialization of ADC, input mixers and output mixers
10367 */
10368static struct hda_verb alc262_volume_init_verbs[] = {
10369 /*
10370 * Unmute ADC0-2 and set the default input to mic-in
10371 */
10372 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10373 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10374 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10375 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10376 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10377 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10378
Takashi Iwaicb53c622007-08-10 17:21:45 +020010379 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010380 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010381 * Note: PASD motherboards uses the Line In 2 as the input for
10382 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010383 */
10384 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010385 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10389 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010390
10391 /*
10392 * Set up output mixers (0x0c - 0x0f)
10393 */
10394 /* set vol=0 to output mixers */
10395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10396 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10397 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010398
Kailang Yangdf694da2005-12-05 19:42:22 +010010399 /* set up input amps for analog loopback */
10400 /* Amp Indices: DAC = 0, mixer = 1 */
10401 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10402 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10403 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10404 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10405 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10406 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10407
10408 /* FIXME: use matrix-type input source selection */
10409 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10410 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10411 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10412 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10413 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10414 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10415 /* Input mixer2 */
10416 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10417 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10418 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10419 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10420 /* Input mixer3 */
10421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10423 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10424 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10425
10426 { }
10427};
10428
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010429static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10430 /*
10431 * Unmute ADC0-2 and set the default input to mic-in
10432 */
10433 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10434 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10435 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10436 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10437 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10438 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10439
Takashi Iwaicb53c622007-08-10 17:21:45 +020010440 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010441 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010442 * Note: PASD motherboards uses the Line In 2 as the input for
10443 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010444 */
10445 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010446 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10447 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10448 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10451 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10452 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010453
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010454 /*
10455 * Set up output mixers (0x0c - 0x0e)
10456 */
10457 /* set vol=0 to output mixers */
10458 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10459 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10460 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10461
10462 /* set up input amps for analog loopback */
10463 /* Amp Indices: DAC = 0, mixer = 1 */
10464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10467 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10469 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10470
Takashi Iwaice875f02008-01-28 18:17:43 +010010471 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010472 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10473 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10474
10475 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10476 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10477
10478 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10479 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10480
10481 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10482 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10484 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10485 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10486
10487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10488 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10489 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10490 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10491 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10492 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10493
10494
10495 /* FIXME: use matrix-type input source selection */
10496 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10497 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10498 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10499 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10500 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10501 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10502 /* Input mixer2 */
10503 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10505 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10506 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10507 /* Input mixer3 */
10508 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10509 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10510 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10511 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10512
Takashi Iwaice875f02008-01-28 18:17:43 +010010513 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10514
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010515 { }
10516};
10517
Kailang Yangcd7509a2007-01-26 18:33:17 +010010518static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10519 /*
10520 * Unmute ADC0-2 and set the default input to mic-in
10521 */
10522 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10523 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10524 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10525 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10526 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10527 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10528
Takashi Iwaicb53c622007-08-10 17:21:45 +020010529 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010530 * mixer widget
10531 * Note: PASD motherboards uses the Line In 2 as the input for front
10532 * panel mic (mic 2)
10533 */
10534 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010535 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10536 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10538 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010543 /*
10544 * Set up output mixers (0x0c - 0x0e)
10545 */
10546 /* set vol=0 to output mixers */
10547 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10549 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10550
10551 /* set up input amps for analog loopback */
10552 /* Amp Indices: DAC = 0, mixer = 1 */
10553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10554 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10555 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10556 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10557 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10558 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10559
10560
10561 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10562 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10563 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10564 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10565 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10566 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10567 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10568
10569 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10570 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10571
10572 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10573 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10574
10575 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10576 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10577 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10578 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10579 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10580 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10581
10582 /* FIXME: use matrix-type input source selection */
10583 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10584 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10585 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10586 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10587 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10588 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10589 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10590 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10591 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10592 /* Input mixer2 */
10593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10594 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10595 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10596 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10597 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10598 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10599 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10600 /* Input mixer3 */
10601 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10602 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10603 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10604 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10605 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10606 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10607 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10608
Takashi Iwaice875f02008-01-28 18:17:43 +010010609 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10610
Kailang Yangcd7509a2007-01-26 18:33:17 +010010611 { }
10612};
10613
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010614static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10615
10616 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10617 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10618 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10619
10620 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10621 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10622 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10623 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10624
10625 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10626 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10627 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10628 {}
10629};
10630
10631
Takashi Iwaicb53c622007-08-10 17:21:45 +020010632#ifdef CONFIG_SND_HDA_POWER_SAVE
10633#define alc262_loopbacks alc880_loopbacks
10634#endif
10635
Kailang Yangdf694da2005-12-05 19:42:22 +010010636/* pcm configuration: identiacal with ALC880 */
10637#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10638#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10639#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10640#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10641
10642/*
10643 * BIOS auto configuration
10644 */
10645static int alc262_parse_auto_config(struct hda_codec *codec)
10646{
10647 struct alc_spec *spec = codec->spec;
10648 int err;
10649 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10650
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010651 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10652 alc262_ignore);
10653 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010654 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010655 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010656 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010657 spec->multiout.max_channels = 2;
10658 spec->no_analog = 1;
10659 goto dig_only;
10660 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010661 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010662 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010663 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10664 if (err < 0)
10665 return err;
10666 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10667 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010668 return err;
10669
10670 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10671
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010672 dig_only:
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010673 if (spec->autocfg.dig_outs) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010674 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
Takashi Iwai0852d7a2009-02-11 11:35:15 +010010675 spec->dig_out_type = spec->autocfg.dig_out_type[0];
Takashi Iwaie64f14f2009-01-20 18:32:55 +010010676 }
Kailang Yangdf694da2005-12-05 19:42:22 +010010677 if (spec->autocfg.dig_in_pin)
10678 spec->dig_in_nid = ALC262_DIGIN_NID;
10679
Takashi Iwai603c4012008-07-30 15:01:44 +020010680 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010681 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010682
Takashi Iwaid88897e2008-10-31 15:01:37 +010010683 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010684 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010685 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010010686
Takashi Iwai776e1842007-08-29 15:07:11 +020010687 err = alc_auto_add_mic_boost(codec);
10688 if (err < 0)
10689 return err;
10690
Takashi Iwaie044c392008-10-27 16:56:24 +010010691 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010692 return 1;
10693}
10694
10695#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10696#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10697#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010698#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010699
10700
10701/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010702static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010703{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010704 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010705 alc262_auto_init_multi_out(codec);
10706 alc262_auto_init_hp_out(codec);
10707 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010708 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010709 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010710 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010711}
10712
10713/*
10714 * configuration and preset
10715 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010716static const char *alc262_models[ALC262_MODEL_LAST] = {
10717 [ALC262_BASIC] = "basic",
10718 [ALC262_HIPPO] = "hippo",
10719 [ALC262_HIPPO_1] = "hippo_1",
10720 [ALC262_FUJITSU] = "fujitsu",
10721 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010722 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010723 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010724 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010725 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010726 [ALC262_BENQ_T31] = "benq-t31",
10727 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010728 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010729 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010730 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010731 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010732 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000010733 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010734 [ALC262_AUTO] = "auto",
10735};
10736
10737static struct snd_pci_quirk alc262_cfg_tbl[] = {
10738 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010739 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010740 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
10741 ALC262_HP_BPC),
10742 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
10743 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010744 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010745 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010746 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010747 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010748 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010749 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010750 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010751 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010752 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10753 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10754 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010755 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10756 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010757 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010758 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010759 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010760 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10761 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10762 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Takashi Iwai57a5ef42008-11-28 14:46:28 +010010763 SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN",
10764 ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010765 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010766 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010767 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010768 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010769 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000010770 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010010771 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
10772 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110010773 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010774 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010775 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010776 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010777 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010778 {}
10779};
10780
10781static struct alc_config_preset alc262_presets[] = {
10782 [ALC262_BASIC] = {
10783 .mixers = { alc262_base_mixer },
10784 .init_verbs = { alc262_init_verbs },
10785 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10786 .dac_nids = alc262_dac_nids,
10787 .hp_nid = 0x03,
10788 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10789 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010790 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010791 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010792 [ALC262_HIPPO] = {
10793 .mixers = { alc262_base_mixer },
10794 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10795 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10796 .dac_nids = alc262_dac_nids,
10797 .hp_nid = 0x03,
10798 .dig_out_nid = ALC262_DIGOUT_NID,
10799 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10800 .channel_mode = alc262_modes,
10801 .input_mux = &alc262_capture_source,
10802 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010803 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010804 },
10805 [ALC262_HIPPO_1] = {
10806 .mixers = { alc262_hippo1_mixer },
10807 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10808 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10809 .dac_nids = alc262_dac_nids,
10810 .hp_nid = 0x02,
10811 .dig_out_nid = ALC262_DIGOUT_NID,
10812 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10813 .channel_mode = alc262_modes,
10814 .input_mux = &alc262_capture_source,
10815 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010816 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010817 },
Takashi Iwai834be882006-03-01 14:16:17 +010010818 [ALC262_FUJITSU] = {
10819 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010820 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10821 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010822 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10823 .dac_nids = alc262_dac_nids,
10824 .hp_nid = 0x03,
10825 .dig_out_nid = ALC262_DIGOUT_NID,
10826 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10827 .channel_mode = alc262_modes,
10828 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010829 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010830 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010831 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010832 [ALC262_HP_BPC] = {
10833 .mixers = { alc262_HP_BPC_mixer },
10834 .init_verbs = { alc262_HP_BPC_init_verbs },
10835 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10836 .dac_nids = alc262_dac_nids,
10837 .hp_nid = 0x03,
10838 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10839 .channel_mode = alc262_modes,
10840 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010841 .unsol_event = alc262_hp_bpc_unsol_event,
10842 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010843 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010844 [ALC262_HP_BPC_D7000_WF] = {
10845 .mixers = { alc262_HP_BPC_WildWest_mixer },
10846 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10847 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10848 .dac_nids = alc262_dac_nids,
10849 .hp_nid = 0x03,
10850 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10851 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010852 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010853 .unsol_event = alc262_hp_wildwest_unsol_event,
10854 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010855 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010856 [ALC262_HP_BPC_D7000_WL] = {
10857 .mixers = { alc262_HP_BPC_WildWest_mixer,
10858 alc262_HP_BPC_WildWest_option_mixer },
10859 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10860 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10861 .dac_nids = alc262_dac_nids,
10862 .hp_nid = 0x03,
10863 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10864 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010865 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010866 .unsol_event = alc262_hp_wildwest_unsol_event,
10867 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010868 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010869 [ALC262_HP_TC_T5735] = {
10870 .mixers = { alc262_hp_t5735_mixer },
10871 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10872 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10873 .dac_nids = alc262_dac_nids,
10874 .hp_nid = 0x03,
10875 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10876 .channel_mode = alc262_modes,
10877 .input_mux = &alc262_capture_source,
10878 .unsol_event = alc262_hp_t5735_unsol_event,
10879 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010880 },
10881 [ALC262_HP_RP5700] = {
10882 .mixers = { alc262_hp_rp5700_mixer },
10883 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10884 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10885 .dac_nids = alc262_dac_nids,
10886 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10887 .channel_mode = alc262_modes,
10888 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010889 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010890 [ALC262_BENQ_ED8] = {
10891 .mixers = { alc262_base_mixer },
10892 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10893 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10894 .dac_nids = alc262_dac_nids,
10895 .hp_nid = 0x03,
10896 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10897 .channel_mode = alc262_modes,
10898 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010899 },
Kailang Yang272a5272007-05-14 11:00:38 +020010900 [ALC262_SONY_ASSAMD] = {
10901 .mixers = { alc262_sony_mixer },
10902 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10903 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10904 .dac_nids = alc262_dac_nids,
10905 .hp_nid = 0x02,
10906 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10907 .channel_mode = alc262_modes,
10908 .input_mux = &alc262_capture_source,
10909 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010910 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010911 },
10912 [ALC262_BENQ_T31] = {
10913 .mixers = { alc262_benq_t31_mixer },
10914 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10915 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10916 .dac_nids = alc262_dac_nids,
10917 .hp_nid = 0x03,
10918 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10919 .channel_mode = alc262_modes,
10920 .input_mux = &alc262_capture_source,
10921 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010922 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010923 },
Tobin Davisf651b502007-10-26 12:40:47 +020010924 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010925 .mixers = { alc262_ultra_mixer },
10926 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010927 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010928 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10929 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010930 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10931 .channel_mode = alc262_modes,
10932 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010933 .adc_nids = alc262_adc_nids, /* ADC0 */
10934 .capsrc_nids = alc262_capsrc_nids,
10935 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010936 .unsol_event = alc262_ultra_unsol_event,
10937 .init_hook = alc262_ultra_automute,
10938 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010939 [ALC262_LENOVO_3000] = {
10940 .mixers = { alc262_lenovo_3000_mixer },
10941 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10942 alc262_lenovo_3000_unsol_verbs },
10943 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10944 .dac_nids = alc262_dac_nids,
10945 .hp_nid = 0x03,
10946 .dig_out_nid = ALC262_DIGOUT_NID,
10947 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10948 .channel_mode = alc262_modes,
10949 .input_mux = &alc262_fujitsu_capture_source,
10950 .unsol_event = alc262_lenovo_3000_unsol_event,
10951 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010952 [ALC262_NEC] = {
10953 .mixers = { alc262_nec_mixer },
10954 .init_verbs = { alc262_nec_verbs },
10955 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10956 .dac_nids = alc262_dac_nids,
10957 .hp_nid = 0x03,
10958 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10959 .channel_mode = alc262_modes,
10960 .input_mux = &alc262_capture_source,
10961 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010962 [ALC262_TOSHIBA_S06] = {
10963 .mixers = { alc262_toshiba_s06_mixer },
10964 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10965 alc262_eapd_verbs },
10966 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10967 .capsrc_nids = alc262_dmic_capsrc_nids,
10968 .dac_nids = alc262_dac_nids,
10969 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10970 .dig_out_nid = ALC262_DIGOUT_NID,
10971 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10972 .channel_mode = alc262_modes,
10973 .input_mux = &alc262_dmic_capture_source,
10974 .unsol_event = alc262_toshiba_s06_unsol_event,
10975 .init_hook = alc262_toshiba_s06_init_hook,
10976 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010977 [ALC262_TOSHIBA_RX1] = {
10978 .mixers = { alc262_toshiba_rx1_mixer },
10979 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10980 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10981 .dac_nids = alc262_dac_nids,
10982 .hp_nid = 0x03,
10983 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10984 .channel_mode = alc262_modes,
10985 .input_mux = &alc262_capture_source,
10986 .unsol_event = alc262_hippo_unsol_event,
10987 .init_hook = alc262_hippo_automute,
10988 },
Tony Vroonba340e82009-02-02 19:01:30 +000010989 [ALC262_TYAN] = {
10990 .mixers = { alc262_tyan_mixer },
10991 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
10992 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10993 .dac_nids = alc262_dac_nids,
10994 .hp_nid = 0x02,
10995 .dig_out_nid = ALC262_DIGOUT_NID,
10996 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10997 .channel_mode = alc262_modes,
10998 .input_mux = &alc262_capture_source,
10999 .unsol_event = alc262_tyan_unsol_event,
11000 .init_hook = alc262_tyan_automute,
11001 },
Kailang Yangdf694da2005-12-05 19:42:22 +010011002};
11003
11004static int patch_alc262(struct hda_codec *codec)
11005{
11006 struct alc_spec *spec;
11007 int board_config;
11008 int err;
11009
Robert P. J. Daydc041e02006-12-19 14:44:15 +010011010 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010011011 if (spec == NULL)
11012 return -ENOMEM;
11013
11014 codec->spec = spec;
11015#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011016 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
11017 * under-run
11018 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011019 {
11020 int tmp;
11021 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11022 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
11023 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
11024 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
11025 }
11026#endif
11027
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011028 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
11029
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011030 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
11031 alc262_models,
11032 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010011033
Takashi Iwaif5fcc132006-11-24 17:07:44 +010011034 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011035 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
11036 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011037 board_config = ALC262_AUTO;
11038 }
11039
11040 if (board_config == ALC262_AUTO) {
11041 /* automatic parse from the BIOS config */
11042 err = alc262_parse_auto_config(codec);
11043 if (err < 0) {
11044 alc_free(codec);
11045 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011046 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011047 printk(KERN_INFO
11048 "hda_codec: Cannot set up configuration "
11049 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010011050 board_config = ALC262_BASIC;
11051 }
11052 }
11053
Takashi Iwai07eba612009-02-19 08:06:35 +010011054 if (!spec->no_analog) {
11055 err = snd_hda_attach_beep_device(codec, 0x1);
11056 if (err < 0) {
11057 alc_free(codec);
11058 return err;
11059 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011060 }
11061
Kailang Yangdf694da2005-12-05 19:42:22 +010011062 if (board_config != ALC262_AUTO)
11063 setup_preset(spec, &alc262_presets[board_config]);
11064
11065 spec->stream_name_analog = "ALC262 Analog";
11066 spec->stream_analog_playback = &alc262_pcm_analog_playback;
11067 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020011068
Kailang Yangdf694da2005-12-05 19:42:22 +010011069 spec->stream_name_digital = "ALC262 Digital";
11070 spec->stream_digital_playback = &alc262_pcm_digital_playback;
11071 spec->stream_digital_capture = &alc262_pcm_digital_capture;
11072
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011073 spec->capture_style = CAPT_MIX;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011074 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010011075 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010011076 unsigned int wcap = get_wcaps(codec, 0x07);
11077
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011078 /* get type */
11079 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010011080 if (wcap != AC_WID_AUD_IN) {
11081 spec->adc_nids = alc262_adc_nids_alt;
11082 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011083 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010011084 } else {
11085 spec->adc_nids = alc262_adc_nids;
11086 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010011087 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010011088 }
11089 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010011090 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010011091 set_capture_mixer(spec);
Takashi Iwai07eba612009-02-19 08:06:35 +010011092 if (!spec->no_analog)
11093 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010011094
Takashi Iwai2134ea42008-01-10 16:53:55 +010011095 spec->vmaster_nid = 0x0c;
11096
Kailang Yangdf694da2005-12-05 19:42:22 +010011097 codec->patch_ops = alc_patch_ops;
11098 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010011099 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011100#ifdef CONFIG_SND_HDA_POWER_SAVE
11101 if (!spec->loopback.amplist)
11102 spec->loopback.amplist = alc262_loopbacks;
11103#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010011104 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020011105
Kailang Yangdf694da2005-12-05 19:42:22 +010011106 return 0;
11107}
11108
Kailang Yangdf694da2005-12-05 19:42:22 +010011109/*
Kailang Yanga361d842007-06-05 12:30:55 +020011110 * ALC268 channel source setting (2 channel)
11111 */
11112#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
11113#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020011114
Kailang Yanga361d842007-06-05 12:30:55 +020011115static hda_nid_t alc268_dac_nids[2] = {
11116 /* front, hp */
11117 0x02, 0x03
11118};
11119
11120static hda_nid_t alc268_adc_nids[2] = {
11121 /* ADC0-1 */
11122 0x08, 0x07
11123};
11124
11125static hda_nid_t alc268_adc_nids_alt[1] = {
11126 /* ADC0 */
11127 0x08
11128};
11129
Takashi Iwaie1406342008-02-11 18:32:32 +010011130static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
11131
Kailang Yanga361d842007-06-05 12:30:55 +020011132static struct snd_kcontrol_new alc268_base_mixer[] = {
11133 /* output mixer control */
11134 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11135 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11136 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11137 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011138 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11139 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11140 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020011141 { }
11142};
11143
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011144/* bind Beep switches of both NID 0x0f and 0x10 */
11145static struct hda_bind_ctls alc268_bind_beep_sw = {
11146 .ops = &snd_hda_bind_sw,
11147 .values = {
11148 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
11149 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
11150 0
11151 },
11152};
11153
11154static struct snd_kcontrol_new alc268_beep_mixer[] = {
11155 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
11156 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
11157 { }
11158};
11159
Kailang Yangd1a991a2007-08-15 16:21:59 +020011160static struct hda_verb alc268_eapd_verbs[] = {
11161 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11162 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11163 { }
11164};
11165
Takashi Iwaid2738092007-08-16 14:59:45 +020011166/* Toshiba specific */
11167#define alc268_toshiba_automute alc262_hippo_automute
11168
11169static struct hda_verb alc268_toshiba_verbs[] = {
11170 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11171 { } /* end */
11172};
11173
Kailang Yang8ef355d2008-08-26 13:10:22 +020011174static struct hda_input_mux alc268_acer_lc_capture_source = {
11175 .num_items = 2,
11176 .items = {
11177 { "i-Mic", 0x6 },
11178 { "E-Mic", 0x0 },
11179 },
11180};
11181
Takashi Iwaid2738092007-08-16 14:59:45 +020011182/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020011183/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020011184static struct hda_bind_ctls alc268_acer_bind_master_vol = {
11185 .ops = &snd_hda_bind_vol,
11186 .values = {
11187 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11188 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11189 0
11190 },
11191};
11192
Takashi Iwai889c4392007-08-23 18:56:52 +020011193/* mute/unmute internal speaker according to the hp jack and mute state */
11194static void alc268_acer_automute(struct hda_codec *codec, int force)
11195{
11196 struct alc_spec *spec = codec->spec;
11197 unsigned int mute;
11198
11199 if (force || !spec->sense_updated) {
11200 unsigned int present;
11201 present = snd_hda_codec_read(codec, 0x14, 0,
11202 AC_VERB_GET_PIN_SENSE, 0);
11203 spec->jack_present = (present & 0x80000000) != 0;
11204 spec->sense_updated = 1;
11205 }
11206 if (spec->jack_present)
11207 mute = HDA_AMP_MUTE; /* mute internal speaker */
11208 else /* unmute internal speaker if necessary */
11209 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
11210 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11211 HDA_AMP_MUTE, mute);
11212}
11213
11214
11215/* bind hp and internal speaker mute (with plug check) */
11216static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
11217 struct snd_ctl_elem_value *ucontrol)
11218{
11219 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11220 long *valp = ucontrol->value.integer.value;
11221 int change;
11222
11223 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
11224 HDA_AMP_MUTE,
11225 valp[0] ? 0 : HDA_AMP_MUTE);
11226 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
11227 HDA_AMP_MUTE,
11228 valp[1] ? 0 : HDA_AMP_MUTE);
11229 if (change)
11230 alc268_acer_automute(codec, 0);
11231 return change;
11232}
Takashi Iwaid2738092007-08-16 14:59:45 +020011233
Kailang Yang8ef355d2008-08-26 13:10:22 +020011234static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
11235 /* output mixer control */
11236 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11237 {
11238 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11239 .name = "Master Playback Switch",
11240 .info = snd_hda_mixer_amp_switch_info,
11241 .get = snd_hda_mixer_amp_switch_get,
11242 .put = alc268_acer_master_sw_put,
11243 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11244 },
11245 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
11246 { }
11247};
11248
Takashi Iwaid2738092007-08-16 14:59:45 +020011249static struct snd_kcontrol_new alc268_acer_mixer[] = {
11250 /* output mixer control */
11251 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11252 {
11253 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11254 .name = "Master Playback Switch",
11255 .info = snd_hda_mixer_amp_switch_info,
11256 .get = snd_hda_mixer_amp_switch_get,
11257 .put = alc268_acer_master_sw_put,
11258 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11259 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020011260 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11261 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11262 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020011263 { }
11264};
11265
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011266static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
11267 /* output mixer control */
11268 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11269 {
11270 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11271 .name = "Master Playback Switch",
11272 .info = snd_hda_mixer_amp_switch_info,
11273 .get = snd_hda_mixer_amp_switch_get,
11274 .put = alc268_acer_master_sw_put,
11275 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11276 },
11277 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11278 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
11279 { }
11280};
11281
Kailang Yang8ef355d2008-08-26 13:10:22 +020011282static struct hda_verb alc268_acer_aspire_one_verbs[] = {
11283 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11284 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11285 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11286 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11287 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
11288 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
11289 { }
11290};
11291
Takashi Iwaid2738092007-08-16 14:59:45 +020011292static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011293 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
11294 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020011295 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11296 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011297 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11298 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020011299 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11300 { }
11301};
11302
11303/* unsolicited event for HP jack sensing */
11304static void alc268_toshiba_unsol_event(struct hda_codec *codec,
11305 unsigned int res)
11306{
Takashi Iwai889c4392007-08-23 18:56:52 +020011307 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011308 return;
11309 alc268_toshiba_automute(codec);
11310}
11311
11312static void alc268_acer_unsol_event(struct hda_codec *codec,
11313 unsigned int res)
11314{
Takashi Iwai889c4392007-08-23 18:56:52 +020011315 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020011316 return;
11317 alc268_acer_automute(codec, 1);
11318}
11319
Takashi Iwai889c4392007-08-23 18:56:52 +020011320static void alc268_acer_init_hook(struct hda_codec *codec)
11321{
11322 alc268_acer_automute(codec, 1);
11323}
11324
Kailang Yang8ef355d2008-08-26 13:10:22 +020011325/* toggle speaker-output according to the hp-jack state */
11326static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
11327{
11328 unsigned int present;
11329 unsigned char bits;
11330
11331 present = snd_hda_codec_read(codec, 0x15, 0,
11332 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11333 bits = present ? AMP_IN_MUTE(0) : 0;
11334 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
11335 AMP_IN_MUTE(0), bits);
11336 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
11337 AMP_IN_MUTE(0), bits);
11338}
11339
11340
11341static void alc268_acer_mic_automute(struct hda_codec *codec)
11342{
11343 unsigned int present;
11344
11345 present = snd_hda_codec_read(codec, 0x18, 0,
11346 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11347 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
11348 present ? 0x0 : 0x6);
11349}
11350
11351static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
11352 unsigned int res)
11353{
11354 if ((res >> 26) == ALC880_HP_EVENT)
11355 alc268_aspire_one_speaker_automute(codec);
11356 if ((res >> 26) == ALC880_MIC_EVENT)
11357 alc268_acer_mic_automute(codec);
11358}
11359
11360static void alc268_acer_lc_init_hook(struct hda_codec *codec)
11361{
11362 alc268_aspire_one_speaker_automute(codec);
11363 alc268_acer_mic_automute(codec);
11364}
11365
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011366static struct snd_kcontrol_new alc268_dell_mixer[] = {
11367 /* output mixer control */
11368 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11369 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11370 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11371 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11372 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11373 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11374 { }
11375};
11376
11377static struct hda_verb alc268_dell_verbs[] = {
11378 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11379 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11380 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11381 { }
11382};
11383
11384/* mute/unmute internal speaker according to the hp jack and mute state */
11385static void alc268_dell_automute(struct hda_codec *codec)
11386{
11387 unsigned int present;
11388 unsigned int mute;
11389
11390 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
11391 if (present & 0x80000000)
11392 mute = HDA_AMP_MUTE;
11393 else
11394 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
11395 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11396 HDA_AMP_MUTE, mute);
11397}
11398
11399static void alc268_dell_unsol_event(struct hda_codec *codec,
11400 unsigned int res)
11401{
11402 if ((res >> 26) != ALC880_HP_EVENT)
11403 return;
11404 alc268_dell_automute(codec);
11405}
11406
11407#define alc268_dell_init_hook alc268_dell_automute
11408
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011409static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
11410 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
11411 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11412 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11413 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11414 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11415 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11416 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11417 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11418 { }
11419};
11420
11421static struct hda_verb alc267_quanta_il1_verbs[] = {
11422 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11423 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11424 { }
11425};
11426
11427static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11428{
11429 unsigned int present;
11430
11431 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11432 & AC_PINSENSE_PRESENCE;
11433 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11434 present ? 0 : PIN_OUT);
11435}
11436
11437static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11438{
11439 unsigned int present;
11440
11441 present = snd_hda_codec_read(codec, 0x18, 0,
11442 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11443 snd_hda_codec_write(codec, 0x23, 0,
11444 AC_VERB_SET_CONNECT_SEL,
11445 present ? 0x00 : 0x01);
11446}
11447
11448static void alc267_quanta_il1_automute(struct hda_codec *codec)
11449{
11450 alc267_quanta_il1_hp_automute(codec);
11451 alc267_quanta_il1_mic_automute(codec);
11452}
11453
11454static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11455 unsigned int res)
11456{
11457 switch (res >> 26) {
11458 case ALC880_HP_EVENT:
11459 alc267_quanta_il1_hp_automute(codec);
11460 break;
11461 case ALC880_MIC_EVENT:
11462 alc267_quanta_il1_mic_automute(codec);
11463 break;
11464 }
11465}
11466
Kailang Yanga361d842007-06-05 12:30:55 +020011467/*
11468 * generic initialization of ADC, input mixers and output mixers
11469 */
11470static struct hda_verb alc268_base_init_verbs[] = {
11471 /* Unmute DAC0-1 and set vol = 0 */
11472 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011473 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011474
11475 /*
11476 * Set up output mixers (0x0c - 0x0e)
11477 */
11478 /* set vol=0 to output mixers */
11479 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011480 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11481
11482 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11483 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11484
11485 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11487 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11488 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11489 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11490 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11491 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11492 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11493
11494 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11496 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11497 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011498 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011499
11500 /* set PCBEEP vol = 0, mute connections */
11501 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11502 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11503 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011504
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011505 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011506
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011507 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11508 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11509 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11510 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011511
Kailang Yanga361d842007-06-05 12:30:55 +020011512 { }
11513};
11514
11515/*
11516 * generic initialization of ADC, input mixers and output mixers
11517 */
11518static struct hda_verb alc268_volume_init_verbs[] = {
11519 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010011520 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11521 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020011522
11523 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11524 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11525 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11526 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11527 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11528
Kailang Yanga361d842007-06-05 12:30:55 +020011529 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020011530 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11531 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11532
11533 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011534 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011535
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011536 /* set PCBEEP vol = 0, mute connections */
11537 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11538 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11539 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011540
11541 { }
11542};
11543
Kailang Yanga361d842007-06-05 12:30:55 +020011544static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11545 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11546 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11547 {
11548 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11549 /* The multiple "Capture Source" controls confuse alsamixer
11550 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011551 */
11552 /* .name = "Capture Source", */
11553 .name = "Input Source",
11554 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011555 .info = alc_mux_enum_info,
11556 .get = alc_mux_enum_get,
11557 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011558 },
11559 { } /* end */
11560};
11561
11562static struct snd_kcontrol_new alc268_capture_mixer[] = {
11563 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11564 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11565 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11566 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11567 {
11568 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11569 /* The multiple "Capture Source" controls confuse alsamixer
11570 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011571 */
11572 /* .name = "Capture Source", */
11573 .name = "Input Source",
11574 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011575 .info = alc_mux_enum_info,
11576 .get = alc_mux_enum_get,
11577 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011578 },
11579 { } /* end */
11580};
11581
11582static struct hda_input_mux alc268_capture_source = {
11583 .num_items = 4,
11584 .items = {
11585 { "Mic", 0x0 },
11586 { "Front Mic", 0x1 },
11587 { "Line", 0x2 },
11588 { "CD", 0x3 },
11589 },
11590};
11591
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011592static struct hda_input_mux alc268_acer_capture_source = {
11593 .num_items = 3,
11594 .items = {
11595 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011596 { "Internal Mic", 0x1 },
11597 { "Line", 0x2 },
11598 },
11599};
11600
11601static struct hda_input_mux alc268_acer_dmic_capture_source = {
11602 .num_items = 3,
11603 .items = {
11604 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011605 { "Internal Mic", 0x6 },
11606 { "Line", 0x2 },
11607 },
11608};
11609
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011610#ifdef CONFIG_SND_DEBUG
11611static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011612 /* Volume widgets */
11613 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11614 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11615 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11616 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11617 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11618 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11619 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11620 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11621 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11622 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11623 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11624 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11625 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011626 /* The below appears problematic on some hardwares */
11627 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011628 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11629 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11630 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11631 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11632
11633 /* Modes for retasking pin widgets */
11634 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11635 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11636 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11637 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11638
11639 /* Controls for GPIO pins, assuming they are configured as outputs */
11640 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11641 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11642 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11643 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11644
11645 /* Switches to allow the digital SPDIF output pin to be enabled.
11646 * The ALC268 does not have an SPDIF input.
11647 */
11648 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11649
11650 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11651 * this output to turn on an external amplifier.
11652 */
11653 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11654 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11655
11656 { } /* end */
11657};
11658#endif
11659
Kailang Yanga361d842007-06-05 12:30:55 +020011660/* create input playback/capture controls for the given pin */
11661static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11662 const char *ctlname, int idx)
11663{
11664 char name[32];
11665 int err;
11666
11667 sprintf(name, "%s Playback Volume", ctlname);
11668 if (nid == 0x14) {
11669 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11670 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11671 HDA_OUTPUT));
11672 if (err < 0)
11673 return err;
11674 } else if (nid == 0x15) {
11675 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11676 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11677 HDA_OUTPUT));
11678 if (err < 0)
11679 return err;
11680 } else
11681 return -1;
11682 sprintf(name, "%s Playback Switch", ctlname);
11683 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11684 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11685 if (err < 0)
11686 return err;
11687 return 0;
11688}
11689
11690/* add playback controls from the parsed DAC table */
11691static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11692 const struct auto_pin_cfg *cfg)
11693{
11694 hda_nid_t nid;
11695 int err;
11696
11697 spec->multiout.num_dacs = 2; /* only use one dac */
11698 spec->multiout.dac_nids = spec->private_dac_nids;
11699 spec->multiout.dac_nids[0] = 2;
11700 spec->multiout.dac_nids[1] = 3;
11701
11702 nid = cfg->line_out_pins[0];
11703 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011704 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011705
11706 nid = cfg->speaker_pins[0];
11707 if (nid == 0x1d) {
11708 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11709 "Speaker Playback Volume",
11710 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11711 if (err < 0)
11712 return err;
11713 }
11714 nid = cfg->hp_pins[0];
11715 if (nid)
11716 alc268_new_analog_output(spec, nid, "Headphone", 0);
11717
11718 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11719 if (nid == 0x16) {
11720 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11721 "Mono Playback Switch",
11722 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11723 if (err < 0)
11724 return err;
11725 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011726 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011727}
11728
11729/* create playback/capture controls for input pins */
11730static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11731 const struct auto_pin_cfg *cfg)
11732{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011733 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011734 int i, idx1;
11735
11736 for (i = 0; i < AUTO_PIN_LAST; i++) {
11737 switch(cfg->input_pins[i]) {
11738 case 0x18:
11739 idx1 = 0; /* Mic 1 */
11740 break;
11741 case 0x19:
11742 idx1 = 1; /* Mic 2 */
11743 break;
11744 case 0x1a:
11745 idx1 = 2; /* Line In */
11746 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011747 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011748 idx1 = 3; /* CD */
11749 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011750 case 0x12:
11751 case 0x13:
11752 idx1 = 6; /* digital mics */
11753 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011754 default:
11755 continue;
11756 }
11757 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11758 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011759 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011760 }
11761 return 0;
11762}
11763
11764static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11765{
11766 struct alc_spec *spec = codec->spec;
11767 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11768 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11769 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11770 unsigned int dac_vol1, dac_vol2;
11771
11772 if (speaker_nid) {
11773 snd_hda_codec_write(codec, speaker_nid, 0,
11774 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11775 snd_hda_codec_write(codec, 0x0f, 0,
11776 AC_VERB_SET_AMP_GAIN_MUTE,
11777 AMP_IN_UNMUTE(1));
11778 snd_hda_codec_write(codec, 0x10, 0,
11779 AC_VERB_SET_AMP_GAIN_MUTE,
11780 AMP_IN_UNMUTE(1));
11781 } else {
11782 snd_hda_codec_write(codec, 0x0f, 0,
11783 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11784 snd_hda_codec_write(codec, 0x10, 0,
11785 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11786 }
11787
11788 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011789 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011790 dac_vol2 = AMP_OUT_ZERO;
11791 else if (line_nid == 0x15)
11792 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011793 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011794 dac_vol2 = AMP_OUT_ZERO;
11795 else if (hp_nid == 0x15)
11796 dac_vol1 = AMP_OUT_ZERO;
11797 if (line_nid != 0x16 || hp_nid != 0x16 ||
11798 spec->autocfg.line_out_pins[1] != 0x16 ||
11799 spec->autocfg.line_out_pins[2] != 0x16)
11800 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11801
11802 snd_hda_codec_write(codec, 0x02, 0,
11803 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11804 snd_hda_codec_write(codec, 0x03, 0,
11805 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11806}
11807
11808/* pcm configuration: identiacal with ALC880 */
11809#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11810#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011811#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011812#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11813
11814/*
11815 * BIOS auto configuration
11816 */
11817static int alc268_parse_auto_config(struct hda_codec *codec)
11818{
11819 struct alc_spec *spec = codec->spec;
11820 int err;
11821 static hda_nid_t alc268_ignore[] = { 0 };
11822
11823 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11824 alc268_ignore);
11825 if (err < 0)
11826 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011827 if (!spec->autocfg.line_outs) {
11828 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
11829 spec->multiout.max_channels = 2;
11830 spec->no_analog = 1;
11831 goto dig_only;
11832 }
Kailang Yanga361d842007-06-05 12:30:55 +020011833 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011834 }
Kailang Yanga361d842007-06-05 12:30:55 +020011835 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11836 if (err < 0)
11837 return err;
11838 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11839 if (err < 0)
11840 return err;
11841
11842 spec->multiout.max_channels = 2;
11843
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011844 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020011845 /* digital only support output */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011846 if (spec->autocfg.dig_outs) {
Kailang Yanga361d842007-06-05 12:30:55 +020011847 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010011848 spec->dig_out_type = spec->autocfg.dig_out_type[0];
11849 }
Takashi Iwai603c4012008-07-30 15:01:44 +020011850 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011851 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011852
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011853 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011854 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011855
Takashi Iwaid88897e2008-10-31 15:01:37 +010011856 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011857 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011858 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020011859
Takashi Iwai776e1842007-08-29 15:07:11 +020011860 err = alc_auto_add_mic_boost(codec);
11861 if (err < 0)
11862 return err;
11863
Takashi Iwaie044c392008-10-27 16:56:24 +010011864 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011865 return 1;
11866}
11867
11868#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11869#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11870#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11871
11872/* init callback for auto-configuration model -- overriding the default init */
11873static void alc268_auto_init(struct hda_codec *codec)
11874{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011875 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011876 alc268_auto_init_multi_out(codec);
11877 alc268_auto_init_hp_out(codec);
11878 alc268_auto_init_mono_speaker_out(codec);
11879 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011880 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011881 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011882}
11883
11884/*
11885 * configuration and preset
11886 */
11887static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011888 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011889 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011890 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011891 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011892 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011893 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011894 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011895 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011896#ifdef CONFIG_SND_DEBUG
11897 [ALC268_TEST] = "test",
11898#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011899 [ALC268_AUTO] = "auto",
11900};
11901
11902static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011903 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011904 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011905 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011906 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011907 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011908 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11909 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011910 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwai57d13922009-01-08 15:52:09 +010011911 SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011912 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011913 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011914 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011915 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011916 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011917 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011918 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011919 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011920 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011921 {}
11922};
11923
11924static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011925 [ALC267_QUANTA_IL1] = {
Takashi Iwai22971e32009-02-10 11:56:44 +010011926 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011927 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11928 alc267_quanta_il1_verbs },
11929 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11930 .dac_nids = alc268_dac_nids,
11931 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11932 .adc_nids = alc268_adc_nids_alt,
11933 .hp_nid = 0x03,
11934 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11935 .channel_mode = alc268_modes,
11936 .input_mux = &alc268_capture_source,
11937 .unsol_event = alc267_quanta_il1_unsol_event,
11938 .init_hook = alc267_quanta_il1_automute,
11939 },
Kailang Yanga361d842007-06-05 12:30:55 +020011940 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011941 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11942 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011943 .init_verbs = { alc268_base_init_verbs },
11944 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11945 .dac_nids = alc268_dac_nids,
11946 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11947 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011948 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011949 .hp_nid = 0x03,
11950 .dig_out_nid = ALC268_DIGOUT_NID,
11951 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11952 .channel_mode = alc268_modes,
11953 .input_mux = &alc268_capture_source,
11954 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011955 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011956 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11957 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011958 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11959 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011960 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11961 .dac_nids = alc268_dac_nids,
11962 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11963 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011964 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011965 .hp_nid = 0x03,
11966 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11967 .channel_mode = alc268_modes,
11968 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011969 .unsol_event = alc268_toshiba_unsol_event,
11970 .init_hook = alc268_toshiba_automute,
11971 },
11972 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011973 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11974 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011975 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11976 alc268_acer_verbs },
11977 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11978 .dac_nids = alc268_dac_nids,
11979 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11980 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011981 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011982 .hp_nid = 0x02,
11983 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11984 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011985 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011986 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011987 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011988 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011989 [ALC268_ACER_DMIC] = {
11990 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11991 alc268_beep_mixer },
11992 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11993 alc268_acer_verbs },
11994 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11995 .dac_nids = alc268_dac_nids,
11996 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11997 .adc_nids = alc268_adc_nids_alt,
11998 .capsrc_nids = alc268_capsrc_nids,
11999 .hp_nid = 0x02,
12000 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12001 .channel_mode = alc268_modes,
12002 .input_mux = &alc268_acer_dmic_capture_source,
12003 .unsol_event = alc268_acer_unsol_event,
12004 .init_hook = alc268_acer_init_hook,
12005 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012006 [ALC268_ACER_ASPIRE_ONE] = {
12007 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010012008 alc268_beep_mixer,
12009 alc268_capture_alt_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020012010 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12011 alc268_acer_aspire_one_verbs },
12012 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12013 .dac_nids = alc268_dac_nids,
12014 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12015 .adc_nids = alc268_adc_nids_alt,
12016 .capsrc_nids = alc268_capsrc_nids,
12017 .hp_nid = 0x03,
12018 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12019 .channel_mode = alc268_modes,
12020 .input_mux = &alc268_acer_lc_capture_source,
12021 .unsol_event = alc268_acer_lc_unsol_event,
12022 .init_hook = alc268_acer_lc_init_hook,
12023 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012024 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012025 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012026 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12027 alc268_dell_verbs },
12028 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12029 .dac_nids = alc268_dac_nids,
12030 .hp_nid = 0x02,
12031 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12032 .channel_mode = alc268_modes,
12033 .unsol_event = alc268_dell_unsol_event,
12034 .init_hook = alc268_dell_init_hook,
12035 .input_mux = &alc268_capture_source,
12036 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012037 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012038 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
12039 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012040 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12041 alc268_toshiba_verbs },
12042 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12043 .dac_nids = alc268_dac_nids,
12044 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12045 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012046 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010012047 .hp_nid = 0x03,
12048 .dig_out_nid = ALC268_DIGOUT_NID,
12049 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12050 .channel_mode = alc268_modes,
12051 .input_mux = &alc268_capture_source,
12052 .unsol_event = alc268_toshiba_unsol_event,
12053 .init_hook = alc268_toshiba_automute
12054 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012055#ifdef CONFIG_SND_DEBUG
12056 [ALC268_TEST] = {
12057 .mixers = { alc268_test_mixer, alc268_capture_mixer },
12058 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
12059 alc268_volume_init_verbs },
12060 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
12061 .dac_nids = alc268_dac_nids,
12062 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
12063 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010012064 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010012065 .hp_nid = 0x03,
12066 .dig_out_nid = ALC268_DIGOUT_NID,
12067 .num_channel_mode = ARRAY_SIZE(alc268_modes),
12068 .channel_mode = alc268_modes,
12069 .input_mux = &alc268_capture_source,
12070 },
12071#endif
Kailang Yanga361d842007-06-05 12:30:55 +020012072};
12073
12074static int patch_alc268(struct hda_codec *codec)
12075{
12076 struct alc_spec *spec;
12077 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010012078 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020012079
12080 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
12081 if (spec == NULL)
12082 return -ENOMEM;
12083
12084 codec->spec = spec;
12085
12086 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
12087 alc268_models,
12088 alc268_cfg_tbl);
12089
12090 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12091 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
12092 "trying auto-probe from BIOS...\n");
12093 board_config = ALC268_AUTO;
12094 }
12095
12096 if (board_config == ALC268_AUTO) {
12097 /* automatic parse from the BIOS config */
12098 err = alc268_parse_auto_config(codec);
12099 if (err < 0) {
12100 alc_free(codec);
12101 return err;
12102 } else if (!err) {
12103 printk(KERN_INFO
12104 "hda_codec: Cannot set up configuration "
12105 "from BIOS. Using base mode...\n");
12106 board_config = ALC268_3ST;
12107 }
12108 }
12109
12110 if (board_config != ALC268_AUTO)
12111 setup_preset(spec, &alc268_presets[board_config]);
12112
Kailang Yang2f893282008-05-27 12:14:47 +020012113 if (codec->vendor_id == 0x10ec0267) {
12114 spec->stream_name_analog = "ALC267 Analog";
12115 spec->stream_name_digital = "ALC267 Digital";
12116 } else {
12117 spec->stream_name_analog = "ALC268 Analog";
12118 spec->stream_name_digital = "ALC268 Digital";
12119 }
12120
Kailang Yanga361d842007-06-05 12:30:55 +020012121 spec->stream_analog_playback = &alc268_pcm_analog_playback;
12122 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010012123 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020012124
Kailang Yanga361d842007-06-05 12:30:55 +020012125 spec->stream_digital_playback = &alc268_pcm_digital_playback;
12126
Takashi Iwai22971e32009-02-10 11:56:44 +010012127 has_beep = 0;
12128 for (i = 0; i < spec->num_mixers; i++) {
12129 if (spec->mixers[i] == alc268_beep_mixer) {
12130 has_beep = 1;
12131 break;
12132 }
12133 }
12134
12135 if (has_beep) {
12136 err = snd_hda_attach_beep_device(codec, 0x1);
12137 if (err < 0) {
12138 alc_free(codec);
12139 return err;
12140 }
12141 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
12142 /* override the amp caps for beep generator */
12143 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012144 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
12145 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
12146 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
12147 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010012148 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012149
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012150 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012151 /* check whether NID 0x07 is valid */
12152 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010012153 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020012154
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012155 /* get type */
12156 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010012157 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012158 spec->adc_nids = alc268_adc_nids_alt;
12159 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012160 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010012161 } else {
12162 spec->adc_nids = alc268_adc_nids;
12163 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010012164 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020012165 }
Takashi Iwaie1406342008-02-11 18:32:32 +010012166 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010012167 /* set default input source */
12168 for (i = 0; i < spec->num_adc_nids; i++)
12169 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
12170 0, AC_VERB_SET_CONNECT_SEL,
12171 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020012172 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010012173
12174 spec->vmaster_nid = 0x02;
12175
Kailang Yanga361d842007-06-05 12:30:55 +020012176 codec->patch_ops = alc_patch_ops;
12177 if (board_config == ALC268_AUTO)
12178 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020012179
Takashi Iwaidaead532008-11-28 12:55:36 +010012180 codec->proc_widget_hook = print_realtek_coef;
12181
Kailang Yanga361d842007-06-05 12:30:55 +020012182 return 0;
12183}
12184
12185/*
Kailang Yangf6a92242007-12-13 16:52:54 +010012186 * ALC269 channel source setting (2 channel)
12187 */
12188#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
12189
12190#define alc269_dac_nids alc260_dac_nids
12191
12192static hda_nid_t alc269_adc_nids[1] = {
12193 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020012194 0x08,
12195};
12196
Takashi Iwaie01bf502008-08-21 16:25:07 +020012197static hda_nid_t alc269_capsrc_nids[1] = {
12198 0x23,
12199};
12200
12201/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
12202 * not a mux!
12203 */
12204
Kailang Yangf53281e2008-07-18 12:36:43 +020012205static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
12206 .num_items = 2,
12207 .items = {
12208 { "i-Mic", 0x5 },
12209 { "e-Mic", 0x0 },
12210 },
12211};
12212
12213static struct hda_input_mux alc269_eeepc_amic_capture_source = {
12214 .num_items = 2,
12215 .items = {
12216 { "i-Mic", 0x1 },
12217 { "e-Mic", 0x0 },
12218 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012219};
12220
12221#define alc269_modes alc260_modes
12222#define alc269_capture_source alc880_lg_lw_capture_source
12223
12224static struct snd_kcontrol_new alc269_base_mixer[] = {
12225 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
12226 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12227 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
12228 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
12229 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12230 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12231 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12232 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12233 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12234 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12235 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12236 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
12237 { } /* end */
12238};
12239
Kailang Yang60db6b52008-08-26 13:13:00 +020012240static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
12241 /* output mixer control */
12242 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12243 {
12244 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12245 .name = "Master Playback Switch",
12246 .info = snd_hda_mixer_amp_switch_info,
12247 .get = snd_hda_mixer_amp_switch_get,
12248 .put = alc268_acer_master_sw_put,
12249 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12250 },
12251 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12252 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12253 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12254 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12255 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12256 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020012257 { }
12258};
12259
Tony Vroon64154832008-11-06 15:08:49 +000012260static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
12261 /* output mixer control */
12262 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12263 {
12264 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12265 .name = "Master Playback Switch",
12266 .info = snd_hda_mixer_amp_switch_info,
12267 .get = snd_hda_mixer_amp_switch_get,
12268 .put = alc268_acer_master_sw_put,
12269 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12270 },
12271 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
12272 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
12273 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12274 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
12275 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
12276 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12277 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
12278 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
12279 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000012280 { }
12281};
12282
Kailang Yangf53281e2008-07-18 12:36:43 +020012283/* bind volumes of both NID 0x0c and 0x0d */
12284static struct hda_bind_ctls alc269_epc_bind_vol = {
12285 .ops = &snd_hda_bind_vol,
12286 .values = {
12287 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12288 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12289 0
12290 },
12291};
12292
12293static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
12294 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12295 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
12296 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12297 { } /* end */
12298};
12299
Kailang Yangf6a92242007-12-13 16:52:54 +010012300/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020012301static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
12302 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12303 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012304 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12305 { } /* end */
12306};
12307
12308/* FSC amilo */
12309static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
12310 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12311 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12312 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020012313 { } /* end */
12314};
12315
Kailang Yang60db6b52008-08-26 13:13:00 +020012316static struct hda_verb alc269_quanta_fl1_verbs[] = {
12317 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12318 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12319 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12320 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12321 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12322 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12323 { }
12324};
12325
Tony Vroon64154832008-11-06 15:08:49 +000012326static struct hda_verb alc269_lifebook_verbs[] = {
12327 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12328 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
12329 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12330 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12331 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12332 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12333 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12334 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12335 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12336 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12337 { }
12338};
12339
Kailang Yang60db6b52008-08-26 13:13:00 +020012340/* toggle speaker-output according to the hp-jack state */
12341static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
12342{
12343 unsigned int present;
12344 unsigned char bits;
12345
12346 present = snd_hda_codec_read(codec, 0x15, 0,
12347 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12348 bits = present ? AMP_IN_MUTE(0) : 0;
12349 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12350 AMP_IN_MUTE(0), bits);
12351 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12352 AMP_IN_MUTE(0), bits);
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, 0x680);
12358
12359 snd_hda_codec_write(codec, 0x20, 0,
12360 AC_VERB_SET_COEF_INDEX, 0x0c);
12361 snd_hda_codec_write(codec, 0x20, 0,
12362 AC_VERB_SET_PROC_COEF, 0x480);
12363}
12364
Tony Vroon64154832008-11-06 15:08:49 +000012365/* toggle speaker-output according to the hp-jacks state */
12366static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
12367{
12368 unsigned int present;
12369 unsigned char bits;
12370
12371 /* Check laptop headphone socket */
12372 present = snd_hda_codec_read(codec, 0x15, 0,
12373 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12374
12375 /* Check port replicator headphone socket */
12376 present |= snd_hda_codec_read(codec, 0x1a, 0,
12377 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12378
12379 bits = present ? AMP_IN_MUTE(0) : 0;
12380 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12381 AMP_IN_MUTE(0), bits);
12382 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12383 AMP_IN_MUTE(0), bits);
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, 0x680);
12389
12390 snd_hda_codec_write(codec, 0x20, 0,
12391 AC_VERB_SET_COEF_INDEX, 0x0c);
12392 snd_hda_codec_write(codec, 0x20, 0,
12393 AC_VERB_SET_PROC_COEF, 0x480);
12394}
12395
Kailang Yang60db6b52008-08-26 13:13:00 +020012396static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
12397{
12398 unsigned int present;
12399
12400 present = snd_hda_codec_read(codec, 0x18, 0,
12401 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12402 snd_hda_codec_write(codec, 0x23, 0,
12403 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
12404}
12405
Tony Vroon64154832008-11-06 15:08:49 +000012406static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
12407{
12408 unsigned int present_laptop;
12409 unsigned int present_dock;
12410
12411 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12412 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12413
12414 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12415 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12416
12417 /* Laptop mic port overrides dock mic port, design decision */
12418 if (present_dock)
12419 snd_hda_codec_write(codec, 0x23, 0,
12420 AC_VERB_SET_CONNECT_SEL, 0x3);
12421 if (present_laptop)
12422 snd_hda_codec_write(codec, 0x23, 0,
12423 AC_VERB_SET_CONNECT_SEL, 0x0);
12424 if (!present_dock && !present_laptop)
12425 snd_hda_codec_write(codec, 0x23, 0,
12426 AC_VERB_SET_CONNECT_SEL, 0x1);
12427}
12428
Kailang Yang60db6b52008-08-26 13:13:00 +020012429static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12430 unsigned int res)
12431{
12432 if ((res >> 26) == ALC880_HP_EVENT)
12433 alc269_quanta_fl1_speaker_automute(codec);
12434 if ((res >> 26) == ALC880_MIC_EVENT)
12435 alc269_quanta_fl1_mic_automute(codec);
12436}
12437
Tony Vroon64154832008-11-06 15:08:49 +000012438static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12439 unsigned int res)
12440{
12441 if ((res >> 26) == ALC880_HP_EVENT)
12442 alc269_lifebook_speaker_automute(codec);
12443 if ((res >> 26) == ALC880_MIC_EVENT)
12444 alc269_lifebook_mic_autoswitch(codec);
12445}
12446
Kailang Yang60db6b52008-08-26 13:13:00 +020012447static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12448{
12449 alc269_quanta_fl1_speaker_automute(codec);
12450 alc269_quanta_fl1_mic_automute(codec);
12451}
12452
Tony Vroon64154832008-11-06 15:08:49 +000012453static void alc269_lifebook_init_hook(struct hda_codec *codec)
12454{
12455 alc269_lifebook_speaker_automute(codec);
12456 alc269_lifebook_mic_autoswitch(codec);
12457}
12458
Kailang Yang60db6b52008-08-26 13:13:00 +020012459static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12460 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12461 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12462 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12463 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12464 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12465 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12466 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12467 {}
12468};
12469
12470static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12471 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12472 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12473 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12474 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12475 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12476 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12477 {}
12478};
12479
12480/* toggle speaker-output according to the hp-jack state */
12481static void alc269_speaker_automute(struct hda_codec *codec)
12482{
12483 unsigned int present;
12484 unsigned char bits;
12485
12486 present = snd_hda_codec_read(codec, 0x15, 0,
12487 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12488 bits = present ? AMP_IN_MUTE(0) : 0;
12489 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12490 AMP_IN_MUTE(0), bits);
12491 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12492 AMP_IN_MUTE(0), bits);
12493}
12494
12495static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12496{
12497 unsigned int present;
12498
12499 present = snd_hda_codec_read(codec, 0x18, 0,
12500 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12501 snd_hda_codec_write(codec, 0x23, 0,
12502 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12503}
12504
12505static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12506{
12507 unsigned int present;
12508
12509 present = snd_hda_codec_read(codec, 0x18, 0,
12510 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12511 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12512 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12513 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12514 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12515}
12516
12517/* unsolicited event for HP jack sensing */
12518static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12519 unsigned int res)
12520{
12521 if ((res >> 26) == ALC880_HP_EVENT)
12522 alc269_speaker_automute(codec);
12523
12524 if ((res >> 26) == ALC880_MIC_EVENT)
12525 alc269_eeepc_dmic_automute(codec);
12526}
12527
12528static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12529{
12530 alc269_speaker_automute(codec);
12531 alc269_eeepc_dmic_automute(codec);
12532}
12533
12534/* unsolicited event for HP jack sensing */
12535static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12536 unsigned int res)
12537{
12538 if ((res >> 26) == ALC880_HP_EVENT)
12539 alc269_speaker_automute(codec);
12540
12541 if ((res >> 26) == ALC880_MIC_EVENT)
12542 alc269_eeepc_amic_automute(codec);
12543}
12544
12545static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12546{
12547 alc269_speaker_automute(codec);
12548 alc269_eeepc_amic_automute(codec);
12549}
12550
Kailang Yangf6a92242007-12-13 16:52:54 +010012551/*
12552 * generic initialization of ADC, input mixers and output mixers
12553 */
12554static struct hda_verb alc269_init_verbs[] = {
12555 /*
12556 * Unmute ADC0 and set the default input to mic-in
12557 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012558 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012559
12560 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12561 * analog-loopback mixer widget
12562 * Note: PASD motherboards uses the Line In 2 as the input for
12563 * front panel mic (mic 2)
12564 */
12565 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12566 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12567 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12568 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12569 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12570 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12571
12572 /*
12573 * Set up output mixers (0x0c - 0x0e)
12574 */
12575 /* set vol=0 to output mixers */
12576 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12577 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12578
12579 /* set up input amps for analog loopback */
12580 /* Amp Indices: DAC = 0, mixer = 1 */
12581 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12582 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12583 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12584 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12585 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12586 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12587
12588 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12589 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12590 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12591 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12592 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12593 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12594 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12595
12596 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12597 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12598 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12599 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12600 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12601 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12602 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12603
12604 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12605 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12606
12607 /* FIXME: use matrix-type input source selection */
12608 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12609 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012610 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12611 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012612 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12613 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12614
12615 /* set EAPD */
12616 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12617 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12618 { }
12619};
12620
12621/* add playback controls from the parsed DAC table */
12622static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12623 const struct auto_pin_cfg *cfg)
12624{
12625 hda_nid_t nid;
12626 int err;
12627
12628 spec->multiout.num_dacs = 1; /* only use one dac */
12629 spec->multiout.dac_nids = spec->private_dac_nids;
12630 spec->multiout.dac_nids[0] = 2;
12631
12632 nid = cfg->line_out_pins[0];
12633 if (nid) {
12634 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12635 "Front Playback Volume",
12636 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12637 if (err < 0)
12638 return err;
12639 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12640 "Front Playback Switch",
12641 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12642 if (err < 0)
12643 return err;
12644 }
12645
12646 nid = cfg->speaker_pins[0];
12647 if (nid) {
12648 if (!cfg->line_out_pins[0]) {
12649 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12650 "Speaker Playback Volume",
12651 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12652 HDA_OUTPUT));
12653 if (err < 0)
12654 return err;
12655 }
12656 if (nid == 0x16) {
12657 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12658 "Speaker Playback Switch",
12659 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12660 HDA_OUTPUT));
12661 if (err < 0)
12662 return err;
12663 } else {
12664 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12665 "Speaker Playback Switch",
12666 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12667 HDA_OUTPUT));
12668 if (err < 0)
12669 return err;
12670 }
12671 }
12672 nid = cfg->hp_pins[0];
12673 if (nid) {
12674 /* spec->multiout.hp_nid = 2; */
12675 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12676 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12677 "Headphone Playback Volume",
12678 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12679 HDA_OUTPUT));
12680 if (err < 0)
12681 return err;
12682 }
12683 if (nid == 0x16) {
12684 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12685 "Headphone Playback Switch",
12686 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12687 HDA_OUTPUT));
12688 if (err < 0)
12689 return err;
12690 } else {
12691 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12692 "Headphone Playback Switch",
12693 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12694 HDA_OUTPUT));
12695 if (err < 0)
12696 return err;
12697 }
12698 }
12699 return 0;
12700}
12701
Takashi Iwaiee956e02008-10-31 17:16:31 +010012702static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12703 const struct auto_pin_cfg *cfg)
12704{
12705 int err;
12706
12707 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12708 if (err < 0)
12709 return err;
12710 /* digital-mic input pin is excluded in alc880_auto_create..()
12711 * because it's under 0x18
12712 */
12713 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12714 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012715 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwaiee956e02008-10-31 17:16:31 +010012716 imux->items[imux->num_items].label = "Int Mic";
12717 imux->items[imux->num_items].index = 0x05;
12718 imux->num_items++;
12719 }
12720 return 0;
12721}
Kailang Yangf6a92242007-12-13 16:52:54 +010012722
12723#ifdef CONFIG_SND_HDA_POWER_SAVE
12724#define alc269_loopbacks alc880_loopbacks
12725#endif
12726
12727/* pcm configuration: identiacal with ALC880 */
12728#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12729#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12730#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12731#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12732
12733/*
12734 * BIOS auto configuration
12735 */
12736static int alc269_parse_auto_config(struct hda_codec *codec)
12737{
12738 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010012739 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012740 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12741
12742 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12743 alc269_ignore);
12744 if (err < 0)
12745 return err;
12746
12747 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12748 if (err < 0)
12749 return err;
12750 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12751 if (err < 0)
12752 return err;
12753
12754 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12755
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012756 if (spec->autocfg.dig_outs)
Kailang Yangf6a92242007-12-13 16:52:54 +010012757 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12758
Takashi Iwai603c4012008-07-30 15:01:44 +020012759 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012760 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012761
Takashi Iwaid88897e2008-10-31 15:01:37 +010012762 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012763 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012764 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie01bf502008-08-21 16:25:07 +020012765 /* set default input source */
12766 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12767 0, AC_VERB_SET_CONNECT_SEL,
12768 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012769
12770 err = alc_auto_add_mic_boost(codec);
12771 if (err < 0)
12772 return err;
12773
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010012774 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012775 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012776
Takashi Iwaie044c392008-10-27 16:56:24 +010012777 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012778 return 1;
12779}
12780
12781#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12782#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12783#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12784
12785
12786/* init callback for auto-configuration model -- overriding the default init */
12787static void alc269_auto_init(struct hda_codec *codec)
12788{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012789 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012790 alc269_auto_init_multi_out(codec);
12791 alc269_auto_init_hp_out(codec);
12792 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012793 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012794 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012795}
12796
12797/*
12798 * configuration and preset
12799 */
12800static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012801 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012802 [ALC269_QUANTA_FL1] = "quanta",
12803 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012804 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012805 [ALC269_FUJITSU] = "fujitsu",
12806 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012807};
12808
12809static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012810 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012811 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12812 ALC269_ASUS_EEEPC_P703),
12813 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12814 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012815 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12816 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012817 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012818 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012819 {}
12820};
12821
12822static struct alc_config_preset alc269_presets[] = {
12823 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012824 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012825 .init_verbs = { alc269_init_verbs },
12826 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12827 .dac_nids = alc269_dac_nids,
12828 .hp_nid = 0x03,
12829 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12830 .channel_mode = alc269_modes,
12831 .input_mux = &alc269_capture_source,
12832 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012833 [ALC269_QUANTA_FL1] = {
12834 .mixers = { alc269_quanta_fl1_mixer },
12835 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12836 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12837 .dac_nids = alc269_dac_nids,
12838 .hp_nid = 0x03,
12839 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12840 .channel_mode = alc269_modes,
12841 .input_mux = &alc269_capture_source,
12842 .unsol_event = alc269_quanta_fl1_unsol_event,
12843 .init_hook = alc269_quanta_fl1_init_hook,
12844 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012845 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012846 .mixers = { alc269_eeepc_mixer },
12847 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012848 .init_verbs = { alc269_init_verbs,
12849 alc269_eeepc_amic_init_verbs },
12850 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12851 .dac_nids = alc269_dac_nids,
12852 .hp_nid = 0x03,
12853 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12854 .channel_mode = alc269_modes,
12855 .input_mux = &alc269_eeepc_amic_capture_source,
12856 .unsol_event = alc269_eeepc_amic_unsol_event,
12857 .init_hook = alc269_eeepc_amic_inithook,
12858 },
12859 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012860 .mixers = { alc269_eeepc_mixer },
12861 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012862 .init_verbs = { alc269_init_verbs,
12863 alc269_eeepc_dmic_init_verbs },
12864 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12865 .dac_nids = alc269_dac_nids,
12866 .hp_nid = 0x03,
12867 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12868 .channel_mode = alc269_modes,
12869 .input_mux = &alc269_eeepc_dmic_capture_source,
12870 .unsol_event = alc269_eeepc_dmic_unsol_event,
12871 .init_hook = alc269_eeepc_dmic_inithook,
12872 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012873 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012874 .mixers = { alc269_fujitsu_mixer },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012875 .cap_mixer = alc269_epc_capture_mixer,
12876 .init_verbs = { alc269_init_verbs,
12877 alc269_eeepc_dmic_init_verbs },
12878 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12879 .dac_nids = alc269_dac_nids,
12880 .hp_nid = 0x03,
12881 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12882 .channel_mode = alc269_modes,
12883 .input_mux = &alc269_eeepc_dmic_capture_source,
12884 .unsol_event = alc269_eeepc_dmic_unsol_event,
12885 .init_hook = alc269_eeepc_dmic_inithook,
12886 },
Tony Vroon64154832008-11-06 15:08:49 +000012887 [ALC269_LIFEBOOK] = {
12888 .mixers = { alc269_lifebook_mixer },
12889 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12890 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12891 .dac_nids = alc269_dac_nids,
12892 .hp_nid = 0x03,
12893 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12894 .channel_mode = alc269_modes,
12895 .input_mux = &alc269_capture_source,
12896 .unsol_event = alc269_lifebook_unsol_event,
12897 .init_hook = alc269_lifebook_init_hook,
12898 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012899};
12900
12901static int patch_alc269(struct hda_codec *codec)
12902{
12903 struct alc_spec *spec;
12904 int board_config;
12905 int err;
12906
12907 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12908 if (spec == NULL)
12909 return -ENOMEM;
12910
12911 codec->spec = spec;
12912
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012913 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12914
Kailang Yangf6a92242007-12-13 16:52:54 +010012915 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12916 alc269_models,
12917 alc269_cfg_tbl);
12918
12919 if (board_config < 0) {
12920 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12921 "trying auto-probe from BIOS...\n");
12922 board_config = ALC269_AUTO;
12923 }
12924
12925 if (board_config == ALC269_AUTO) {
12926 /* automatic parse from the BIOS config */
12927 err = alc269_parse_auto_config(codec);
12928 if (err < 0) {
12929 alc_free(codec);
12930 return err;
12931 } else if (!err) {
12932 printk(KERN_INFO
12933 "hda_codec: Cannot set up configuration "
12934 "from BIOS. Using base mode...\n");
12935 board_config = ALC269_BASIC;
12936 }
12937 }
12938
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012939 err = snd_hda_attach_beep_device(codec, 0x1);
12940 if (err < 0) {
12941 alc_free(codec);
12942 return err;
12943 }
12944
Kailang Yangf6a92242007-12-13 16:52:54 +010012945 if (board_config != ALC269_AUTO)
12946 setup_preset(spec, &alc269_presets[board_config]);
12947
12948 spec->stream_name_analog = "ALC269 Analog";
12949 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12950 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12951
12952 spec->stream_name_digital = "ALC269 Digital";
12953 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12954 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12955
12956 spec->adc_nids = alc269_adc_nids;
12957 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012958 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012959 if (!spec->cap_mixer)
12960 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010012961 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010012962
12963 codec->patch_ops = alc_patch_ops;
12964 if (board_config == ALC269_AUTO)
12965 spec->init_hook = alc269_auto_init;
12966#ifdef CONFIG_SND_HDA_POWER_SAVE
12967 if (!spec->loopback.amplist)
12968 spec->loopback.amplist = alc269_loopbacks;
12969#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010012970 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010012971
12972 return 0;
12973}
12974
12975/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012976 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12977 */
12978
12979/*
12980 * set the path ways for 2 channel output
12981 * need to set the codec line out and mic 1 pin widgets to inputs
12982 */
12983static struct hda_verb alc861_threestack_ch2_init[] = {
12984 /* set pin widget 1Ah (line in) for input */
12985 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012986 /* set pin widget 18h (mic1/2) for input, for mic also enable
12987 * the vref
12988 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012989 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12990
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012991 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12992#if 0
12993 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12994 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12995#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012996 { } /* end */
12997};
12998/*
12999 * 6ch mode
13000 * need to set the codec line out and mic 1 pin widgets to outputs
13001 */
13002static struct hda_verb alc861_threestack_ch6_init[] = {
13003 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13004 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13005 /* set pin widget 18h (mic1) for output (CLFE)*/
13006 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13007
13008 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013009 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013010
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013011 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13012#if 0
13013 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13014 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13015#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010013016 { } /* end */
13017};
13018
13019static struct hda_channel_mode alc861_threestack_modes[2] = {
13020 { 2, alc861_threestack_ch2_init },
13021 { 6, alc861_threestack_ch6_init },
13022};
Takashi Iwai22309c32006-08-09 16:57:28 +020013023/* Set mic1 as input and unmute the mixer */
13024static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
13025 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13026 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13027 { } /* end */
13028};
13029/* Set mic1 as output and mute mixer */
13030static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
13031 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13032 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13033 { } /* end */
13034};
13035
13036static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
13037 { 2, alc861_uniwill_m31_ch2_init },
13038 { 4, alc861_uniwill_m31_ch4_init },
13039};
Kailang Yangdf694da2005-12-05 19:42:22 +010013040
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013041/* Set mic1 and line-in as input and unmute the mixer */
13042static struct hda_verb alc861_asus_ch2_init[] = {
13043 /* set pin widget 1Ah (line in) for input */
13044 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013045 /* set pin widget 18h (mic1/2) for input, for mic also enable
13046 * the vref
13047 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013048 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13049
13050 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
13051#if 0
13052 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
13053 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
13054#endif
13055 { } /* end */
13056};
13057/* Set mic1 nad line-in as output and mute mixer */
13058static struct hda_verb alc861_asus_ch6_init[] = {
13059 /* set pin widget 1Ah (line in) for output (Back Surround)*/
13060 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13061 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13062 /* set pin widget 18h (mic1) for output (CLFE)*/
13063 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13064 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
13065 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
13066 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
13067
13068 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
13069#if 0
13070 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
13071 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
13072#endif
13073 { } /* end */
13074};
13075
13076static struct hda_channel_mode alc861_asus_modes[2] = {
13077 { 2, alc861_asus_ch2_init },
13078 { 6, alc861_asus_ch6_init },
13079};
13080
Kailang Yangdf694da2005-12-05 19:42:22 +010013081/* patch-ALC861 */
13082
13083static struct snd_kcontrol_new alc861_base_mixer[] = {
13084 /* output mixer control */
13085 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13086 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13087 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13088 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13089 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13090
13091 /*Input mixer control */
13092 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13093 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13094 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13095 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13096 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13097 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13099 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13100 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13101 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013102
Kailang Yangdf694da2005-12-05 19:42:22 +010013103 { } /* end */
13104};
13105
13106static struct snd_kcontrol_new alc861_3ST_mixer[] = {
13107 /* output mixer control */
13108 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13109 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13110 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13111 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13112 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13113
13114 /* Input mixer control */
13115 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13116 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13117 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13118 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13119 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13120 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13121 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13122 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13123 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13124 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013125
Kailang Yangdf694da2005-12-05 19:42:22 +010013126 {
13127 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13128 .name = "Channel Mode",
13129 .info = alc_ch_mode_info,
13130 .get = alc_ch_mode_get,
13131 .put = alc_ch_mode_put,
13132 .private_value = ARRAY_SIZE(alc861_threestack_modes),
13133 },
13134 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013135};
13136
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013137static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013138 /* output mixer control */
13139 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13140 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13141 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013142
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013143 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013144};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013145
Takashi Iwai22309c32006-08-09 16:57:28 +020013146static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
13147 /* output mixer control */
13148 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13149 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13150 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13151 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13152 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
13153
13154 /* Input mixer control */
13155 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13156 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
13157 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13158 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13159 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13160 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13161 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13162 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13163 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
13164 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013165
Takashi Iwai22309c32006-08-09 16:57:28 +020013166 {
13167 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13168 .name = "Channel Mode",
13169 .info = alc_ch_mode_info,
13170 .get = alc_ch_mode_get,
13171 .put = alc_ch_mode_put,
13172 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
13173 },
13174 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013175};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013176
13177static struct snd_kcontrol_new alc861_asus_mixer[] = {
13178 /* output mixer control */
13179 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
13180 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
13181 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
13182 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
13183 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
13184
13185 /* Input mixer control */
13186 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
13187 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13188 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13189 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
13190 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
13191 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
13192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
13193 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
13194 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013195 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
13196
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013197 {
13198 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13199 .name = "Channel Mode",
13200 .info = alc_ch_mode_info,
13201 .get = alc_ch_mode_get,
13202 .put = alc_ch_mode_put,
13203 .private_value = ARRAY_SIZE(alc861_asus_modes),
13204 },
13205 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013206};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013207
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013208/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010013209static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013210 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
13211 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013212 { }
13213};
13214
Kailang Yangdf694da2005-12-05 19:42:22 +010013215/*
13216 * generic initialization of ADC, input mixers and output mixers
13217 */
13218static struct hda_verb alc861_base_init_verbs[] = {
13219 /*
13220 * Unmute ADC0 and set the default input to mic-in
13221 */
13222 /* port-A for surround (rear panel) */
13223 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13224 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
13225 /* port-B for mic-in (rear panel) with vref */
13226 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13227 /* port-C for line-in (rear panel) */
13228 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13229 /* port-D for Front */
13230 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13231 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13232 /* port-E for HP out (front panel) */
13233 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13234 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013235 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013236 /* port-F for mic-in (front panel) with vref */
13237 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13238 /* port-G for CLFE (rear panel) */
13239 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13240 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
13241 /* port-H for side (rear panel) */
13242 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13243 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
13244 /* CD-in */
13245 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13246 /* route front mic to ADC1*/
13247 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13248 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013249
Kailang Yangdf694da2005-12-05 19:42:22 +010013250 /* Unmute DAC0~3 & spdif out*/
13251 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13252 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13253 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13254 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13255 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013256
Kailang Yangdf694da2005-12-05 19:42:22 +010013257 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13258 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13259 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13260 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13261 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013262
Kailang Yangdf694da2005-12-05 19:42:22 +010013263 /* Unmute Stereo Mixer 15 */
13264 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13265 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13266 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013267 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013268
13269 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13270 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13271 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13272 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13273 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13274 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13275 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13276 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013277 /* hp used DAC 3 (Front) */
13278 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013279 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13280
13281 { }
13282};
13283
13284static struct hda_verb alc861_threestack_init_verbs[] = {
13285 /*
13286 * Unmute ADC0 and set the default input to mic-in
13287 */
13288 /* port-A for surround (rear panel) */
13289 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13290 /* port-B for mic-in (rear panel) with vref */
13291 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13292 /* port-C for line-in (rear panel) */
13293 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13294 /* port-D for Front */
13295 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13296 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13297 /* port-E for HP out (front panel) */
13298 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
13299 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013300 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010013301 /* port-F for mic-in (front panel) with vref */
13302 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13303 /* port-G for CLFE (rear panel) */
13304 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13305 /* port-H for side (rear panel) */
13306 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13307 /* CD-in */
13308 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13309 /* route front mic to ADC1*/
13310 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13311 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13312 /* Unmute DAC0~3 & spdif out*/
13313 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13314 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13315 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13316 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13317 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013318
Kailang Yangdf694da2005-12-05 19:42:22 +010013319 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13320 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13321 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13322 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13323 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013324
Kailang Yangdf694da2005-12-05 19:42:22 +010013325 /* Unmute Stereo Mixer 15 */
13326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13328 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013329 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010013330
13331 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13332 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13333 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13334 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13335 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13336 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13337 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13338 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013339 /* hp used DAC 3 (Front) */
13340 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013341 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13342 { }
13343};
Takashi Iwai22309c32006-08-09 16:57:28 +020013344
13345static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
13346 /*
13347 * Unmute ADC0 and set the default input to mic-in
13348 */
13349 /* port-A for surround (rear panel) */
13350 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13351 /* port-B for mic-in (rear panel) with vref */
13352 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13353 /* port-C for line-in (rear panel) */
13354 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13355 /* port-D for Front */
13356 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13357 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13358 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013359 /* this has to be set to VREF80 */
13360 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013361 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013362 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013363 /* port-F for mic-in (front panel) with vref */
13364 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13365 /* port-G for CLFE (rear panel) */
13366 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13367 /* port-H for side (rear panel) */
13368 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13369 /* CD-in */
13370 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13371 /* route front mic to ADC1*/
13372 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13373 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13374 /* Unmute DAC0~3 & spdif out*/
13375 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13376 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13377 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13378 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013380
Takashi Iwai22309c32006-08-09 16:57:28 +020013381 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13382 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13383 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13384 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13385 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013386
Takashi Iwai22309c32006-08-09 16:57:28 +020013387 /* Unmute Stereo Mixer 15 */
13388 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13389 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13390 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013391 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020013392
13393 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13394 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13395 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13396 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13397 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13398 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13399 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13400 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013401 /* hp used DAC 3 (Front) */
13402 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020013403 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13404 { }
13405};
13406
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013407static struct hda_verb alc861_asus_init_verbs[] = {
13408 /*
13409 * Unmute ADC0 and set the default input to mic-in
13410 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013411 /* port-A for surround (rear panel)
13412 * according to codec#0 this is the HP jack
13413 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013414 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13415 /* route front PCM to HP */
13416 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13417 /* port-B for mic-in (rear panel) with vref */
13418 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13419 /* port-C for line-in (rear panel) */
13420 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13421 /* port-D for Front */
13422 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13423 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13424 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013425 /* this has to be set to VREF80 */
13426 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013427 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013428 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013429 /* port-F for mic-in (front panel) with vref */
13430 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13431 /* port-G for CLFE (rear panel) */
13432 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13433 /* port-H for side (rear panel) */
13434 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13435 /* CD-in */
13436 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13437 /* route front mic to ADC1*/
13438 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13439 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13440 /* Unmute DAC0~3 & spdif out*/
13441 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13442 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13443 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13444 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13445 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13446 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13447 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13448 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13449 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13450 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013451
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013452 /* Unmute Stereo Mixer 15 */
13453 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13454 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13455 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013456 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013457
13458 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13459 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13460 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13461 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13462 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13463 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13464 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13465 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013466 /* hp used DAC 3 (Front) */
13467 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013468 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13469 { }
13470};
13471
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013472/* additional init verbs for ASUS laptops */
13473static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13474 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13475 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13476 { }
13477};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013478
Kailang Yangdf694da2005-12-05 19:42:22 +010013479/*
13480 * generic initialization of ADC, input mixers and output mixers
13481 */
13482static struct hda_verb alc861_auto_init_verbs[] = {
13483 /*
13484 * Unmute ADC0 and set the default input to mic-in
13485 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013486 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013487 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013488
Kailang Yangdf694da2005-12-05 19:42:22 +010013489 /* Unmute DAC0~3 & spdif out*/
13490 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13491 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13492 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13493 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13494 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013495
Kailang Yangdf694da2005-12-05 19:42:22 +010013496 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13497 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13498 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13499 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13500 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013501
Kailang Yangdf694da2005-12-05 19:42:22 +010013502 /* Unmute Stereo Mixer 15 */
13503 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13504 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13505 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13506 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13507
13508 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13509 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13510 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13511 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13512 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13514 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13515 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13516
13517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13518 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013519 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13520 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013521 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13522 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013523 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13524 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013525
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013526 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013527
13528 { }
13529};
13530
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013531static struct hda_verb alc861_toshiba_init_verbs[] = {
13532 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013533
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013534 { }
13535};
13536
13537/* toggle speaker-output according to the hp-jack state */
13538static void alc861_toshiba_automute(struct hda_codec *codec)
13539{
13540 unsigned int present;
13541
13542 present = snd_hda_codec_read(codec, 0x0f, 0,
13543 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013544 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13545 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13546 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13547 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013548}
13549
13550static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13551 unsigned int res)
13552{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013553 if ((res >> 26) == ALC880_HP_EVENT)
13554 alc861_toshiba_automute(codec);
13555}
13556
Kailang Yangdf694da2005-12-05 19:42:22 +010013557/* pcm configuration: identiacal with ALC880 */
13558#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13559#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13560#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13561#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13562
13563
13564#define ALC861_DIGOUT_NID 0x07
13565
13566static struct hda_channel_mode alc861_8ch_modes[1] = {
13567 { 8, NULL }
13568};
13569
13570static hda_nid_t alc861_dac_nids[4] = {
13571 /* front, surround, clfe, side */
13572 0x03, 0x06, 0x05, 0x04
13573};
13574
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013575static hda_nid_t alc660_dac_nids[3] = {
13576 /* front, clfe, surround */
13577 0x03, 0x05, 0x06
13578};
13579
Kailang Yangdf694da2005-12-05 19:42:22 +010013580static hda_nid_t alc861_adc_nids[1] = {
13581 /* ADC0-2 */
13582 0x08,
13583};
13584
13585static struct hda_input_mux alc861_capture_source = {
13586 .num_items = 5,
13587 .items = {
13588 { "Mic", 0x0 },
13589 { "Front Mic", 0x3 },
13590 { "Line", 0x1 },
13591 { "CD", 0x4 },
13592 { "Mixer", 0x5 },
13593 },
13594};
13595
13596/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013597static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13598 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013599{
13600 int i;
13601 hda_nid_t nid;
13602
13603 spec->multiout.dac_nids = spec->private_dac_nids;
13604 for (i = 0; i < cfg->line_outs; i++) {
13605 nid = cfg->line_out_pins[i];
13606 if (nid) {
13607 if (i >= ARRAY_SIZE(alc861_dac_nids))
13608 continue;
13609 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13610 }
13611 }
13612 spec->multiout.num_dacs = cfg->line_outs;
13613 return 0;
13614}
13615
13616/* add playback controls from the parsed DAC table */
13617static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13618 const struct auto_pin_cfg *cfg)
13619{
13620 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013621 static const char *chname[4] = {
13622 "Front", "Surround", NULL /*CLFE*/, "Side"
13623 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013624 hda_nid_t nid;
13625 int i, idx, err;
13626
13627 for (i = 0; i < cfg->line_outs; i++) {
13628 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013629 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013630 continue;
13631 if (nid == 0x05) {
13632 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013633 err = add_control(spec, ALC_CTL_BIND_MUTE,
13634 "Center Playback Switch",
13635 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13636 HDA_OUTPUT));
13637 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013638 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013639 err = add_control(spec, ALC_CTL_BIND_MUTE,
13640 "LFE Playback Switch",
13641 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13642 HDA_OUTPUT));
13643 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013644 return err;
13645 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013646 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13647 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013648 if (nid == alc861_dac_nids[idx])
13649 break;
13650 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013651 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13652 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13653 HDA_OUTPUT));
13654 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013655 return err;
13656 }
13657 }
13658 return 0;
13659}
13660
13661static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13662{
13663 int err;
13664 hda_nid_t nid;
13665
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013666 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013667 return 0;
13668
13669 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13670 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013671 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13672 "Headphone Playback Switch",
13673 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13674 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013675 return err;
13676 spec->multiout.hp_nid = nid;
13677 }
13678 return 0;
13679}
13680
13681/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013682static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13683 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013684{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013685 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013686 int i, err, idx, idx1;
13687
13688 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013689 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013690 case 0x0c:
13691 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013692 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013693 break;
13694 case 0x0f:
13695 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013696 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013697 break;
13698 case 0x0d:
13699 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013700 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013701 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013702 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013703 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013704 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013705 break;
13706 case 0x11:
13707 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013708 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013709 break;
13710 default:
13711 continue;
13712 }
13713
Takashi Iwai4a471b72005-12-07 13:56:29 +010013714 err = new_analog_input(spec, cfg->input_pins[i],
13715 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013716 if (err < 0)
13717 return err;
13718
Takashi Iwai4a471b72005-12-07 13:56:29 +010013719 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013720 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013721 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013722 }
13723 return 0;
13724}
13725
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013726static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13727 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013728 int pin_type, int dac_idx)
13729{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013730 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13731 pin_type);
13732 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13733 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013734}
13735
13736static void alc861_auto_init_multi_out(struct hda_codec *codec)
13737{
13738 struct alc_spec *spec = codec->spec;
13739 int i;
13740
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013741 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013742 for (i = 0; i < spec->autocfg.line_outs; i++) {
13743 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013744 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013745 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013746 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013747 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013748 }
13749}
13750
13751static void alc861_auto_init_hp_out(struct hda_codec *codec)
13752{
13753 struct alc_spec *spec = codec->spec;
13754 hda_nid_t pin;
13755
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013756 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013757 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013758 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13759 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013760 pin = spec->autocfg.speaker_pins[0];
13761 if (pin)
13762 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013763}
13764
13765static void alc861_auto_init_analog_input(struct hda_codec *codec)
13766{
13767 struct alc_spec *spec = codec->spec;
13768 int i;
13769
13770 for (i = 0; i < AUTO_PIN_LAST; i++) {
13771 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013772 if (nid >= 0x0c && nid <= 0x11) {
13773 snd_hda_codec_write(codec, nid, 0,
13774 AC_VERB_SET_PIN_WIDGET_CONTROL,
13775 i <= AUTO_PIN_FRONT_MIC ?
13776 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013777 }
13778 }
13779}
13780
13781/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013782/* return 1 if successful, 0 if the proper config is not found,
13783 * or a negative error code
13784 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013785static int alc861_parse_auto_config(struct hda_codec *codec)
13786{
13787 struct alc_spec *spec = codec->spec;
13788 int err;
13789 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13790
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013791 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13792 alc861_ignore);
13793 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013794 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013795 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013796 return 0; /* can't find valid BIOS pin config */
13797
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013798 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13799 if (err < 0)
13800 return err;
13801 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13802 if (err < 0)
13803 return err;
13804 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13805 if (err < 0)
13806 return err;
13807 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13808 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013809 return err;
13810
13811 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13812
Takashi Iwai0852d7a2009-02-11 11:35:15 +010013813 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013814 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13815
Takashi Iwai603c4012008-07-30 15:01:44 +020013816 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013817 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013818
Takashi Iwaid88897e2008-10-31 15:01:37 +010013819 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013820
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013821 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013822 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013823
13824 spec->adc_nids = alc861_adc_nids;
13825 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013826 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013827
Takashi Iwaie044c392008-10-27 16:56:24 +010013828 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013829 return 1;
13830}
13831
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013832/* additional initialization for auto-configuration model */
13833static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013834{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013835 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013836 alc861_auto_init_multi_out(codec);
13837 alc861_auto_init_hp_out(codec);
13838 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013839 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013840 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013841}
13842
Takashi Iwaicb53c622007-08-10 17:21:45 +020013843#ifdef CONFIG_SND_HDA_POWER_SAVE
13844static struct hda_amp_list alc861_loopbacks[] = {
13845 { 0x15, HDA_INPUT, 0 },
13846 { 0x15, HDA_INPUT, 1 },
13847 { 0x15, HDA_INPUT, 2 },
13848 { 0x15, HDA_INPUT, 3 },
13849 { } /* end */
13850};
13851#endif
13852
Kailang Yangdf694da2005-12-05 19:42:22 +010013853
13854/*
13855 * configuration and preset
13856 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013857static const char *alc861_models[ALC861_MODEL_LAST] = {
13858 [ALC861_3ST] = "3stack",
13859 [ALC660_3ST] = "3stack-660",
13860 [ALC861_3ST_DIG] = "3stack-dig",
13861 [ALC861_6ST_DIG] = "6stack-dig",
13862 [ALC861_UNIWILL_M31] = "uniwill-m31",
13863 [ALC861_TOSHIBA] = "toshiba",
13864 [ALC861_ASUS] = "asus",
13865 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13866 [ALC861_AUTO] = "auto",
13867};
13868
13869static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013870 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013871 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13872 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13873 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013874 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013875 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013876 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013877 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13878 * Any other models that need this preset?
13879 */
13880 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013881 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13882 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013883 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13884 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13885 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13886 /* FIXME: the below seems conflict */
13887 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13888 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13889 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013890 {}
13891};
13892
13893static struct alc_config_preset alc861_presets[] = {
13894 [ALC861_3ST] = {
13895 .mixers = { alc861_3ST_mixer },
13896 .init_verbs = { alc861_threestack_init_verbs },
13897 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13898 .dac_nids = alc861_dac_nids,
13899 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13900 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013901 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013902 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13903 .adc_nids = alc861_adc_nids,
13904 .input_mux = &alc861_capture_source,
13905 },
13906 [ALC861_3ST_DIG] = {
13907 .mixers = { alc861_base_mixer },
13908 .init_verbs = { alc861_threestack_init_verbs },
13909 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13910 .dac_nids = alc861_dac_nids,
13911 .dig_out_nid = ALC861_DIGOUT_NID,
13912 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13913 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013914 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013915 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13916 .adc_nids = alc861_adc_nids,
13917 .input_mux = &alc861_capture_source,
13918 },
13919 [ALC861_6ST_DIG] = {
13920 .mixers = { alc861_base_mixer },
13921 .init_verbs = { alc861_base_init_verbs },
13922 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13923 .dac_nids = alc861_dac_nids,
13924 .dig_out_nid = ALC861_DIGOUT_NID,
13925 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13926 .channel_mode = alc861_8ch_modes,
13927 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13928 .adc_nids = alc861_adc_nids,
13929 .input_mux = &alc861_capture_source,
13930 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013931 [ALC660_3ST] = {
13932 .mixers = { alc861_3ST_mixer },
13933 .init_verbs = { alc861_threestack_init_verbs },
13934 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13935 .dac_nids = alc660_dac_nids,
13936 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13937 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013938 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013939 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13940 .adc_nids = alc861_adc_nids,
13941 .input_mux = &alc861_capture_source,
13942 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013943 [ALC861_UNIWILL_M31] = {
13944 .mixers = { alc861_uniwill_m31_mixer },
13945 .init_verbs = { alc861_uniwill_m31_init_verbs },
13946 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13947 .dac_nids = alc861_dac_nids,
13948 .dig_out_nid = ALC861_DIGOUT_NID,
13949 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13950 .channel_mode = alc861_uniwill_m31_modes,
13951 .need_dac_fix = 1,
13952 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13953 .adc_nids = alc861_adc_nids,
13954 .input_mux = &alc861_capture_source,
13955 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013956 [ALC861_TOSHIBA] = {
13957 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013958 .init_verbs = { alc861_base_init_verbs,
13959 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013960 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13961 .dac_nids = alc861_dac_nids,
13962 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13963 .channel_mode = alc883_3ST_2ch_modes,
13964 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13965 .adc_nids = alc861_adc_nids,
13966 .input_mux = &alc861_capture_source,
13967 .unsol_event = alc861_toshiba_unsol_event,
13968 .init_hook = alc861_toshiba_automute,
13969 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013970 [ALC861_ASUS] = {
13971 .mixers = { alc861_asus_mixer },
13972 .init_verbs = { alc861_asus_init_verbs },
13973 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13974 .dac_nids = alc861_dac_nids,
13975 .dig_out_nid = ALC861_DIGOUT_NID,
13976 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13977 .channel_mode = alc861_asus_modes,
13978 .need_dac_fix = 1,
13979 .hp_nid = 0x06,
13980 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13981 .adc_nids = alc861_adc_nids,
13982 .input_mux = &alc861_capture_source,
13983 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013984 [ALC861_ASUS_LAPTOP] = {
13985 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13986 .init_verbs = { alc861_asus_init_verbs,
13987 alc861_asus_laptop_init_verbs },
13988 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13989 .dac_nids = alc861_dac_nids,
13990 .dig_out_nid = ALC861_DIGOUT_NID,
13991 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13992 .channel_mode = alc883_3ST_2ch_modes,
13993 .need_dac_fix = 1,
13994 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13995 .adc_nids = alc861_adc_nids,
13996 .input_mux = &alc861_capture_source,
13997 },
13998};
Kailang Yangdf694da2005-12-05 19:42:22 +010013999
14000
14001static int patch_alc861(struct hda_codec *codec)
14002{
14003 struct alc_spec *spec;
14004 int board_config;
14005 int err;
14006
Robert P. J. Daydc041e02006-12-19 14:44:15 +010014007 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010014008 if (spec == NULL)
14009 return -ENOMEM;
14010
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014011 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010014012
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014013 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
14014 alc861_models,
14015 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014016
Takashi Iwaif5fcc132006-11-24 17:07:44 +010014017 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014018 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
14019 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014020 board_config = ALC861_AUTO;
14021 }
14022
14023 if (board_config == ALC861_AUTO) {
14024 /* automatic parse from the BIOS config */
14025 err = alc861_parse_auto_config(codec);
14026 if (err < 0) {
14027 alc_free(codec);
14028 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014029 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020014030 printk(KERN_INFO
14031 "hda_codec: Cannot set up configuration "
14032 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010014033 board_config = ALC861_3ST_DIG;
14034 }
14035 }
14036
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014037 err = snd_hda_attach_beep_device(codec, 0x23);
14038 if (err < 0) {
14039 alc_free(codec);
14040 return err;
14041 }
14042
Kailang Yangdf694da2005-12-05 19:42:22 +010014043 if (board_config != ALC861_AUTO)
14044 setup_preset(spec, &alc861_presets[board_config]);
14045
14046 spec->stream_name_analog = "ALC861 Analog";
14047 spec->stream_analog_playback = &alc861_pcm_analog_playback;
14048 spec->stream_analog_capture = &alc861_pcm_analog_capture;
14049
14050 spec->stream_name_digital = "ALC861 Digital";
14051 spec->stream_digital_playback = &alc861_pcm_digital_playback;
14052 spec->stream_digital_capture = &alc861_pcm_digital_capture;
14053
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014054 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
14055
Takashi Iwai2134ea42008-01-10 16:53:55 +010014056 spec->vmaster_nid = 0x03;
14057
Kailang Yangdf694da2005-12-05 19:42:22 +010014058 codec->patch_ops = alc_patch_ops;
14059 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010014060 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014061#ifdef CONFIG_SND_HDA_POWER_SAVE
14062 if (!spec->loopback.amplist)
14063 spec->loopback.amplist = alc861_loopbacks;
14064#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010014065 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangea1fb292008-08-26 12:58:38 +020014066
Kailang Yangdf694da2005-12-05 19:42:22 +010014067 return 0;
14068}
14069
14070/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014071 * ALC861-VD support
14072 *
14073 * Based on ALC882
14074 *
14075 * In addition, an independent DAC
14076 */
14077#define ALC861VD_DIGOUT_NID 0x06
14078
14079static hda_nid_t alc861vd_dac_nids[4] = {
14080 /* front, surr, clfe, side surr */
14081 0x02, 0x03, 0x04, 0x05
14082};
14083
14084/* dac_nids for ALC660vd are in a different order - according to
14085 * Realtek's driver.
14086 * This should probably tesult in a different mixer for 6stack models
14087 * of ALC660vd codecs, but for now there is only 3stack mixer
14088 * - and it is the same as in 861vd.
14089 * adc_nids in ALC660vd are (is) the same as in 861vd
14090 */
14091static hda_nid_t alc660vd_dac_nids[3] = {
14092 /* front, rear, clfe, rear_surr */
14093 0x02, 0x04, 0x03
14094};
14095
14096static hda_nid_t alc861vd_adc_nids[1] = {
14097 /* ADC0 */
14098 0x09,
14099};
14100
Takashi Iwaie1406342008-02-11 18:32:32 +010014101static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
14102
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014103/* input MUX */
14104/* FIXME: should be a matrix-type input source selection */
14105static struct hda_input_mux alc861vd_capture_source = {
14106 .num_items = 4,
14107 .items = {
14108 { "Mic", 0x0 },
14109 { "Front Mic", 0x1 },
14110 { "Line", 0x2 },
14111 { "CD", 0x4 },
14112 },
14113};
14114
Kailang Yang272a5272007-05-14 11:00:38 +020014115static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010014116 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020014117 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010014118 { "Ext Mic", 0x0 },
14119 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020014120 },
14121};
14122
Kailang Yangd1a991a2007-08-15 16:21:59 +020014123static struct hda_input_mux alc861vd_hp_capture_source = {
14124 .num_items = 2,
14125 .items = {
14126 { "Front Mic", 0x0 },
14127 { "ATAPI Mic", 0x1 },
14128 },
14129};
14130
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014131/*
14132 * 2ch mode
14133 */
14134static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
14135 { 2, NULL }
14136};
14137
14138/*
14139 * 6ch mode
14140 */
14141static struct hda_verb alc861vd_6stack_ch6_init[] = {
14142 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14143 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14144 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14145 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14146 { } /* end */
14147};
14148
14149/*
14150 * 8ch mode
14151 */
14152static struct hda_verb alc861vd_6stack_ch8_init[] = {
14153 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14154 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14155 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14156 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14157 { } /* end */
14158};
14159
14160static struct hda_channel_mode alc861vd_6stack_modes[2] = {
14161 { 6, alc861vd_6stack_ch6_init },
14162 { 8, alc861vd_6stack_ch8_init },
14163};
14164
14165static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
14166 {
14167 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14168 .name = "Channel Mode",
14169 .info = alc_ch_mode_info,
14170 .get = alc_ch_mode_get,
14171 .put = alc_ch_mode_put,
14172 },
14173 { } /* end */
14174};
14175
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014176/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14177 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14178 */
14179static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
14180 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14181 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14182
14183 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14184 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
14185
14186 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
14187 HDA_OUTPUT),
14188 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
14189 HDA_OUTPUT),
14190 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
14191 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
14192
14193 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
14194 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
14195
14196 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14197
14198 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14199 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14200 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14201
14202 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14203 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14204 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14205
14206 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14207 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14208
14209 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14210 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14211
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014212 { } /* end */
14213};
14214
14215static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
14216 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14217 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14218
14219 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14220
14221 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14222 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14223 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14224
14225 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14226 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14228
14229 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14230 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14231
14232 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14233 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14234
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014235 { } /* end */
14236};
14237
Kailang Yangbdd148a2007-05-08 15:19:08 +020014238static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
14239 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14240 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
14241 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14242
14243 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14244
14245 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14247 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14248
14249 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14250 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14251 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14252
14253 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14254 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14255
14256 { } /* end */
14257};
14258
Tobin Davisb419f342008-03-07 11:57:51 +010014259/* Pin assignment: Speaker=0x14, HP = 0x15,
14260 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020014261 */
14262static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010014263 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14264 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014265 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14266 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010014267 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
14268 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14269 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14270 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
14271 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14272 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020014273 { } /* end */
14274};
14275
Kailang Yangd1a991a2007-08-15 16:21:59 +020014276/* Pin assignment: Speaker=0x14, Line-out = 0x15,
14277 * Front Mic=0x18, ATAPI Mic = 0x19,
14278 */
14279static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
14280 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14281 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
14282 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14283 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
14284 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14285 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14286 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14287 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020014288
Kailang Yangd1a991a2007-08-15 16:21:59 +020014289 { } /* end */
14290};
14291
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014292/*
14293 * generic initialization of ADC, input mixers and output mixers
14294 */
14295static struct hda_verb alc861vd_volume_init_verbs[] = {
14296 /*
14297 * Unmute ADC0 and set the default input to mic-in
14298 */
14299 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14300 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14301
14302 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
14303 * the analog-loopback mixer widget
14304 */
14305 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014306 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14307 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14308 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14309 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14310 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014311
14312 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020014313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014316 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014317
14318 /*
14319 * Set up output mixers (0x02 - 0x05)
14320 */
14321 /* set vol=0 to output mixers */
14322 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14323 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14324 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14325 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14326
14327 /* set up input amps for analog loopback */
14328 /* Amp Indices: DAC = 0, mixer = 1 */
14329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14336 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14337
14338 { }
14339};
14340
14341/*
14342 * 3-stack pin configuration:
14343 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
14344 */
14345static struct hda_verb alc861vd_3stack_init_verbs[] = {
14346 /*
14347 * Set pin mode and muting
14348 */
14349 /* set front pin widgets 0x14 for output */
14350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14352 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14353
14354 /* Mic (rear) pin: input vref at 80% */
14355 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14356 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14357 /* Front Mic pin: input vref at 80% */
14358 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14359 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14360 /* Line In pin: input */
14361 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14362 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14363 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14364 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14365 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14366 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14367 /* CD pin widget for input */
14368 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14369
14370 { }
14371};
14372
14373/*
14374 * 6-stack pin configuration:
14375 */
14376static struct hda_verb alc861vd_6stack_init_verbs[] = {
14377 /*
14378 * Set pin mode and muting
14379 */
14380 /* set front pin widgets 0x14 for output */
14381 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14382 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14383 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
14384
14385 /* Rear Pin: output 1 (0x0d) */
14386 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14388 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14389 /* CLFE Pin: output 2 (0x0e) */
14390 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14391 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14392 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
14393 /* Side Pin: output 3 (0x0f) */
14394 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14395 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14396 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
14397
14398 /* Mic (rear) pin: input vref at 80% */
14399 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14400 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14401 /* Front Mic pin: input vref at 80% */
14402 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14403 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14404 /* Line In pin: input */
14405 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14406 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14407 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14408 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14409 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14410 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14411 /* CD pin widget for input */
14412 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14413
14414 { }
14415};
14416
Kailang Yangbdd148a2007-05-08 15:19:08 +020014417static struct hda_verb alc861vd_eapd_verbs[] = {
14418 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14419 { }
14420};
14421
Kailang Yangf9423e72008-05-27 12:32:25 +020014422static struct hda_verb alc660vd_eapd_verbs[] = {
14423 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14424 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14425 { }
14426};
14427
Kailang Yangbdd148a2007-05-08 15:19:08 +020014428static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14431 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14432 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014433 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014434 {}
14435};
14436
14437/* toggle speaker-output according to the hp-jack state */
14438static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14439{
14440 unsigned int present;
14441 unsigned char bits;
14442
14443 present = snd_hda_codec_read(codec, 0x1b, 0,
14444 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014445 bits = present ? HDA_AMP_MUTE : 0;
14446 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14447 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014448}
14449
14450static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14451{
14452 unsigned int present;
14453 unsigned char bits;
14454
14455 present = snd_hda_codec_read(codec, 0x18, 0,
14456 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014457 bits = present ? HDA_AMP_MUTE : 0;
14458 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14459 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014460}
14461
14462static void alc861vd_lenovo_automute(struct hda_codec *codec)
14463{
14464 alc861vd_lenovo_hp_automute(codec);
14465 alc861vd_lenovo_mic_automute(codec);
14466}
14467
14468static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14469 unsigned int res)
14470{
14471 switch (res >> 26) {
14472 case ALC880_HP_EVENT:
14473 alc861vd_lenovo_hp_automute(codec);
14474 break;
14475 case ALC880_MIC_EVENT:
14476 alc861vd_lenovo_mic_automute(codec);
14477 break;
14478 }
14479}
14480
Kailang Yang272a5272007-05-14 11:00:38 +020014481static struct hda_verb alc861vd_dallas_verbs[] = {
14482 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14483 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14484 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14485 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14486
14487 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14488 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14489 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14490 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14491 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14492 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14493 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14494 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014495
Kailang Yang272a5272007-05-14 11:00:38 +020014496 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14497 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14498 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14500 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14501 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14502 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14503 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14504
14505 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14506 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14507 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14508 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14509 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14510 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14511 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14512 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14513
14514 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14515 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14516 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14517 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14518
14519 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014520 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014521 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14522
14523 { } /* end */
14524};
14525
14526/* toggle speaker-output according to the hp-jack state */
14527static void alc861vd_dallas_automute(struct hda_codec *codec)
14528{
14529 unsigned int present;
14530
14531 present = snd_hda_codec_read(codec, 0x15, 0,
14532 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014533 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14534 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014535}
14536
14537static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14538{
14539 if ((res >> 26) == ALC880_HP_EVENT)
14540 alc861vd_dallas_automute(codec);
14541}
14542
Takashi Iwaicb53c622007-08-10 17:21:45 +020014543#ifdef CONFIG_SND_HDA_POWER_SAVE
14544#define alc861vd_loopbacks alc880_loopbacks
14545#endif
14546
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014547/* pcm configuration: identiacal with ALC880 */
14548#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14549#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14550#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14551#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14552
14553/*
14554 * configuration and preset
14555 */
14556static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14557 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014558 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014559 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014560 [ALC861VD_3ST] = "3stack",
14561 [ALC861VD_3ST_DIG] = "3stack-digout",
14562 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014563 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014564 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014565 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014566 [ALC861VD_AUTO] = "auto",
14567};
14568
14569static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014570 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14571 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014572 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014573 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014574 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014575 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014576 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014577 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014578 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014579 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014580 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014581 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014582 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010014583 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014584 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014585 {}
14586};
14587
14588static struct alc_config_preset alc861vd_presets[] = {
14589 [ALC660VD_3ST] = {
14590 .mixers = { alc861vd_3st_mixer },
14591 .init_verbs = { alc861vd_volume_init_verbs,
14592 alc861vd_3stack_init_verbs },
14593 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14594 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014595 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14596 .channel_mode = alc861vd_3stack_2ch_modes,
14597 .input_mux = &alc861vd_capture_source,
14598 },
Mike Crash6963f842007-06-25 12:12:51 +020014599 [ALC660VD_3ST_DIG] = {
14600 .mixers = { alc861vd_3st_mixer },
14601 .init_verbs = { alc861vd_volume_init_verbs,
14602 alc861vd_3stack_init_verbs },
14603 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14604 .dac_nids = alc660vd_dac_nids,
14605 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014606 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14607 .channel_mode = alc861vd_3stack_2ch_modes,
14608 .input_mux = &alc861vd_capture_source,
14609 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014610 [ALC861VD_3ST] = {
14611 .mixers = { alc861vd_3st_mixer },
14612 .init_verbs = { alc861vd_volume_init_verbs,
14613 alc861vd_3stack_init_verbs },
14614 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14615 .dac_nids = alc861vd_dac_nids,
14616 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14617 .channel_mode = alc861vd_3stack_2ch_modes,
14618 .input_mux = &alc861vd_capture_source,
14619 },
14620 [ALC861VD_3ST_DIG] = {
14621 .mixers = { alc861vd_3st_mixer },
14622 .init_verbs = { alc861vd_volume_init_verbs,
14623 alc861vd_3stack_init_verbs },
14624 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14625 .dac_nids = alc861vd_dac_nids,
14626 .dig_out_nid = ALC861VD_DIGOUT_NID,
14627 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14628 .channel_mode = alc861vd_3stack_2ch_modes,
14629 .input_mux = &alc861vd_capture_source,
14630 },
14631 [ALC861VD_6ST_DIG] = {
14632 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14633 .init_verbs = { alc861vd_volume_init_verbs,
14634 alc861vd_6stack_init_verbs },
14635 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14636 .dac_nids = alc861vd_dac_nids,
14637 .dig_out_nid = ALC861VD_DIGOUT_NID,
14638 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14639 .channel_mode = alc861vd_6stack_modes,
14640 .input_mux = &alc861vd_capture_source,
14641 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014642 [ALC861VD_LENOVO] = {
14643 .mixers = { alc861vd_lenovo_mixer },
14644 .init_verbs = { alc861vd_volume_init_verbs,
14645 alc861vd_3stack_init_verbs,
14646 alc861vd_eapd_verbs,
14647 alc861vd_lenovo_unsol_verbs },
14648 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14649 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014650 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14651 .channel_mode = alc861vd_3stack_2ch_modes,
14652 .input_mux = &alc861vd_capture_source,
14653 .unsol_event = alc861vd_lenovo_unsol_event,
14654 .init_hook = alc861vd_lenovo_automute,
14655 },
Kailang Yang272a5272007-05-14 11:00:38 +020014656 [ALC861VD_DALLAS] = {
14657 .mixers = { alc861vd_dallas_mixer },
14658 .init_verbs = { alc861vd_dallas_verbs },
14659 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14660 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014661 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14662 .channel_mode = alc861vd_3stack_2ch_modes,
14663 .input_mux = &alc861vd_dallas_capture_source,
14664 .unsol_event = alc861vd_dallas_unsol_event,
14665 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014666 },
14667 [ALC861VD_HP] = {
14668 .mixers = { alc861vd_hp_mixer },
14669 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14670 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14671 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014672 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014673 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14674 .channel_mode = alc861vd_3stack_2ch_modes,
14675 .input_mux = &alc861vd_hp_capture_source,
14676 .unsol_event = alc861vd_dallas_unsol_event,
14677 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014678 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014679 [ALC660VD_ASUS_V1S] = {
14680 .mixers = { alc861vd_lenovo_mixer },
14681 .init_verbs = { alc861vd_volume_init_verbs,
14682 alc861vd_3stack_init_verbs,
14683 alc861vd_eapd_verbs,
14684 alc861vd_lenovo_unsol_verbs },
14685 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14686 .dac_nids = alc660vd_dac_nids,
14687 .dig_out_nid = ALC861VD_DIGOUT_NID,
14688 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14689 .channel_mode = alc861vd_3stack_2ch_modes,
14690 .input_mux = &alc861vd_capture_source,
14691 .unsol_event = alc861vd_lenovo_unsol_event,
14692 .init_hook = alc861vd_lenovo_automute,
14693 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014694};
14695
14696/*
14697 * BIOS auto configuration
14698 */
14699static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14700 hda_nid_t nid, int pin_type, int dac_idx)
14701{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014702 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014703}
14704
14705static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14706{
14707 struct alc_spec *spec = codec->spec;
14708 int i;
14709
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014710 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014711 for (i = 0; i <= HDA_SIDE; i++) {
14712 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014713 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014714 if (nid)
14715 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014716 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014717 }
14718}
14719
14720
14721static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14722{
14723 struct alc_spec *spec = codec->spec;
14724 hda_nid_t pin;
14725
14726 pin = spec->autocfg.hp_pins[0];
14727 if (pin) /* connect to front and use dac 0 */
14728 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014729 pin = spec->autocfg.speaker_pins[0];
14730 if (pin)
14731 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014732}
14733
14734#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14735#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14736
14737static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14738{
14739 struct alc_spec *spec = codec->spec;
14740 int i;
14741
14742 for (i = 0; i < AUTO_PIN_LAST; i++) {
14743 hda_nid_t nid = spec->autocfg.input_pins[i];
14744 if (alc861vd_is_input_pin(nid)) {
14745 snd_hda_codec_write(codec, nid, 0,
14746 AC_VERB_SET_PIN_WIDGET_CONTROL,
14747 i <= AUTO_PIN_FRONT_MIC ?
14748 PIN_VREF80 : PIN_IN);
14749 if (nid != ALC861VD_PIN_CD_NID)
14750 snd_hda_codec_write(codec, nid, 0,
14751 AC_VERB_SET_AMP_GAIN_MUTE,
14752 AMP_OUT_MUTE);
14753 }
14754 }
14755}
14756
Takashi Iwaif511b012008-08-15 16:46:42 +020014757#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14758
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014759#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14760#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14761
14762/* add playback controls from the parsed DAC table */
14763/* Based on ALC880 version. But ALC861VD has separate,
14764 * different NIDs for mute/unmute switch and volume control */
14765static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14766 const struct auto_pin_cfg *cfg)
14767{
14768 char name[32];
14769 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14770 hda_nid_t nid_v, nid_s;
14771 int i, err;
14772
14773 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014774 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014775 continue;
14776 nid_v = alc861vd_idx_to_mixer_vol(
14777 alc880_dac_to_idx(
14778 spec->multiout.dac_nids[i]));
14779 nid_s = alc861vd_idx_to_mixer_switch(
14780 alc880_dac_to_idx(
14781 spec->multiout.dac_nids[i]));
14782
14783 if (i == 2) {
14784 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014785 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14786 "Center Playback Volume",
14787 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14788 HDA_OUTPUT));
14789 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014790 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014791 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14792 "LFE Playback Volume",
14793 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14794 HDA_OUTPUT));
14795 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014796 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014797 err = add_control(spec, ALC_CTL_BIND_MUTE,
14798 "Center Playback Switch",
14799 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14800 HDA_INPUT));
14801 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014802 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014803 err = add_control(spec, ALC_CTL_BIND_MUTE,
14804 "LFE Playback Switch",
14805 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14806 HDA_INPUT));
14807 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014808 return err;
14809 } else {
14810 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014811 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14812 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14813 HDA_OUTPUT));
14814 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014815 return err;
14816 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014817 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014818 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014819 HDA_INPUT));
14820 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014821 return err;
14822 }
14823 }
14824 return 0;
14825}
14826
14827/* add playback controls for speaker and HP outputs */
14828/* Based on ALC880 version. But ALC861VD has separate,
14829 * different NIDs for mute/unmute switch and volume control */
14830static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14831 hda_nid_t pin, const char *pfx)
14832{
14833 hda_nid_t nid_v, nid_s;
14834 int err;
14835 char name[32];
14836
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014837 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014838 return 0;
14839
14840 if (alc880_is_fixed_pin(pin)) {
14841 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14842 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014843 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014844 spec->multiout.hp_nid = nid_v;
14845 else
14846 spec->multiout.extra_out_nid[0] = nid_v;
14847 /* control HP volume/switch on the output mixer amp */
14848 nid_v = alc861vd_idx_to_mixer_vol(
14849 alc880_fixed_pin_idx(pin));
14850 nid_s = alc861vd_idx_to_mixer_switch(
14851 alc880_fixed_pin_idx(pin));
14852
14853 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014854 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14855 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14856 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014857 return err;
14858 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014859 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14860 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14861 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014862 return err;
14863 } else if (alc880_is_multi_pin(pin)) {
14864 /* set manual connection */
14865 /* we have only a switch on HP-out PIN */
14866 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014867 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14868 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14869 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014870 return err;
14871 }
14872 return 0;
14873}
14874
14875/* parse the BIOS configuration and set up the alc_spec
14876 * return 1 if successful, 0 if the proper config is not found,
14877 * or a negative error code
14878 * Based on ALC880 version - had to change it to override
14879 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14880static int alc861vd_parse_auto_config(struct hda_codec *codec)
14881{
14882 struct alc_spec *spec = codec->spec;
14883 int err;
14884 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14885
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014886 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14887 alc861vd_ignore);
14888 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014889 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014890 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014891 return 0; /* can't find valid BIOS pin config */
14892
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014893 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14894 if (err < 0)
14895 return err;
14896 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14897 if (err < 0)
14898 return err;
14899 err = alc861vd_auto_create_extra_out(spec,
14900 spec->autocfg.speaker_pins[0],
14901 "Speaker");
14902 if (err < 0)
14903 return err;
14904 err = alc861vd_auto_create_extra_out(spec,
14905 spec->autocfg.hp_pins[0],
14906 "Headphone");
14907 if (err < 0)
14908 return err;
14909 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14910 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014911 return err;
14912
14913 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14914
Takashi Iwai0852d7a2009-02-11 11:35:15 +010014915 if (spec->autocfg.dig_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014916 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14917
Takashi Iwai603c4012008-07-30 15:01:44 +020014918 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014919 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014920
Takashi Iwaid88897e2008-10-31 15:01:37 +010014921 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014922
14923 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014924 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014925
Takashi Iwai776e1842007-08-29 15:07:11 +020014926 err = alc_auto_add_mic_boost(codec);
14927 if (err < 0)
14928 return err;
14929
Takashi Iwaie044c392008-10-27 16:56:24 +010014930 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014931 return 1;
14932}
14933
14934/* additional initialization for auto-configuration model */
14935static void alc861vd_auto_init(struct hda_codec *codec)
14936{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014937 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014938 alc861vd_auto_init_multi_out(codec);
14939 alc861vd_auto_init_hp_out(codec);
14940 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014941 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014942 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014943 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014944}
14945
14946static int patch_alc861vd(struct hda_codec *codec)
14947{
14948 struct alc_spec *spec;
14949 int err, board_config;
14950
14951 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14952 if (spec == NULL)
14953 return -ENOMEM;
14954
14955 codec->spec = spec;
14956
14957 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14958 alc861vd_models,
14959 alc861vd_cfg_tbl);
14960
14961 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14962 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14963 "ALC861VD, trying auto-probe from BIOS...\n");
14964 board_config = ALC861VD_AUTO;
14965 }
14966
14967 if (board_config == ALC861VD_AUTO) {
14968 /* automatic parse from the BIOS config */
14969 err = alc861vd_parse_auto_config(codec);
14970 if (err < 0) {
14971 alc_free(codec);
14972 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014973 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014974 printk(KERN_INFO
14975 "hda_codec: Cannot set up configuration "
14976 "from BIOS. Using base mode...\n");
14977 board_config = ALC861VD_3ST;
14978 }
14979 }
14980
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014981 err = snd_hda_attach_beep_device(codec, 0x23);
14982 if (err < 0) {
14983 alc_free(codec);
14984 return err;
14985 }
14986
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014987 if (board_config != ALC861VD_AUTO)
14988 setup_preset(spec, &alc861vd_presets[board_config]);
14989
Kailang Yang2f893282008-05-27 12:14:47 +020014990 if (codec->vendor_id == 0x10ec0660) {
14991 spec->stream_name_analog = "ALC660-VD Analog";
14992 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014993 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014994 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014995 } else {
14996 spec->stream_name_analog = "ALC861VD Analog";
14997 spec->stream_name_digital = "ALC861VD Digital";
14998 }
14999
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015000 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
15001 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
15002
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015003 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15004 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15005
15006 spec->adc_nids = alc861vd_adc_nids;
15007 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010015008 spec->capsrc_nids = alc861vd_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015009 spec->capture_style = CAPT_MIX;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015010
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015011 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015012 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015013
Takashi Iwai2134ea42008-01-10 16:53:55 +010015014 spec->vmaster_nid = 0x02;
15015
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015016 codec->patch_ops = alc_patch_ops;
15017
15018 if (board_config == ALC861VD_AUTO)
15019 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015020#ifdef CONFIG_SND_HDA_POWER_SAVE
15021 if (!spec->loopback.amplist)
15022 spec->loopback.amplist = alc861vd_loopbacks;
15023#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010015024 codec->proc_widget_hook = print_realtek_coef;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015025
15026 return 0;
15027}
15028
15029/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015030 * ALC662 support
15031 *
15032 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
15033 * configuration. Each pin widget can choose any input DACs and a mixer.
15034 * Each ADC is connected from a mixer of all inputs. This makes possible
15035 * 6-channel independent captures.
15036 *
15037 * In addition, an independent DAC for the multi-playback (not used in this
15038 * driver yet).
15039 */
15040#define ALC662_DIGOUT_NID 0x06
15041#define ALC662_DIGIN_NID 0x0a
15042
15043static hda_nid_t alc662_dac_nids[4] = {
15044 /* front, rear, clfe, rear_surr */
15045 0x02, 0x03, 0x04
15046};
15047
15048static hda_nid_t alc662_adc_nids[1] = {
15049 /* ADC1-2 */
15050 0x09,
15051};
Takashi Iwaie1406342008-02-11 18:32:32 +010015052
Kailang Yang77a261b2008-02-19 11:38:05 +010015053static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010015054
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015055/* input MUX */
15056/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015057static struct hda_input_mux alc662_capture_source = {
15058 .num_items = 4,
15059 .items = {
15060 { "Mic", 0x0 },
15061 { "Front Mic", 0x1 },
15062 { "Line", 0x2 },
15063 { "CD", 0x4 },
15064 },
15065};
15066
15067static struct hda_input_mux alc662_lenovo_101e_capture_source = {
15068 .num_items = 2,
15069 .items = {
15070 { "Mic", 0x1 },
15071 { "Line", 0x2 },
15072 },
15073};
Kailang Yang291702f2007-10-16 14:28:03 +020015074
15075static struct hda_input_mux alc662_eeepc_capture_source = {
15076 .num_items = 2,
15077 .items = {
15078 { "i-Mic", 0x1 },
15079 { "e-Mic", 0x0 },
15080 },
15081};
15082
Kailang Yang6dda9f42008-05-27 12:05:31 +020015083static struct hda_input_mux alc663_capture_source = {
15084 .num_items = 3,
15085 .items = {
15086 { "Mic", 0x0 },
15087 { "Front Mic", 0x1 },
15088 { "Line", 0x2 },
15089 },
15090};
15091
15092static struct hda_input_mux alc663_m51va_capture_source = {
15093 .num_items = 2,
15094 .items = {
15095 { "Ext-Mic", 0x0 },
15096 { "D-Mic", 0x9 },
15097 },
15098};
15099
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015100/*
15101 * 2ch mode
15102 */
15103static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
15104 { 2, NULL }
15105};
15106
15107/*
15108 * 2ch mode
15109 */
15110static struct hda_verb alc662_3ST_ch2_init[] = {
15111 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
15112 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15113 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
15114 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
15115 { } /* end */
15116};
15117
15118/*
15119 * 6ch mode
15120 */
15121static struct hda_verb alc662_3ST_ch6_init[] = {
15122 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15123 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15124 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
15125 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15126 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
15127 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
15128 { } /* end */
15129};
15130
15131static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
15132 { 2, alc662_3ST_ch2_init },
15133 { 6, alc662_3ST_ch6_init },
15134};
15135
15136/*
15137 * 2ch mode
15138 */
15139static struct hda_verb alc662_sixstack_ch6_init[] = {
15140 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15141 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15142 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15143 { } /* end */
15144};
15145
15146/*
15147 * 6ch mode
15148 */
15149static struct hda_verb alc662_sixstack_ch8_init[] = {
15150 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15151 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15152 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
15153 { } /* end */
15154};
15155
15156static struct hda_channel_mode alc662_5stack_modes[2] = {
15157 { 2, alc662_sixstack_ch6_init },
15158 { 6, alc662_sixstack_ch8_init },
15159};
15160
15161/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
15162 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
15163 */
15164
15165static struct snd_kcontrol_new alc662_base_mixer[] = {
15166 /* output mixer control */
15167 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015168 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015169 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015170 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015171 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15172 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015173 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15174 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15176
15177 /*Input mixer control */
15178 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
15179 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
15180 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
15181 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
15182 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
15183 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
15184 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
15185 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015186 { } /* end */
15187};
15188
15189static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
15190 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015191 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015192 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15193 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15194 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15195 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15196 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15198 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15199 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15200 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015201 { } /* end */
15202};
15203
15204static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
15205 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015206 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015207 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015208 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015209 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15210 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010015211 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
15212 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015213 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15214 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
15215 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
15216 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15217 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15218 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15219 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15220 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15221 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015222 { } /* end */
15223};
15224
15225static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
15226 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15227 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015228 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15229 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015230 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15231 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15232 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15233 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15234 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015235 { } /* end */
15236};
15237
Kailang Yang291702f2007-10-16 14:28:03 +020015238static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010015239 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015240
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010015241 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15242 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020015243
15244 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
15245 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15246 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15247
15248 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15249 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15250 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15251 { } /* end */
15252};
15253
Kailang Yang8c427222008-01-10 13:03:59 +010015254static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010015255 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15256 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015257 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15258 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
15259 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
15260 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
15261 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
15262 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010015263 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010015264 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
15265 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15266 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15267 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15268 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15269 { } /* end */
15270};
15271
Kailang Yangf1d4e282008-08-26 14:03:29 +020015272static struct hda_bind_ctls alc663_asus_bind_master_vol = {
15273 .ops = &snd_hda_bind_vol,
15274 .values = {
15275 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15276 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
15277 0
15278 },
15279};
15280
15281static struct hda_bind_ctls alc663_asus_one_bind_switch = {
15282 .ops = &snd_hda_bind_sw,
15283 .values = {
15284 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15285 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15286 0
15287 },
15288};
15289
Kailang Yang6dda9f42008-05-27 12:05:31 +020015290static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015291 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15292 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
15293 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15294 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15295 { } /* end */
15296};
15297
15298static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
15299 .ops = &snd_hda_bind_sw,
15300 .values = {
15301 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15302 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15303 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
15304 0
15305 },
15306};
15307
15308static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
15309 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15310 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
15311 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15312 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15313 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15314 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15315
15316 { } /* end */
15317};
15318
15319static struct hda_bind_ctls alc663_asus_four_bind_switch = {
15320 .ops = &snd_hda_bind_sw,
15321 .values = {
15322 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15323 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
15324 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15325 0
15326 },
15327};
15328
15329static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
15330 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15331 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
15332 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15333 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15334 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15335 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15336 { } /* end */
15337};
15338
15339static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015340 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15341 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015342 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
15343 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15344 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15345 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15346 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15347 { } /* end */
15348};
15349
15350static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
15351 .ops = &snd_hda_bind_vol,
15352 .values = {
15353 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
15354 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
15355 0
15356 },
15357};
15358
15359static struct hda_bind_ctls alc663_asus_two_bind_switch = {
15360 .ops = &snd_hda_bind_sw,
15361 .values = {
15362 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
15363 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
15364 0
15365 },
15366};
15367
15368static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
15369 HDA_BIND_VOL("Master Playback Volume",
15370 &alc663_asus_two_bind_master_vol),
15371 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15372 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015373 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15374 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15375 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015376 { } /* end */
15377};
15378
15379static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
15380 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
15381 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
15382 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15383 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15384 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15385 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015386 { } /* end */
15387};
15388
15389static struct snd_kcontrol_new alc663_g71v_mixer[] = {
15390 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15391 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15392 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
15393 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15394 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15395
15396 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15397 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15398 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15399 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15400 { } /* end */
15401};
15402
15403static struct snd_kcontrol_new alc663_g50v_mixer[] = {
15404 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15405 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
15406 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
15407
15408 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
15409 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
15410 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15411 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15412 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
15413 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15414 { } /* end */
15415};
15416
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015417static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15418 {
15419 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15420 .name = "Channel Mode",
15421 .info = alc_ch_mode_info,
15422 .get = alc_ch_mode_get,
15423 .put = alc_ch_mode_put,
15424 },
15425 { } /* end */
15426};
15427
15428static struct hda_verb alc662_init_verbs[] = {
15429 /* ADC: mute amp left and right */
15430 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15431 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15432 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15433
Takashi Iwaicb53c622007-08-10 17:21:45 +020015434 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15435 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15436 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15437 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15438 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015439
Kailang Yangb60dd392007-09-20 12:50:29 +020015440 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15441 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15442 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15443 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15444 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15445 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015446
15447 /* Front Pin: output 0 (0x0c) */
15448 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15449 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15450
15451 /* Rear Pin: output 1 (0x0d) */
15452 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15453 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15454
15455 /* CLFE Pin: output 2 (0x0e) */
15456 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15457 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15458
15459 /* Mic (rear) pin: input vref at 80% */
15460 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15461 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15462 /* Front Mic pin: input vref at 80% */
15463 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15464 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15465 /* Line In pin: input */
15466 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15467 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15468 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15469 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15470 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15471 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15472 /* CD pin widget for input */
15473 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15474
15475 /* FIXME: use matrix-type input source selection */
15476 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15477 /* Input mixer */
15478 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015482
15483 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15484 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15485 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15486 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015487
15488 /* always trun on EAPD */
15489 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15490 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15491
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015492 { }
15493};
15494
15495static struct hda_verb alc662_sue_init_verbs[] = {
15496 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15497 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015498 {}
15499};
15500
15501static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15502 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15503 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15504 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015505};
15506
Kailang Yang8c427222008-01-10 13:03:59 +010015507/* Set Unsolicited Event*/
15508static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15509 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15510 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15511 {}
15512};
15513
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015514/*
15515 * generic initialization of ADC, input mixers and output mixers
15516 */
15517static struct hda_verb alc662_auto_init_verbs[] = {
15518 /*
15519 * Unmute ADC and set the default input to mic-in
15520 */
15521 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15522 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15523
15524 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15525 * mixer widget
15526 * Note: PASD motherboards uses the Line In 2 as the input for front
15527 * panel mic (mic 2)
15528 */
15529 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015530 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15532 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15533 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15534 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015535
15536 /*
15537 * Set up output mixers (0x0c - 0x0f)
15538 */
15539 /* set vol=0 to output mixers */
15540 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15541 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15542 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15543
15544 /* set up input amps for analog loopback */
15545 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015546 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15547 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15548 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15549 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15550 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15551 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015552
15553
15554 /* FIXME: use matrix-type input source selection */
15555 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15556 /* Input mixer */
15557 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015558 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015559 { }
15560};
15561
Takashi Iwai24fb9172008-09-02 14:48:20 +020015562/* additional verbs for ALC663 */
15563static struct hda_verb alc663_auto_init_verbs[] = {
15564 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15565 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15566 { }
15567};
15568
Kailang Yang6dda9f42008-05-27 12:05:31 +020015569static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015570 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15571 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015572 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15573 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015574 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15575 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15576 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015577 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15578 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15579 {}
15580};
15581
Kailang Yangf1d4e282008-08-26 14:03:29 +020015582static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15583 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15584 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15585 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15586 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15587 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15588 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15589 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15590 {}
15591};
15592
15593static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15594 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15595 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15596 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15597 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15598 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15599 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15600 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15601 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15602 {}
15603};
15604
15605static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15606 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15607 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15608 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15609 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15610 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15611 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15612 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15613 {}
15614};
15615
15616static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15617 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15618 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15619 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15620 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15621 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15623 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15624 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15625 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15626 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15627 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15628 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15629 {}
15630};
15631
15632static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15633 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15634 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15635 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15636 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15637 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15638 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15639 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15640 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15641 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15642 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15643 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15644 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15645 {}
15646};
15647
Kailang Yang6dda9f42008-05-27 12:05:31 +020015648static struct hda_verb alc663_g71v_init_verbs[] = {
15649 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15650 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15651 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15652
15653 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15654 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15655 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15656
15657 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15658 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15659 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15660 {}
15661};
15662
15663static struct hda_verb alc663_g50v_init_verbs[] = {
15664 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15665 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15666 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15667
15668 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15669 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15670 {}
15671};
15672
Kailang Yangf1d4e282008-08-26 14:03:29 +020015673static struct hda_verb alc662_ecs_init_verbs[] = {
15674 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15675 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15676 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15677 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15678 {}
15679};
15680
Kailang Yangf1d4e282008-08-26 14:03:29 +020015681static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15682 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15683 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15684 { } /* end */
15685};
15686
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015687static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15688{
15689 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015690 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015691
15692 present = snd_hda_codec_read(codec, 0x14, 0,
15693 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015694 bits = present ? HDA_AMP_MUTE : 0;
15695 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15696 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015697}
15698
15699static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15700{
15701 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015702 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015703
15704 present = snd_hda_codec_read(codec, 0x1b, 0,
15705 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015706 bits = present ? HDA_AMP_MUTE : 0;
15707 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15708 HDA_AMP_MUTE, bits);
15709 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15710 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015711}
15712
15713static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15714 unsigned int res)
15715{
15716 if ((res >> 26) == ALC880_HP_EVENT)
15717 alc662_lenovo_101e_all_automute(codec);
15718 if ((res >> 26) == ALC880_FRONT_EVENT)
15719 alc662_lenovo_101e_ispeaker_automute(codec);
15720}
15721
Kailang Yang291702f2007-10-16 14:28:03 +020015722static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15723{
15724 unsigned int present;
15725
15726 present = snd_hda_codec_read(codec, 0x18, 0,
15727 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15728 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15729 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15730 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15731 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15732 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15733 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15734 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15735 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15736}
15737
15738/* unsolicited event for HP jack sensing */
15739static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15740 unsigned int res)
15741{
15742 if ((res >> 26) == ALC880_HP_EVENT)
15743 alc262_hippo1_automute( codec );
15744
15745 if ((res >> 26) == ALC880_MIC_EVENT)
15746 alc662_eeepc_mic_automute(codec);
15747}
15748
15749static void alc662_eeepc_inithook(struct hda_codec *codec)
15750{
15751 alc262_hippo1_automute( codec );
15752 alc662_eeepc_mic_automute(codec);
15753}
15754
Kailang Yang8c427222008-01-10 13:03:59 +010015755static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15756{
15757 unsigned int mute;
15758 unsigned int present;
15759
15760 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15761 present = snd_hda_codec_read(codec, 0x14, 0,
15762 AC_VERB_GET_PIN_SENSE, 0);
15763 present = (present & 0x80000000) != 0;
15764 if (present) {
15765 /* mute internal speaker */
15766 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015767 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015768 } else {
15769 /* unmute internal speaker if necessary */
15770 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15771 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015772 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015773 }
15774}
15775
15776/* unsolicited event for HP jack sensing */
15777static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15778 unsigned int res)
15779{
15780 if ((res >> 26) == ALC880_HP_EVENT)
15781 alc662_eeepc_ep20_automute(codec);
15782}
15783
15784static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15785{
15786 alc662_eeepc_ep20_automute(codec);
15787}
15788
Kailang Yang6dda9f42008-05-27 12:05:31 +020015789static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15790{
15791 unsigned int present;
15792 unsigned char bits;
15793
15794 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015795 AC_VERB_GET_PIN_SENSE, 0)
15796 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015797 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015798 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15799 AMP_IN_MUTE(0), bits);
15800 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15801 AMP_IN_MUTE(0), bits);
15802}
15803
15804static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15805{
15806 unsigned int present;
15807 unsigned char bits;
15808
15809 present = snd_hda_codec_read(codec, 0x21, 0,
15810 AC_VERB_GET_PIN_SENSE, 0)
15811 & AC_PINSENSE_PRESENCE;
15812 bits = present ? HDA_AMP_MUTE : 0;
15813 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15814 AMP_IN_MUTE(0), bits);
15815 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15816 AMP_IN_MUTE(0), bits);
15817 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15818 AMP_IN_MUTE(0), bits);
15819 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15820 AMP_IN_MUTE(0), bits);
15821}
15822
15823static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15824{
15825 unsigned int present;
15826 unsigned char bits;
15827
15828 present = snd_hda_codec_read(codec, 0x15, 0,
15829 AC_VERB_GET_PIN_SENSE, 0)
15830 & AC_PINSENSE_PRESENCE;
15831 bits = present ? HDA_AMP_MUTE : 0;
15832 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15833 AMP_IN_MUTE(0), bits);
15834 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15835 AMP_IN_MUTE(0), bits);
15836 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15837 AMP_IN_MUTE(0), bits);
15838 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15839 AMP_IN_MUTE(0), bits);
15840}
15841
15842static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15843{
15844 unsigned int present;
15845 unsigned char bits;
15846
15847 present = snd_hda_codec_read(codec, 0x1b, 0,
15848 AC_VERB_GET_PIN_SENSE, 0)
15849 & AC_PINSENSE_PRESENCE;
15850 bits = present ? 0 : PIN_OUT;
15851 snd_hda_codec_write(codec, 0x14, 0,
15852 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15853}
15854
15855static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15856{
15857 unsigned int present1, present2;
15858
15859 present1 = snd_hda_codec_read(codec, 0x21, 0,
15860 AC_VERB_GET_PIN_SENSE, 0)
15861 & AC_PINSENSE_PRESENCE;
15862 present2 = snd_hda_codec_read(codec, 0x15, 0,
15863 AC_VERB_GET_PIN_SENSE, 0)
15864 & AC_PINSENSE_PRESENCE;
15865
15866 if (present1 || present2) {
15867 snd_hda_codec_write_cache(codec, 0x14, 0,
15868 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15869 } else {
15870 snd_hda_codec_write_cache(codec, 0x14, 0,
15871 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15872 }
15873}
15874
15875static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15876{
15877 unsigned int present1, present2;
15878
15879 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15880 AC_VERB_GET_PIN_SENSE, 0)
15881 & AC_PINSENSE_PRESENCE;
15882 present2 = snd_hda_codec_read(codec, 0x15, 0,
15883 AC_VERB_GET_PIN_SENSE, 0)
15884 & AC_PINSENSE_PRESENCE;
15885
15886 if (present1 || present2) {
15887 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15888 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15889 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15890 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15891 } else {
15892 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15893 AMP_IN_MUTE(0), 0);
15894 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15895 AMP_IN_MUTE(0), 0);
15896 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015897}
15898
15899static void alc663_m51va_mic_automute(struct hda_codec *codec)
15900{
15901 unsigned int present;
15902
15903 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015904 AC_VERB_GET_PIN_SENSE, 0)
15905 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015906 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015907 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015908 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015909 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015910 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015911 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015912 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015913 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015914}
15915
15916static void alc663_m51va_unsol_event(struct hda_codec *codec,
15917 unsigned int res)
15918{
15919 switch (res >> 26) {
15920 case ALC880_HP_EVENT:
15921 alc663_m51va_speaker_automute(codec);
15922 break;
15923 case ALC880_MIC_EVENT:
15924 alc663_m51va_mic_automute(codec);
15925 break;
15926 }
15927}
15928
15929static void alc663_m51va_inithook(struct hda_codec *codec)
15930{
15931 alc663_m51va_speaker_automute(codec);
15932 alc663_m51va_mic_automute(codec);
15933}
15934
Kailang Yangf1d4e282008-08-26 14:03:29 +020015935/* ***************** Mode1 ******************************/
15936static void alc663_mode1_unsol_event(struct hda_codec *codec,
15937 unsigned int res)
15938{
15939 switch (res >> 26) {
15940 case ALC880_HP_EVENT:
15941 alc663_m51va_speaker_automute(codec);
15942 break;
15943 case ALC880_MIC_EVENT:
15944 alc662_eeepc_mic_automute(codec);
15945 break;
15946 }
15947}
15948
15949static void alc663_mode1_inithook(struct hda_codec *codec)
15950{
15951 alc663_m51va_speaker_automute(codec);
15952 alc662_eeepc_mic_automute(codec);
15953}
15954/* ***************** Mode2 ******************************/
15955static void alc662_mode2_unsol_event(struct hda_codec *codec,
15956 unsigned int res)
15957{
15958 switch (res >> 26) {
15959 case ALC880_HP_EVENT:
15960 alc662_f5z_speaker_automute(codec);
15961 break;
15962 case ALC880_MIC_EVENT:
15963 alc662_eeepc_mic_automute(codec);
15964 break;
15965 }
15966}
15967
15968static void alc662_mode2_inithook(struct hda_codec *codec)
15969{
15970 alc662_f5z_speaker_automute(codec);
15971 alc662_eeepc_mic_automute(codec);
15972}
15973/* ***************** Mode3 ******************************/
15974static void alc663_mode3_unsol_event(struct hda_codec *codec,
15975 unsigned int res)
15976{
15977 switch (res >> 26) {
15978 case ALC880_HP_EVENT:
15979 alc663_two_hp_m1_speaker_automute(codec);
15980 break;
15981 case ALC880_MIC_EVENT:
15982 alc662_eeepc_mic_automute(codec);
15983 break;
15984 }
15985}
15986
15987static void alc663_mode3_inithook(struct hda_codec *codec)
15988{
15989 alc663_two_hp_m1_speaker_automute(codec);
15990 alc662_eeepc_mic_automute(codec);
15991}
15992/* ***************** Mode4 ******************************/
15993static void alc663_mode4_unsol_event(struct hda_codec *codec,
15994 unsigned int res)
15995{
15996 switch (res >> 26) {
15997 case ALC880_HP_EVENT:
15998 alc663_21jd_two_speaker_automute(codec);
15999 break;
16000 case ALC880_MIC_EVENT:
16001 alc662_eeepc_mic_automute(codec);
16002 break;
16003 }
16004}
16005
16006static void alc663_mode4_inithook(struct hda_codec *codec)
16007{
16008 alc663_21jd_two_speaker_automute(codec);
16009 alc662_eeepc_mic_automute(codec);
16010}
16011/* ***************** Mode5 ******************************/
16012static void alc663_mode5_unsol_event(struct hda_codec *codec,
16013 unsigned int res)
16014{
16015 switch (res >> 26) {
16016 case ALC880_HP_EVENT:
16017 alc663_15jd_two_speaker_automute(codec);
16018 break;
16019 case ALC880_MIC_EVENT:
16020 alc662_eeepc_mic_automute(codec);
16021 break;
16022 }
16023}
16024
16025static void alc663_mode5_inithook(struct hda_codec *codec)
16026{
16027 alc663_15jd_two_speaker_automute(codec);
16028 alc662_eeepc_mic_automute(codec);
16029}
16030/* ***************** Mode6 ******************************/
16031static void alc663_mode6_unsol_event(struct hda_codec *codec,
16032 unsigned int res)
16033{
16034 switch (res >> 26) {
16035 case ALC880_HP_EVENT:
16036 alc663_two_hp_m2_speaker_automute(codec);
16037 break;
16038 case ALC880_MIC_EVENT:
16039 alc662_eeepc_mic_automute(codec);
16040 break;
16041 }
16042}
16043
16044static void alc663_mode6_inithook(struct hda_codec *codec)
16045{
16046 alc663_two_hp_m2_speaker_automute(codec);
16047 alc662_eeepc_mic_automute(codec);
16048}
16049
Kailang Yang6dda9f42008-05-27 12:05:31 +020016050static void alc663_g71v_hp_automute(struct hda_codec *codec)
16051{
16052 unsigned int present;
16053 unsigned char bits;
16054
16055 present = snd_hda_codec_read(codec, 0x21, 0,
16056 AC_VERB_GET_PIN_SENSE, 0)
16057 & AC_PINSENSE_PRESENCE;
16058 bits = present ? HDA_AMP_MUTE : 0;
16059 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
16060 HDA_AMP_MUTE, bits);
16061 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16062 HDA_AMP_MUTE, bits);
16063}
16064
16065static void alc663_g71v_front_automute(struct hda_codec *codec)
16066{
16067 unsigned int present;
16068 unsigned char bits;
16069
16070 present = snd_hda_codec_read(codec, 0x15, 0,
16071 AC_VERB_GET_PIN_SENSE, 0)
16072 & AC_PINSENSE_PRESENCE;
16073 bits = present ? HDA_AMP_MUTE : 0;
16074 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
16075 HDA_AMP_MUTE, bits);
16076}
16077
16078static void alc663_g71v_unsol_event(struct hda_codec *codec,
16079 unsigned int res)
16080{
16081 switch (res >> 26) {
16082 case ALC880_HP_EVENT:
16083 alc663_g71v_hp_automute(codec);
16084 break;
16085 case ALC880_FRONT_EVENT:
16086 alc663_g71v_front_automute(codec);
16087 break;
16088 case ALC880_MIC_EVENT:
16089 alc662_eeepc_mic_automute(codec);
16090 break;
16091 }
16092}
16093
16094static void alc663_g71v_inithook(struct hda_codec *codec)
16095{
16096 alc663_g71v_front_automute(codec);
16097 alc663_g71v_hp_automute(codec);
16098 alc662_eeepc_mic_automute(codec);
16099}
16100
16101static void alc663_g50v_unsol_event(struct hda_codec *codec,
16102 unsigned int res)
16103{
16104 switch (res >> 26) {
16105 case ALC880_HP_EVENT:
16106 alc663_m51va_speaker_automute(codec);
16107 break;
16108 case ALC880_MIC_EVENT:
16109 alc662_eeepc_mic_automute(codec);
16110 break;
16111 }
16112}
16113
16114static void alc663_g50v_inithook(struct hda_codec *codec)
16115{
16116 alc663_m51va_speaker_automute(codec);
16117 alc662_eeepc_mic_automute(codec);
16118}
16119
Kailang Yangf1d4e282008-08-26 14:03:29 +020016120/* bind hp and internal speaker mute (with plug check) */
16121static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
16122 struct snd_ctl_elem_value *ucontrol)
16123{
16124 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
16125 long *valp = ucontrol->value.integer.value;
16126 int change;
16127
16128 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
16129 HDA_AMP_MUTE,
16130 valp[0] ? 0 : HDA_AMP_MUTE);
16131 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
16132 HDA_AMP_MUTE,
16133 valp[1] ? 0 : HDA_AMP_MUTE);
16134 if (change)
16135 alc262_hippo1_automute(codec);
16136 return change;
16137}
16138
16139static struct snd_kcontrol_new alc662_ecs_mixer[] = {
16140 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16141 {
16142 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16143 .name = "Master Playback Switch",
16144 .info = snd_hda_mixer_amp_switch_info,
16145 .get = snd_hda_mixer_amp_switch_get,
16146 .put = alc662_ecs_master_sw_put,
16147 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
16148 },
16149
16150 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
16151 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
16152 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
16153
16154 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
16155 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16156 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16157 { } /* end */
16158};
16159
Takashi Iwaicb53c622007-08-10 17:21:45 +020016160#ifdef CONFIG_SND_HDA_POWER_SAVE
16161#define alc662_loopbacks alc880_loopbacks
16162#endif
16163
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016164
16165/* pcm configuration: identiacal with ALC880 */
16166#define alc662_pcm_analog_playback alc880_pcm_analog_playback
16167#define alc662_pcm_analog_capture alc880_pcm_analog_capture
16168#define alc662_pcm_digital_playback alc880_pcm_digital_playback
16169#define alc662_pcm_digital_capture alc880_pcm_digital_capture
16170
16171/*
16172 * configuration and preset
16173 */
16174static const char *alc662_models[ALC662_MODEL_LAST] = {
16175 [ALC662_3ST_2ch_DIG] = "3stack-dig",
16176 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
16177 [ALC662_3ST_6ch] = "3stack-6ch",
16178 [ALC662_5ST_DIG] = "6stack-dig",
16179 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020016180 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010016181 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016182 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020016183 [ALC663_ASUS_M51VA] = "m51va",
16184 [ALC663_ASUS_G71V] = "g71v",
16185 [ALC663_ASUS_H13] = "h13",
16186 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020016187 [ALC663_ASUS_MODE1] = "asus-mode1",
16188 [ALC662_ASUS_MODE2] = "asus-mode2",
16189 [ALC663_ASUS_MODE3] = "asus-mode3",
16190 [ALC663_ASUS_MODE4] = "asus-mode4",
16191 [ALC663_ASUS_MODE5] = "asus-mode5",
16192 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016193 [ALC662_AUTO] = "auto",
16194};
16195
16196static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010016197 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
16198 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
16199 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
16200 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
16201 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
16202 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
16203 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
16204 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
16205 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
16206 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
16207 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
16208 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
16209 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
16210 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
16211 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
16212 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
16213 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
16214 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
16215 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020016216 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016217 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
16218 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
16219 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
16220 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
16221 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
16222 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
16223 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
16224 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
16225 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020016226 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016227 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
16228 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
16229 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
16230 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
16231 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010016232 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020016233 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010016234 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016235 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030016236 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
16237 ALC662_3ST_6ch_DIG),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030016238 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
16239 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020016240 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016241 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020016242 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020016243 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016244 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
16245 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016246 {}
16247};
16248
16249static struct alc_config_preset alc662_presets[] = {
16250 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016251 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016252 .init_verbs = { alc662_init_verbs },
16253 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16254 .dac_nids = alc662_dac_nids,
16255 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016256 .dig_in_nid = ALC662_DIGIN_NID,
16257 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16258 .channel_mode = alc662_3ST_2ch_modes,
16259 .input_mux = &alc662_capture_source,
16260 },
16261 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016262 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016263 .init_verbs = { alc662_init_verbs },
16264 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16265 .dac_nids = alc662_dac_nids,
16266 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016267 .dig_in_nid = ALC662_DIGIN_NID,
16268 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16269 .channel_mode = alc662_3ST_6ch_modes,
16270 .need_dac_fix = 1,
16271 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016272 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016273 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016274 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016275 .init_verbs = { alc662_init_verbs },
16276 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16277 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016278 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16279 .channel_mode = alc662_3ST_6ch_modes,
16280 .need_dac_fix = 1,
16281 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016282 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016283 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016284 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016285 .init_verbs = { alc662_init_verbs },
16286 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16287 .dac_nids = alc662_dac_nids,
16288 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016289 .dig_in_nid = ALC662_DIGIN_NID,
16290 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
16291 .channel_mode = alc662_5stack_modes,
16292 .input_mux = &alc662_capture_source,
16293 },
16294 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016295 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016296 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
16297 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16298 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016299 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16300 .channel_mode = alc662_3ST_2ch_modes,
16301 .input_mux = &alc662_lenovo_101e_capture_source,
16302 .unsol_event = alc662_lenovo_101e_unsol_event,
16303 .init_hook = alc662_lenovo_101e_all_automute,
16304 },
Kailang Yang291702f2007-10-16 14:28:03 +020016305 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016306 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020016307 .init_verbs = { alc662_init_verbs,
16308 alc662_eeepc_sue_init_verbs },
16309 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16310 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020016311 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16312 .channel_mode = alc662_3ST_2ch_modes,
16313 .input_mux = &alc662_eeepc_capture_source,
16314 .unsol_event = alc662_eeepc_unsol_event,
16315 .init_hook = alc662_eeepc_inithook,
16316 },
Kailang Yang8c427222008-01-10 13:03:59 +010016317 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016318 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010016319 alc662_chmode_mixer },
16320 .init_verbs = { alc662_init_verbs,
16321 alc662_eeepc_ep20_sue_init_verbs },
16322 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16323 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010016324 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16325 .channel_mode = alc662_3ST_6ch_modes,
16326 .input_mux = &alc662_lenovo_101e_capture_source,
16327 .unsol_event = alc662_eeepc_ep20_unsol_event,
16328 .init_hook = alc662_eeepc_ep20_inithook,
16329 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016330 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016331 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016332 .init_verbs = { alc662_init_verbs,
16333 alc662_ecs_init_verbs },
16334 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16335 .dac_nids = alc662_dac_nids,
16336 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16337 .channel_mode = alc662_3ST_2ch_modes,
16338 .input_mux = &alc662_eeepc_capture_source,
16339 .unsol_event = alc662_eeepc_unsol_event,
16340 .init_hook = alc662_eeepc_inithook,
16341 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016342 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016343 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016344 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16345 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16346 .dac_nids = alc662_dac_nids,
16347 .dig_out_nid = ALC662_DIGOUT_NID,
16348 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16349 .channel_mode = alc662_3ST_2ch_modes,
16350 .input_mux = &alc663_m51va_capture_source,
16351 .unsol_event = alc663_m51va_unsol_event,
16352 .init_hook = alc663_m51va_inithook,
16353 },
16354 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016355 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016356 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
16357 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16358 .dac_nids = alc662_dac_nids,
16359 .dig_out_nid = ALC662_DIGOUT_NID,
16360 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16361 .channel_mode = alc662_3ST_2ch_modes,
16362 .input_mux = &alc662_eeepc_capture_source,
16363 .unsol_event = alc663_g71v_unsol_event,
16364 .init_hook = alc663_g71v_inithook,
16365 },
16366 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016367 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016368 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
16369 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16370 .dac_nids = alc662_dac_nids,
16371 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16372 .channel_mode = alc662_3ST_2ch_modes,
16373 .input_mux = &alc663_m51va_capture_source,
16374 .unsol_event = alc663_m51va_unsol_event,
16375 .init_hook = alc663_m51va_inithook,
16376 },
16377 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016378 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016379 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
16380 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16381 .dac_nids = alc662_dac_nids,
16382 .dig_out_nid = ALC662_DIGOUT_NID,
16383 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
16384 .channel_mode = alc662_3ST_6ch_modes,
16385 .input_mux = &alc663_capture_source,
16386 .unsol_event = alc663_g50v_unsol_event,
16387 .init_hook = alc663_g50v_inithook,
16388 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020016389 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016390 .mixers = { alc663_m51va_mixer },
16391 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016392 .init_verbs = { alc662_init_verbs,
16393 alc663_21jd_amic_init_verbs },
16394 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16395 .hp_nid = 0x03,
16396 .dac_nids = alc662_dac_nids,
16397 .dig_out_nid = ALC662_DIGOUT_NID,
16398 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16399 .channel_mode = alc662_3ST_2ch_modes,
16400 .input_mux = &alc662_eeepc_capture_source,
16401 .unsol_event = alc663_mode1_unsol_event,
16402 .init_hook = alc663_mode1_inithook,
16403 },
16404 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016405 .mixers = { alc662_1bjd_mixer },
16406 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016407 .init_verbs = { alc662_init_verbs,
16408 alc662_1bjd_amic_init_verbs },
16409 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16410 .dac_nids = alc662_dac_nids,
16411 .dig_out_nid = ALC662_DIGOUT_NID,
16412 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16413 .channel_mode = alc662_3ST_2ch_modes,
16414 .input_mux = &alc662_eeepc_capture_source,
16415 .unsol_event = alc662_mode2_unsol_event,
16416 .init_hook = alc662_mode2_inithook,
16417 },
16418 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016419 .mixers = { alc663_two_hp_m1_mixer },
16420 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016421 .init_verbs = { alc662_init_verbs,
16422 alc663_two_hp_amic_m1_init_verbs },
16423 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16424 .hp_nid = 0x03,
16425 .dac_nids = alc662_dac_nids,
16426 .dig_out_nid = ALC662_DIGOUT_NID,
16427 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16428 .channel_mode = alc662_3ST_2ch_modes,
16429 .input_mux = &alc662_eeepc_capture_source,
16430 .unsol_event = alc663_mode3_unsol_event,
16431 .init_hook = alc663_mode3_inithook,
16432 },
16433 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016434 .mixers = { alc663_asus_21jd_clfe_mixer },
16435 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016436 .init_verbs = { alc662_init_verbs,
16437 alc663_21jd_amic_init_verbs},
16438 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16439 .hp_nid = 0x03,
16440 .dac_nids = alc662_dac_nids,
16441 .dig_out_nid = ALC662_DIGOUT_NID,
16442 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16443 .channel_mode = alc662_3ST_2ch_modes,
16444 .input_mux = &alc662_eeepc_capture_source,
16445 .unsol_event = alc663_mode4_unsol_event,
16446 .init_hook = alc663_mode4_inithook,
16447 },
16448 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016449 .mixers = { alc663_asus_15jd_clfe_mixer },
16450 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016451 .init_verbs = { alc662_init_verbs,
16452 alc663_15jd_amic_init_verbs },
16453 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16454 .hp_nid = 0x03,
16455 .dac_nids = alc662_dac_nids,
16456 .dig_out_nid = ALC662_DIGOUT_NID,
16457 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16458 .channel_mode = alc662_3ST_2ch_modes,
16459 .input_mux = &alc662_eeepc_capture_source,
16460 .unsol_event = alc663_mode5_unsol_event,
16461 .init_hook = alc663_mode5_inithook,
16462 },
16463 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016464 .mixers = { alc663_two_hp_m2_mixer },
16465 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016466 .init_verbs = { alc662_init_verbs,
16467 alc663_two_hp_amic_m2_init_verbs },
16468 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16469 .hp_nid = 0x03,
16470 .dac_nids = alc662_dac_nids,
16471 .dig_out_nid = ALC662_DIGOUT_NID,
16472 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16473 .channel_mode = alc662_3ST_2ch_modes,
16474 .input_mux = &alc662_eeepc_capture_source,
16475 .unsol_event = alc663_mode6_unsol_event,
16476 .init_hook = alc663_mode6_inithook,
16477 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016478};
16479
16480
16481/*
16482 * BIOS auto configuration
16483 */
16484
16485/* add playback controls from the parsed DAC table */
16486static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16487 const struct auto_pin_cfg *cfg)
16488{
16489 char name[32];
16490 static const char *chname[4] = {
16491 "Front", "Surround", NULL /*CLFE*/, "Side"
16492 };
16493 hda_nid_t nid;
16494 int i, err;
16495
16496 for (i = 0; i < cfg->line_outs; i++) {
16497 if (!spec->multiout.dac_nids[i])
16498 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016499 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016500 if (i == 2) {
16501 /* Center/LFE */
16502 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16503 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016504 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16505 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016506 if (err < 0)
16507 return err;
16508 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16509 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016510 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16511 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016512 if (err < 0)
16513 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016514 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016515 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016516 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016517 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016518 if (err < 0)
16519 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016520 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016521 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016522 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016523 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016524 if (err < 0)
16525 return err;
16526 } else {
16527 sprintf(name, "%s Playback Volume", chname[i]);
16528 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016529 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16530 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016531 if (err < 0)
16532 return err;
16533 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016534 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16535 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16536 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016537 if (err < 0)
16538 return err;
16539 }
16540 }
16541 return 0;
16542}
16543
16544/* add playback controls for speaker and HP outputs */
16545static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16546 const char *pfx)
16547{
16548 hda_nid_t nid;
16549 int err;
16550 char name[32];
16551
16552 if (!pin)
16553 return 0;
16554
Takashi Iwai24fb9172008-09-02 14:48:20 +020016555 if (pin == 0x17) {
16556 /* ALC663 has a mono output pin on 0x17 */
16557 sprintf(name, "%s Playback Switch", pfx);
16558 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16559 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16560 return err;
16561 }
16562
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016563 if (alc880_is_fixed_pin(pin)) {
16564 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai939778a2009-02-05 15:57:55 +010016565 /* printk(KERN_DEBUG "DAC nid=%x\n",nid); */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016566 /* specify the DAC as the extra output */
16567 if (!spec->multiout.hp_nid)
16568 spec->multiout.hp_nid = nid;
16569 else
16570 spec->multiout.extra_out_nid[0] = nid;
16571 /* control HP volume/switch on the output mixer amp */
16572 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16573 sprintf(name, "%s Playback Volume", pfx);
16574 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16575 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16576 if (err < 0)
16577 return err;
16578 sprintf(name, "%s Playback Switch", pfx);
16579 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16580 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16581 if (err < 0)
16582 return err;
16583 } else if (alc880_is_multi_pin(pin)) {
16584 /* set manual connection */
16585 /* we have only a switch on HP-out PIN */
16586 sprintf(name, "%s Playback Switch", pfx);
16587 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16588 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16589 if (err < 0)
16590 return err;
16591 }
16592 return 0;
16593}
16594
16595/* create playback/capture controls for input pins */
16596static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16597 const struct auto_pin_cfg *cfg)
16598{
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016599 struct hda_input_mux *imux = &spec->private_imux[0];
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016600 int i, err, idx;
16601
16602 for (i = 0; i < AUTO_PIN_LAST; i++) {
16603 if (alc880_is_input_pin(cfg->input_pins[i])) {
16604 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16605 err = new_analog_input(spec, cfg->input_pins[i],
16606 auto_pin_cfg_labels[i],
16607 idx, 0x0b);
16608 if (err < 0)
16609 return err;
16610 imux->items[imux->num_items].label =
16611 auto_pin_cfg_labels[i];
16612 imux->items[imux->num_items].index =
16613 alc880_input_pin_idx(cfg->input_pins[i]);
16614 imux->num_items++;
16615 }
16616 }
16617 return 0;
16618}
16619
16620static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16621 hda_nid_t nid, int pin_type,
16622 int dac_idx)
16623{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016624 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016625 /* need the manual connection? */
16626 if (alc880_is_multi_pin(nid)) {
16627 struct alc_spec *spec = codec->spec;
16628 int idx = alc880_multi_pin_idx(nid);
16629 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16630 AC_VERB_SET_CONNECT_SEL,
16631 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16632 }
16633}
16634
16635static void alc662_auto_init_multi_out(struct hda_codec *codec)
16636{
16637 struct alc_spec *spec = codec->spec;
16638 int i;
16639
Kailang Yang8c427222008-01-10 13:03:59 +010016640 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016641 for (i = 0; i <= HDA_SIDE; i++) {
16642 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016643 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016644 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016645 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016646 i);
16647 }
16648}
16649
16650static void alc662_auto_init_hp_out(struct hda_codec *codec)
16651{
16652 struct alc_spec *spec = codec->spec;
16653 hda_nid_t pin;
16654
16655 pin = spec->autocfg.hp_pins[0];
16656 if (pin) /* connect to front */
16657 /* use dac 0 */
16658 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016659 pin = spec->autocfg.speaker_pins[0];
16660 if (pin)
16661 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016662}
16663
16664#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16665#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16666
16667static void alc662_auto_init_analog_input(struct hda_codec *codec)
16668{
16669 struct alc_spec *spec = codec->spec;
16670 int i;
16671
16672 for (i = 0; i < AUTO_PIN_LAST; i++) {
16673 hda_nid_t nid = spec->autocfg.input_pins[i];
16674 if (alc662_is_input_pin(nid)) {
16675 snd_hda_codec_write(codec, nid, 0,
16676 AC_VERB_SET_PIN_WIDGET_CONTROL,
16677 (i <= AUTO_PIN_FRONT_MIC ?
16678 PIN_VREF80 : PIN_IN));
16679 if (nid != ALC662_PIN_CD_NID)
16680 snd_hda_codec_write(codec, nid, 0,
16681 AC_VERB_SET_AMP_GAIN_MUTE,
16682 AMP_OUT_MUTE);
16683 }
16684 }
16685}
16686
Takashi Iwaif511b012008-08-15 16:46:42 +020016687#define alc662_auto_init_input_src alc882_auto_init_input_src
16688
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016689static int alc662_parse_auto_config(struct hda_codec *codec)
16690{
16691 struct alc_spec *spec = codec->spec;
16692 int err;
16693 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16694
16695 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16696 alc662_ignore);
16697 if (err < 0)
16698 return err;
16699 if (!spec->autocfg.line_outs)
16700 return 0; /* can't find valid BIOS pin config */
16701
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016702 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16703 if (err < 0)
16704 return err;
16705 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16706 if (err < 0)
16707 return err;
16708 err = alc662_auto_create_extra_out(spec,
16709 spec->autocfg.speaker_pins[0],
16710 "Speaker");
16711 if (err < 0)
16712 return err;
16713 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16714 "Headphone");
16715 if (err < 0)
16716 return err;
16717 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16718 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016719 return err;
16720
16721 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16722
Takashi Iwai0852d7a2009-02-11 11:35:15 +010016723 if (spec->autocfg.dig_outs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016724 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16725
Takashi Iwai603c4012008-07-30 15:01:44 +020016726 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016727 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016728
16729 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016730 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020016731
Takashi Iwaid88897e2008-10-31 15:01:37 +010016732 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016733 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016734 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016735
16736 err = alc_auto_add_mic_boost(codec);
16737 if (err < 0)
16738 return err;
16739
Takashi Iwaie044c392008-10-27 16:56:24 +010016740 store_pin_configs(codec);
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016741 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016742}
16743
16744/* additional initialization for auto-configuration model */
16745static void alc662_auto_init(struct hda_codec *codec)
16746{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016747 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016748 alc662_auto_init_multi_out(codec);
16749 alc662_auto_init_hp_out(codec);
16750 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016751 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016752 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016753 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016754}
16755
16756static int patch_alc662(struct hda_codec *codec)
16757{
16758 struct alc_spec *spec;
16759 int err, board_config;
16760
16761 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16762 if (!spec)
16763 return -ENOMEM;
16764
16765 codec->spec = spec;
16766
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016767 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16768
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016769 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16770 alc662_models,
16771 alc662_cfg_tbl);
16772 if (board_config < 0) {
16773 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16774 "trying auto-probe from BIOS...\n");
16775 board_config = ALC662_AUTO;
16776 }
16777
16778 if (board_config == ALC662_AUTO) {
16779 /* automatic parse from the BIOS config */
16780 err = alc662_parse_auto_config(codec);
16781 if (err < 0) {
16782 alc_free(codec);
16783 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016784 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016785 printk(KERN_INFO
16786 "hda_codec: Cannot set up configuration "
16787 "from BIOS. Using base mode...\n");
16788 board_config = ALC662_3ST_2ch_DIG;
16789 }
16790 }
16791
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016792 err = snd_hda_attach_beep_device(codec, 0x1);
16793 if (err < 0) {
16794 alc_free(codec);
16795 return err;
16796 }
16797
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016798 if (board_config != ALC662_AUTO)
16799 setup_preset(spec, &alc662_presets[board_config]);
16800
Kailang Yang6dda9f42008-05-27 12:05:31 +020016801 if (codec->vendor_id == 0x10ec0663) {
16802 spec->stream_name_analog = "ALC663 Analog";
16803 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016804 } else if (codec->vendor_id == 0x10ec0272) {
16805 spec->stream_name_analog = "ALC272 Analog";
16806 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016807 } else {
16808 spec->stream_name_analog = "ALC662 Analog";
16809 spec->stream_name_digital = "ALC662 Digital";
16810 }
16811
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016812 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16813 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16814
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016815 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16816 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16817
Takashi Iwaie1406342008-02-11 18:32:32 +010016818 spec->adc_nids = alc662_adc_nids;
16819 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16820 spec->capsrc_nids = alc662_capsrc_nids;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016821 spec->capture_style = CAPT_MIX;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016822
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016823 if (!spec->cap_mixer)
16824 set_capture_mixer(spec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016825 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016826
Takashi Iwai2134ea42008-01-10 16:53:55 +010016827 spec->vmaster_nid = 0x02;
16828
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016829 codec->patch_ops = alc_patch_ops;
16830 if (board_config == ALC662_AUTO)
16831 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016832#ifdef CONFIG_SND_HDA_POWER_SAVE
16833 if (!spec->loopback.amplist)
16834 spec->loopback.amplist = alc662_loopbacks;
16835#endif
Takashi Iwaidaead532008-11-28 12:55:36 +010016836 codec->proc_widget_hook = print_realtek_coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016837
16838 return 0;
16839}
16840
16841/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016842 * patch entries
16843 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016844static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070016845 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016846 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016847 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016848 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016849 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016850 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016851 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016852 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016853 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16854 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16855 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016856 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16857 .patch = patch_alc883 },
16858 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16859 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016860 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016861 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016862 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016863 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016864 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16865 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016866 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016867 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016868 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016869 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016870 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16871 .patch = patch_alc883 },
Wu Fengguang3fea2cb2008-12-26 12:20:43 +080016872 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016873 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016874 {} /* terminator */
16875};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010016876
16877MODULE_ALIAS("snd-hda-codec-id:10ec*");
16878
16879MODULE_LICENSE("GPL");
16880MODULE_DESCRIPTION("Realtek HD-audio codec");
16881
16882static struct hda_codec_preset_list realtek_list = {
16883 .preset = snd_hda_preset_realtek,
16884 .owner = THIS_MODULE,
16885};
16886
16887static int __init patch_realtek_init(void)
16888{
16889 return snd_hda_add_codec_preset(&realtek_list);
16890}
16891
16892static void __exit patch_realtek_exit(void)
16893{
16894 snd_hda_delete_codec_preset(&realtek_list);
16895}
16896
16897module_init(patch_realtek_init)
16898module_exit(patch_realtek_exit)