blob: 6ec56c62cb18421d653f33760faca45e5c0f5e80 [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"
Harvey Harrison3c9a3202008-02-29 11:59:26 +010033#include "hda_patch.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,
Kailang Yangdf694da2005-12-05 19:42:22 +0100107 ALC262_AUTO,
108 ALC262_MODEL_LAST /* last tag */
109};
110
Kailang Yanga361d842007-06-05 12:30:55 +0200111/* ALC268 models */
112enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200113 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200114 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200115 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200116 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100117 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200118 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100119 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100120 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100121#ifdef CONFIG_SND_DEBUG
122 ALC268_TEST,
123#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200124 ALC268_AUTO,
125 ALC268_MODEL_LAST /* last tag */
126};
127
Kailang Yangf6a92242007-12-13 16:52:54 +0100128/* ALC269 models */
129enum {
130 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200131 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200132 ALC269_ASUS_EEEPC_P703,
133 ALC269_ASUS_EEEPC_P901,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100134 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000135 ALC269_LIFEBOOK,
Kailang Yangf6a92242007-12-13 16:52:54 +0100136 ALC269_AUTO,
137 ALC269_MODEL_LAST /* last tag */
138};
139
Kailang Yangdf694da2005-12-05 19:42:22 +0100140/* ALC861 models */
141enum {
142 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200143 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100144 ALC861_3ST_DIG,
145 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200146 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200147 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200148 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100149 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_AUTO,
151 ALC861_MODEL_LAST,
152};
153
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100154/* ALC861-VD models */
155enum {
156 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200157 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100158 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100159 ALC861VD_3ST,
160 ALC861VD_3ST_DIG,
161 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200162 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200163 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200164 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_AUTO,
166 ALC861VD_MODEL_LAST,
167};
168
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200169/* ALC662 models */
170enum {
171 ALC662_3ST_2ch_DIG,
172 ALC662_3ST_6ch_DIG,
173 ALC662_3ST_6ch,
174 ALC662_5ST_DIG,
175 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200176 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100177 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200178 ALC663_ASUS_M51VA,
179 ALC663_ASUS_G71V,
180 ALC663_ASUS_H13,
181 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200182 ALC662_ECS,
183 ALC663_ASUS_MODE1,
184 ALC662_ASUS_MODE2,
185 ALC663_ASUS_MODE3,
186 ALC663_ASUS_MODE4,
187 ALC663_ASUS_MODE5,
188 ALC663_ASUS_MODE6,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200189 ALC662_AUTO,
190 ALC662_MODEL_LAST,
191};
192
Kailang Yangdf694da2005-12-05 19:42:22 +0100193/* ALC882 models */
194enum {
195 ALC882_3ST_DIG,
196 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200197 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200198 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200199 ALC882_TARGA,
200 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200201 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100202 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200203 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200204 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200205 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100206 ALC882_MODEL_LAST,
207};
208
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200209/* ALC883 models */
210enum {
211 ALC883_3ST_2ch_DIG,
212 ALC883_3ST_6ch_DIG,
213 ALC883_3ST_6ch,
214 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200215 ALC883_TARGA_DIG,
216 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200217 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200218 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800219 ALC888_ACER_ASPIRE_4930G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200220 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200221 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100222 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200223 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200224 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200225 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200226 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200227 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200228 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100229 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100230 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100231 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100232 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200233 ALC883_3ST_6ch_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200234 ALC888_ASUS_M90V,
235 ALC888_ASUS_EEE1601,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100236 ALC1200_ASUS_P5Q,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200237 ALC883_AUTO,
238 ALC883_MODEL_LAST,
239};
240
Kailang Yangdf694da2005-12-05 19:42:22 +0100241/* for GPIO Poll */
242#define GPIO_MASK 0x03
243
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244struct alc_spec {
245 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100246 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100248 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Kailang Yangdf694da2005-12-05 19:42:22 +0100250 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200251 * don't forget NULL
252 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200253 */
254 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255
Takashi Iwai16ded522005-06-10 19:58:24 +0200256 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 struct hda_pcm_stream *stream_analog_playback;
258 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100259 struct hda_pcm_stream *stream_analog_alt_playback;
260 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200262 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 struct hda_pcm_stream *stream_digital_playback;
264 struct hda_pcm_stream *stream_digital_capture;
265
266 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200267 struct hda_multi_out multiout; /* playback set-up
268 * max_channels, dacs must be set
269 * dig_out_nid and hp_nid are optional
270 */
Takashi Iwai63300792008-01-24 15:31:36 +0100271 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
273 /* capture */
274 unsigned int num_adc_nids;
275 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100276 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200277 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100278 unsigned char is_mix_capture; /* matrix-style capture (non-mux) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
280 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200281 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 const struct hda_input_mux *input_mux;
283 unsigned int cur_mux[3];
284
285 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100286 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200288 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289
290 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100291 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200292
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200293 /* dynamic controls, init_verbs and input_mux */
294 struct auto_pin_cfg autocfg;
Takashi Iwai603c4012008-07-30 15:01:44 +0200295 struct snd_array kctls;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200296 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200297 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100298
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100299 /* hooks */
300 void (*init_hook)(struct hda_codec *codec);
301 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
302
Takashi Iwai834be882006-03-01 14:16:17 +0100303 /* for pin sensing */
304 unsigned int sense_updated: 1;
305 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100306 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200307
Takashi Iwai2134ea42008-01-10 16:53:55 +0100308 /* for virtual master */
309 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200310#ifdef CONFIG_SND_HDA_POWER_SAVE
311 struct hda_loopback_check loopback;
312#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200313
314 /* for PLL fix */
315 hda_nid_t pll_nid;
316 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaie044c392008-10-27 16:56:24 +0100317
318#ifdef SND_HDA_NEEDS_RESUME
319#define ALC_MAX_PINS 16
320 unsigned int num_pins;
321 hda_nid_t pin_nids[ALC_MAX_PINS];
322 unsigned int pin_cfgs[ALC_MAX_PINS];
323#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100324};
325
326/*
327 * configuration template - to be copied to the spec instance
328 */
329struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200330 struct snd_kcontrol_new *mixers[5]; /* should be identical size
331 * with spec
332 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100333 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100334 const struct hda_verb *init_verbs[5];
335 unsigned int num_dacs;
336 hda_nid_t *dac_nids;
337 hda_nid_t dig_out_nid; /* optional */
338 hda_nid_t hp_nid; /* optional */
339 unsigned int num_adc_nids;
340 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100341 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100342 hda_nid_t dig_in_nid;
343 unsigned int num_channel_mode;
344 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200345 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200346 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100347 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100348 void (*unsol_event)(struct hda_codec *, unsigned int);
349 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200350#ifdef CONFIG_SND_HDA_POWER_SAVE
351 struct hda_amp_list *loopbacks;
352#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353};
354
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
356/*
357 * input MUX handling
358 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200359static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
360 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361{
362 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
363 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200364 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
365 if (mux_idx >= spec->num_mux_defs)
366 mux_idx = 0;
367 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368}
369
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200370static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
371 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372{
373 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
374 struct alc_spec *spec = codec->spec;
375 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
376
377 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
378 return 0;
379}
380
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200381static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
382 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383{
384 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
385 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100386 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100388 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100389 hda_nid_t nid = spec->capsrc_nids ?
390 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391
Takashi Iwaicd896c32008-11-18 12:36:33 +0100392 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
393 imux = &spec->input_mux[mux_idx];
394
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100395 if (spec->is_mix_capture) {
396 /* Matrix-mixer style (e.g. ALC882) */
397 unsigned int *cur_val = &spec->cur_mux[adc_idx];
398 unsigned int i, idx;
399
400 idx = ucontrol->value.enumerated.item[0];
401 if (idx >= imux->num_items)
402 idx = imux->num_items - 1;
403 if (*cur_val == idx)
404 return 0;
405 for (i = 0; i < imux->num_items; i++) {
406 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
407 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
408 imux->items[i].index,
409 HDA_AMP_MUTE, v);
410 }
411 *cur_val = idx;
412 return 1;
413 } else {
414 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100415 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100416 &spec->cur_mux[adc_idx]);
417 }
418}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200419
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420/*
421 * channel mode setting
422 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200423static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
424 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425{
426 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
427 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100428 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
429 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430}
431
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200432static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
433 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434{
435 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
436 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100437 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200438 spec->num_channel_mode,
439 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440}
441
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200442static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
443 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444{
445 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
446 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200447 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
448 spec->num_channel_mode,
449 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200450 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200451 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
452 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453}
454
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100456 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200457 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100458 * being part of a format specifier. Maximum allowed length of a value is
459 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100460 *
461 * Note: some retasking pin complexes seem to ignore requests for input
462 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
463 * are requested. Therefore order this list so that this behaviour will not
464 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200465 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
466 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200467 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100468static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100469 "Mic 50pc bias", "Mic 80pc bias",
470 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100471};
472static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100473 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100474};
475/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200476 * in the pin being assumed to be exclusively an input or an output pin. In
477 * addition, "input" pins may or may not process the mic bias option
478 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
479 * accept requests for bias as of chip versions up to March 2006) and/or
480 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100481 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200482#define ALC_PIN_DIR_IN 0x00
483#define ALC_PIN_DIR_OUT 0x01
484#define ALC_PIN_DIR_INOUT 0x02
485#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
486#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100487
Kailang Yangea1fb292008-08-26 12:58:38 +0200488/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100489 * For each direction the minimum and maximum values are given.
490 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200491static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100492 { 0, 2 }, /* ALC_PIN_DIR_IN */
493 { 3, 4 }, /* ALC_PIN_DIR_OUT */
494 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200495 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
496 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100497};
498#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
499#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
500#define alc_pin_mode_n_items(_dir) \
501 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
502
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200503static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
504 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200505{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100506 unsigned int item_num = uinfo->value.enumerated.item;
507 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
508
509 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200510 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100511 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
512
513 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
514 item_num = alc_pin_mode_min(dir);
515 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200516 return 0;
517}
518
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200519static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
520 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200521{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100522 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200523 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
524 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100525 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200526 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200527 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
528 AC_VERB_GET_PIN_WIDGET_CONTROL,
529 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200530
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100531 /* Find enumerated value for current pinctl setting */
532 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200533 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100534 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200535 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100536 return 0;
537}
538
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200539static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
540 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100541{
542 signed int change;
543 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
544 hda_nid_t nid = kcontrol->private_value & 0xffff;
545 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
546 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200547 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
548 AC_VERB_GET_PIN_WIDGET_CONTROL,
549 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200551 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 val = alc_pin_mode_min(dir);
553
554 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100555 if (change) {
556 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200557 snd_hda_codec_write_cache(codec, nid, 0,
558 AC_VERB_SET_PIN_WIDGET_CONTROL,
559 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100560
Kailang Yangea1fb292008-08-26 12:58:38 +0200561 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100562 * for the requested pin mode. Enum values of 2 or less are
563 * input modes.
564 *
565 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200566 * reduces noise slightly (particularly on input) so we'll
567 * do it. However, having both input and output buffers
568 * enabled simultaneously doesn't seem to be problematic if
569 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100570 */
571 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200572 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
573 HDA_AMP_MUTE, HDA_AMP_MUTE);
574 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
575 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100576 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200577 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
578 HDA_AMP_MUTE, HDA_AMP_MUTE);
579 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
580 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100581 }
582 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200583 return change;
584}
585
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100586#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200587 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100588 .info = alc_pin_mode_info, \
589 .get = alc_pin_mode_get, \
590 .put = alc_pin_mode_put, \
591 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100592
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100593/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
594 * together using a mask with more than one bit set. This control is
595 * currently used only by the ALC260 test model. At this stage they are not
596 * needed for any "production" models.
597 */
598#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200599#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200600
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200601static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
602 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100603{
604 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
605 hda_nid_t nid = kcontrol->private_value & 0xffff;
606 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
607 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200608 unsigned int val = snd_hda_codec_read(codec, nid, 0,
609 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100610
611 *valp = (val & mask) != 0;
612 return 0;
613}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200614static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100616{
617 signed int change;
618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
619 hda_nid_t nid = kcontrol->private_value & 0xffff;
620 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
621 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200622 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
623 AC_VERB_GET_GPIO_DATA,
624 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100625
626 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200627 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
628 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100629 gpio_data &= ~mask;
630 else
631 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200632 snd_hda_codec_write_cache(codec, nid, 0,
633 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100634
635 return change;
636}
637#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
638 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
639 .info = alc_gpio_data_info, \
640 .get = alc_gpio_data_get, \
641 .put = alc_gpio_data_put, \
642 .private_value = nid | (mask<<16) }
643#endif /* CONFIG_SND_DEBUG */
644
Jonathan Woithe92621f12006-02-28 11:47:47 +0100645/* A switch control to allow the enabling of the digital IO pins on the
646 * ALC260. This is incredibly simplistic; the intention of this control is
647 * to provide something in the test model allowing digital outputs to be
648 * identified if present. If models are found which can utilise these
649 * outputs a more complete mixer control can be devised for those models if
650 * necessary.
651 */
652#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200653#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200654
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200655static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100657{
658 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
659 hda_nid_t nid = kcontrol->private_value & 0xffff;
660 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
661 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200662 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100663 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100664
665 *valp = (val & mask) != 0;
666 return 0;
667}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200668static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
669 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100670{
671 signed int change;
672 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
673 hda_nid_t nid = kcontrol->private_value & 0xffff;
674 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
675 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200676 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100677 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200678 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100679
680 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200681 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100682 if (val==0)
683 ctrl_data &= ~mask;
684 else
685 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200686 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
687 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100688
689 return change;
690}
691#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
692 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
693 .info = alc_spdif_ctrl_info, \
694 .get = alc_spdif_ctrl_get, \
695 .put = alc_spdif_ctrl_put, \
696 .private_value = nid | (mask<<16) }
697#endif /* CONFIG_SND_DEBUG */
698
Jonathan Woithef8225f62008-01-08 12:16:54 +0100699/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
700 * Again, this is only used in the ALC26x test models to help identify when
701 * the EAPD line must be asserted for features to work.
702 */
703#ifdef CONFIG_SND_DEBUG
704#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
705
706static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
707 struct snd_ctl_elem_value *ucontrol)
708{
709 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
710 hda_nid_t nid = kcontrol->private_value & 0xffff;
711 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
712 long *valp = ucontrol->value.integer.value;
713 unsigned int val = snd_hda_codec_read(codec, nid, 0,
714 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
715
716 *valp = (val & mask) != 0;
717 return 0;
718}
719
720static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
721 struct snd_ctl_elem_value *ucontrol)
722{
723 int change;
724 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
725 hda_nid_t nid = kcontrol->private_value & 0xffff;
726 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
727 long val = *ucontrol->value.integer.value;
728 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
729 AC_VERB_GET_EAPD_BTLENABLE,
730 0x00);
731
732 /* Set/unset the masked control bit(s) as needed */
733 change = (!val ? 0 : mask) != (ctrl_data & mask);
734 if (!val)
735 ctrl_data &= ~mask;
736 else
737 ctrl_data |= mask;
738 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
739 ctrl_data);
740
741 return change;
742}
743
744#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
745 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
746 .info = alc_eapd_ctrl_info, \
747 .get = alc_eapd_ctrl_get, \
748 .put = alc_eapd_ctrl_put, \
749 .private_value = nid | (mask<<16) }
750#endif /* CONFIG_SND_DEBUG */
751
Kailang Yangdf694da2005-12-05 19:42:22 +0100752/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100753 */
754static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
755{
756 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
757 return;
758 spec->mixers[spec->num_mixers++] = mix;
759}
760
761static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
762{
763 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
764 return;
765 spec->init_verbs[spec->num_init_verbs++] = verb;
766}
767
768/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100769 * set up from the preset table
770 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200771static void setup_preset(struct alc_spec *spec,
772 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100773{
774 int i;
775
776 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100777 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100778 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200779 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
780 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100781 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200782
Kailang Yangdf694da2005-12-05 19:42:22 +0100783 spec->channel_mode = preset->channel_mode;
784 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200785 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100786
787 spec->multiout.max_channels = spec->channel_mode[0].channels;
788
789 spec->multiout.num_dacs = preset->num_dacs;
790 spec->multiout.dac_nids = preset->dac_nids;
791 spec->multiout.dig_out_nid = preset->dig_out_nid;
792 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200793
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200794 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200795 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200796 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100797 spec->input_mux = preset->input_mux;
798
799 spec->num_adc_nids = preset->num_adc_nids;
800 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100801 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100802 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100803
804 spec->unsol_event = preset->unsol_event;
805 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200806#ifdef CONFIG_SND_HDA_POWER_SAVE
807 spec->loopback.amplist = preset->loopbacks;
808#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100809}
810
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200811/* Enable GPIO mask and set output */
812static struct hda_verb alc_gpio1_init_verbs[] = {
813 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
814 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
815 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
816 { }
817};
818
819static struct hda_verb alc_gpio2_init_verbs[] = {
820 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
821 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
822 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
823 { }
824};
825
Kailang Yangbdd148a2007-05-08 15:19:08 +0200826static struct hda_verb alc_gpio3_init_verbs[] = {
827 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
828 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
829 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
830 { }
831};
832
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200833/*
834 * Fix hardware PLL issue
835 * On some codecs, the analog PLL gating control must be off while
836 * the default value is 1.
837 */
838static void alc_fix_pll(struct hda_codec *codec)
839{
840 struct alc_spec *spec = codec->spec;
841 unsigned int val;
842
843 if (!spec->pll_nid)
844 return;
845 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
846 spec->pll_coef_idx);
847 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
848 AC_VERB_GET_PROC_COEF, 0);
849 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
850 spec->pll_coef_idx);
851 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
852 val & ~(1 << spec->pll_coef_bit));
853}
854
855static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
856 unsigned int coef_idx, unsigned int coef_bit)
857{
858 struct alc_spec *spec = codec->spec;
859 spec->pll_nid = nid;
860 spec->pll_coef_idx = coef_idx;
861 spec->pll_coef_bit = coef_bit;
862 alc_fix_pll(codec);
863}
864
Kailang Yangc9b58002007-10-16 14:30:01 +0200865static void alc_sku_automute(struct hda_codec *codec)
866{
867 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200868 unsigned int present;
869 unsigned int hp_nid = spec->autocfg.hp_pins[0];
870 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
871
872 /* need to execute and sync at first */
873 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
874 present = snd_hda_codec_read(codec, hp_nid, 0,
875 AC_VERB_GET_PIN_SENSE, 0);
876 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100877 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
878 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200879}
880
Takashi Iwai4605b712008-10-31 14:18:24 +0100881#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200882static void alc_mic_automute(struct hda_codec *codec)
883{
884 struct alc_spec *spec = codec->spec;
885 unsigned int present;
886 unsigned int mic_nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
887 unsigned int fmic_nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
888 unsigned int mix_nid = spec->capsrc_nids[0];
889 unsigned int capsrc_idx_mic, capsrc_idx_fmic;
890
891 capsrc_idx_mic = mic_nid - 0x18;
892 capsrc_idx_fmic = fmic_nid - 0x18;
893 present = snd_hda_codec_read(codec, mic_nid, 0,
894 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
895 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
896 0x7000 | (capsrc_idx_mic << 8) | (present ? 0 : 0x80));
897 snd_hda_codec_write(codec, mix_nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
898 0x7000 | (capsrc_idx_fmic << 8) | (present ? 0x80 : 0));
899 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, capsrc_idx_fmic,
900 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
901}
Takashi Iwai4605b712008-10-31 14:18:24 +0100902#else
903#define alc_mic_automute(codec) /* NOP */
904#endif /* disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +0200905
Kailang Yangc9b58002007-10-16 14:30:01 +0200906/* unsolicited event for HP jack sensing */
907static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
908{
909 if (codec->vendor_id == 0x10ec0880)
910 res >>= 28;
911 else
912 res >>= 26;
Kailang Yang7fb0d782008-10-15 11:12:35 +0200913 if (res == ALC880_HP_EVENT)
914 alc_sku_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200915
Kailang Yang7fb0d782008-10-15 11:12:35 +0200916 if (res == ALC880_MIC_EVENT)
917 alc_mic_automute(codec);
918}
919
920static void alc_inithook(struct hda_codec *codec)
921{
Kailang Yangc9b58002007-10-16 14:30:01 +0200922 alc_sku_automute(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +0200923 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +0200924}
925
Kailang Yangf9423e72008-05-27 12:32:25 +0200926/* additional initialization for ALC888 variants */
927static void alc888_coef_init(struct hda_codec *codec)
928{
929 unsigned int tmp;
930
931 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
932 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
933 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
934 if ((tmp & 0xf0) == 2)
935 /* alc888S-VC */
936 snd_hda_codec_read(codec, 0x20, 0,
937 AC_VERB_SET_PROC_COEF, 0x830);
938 else
939 /* alc888-VB */
940 snd_hda_codec_read(codec, 0x20, 0,
941 AC_VERB_SET_PROC_COEF, 0x3030);
942}
943
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200944/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
945 * 31 ~ 16 : Manufacture ID
946 * 15 ~ 8 : SKU ID
947 * 7 ~ 0 : Assembly ID
948 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
949 */
950static void alc_subsystem_id(struct hda_codec *codec,
951 unsigned int porta, unsigned int porte,
952 unsigned int portd)
953{
Kailang Yangc9b58002007-10-16 14:30:01 +0200954 unsigned int ass, tmp, i;
955 unsigned nid;
956 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200957
Kailang Yangc9b58002007-10-16 14:30:01 +0200958 ass = codec->subsystem_id & 0xffff;
959 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
960 goto do_sku;
961
Kailang Yangea1fb292008-08-26 12:58:38 +0200962 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200963 * 31~30 : port conetcivity
964 * 29~21 : reserve
965 * 20 : PCBEEP input
966 * 19~16 : Check sum (15:1)
967 * 15~1 : Custom
968 * 0 : override
969 */
970 nid = 0x1d;
971 if (codec->vendor_id == 0x10ec0260)
972 nid = 0x17;
973 ass = snd_hda_codec_read(codec, nid, 0,
974 AC_VERB_GET_CONFIG_DEFAULT, 0);
975 if (!(ass & 1) && !(ass & 0x100000))
976 return;
977 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200978 return;
979
Kailang Yangc9b58002007-10-16 14:30:01 +0200980 /* check sum */
981 tmp = 0;
982 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100983 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200984 tmp++;
985 }
986 if (((ass >> 16) & 0xf) != tmp)
987 return;
988do_sku:
989 /*
990 * 0 : override
991 * 1 : Swap Jack
992 * 2 : 0 --> Desktop, 1 --> Laptop
993 * 3~5 : External Amplifier control
994 * 7~6 : Reserved
995 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200996 tmp = (ass & 0x38) >> 3; /* external Amp control */
997 switch (tmp) {
998 case 1:
999 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1000 break;
1001 case 3:
1002 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1003 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001004 case 7:
1005 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1006 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001007 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +02001008 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001009 case 0x10ec0260:
1010 snd_hda_codec_write(codec, 0x0f, 0,
1011 AC_VERB_SET_EAPD_BTLENABLE, 2);
1012 snd_hda_codec_write(codec, 0x10, 0,
1013 AC_VERB_SET_EAPD_BTLENABLE, 2);
1014 break;
1015 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001016 case 0x10ec0267:
1017 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001018 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +02001019 case 0x10ec0660:
1020 case 0x10ec0662:
1021 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001022 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001023 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001024 snd_hda_codec_write(codec, 0x14, 0,
1025 AC_VERB_SET_EAPD_BTLENABLE, 2);
1026 snd_hda_codec_write(codec, 0x15, 0,
1027 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +02001028 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001029 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001030 switch (codec->vendor_id) {
1031 case 0x10ec0260:
1032 snd_hda_codec_write(codec, 0x1a, 0,
1033 AC_VERB_SET_COEF_INDEX, 7);
1034 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1035 AC_VERB_GET_PROC_COEF, 0);
1036 snd_hda_codec_write(codec, 0x1a, 0,
1037 AC_VERB_SET_COEF_INDEX, 7);
1038 snd_hda_codec_write(codec, 0x1a, 0,
1039 AC_VERB_SET_PROC_COEF,
1040 tmp | 0x2010);
1041 break;
1042 case 0x10ec0262:
1043 case 0x10ec0880:
1044 case 0x10ec0882:
1045 case 0x10ec0883:
1046 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001047 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +02001048 snd_hda_codec_write(codec, 0x20, 0,
1049 AC_VERB_SET_COEF_INDEX, 7);
1050 tmp = snd_hda_codec_read(codec, 0x20, 0,
1051 AC_VERB_GET_PROC_COEF, 0);
1052 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001053 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001054 snd_hda_codec_write(codec, 0x20, 0,
1055 AC_VERB_SET_PROC_COEF,
1056 tmp | 0x2010);
1057 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001058 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +02001059 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +02001060 break;
Kailang Yangc9b58002007-10-16 14:30:01 +02001061 case 0x10ec0267:
1062 case 0x10ec0268:
1063 snd_hda_codec_write(codec, 0x20, 0,
1064 AC_VERB_SET_COEF_INDEX, 7);
1065 tmp = snd_hda_codec_read(codec, 0x20, 0,
1066 AC_VERB_GET_PROC_COEF, 0);
1067 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001068 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001069 snd_hda_codec_write(codec, 0x20, 0,
1070 AC_VERB_SET_PROC_COEF,
1071 tmp | 0x3000);
1072 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001073 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001074 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001075 break;
1076 }
Kailang Yangea1fb292008-08-26 12:58:38 +02001077
Kailang Yang8c427222008-01-10 13:03:59 +01001078 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +02001079 * when the external headphone out jack is plugged"
1080 */
Kailang Yang8c427222008-01-10 13:03:59 +01001081 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +02001082 return;
1083 /*
1084 * 10~8 : Jack location
1085 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1086 * 14~13: Resvered
1087 * 15 : 1 --> enable the function "Mute internal speaker
1088 * when the external headphone out jack is plugged"
1089 */
1090 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +01001091 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +02001092 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +01001093 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +02001094 else
1095 return;
1096 }
1097
1098 if (!spec->autocfg.hp_pins[0]) {
1099 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1100 if (tmp == 0)
1101 spec->autocfg.hp_pins[0] = porta;
1102 else if (tmp == 1)
1103 spec->autocfg.hp_pins[0] = porte;
1104 else if (tmp == 2)
1105 spec->autocfg.hp_pins[0] = portd;
1106 else
1107 return;
1108 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001109 if (spec->autocfg.hp_pins[0])
1110 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1111 AC_VERB_SET_UNSOLICITED_ENABLE,
1112 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangc9b58002007-10-16 14:30:01 +02001113
Takashi Iwai4605b712008-10-31 14:18:24 +01001114#if 0 /* it's broken in some acses -- temporarily disabled */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001115 if (spec->autocfg.input_pins[AUTO_PIN_MIC] &&
1116 spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC])
1117 snd_hda_codec_write(codec,
1118 spec->autocfg.input_pins[AUTO_PIN_MIC], 0,
1119 AC_VERB_SET_UNSOLICITED_ENABLE,
1120 AC_USRSP_EN | ALC880_MIC_EVENT);
Takashi Iwai4605b712008-10-31 14:18:24 +01001121#endif /* disabled */
Kailang Yangea1fb292008-08-26 12:58:38 +02001122
Kailang Yangc9b58002007-10-16 14:30:01 +02001123 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001124}
1125
Takashi Iwai41e41f12005-06-08 14:48:49 +02001126/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001127 * Fix-up pin default configurations
1128 */
1129
1130struct alc_pincfg {
1131 hda_nid_t nid;
1132 u32 val;
1133};
1134
1135static void alc_fix_pincfg(struct hda_codec *codec,
1136 const struct snd_pci_quirk *quirk,
1137 const struct alc_pincfg **pinfix)
1138{
1139 const struct alc_pincfg *cfg;
1140
1141 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1142 if (!quirk)
1143 return;
1144
1145 cfg = pinfix[quirk->value];
1146 for (; cfg->nid; cfg++) {
1147 int i;
1148 u32 val = cfg->val;
1149 for (i = 0; i < 4; i++) {
1150 snd_hda_codec_write(codec, cfg->nid, 0,
1151 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1152 val & 0xff);
1153 val >>= 8;
1154 }
1155 }
1156}
1157
1158/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001159 * ALC888 Acer Aspire 4930G model
1160 */
1161
1162static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1163/* Front Mic: set to PIN_IN (empty by default) */
1164 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1165/* Unselect Front Mic by default in input mixer 3 */
1166 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1167/* enable unsolicited event fpr HP jack */
1168 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1169/* Connect Internal HP to front */
1170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1171 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1172 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1173/* Connect HP out to front */
1174 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1175 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1176 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1177 { }
1178};
1179
1180static struct hda_input_mux alc888_acer_aspire_4930g_capture_source[2] = {
1181 /* Front mic only available on one ADC */
1182 {
1183 .num_items = 4,
1184 .items = {
1185 { "Mic", 0x0 },
1186 { "Line", 0x2 },
1187 { "CD", 0x4 },
1188 { "Front Mic", 0xb },
1189 },
1190 },
1191 {
1192 .num_items = 3,
1193 .items = {
1194 { "Mic", 0x0 },
1195 { "Line", 0x2 },
1196 { "CD", 0x4 },
1197 },
1198 }
1199};
1200
1201static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
1202 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1203 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
1204 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1205 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
1206 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
1207 HDA_OUTPUT),
1208 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1209 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1210 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1211 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
1212 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
1213 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1214 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1215 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1216 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1217 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1218 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
1219 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1220 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1221 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1222 { } /* end */
1223};
1224
1225static void alc888_acer_aspire_4930g_automute(struct hda_codec *codec)
1226{
1227 unsigned int present;
1228 present = snd_hda_codec_read(codec, 0x15, 0,
1229 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
1230 /* Toggle the internal HP PIN (regular muting doesn't work) */
1231 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
1232 (present ? 0x0 : PIN_OUT));
1233}
1234
1235static void alc888_acer_aspire_4930g_unsol_event(struct hda_codec *codec,
1236 unsigned int res)
1237{
1238 if (res >> 26 == ALC880_HP_EVENT)
1239 alc888_acer_aspire_4930g_automute(codec);
1240}
1241
1242/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001243 * ALC880 3-stack model
1244 *
1245 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001246 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1247 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 */
1249
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001250static hda_nid_t alc880_dac_nids[4] = {
1251 /* front, rear, clfe, rear_surr */
1252 0x02, 0x05, 0x04, 0x03
1253};
1254
1255static hda_nid_t alc880_adc_nids[3] = {
1256 /* ADC0-2 */
1257 0x07, 0x08, 0x09,
1258};
1259
1260/* The datasheet says the node 0x07 is connected from inputs,
1261 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001262 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001264static hda_nid_t alc880_adc_nids_alt[2] = {
1265 /* ADC1-2 */
1266 0x08, 0x09,
1267};
1268
1269#define ALC880_DIGOUT_NID 0x06
1270#define ALC880_DIGIN_NID 0x0a
1271
1272static struct hda_input_mux alc880_capture_source = {
1273 .num_items = 4,
1274 .items = {
1275 { "Mic", 0x0 },
1276 { "Front Mic", 0x3 },
1277 { "Line", 0x2 },
1278 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001280};
1281
1282/* channel source setting (2/6 channel selection for 3-stack) */
1283/* 2ch mode */
1284static struct hda_verb alc880_threestack_ch2_init[] = {
1285 /* set line-in to input, mute it */
1286 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1287 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1288 /* set mic-in to input vref 80%, mute it */
1289 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1290 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001291 { } /* end */
1292};
1293
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001294/* 6ch mode */
1295static struct hda_verb alc880_threestack_ch6_init[] = {
1296 /* set line-in to output, unmute it */
1297 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1298 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1299 /* set mic-in to output, unmute it */
1300 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1301 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1302 { } /* end */
1303};
1304
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001305static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001306 { 2, alc880_threestack_ch2_init },
1307 { 6, alc880_threestack_ch6_init },
1308};
1309
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001310static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001311 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001312 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001313 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001314 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001315 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1316 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001317 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1318 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1320 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1321 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1322 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1323 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1324 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1325 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1326 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1327 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1328 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001330 {
1331 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1332 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001333 .info = alc_ch_mode_info,
1334 .get = alc_ch_mode_get,
1335 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001336 },
1337 { } /* end */
1338};
1339
1340/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001341static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
1342 struct snd_ctl_elem_info *uinfo)
1343{
1344 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1345 struct alc_spec *spec = codec->spec;
1346 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001347
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001348 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1349 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1350 HDA_INPUT);
1351 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
1352 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1353 return err;
1354}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001356static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1357 unsigned int size, unsigned int __user *tlv)
1358{
1359 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1360 struct alc_spec *spec = codec->spec;
1361 int err;
1362
1363 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1364 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
1365 HDA_INPUT);
1366 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
1367 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1368 return err;
1369}
1370
1371typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
1372 struct snd_ctl_elem_value *ucontrol);
1373
1374static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
1375 struct snd_ctl_elem_value *ucontrol,
1376 getput_call_t func)
1377{
1378 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1379 struct alc_spec *spec = codec->spec;
1380 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1381 int err;
1382
1383 mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */
1384 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
1385 3, 0, HDA_INPUT);
1386 err = func(kcontrol, ucontrol);
1387 mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */
1388 return err;
1389}
1390
1391static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
1392 struct snd_ctl_elem_value *ucontrol)
1393{
1394 return alc_cap_getput_caller(kcontrol, ucontrol,
1395 snd_hda_mixer_amp_volume_get);
1396}
1397
1398static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
1399 struct snd_ctl_elem_value *ucontrol)
1400{
1401 return alc_cap_getput_caller(kcontrol, ucontrol,
1402 snd_hda_mixer_amp_volume_put);
1403}
1404
1405/* capture mixer elements */
1406#define alc_cap_sw_info snd_ctl_boolean_stereo_info
1407
1408static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
1409 struct snd_ctl_elem_value *ucontrol)
1410{
1411 return alc_cap_getput_caller(kcontrol, ucontrol,
1412 snd_hda_mixer_amp_switch_get);
1413}
1414
1415static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
1416 struct snd_ctl_elem_value *ucontrol)
1417{
1418 return alc_cap_getput_caller(kcontrol, ucontrol,
1419 snd_hda_mixer_amp_switch_put);
1420}
1421
1422#define DEFINE_CAPMIX(num) \
1423static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
1424 { \
1425 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1426 .name = "Capture Switch", \
1427 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
1428 .count = num, \
1429 .info = alc_cap_sw_info, \
1430 .get = alc_cap_sw_get, \
1431 .put = alc_cap_sw_put, \
1432 }, \
1433 { \
1434 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1435 .name = "Capture Volume", \
1436 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
1437 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
1438 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
1439 .count = num, \
1440 .info = alc_cap_vol_info, \
1441 .get = alc_cap_vol_get, \
1442 .put = alc_cap_vol_put, \
1443 .tlv = { .c = alc_cap_vol_tlv }, \
1444 }, \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01001445 { \
1446 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
1447 /* .name = "Capture Source", */ \
1448 .name = "Input Source", \
1449 .count = num, \
1450 .info = alc_mux_enum_info, \
1451 .get = alc_mux_enum_get, \
1452 .put = alc_mux_enum_put, \
1453 }, \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001454 { } /* end */ \
1455}
1456
1457/* up to three ADCs */
1458DEFINE_CAPMIX(1);
1459DEFINE_CAPMIX(2);
1460DEFINE_CAPMIX(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001461
1462
1463/*
1464 * ALC880 5-stack model
1465 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001466 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1467 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001468 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1469 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1470 */
1471
1472/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001473static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001474 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001475 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 { } /* end */
1477};
1478
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001479/* channel source setting (6/8 channel selection for 5-stack) */
1480/* 6ch mode */
1481static struct hda_verb alc880_fivestack_ch6_init[] = {
1482 /* set line-in to input, mute it */
1483 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1484 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001485 { } /* end */
1486};
1487
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001488/* 8ch mode */
1489static struct hda_verb alc880_fivestack_ch8_init[] = {
1490 /* set line-in to output, unmute it */
1491 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1492 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1493 { } /* end */
1494};
1495
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001496static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001497 { 6, alc880_fivestack_ch6_init },
1498 { 8, alc880_fivestack_ch8_init },
1499};
1500
1501
1502/*
1503 * ALC880 6-stack model
1504 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001505 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1506 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001507 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1508 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1509 */
1510
1511static hda_nid_t alc880_6st_dac_nids[4] = {
1512 /* front, rear, clfe, rear_surr */
1513 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001514};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001515
1516static struct hda_input_mux alc880_6stack_capture_source = {
1517 .num_items = 4,
1518 .items = {
1519 { "Mic", 0x0 },
1520 { "Front Mic", 0x1 },
1521 { "Line", 0x2 },
1522 { "CD", 0x4 },
1523 },
1524};
1525
1526/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001527static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001528 { 8, NULL },
1529};
1530
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001531static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001532 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001533 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001534 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001535 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001536 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1537 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001538 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1539 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001540 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001541 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001542 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1543 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1544 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1545 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1546 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1547 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1548 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1549 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1550 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1551 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001552 {
1553 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1554 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001555 .info = alc_ch_mode_info,
1556 .get = alc_ch_mode_get,
1557 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001558 },
1559 { } /* end */
1560};
1561
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001562
1563/*
1564 * ALC880 W810 model
1565 *
1566 * W810 has rear IO for:
1567 * Front (DAC 02)
1568 * Surround (DAC 03)
1569 * Center/LFE (DAC 04)
1570 * Digital out (06)
1571 *
1572 * The system also has a pair of internal speakers, and a headphone jack.
1573 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001574 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001575 * There is a variable resistor to control the speaker or headphone
1576 * volume. This is a hardware-only device without a software API.
1577 *
1578 * Plugging headphones in will disable the internal speakers. This is
1579 * implemented in hardware, not via the driver using jack sense. In
1580 * a similar fashion, plugging into the rear socket marked "front" will
1581 * disable both the speakers and headphones.
1582 *
1583 * For input, there's a microphone jack, and an "audio in" jack.
1584 * These may not do anything useful with this driver yet, because I
1585 * haven't setup any initialization verbs for these yet...
1586 */
1587
1588static hda_nid_t alc880_w810_dac_nids[3] = {
1589 /* front, rear/surround, clfe */
1590 0x02, 0x03, 0x04
1591};
1592
1593/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001594static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001595 { 6, NULL }
1596};
1597
1598/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001599static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001600 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001601 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001602 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001603 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001604 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1605 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001606 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1607 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001608 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1609 { } /* end */
1610};
1611
1612
1613/*
1614 * Z710V model
1615 *
1616 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001617 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1618 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001619 */
1620
1621static hda_nid_t alc880_z71v_dac_nids[1] = {
1622 0x02
1623};
1624#define ALC880_Z71V_HP_DAC 0x03
1625
1626/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001627static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001628 { 2, NULL }
1629};
1630
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001631static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001632 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001633 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001634 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001635 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001636 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1637 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1638 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1639 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1640 { } /* end */
1641};
1642
1643
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001644/*
1645 * ALC880 F1734 model
1646 *
1647 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1648 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1649 */
1650
1651static hda_nid_t alc880_f1734_dac_nids[1] = {
1652 0x03
1653};
1654#define ALC880_F1734_HP_DAC 0x02
1655
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001656static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001657 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001658 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001659 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1660 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001661 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1662 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001663 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1664 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001665 { } /* end */
1666};
1667
Takashi Iwai937b4162008-02-11 14:52:36 +01001668static struct hda_input_mux alc880_f1734_capture_source = {
1669 .num_items = 2,
1670 .items = {
1671 { "Mic", 0x1 },
1672 { "CD", 0x4 },
1673 },
1674};
1675
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001676
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001677/*
1678 * ALC880 ASUS model
1679 *
1680 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1681 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1682 * Mic = 0x18, Line = 0x1a
1683 */
1684
1685#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1686#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1687
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001688static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001689 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001690 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001691 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001692 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001693 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1694 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001695 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1696 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001697 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1698 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1699 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1700 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1701 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1702 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001703 {
1704 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1705 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001706 .info = alc_ch_mode_info,
1707 .get = alc_ch_mode_get,
1708 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001709 },
1710 { } /* end */
1711};
1712
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001713/*
1714 * ALC880 ASUS W1V model
1715 *
1716 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1717 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1718 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1719 */
1720
1721/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001722static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001723 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1724 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001725 { } /* end */
1726};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001727
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001728/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001729static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001730 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1731 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1732 { } /* end */
1733};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001734
Kailang Yangdf694da2005-12-05 19:42:22 +01001735/* TCL S700 */
1736static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1737 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1738 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1739 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1740 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1741 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1742 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1743 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1744 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1745 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01001746 { } /* end */
1747};
1748
Kailang Yangccc656c2006-10-17 12:32:26 +02001749/* Uniwill */
1750static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001751 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1752 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1753 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1754 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001755 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1756 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1757 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1758 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1759 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1760 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1761 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1762 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1765 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1766 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1767 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1768 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1769 {
1770 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1771 .name = "Channel Mode",
1772 .info = alc_ch_mode_info,
1773 .get = alc_ch_mode_get,
1774 .put = alc_ch_mode_put,
1775 },
1776 { } /* end */
1777};
1778
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001779static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1780 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1781 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1782 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1783 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1784 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1785 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1786 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1787 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1788 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1789 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1790 { } /* end */
1791};
1792
Kailang Yangccc656c2006-10-17 12:32:26 +02001793static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001794 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1795 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1796 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1797 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1799 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1800 { } /* end */
1801};
1802
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001804 * virtual master controls
1805 */
1806
1807/*
1808 * slave controls for virtual master
1809 */
1810static const char *alc_slave_vols[] = {
1811 "Front Playback Volume",
1812 "Surround Playback Volume",
1813 "Center Playback Volume",
1814 "LFE Playback Volume",
1815 "Side Playback Volume",
1816 "Headphone Playback Volume",
1817 "Speaker Playback Volume",
1818 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001819 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01001820 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001821 NULL,
1822};
1823
1824static const char *alc_slave_sws[] = {
1825 "Front Playback Switch",
1826 "Surround Playback Switch",
1827 "Center Playback Switch",
1828 "LFE Playback Switch",
1829 "Side Playback Switch",
1830 "Headphone Playback Switch",
1831 "Speaker Playback Switch",
1832 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001833 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001834 NULL,
1835};
1836
1837/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001838 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001839 */
Takashi Iwai603c4012008-07-30 15:01:44 +02001840
1841static void alc_free_kctls(struct hda_codec *codec);
1842
Linus Torvalds1da177e2005-04-16 15:20:36 -07001843static int alc_build_controls(struct hda_codec *codec)
1844{
1845 struct alc_spec *spec = codec->spec;
1846 int err;
1847 int i;
1848
1849 for (i = 0; i < spec->num_mixers; i++) {
1850 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1851 if (err < 0)
1852 return err;
1853 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01001854 if (spec->cap_mixer) {
1855 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
1856 if (err < 0)
1857 return err;
1858 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001860 err = snd_hda_create_spdif_out_ctls(codec,
1861 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862 if (err < 0)
1863 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001864 err = snd_hda_create_spdif_share_sw(codec,
1865 &spec->multiout);
1866 if (err < 0)
1867 return err;
1868 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869 }
1870 if (spec->dig_in_nid) {
1871 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1872 if (err < 0)
1873 return err;
1874 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001875
1876 /* if we have no master control, let's create it */
1877 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001878 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001879 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001880 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001881 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001882 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001883 if (err < 0)
1884 return err;
1885 }
1886 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1887 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1888 NULL, alc_slave_sws);
1889 if (err < 0)
1890 return err;
1891 }
1892
Takashi Iwai603c4012008-07-30 15:01:44 +02001893 alc_free_kctls(codec); /* no longer needed */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001894 return 0;
1895}
1896
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001897
Linus Torvalds1da177e2005-04-16 15:20:36 -07001898/*
1899 * initialize the codec volumes, etc
1900 */
1901
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001902/*
1903 * generic initialization of ADC, input mixers and output mixers
1904 */
1905static struct hda_verb alc880_volume_init_verbs[] = {
1906 /*
1907 * Unmute ADC0-2 and set the default input to mic-in
1908 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001909 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001910 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001911 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001912 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001913 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001914 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001915
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001916 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1917 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001918 * Note: PASD motherboards uses the Line In 2 as the input for front
1919 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001920 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001921 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001922 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1923 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1924 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1928 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001929
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001930 /*
1931 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001932 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001933 /* set vol=0 to output mixers */
1934 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1935 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1936 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1937 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1938 /* set up input amps for analog loopback */
1939 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001940 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1941 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001942 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001944 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001946 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1947 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001948
1949 { }
1950};
1951
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001952/*
1953 * 3-stack pin configuration:
1954 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1955 */
1956static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1957 /*
1958 * preset connection lists of input pins
1959 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1960 */
1961 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1962 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1963 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1964
1965 /*
1966 * Set pin mode and muting
1967 */
1968 /* set front pin widgets 0x14 for output */
1969 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1970 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1971 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1972 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1973 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1974 /* Mic2 (as headphone out) for HP output */
1975 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1976 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1977 /* Line In pin widget for input */
1978 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1979 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1980 /* Line2 (as front mic) pin widget for input and vref at 80% */
1981 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1982 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1983 /* CD pin widget for input */
1984 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1985
1986 { }
1987};
1988
1989/*
1990 * 5-stack pin configuration:
1991 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1992 * line-in/side = 0x1a, f-mic = 0x1b
1993 */
1994static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1995 /*
1996 * preset connection lists of input pins
1997 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1998 */
1999 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2000 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
2001
2002 /*
2003 * Set pin mode and muting
2004 */
2005 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02002006 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2008 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2009 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002010 /* unmute pins for output (no gain on this amp) */
2011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2012 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2013 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2014 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2015
Linus Torvalds1da177e2005-04-16 15:20:36 -07002016 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02002017 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002018 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2019 /* Mic2 (as headphone out) for HP output */
2020 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002021 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002022 /* Line In pin widget for input */
2023 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2024 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2025 /* Line2 (as front mic) pin widget for input and vref at 80% */
2026 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2027 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2028 /* CD pin widget for input */
2029 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002030
2031 { }
2032};
2033
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002034/*
2035 * W810 pin configuration:
2036 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
2037 */
2038static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039 /* hphone/speaker input selector: front DAC */
2040 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
2041
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002042 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2043 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2044 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2045 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2046 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2047 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2048
2049 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02002050 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002051
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052 { }
2053};
2054
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002055/*
2056 * Z71V pin configuration:
2057 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
2058 */
2059static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002060 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002061 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02002062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002064
Takashi Iwai16ded522005-06-10 19:58:24 +02002065 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002066 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002067 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002068 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002069
2070 { }
2071};
2072
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002073/*
2074 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002075 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
2076 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002077 */
2078static struct hda_verb alc880_pin_6stack_init_verbs[] = {
2079 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2080
Takashi Iwai16ded522005-06-10 19:58:24 +02002081 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002082 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002083 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002084 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002085 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002086 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002087 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002088 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2089
Takashi Iwai16ded522005-06-10 19:58:24 +02002090 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002091 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002092 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002093 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002094 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002095 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002096 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02002097 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02002098 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002099
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002100 { }
2101};
Takashi Iwai16ded522005-06-10 19:58:24 +02002102
Kailang Yangccc656c2006-10-17 12:32:26 +02002103/*
2104 * Uniwill pin configuration:
2105 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
2106 * line = 0x1a
2107 */
2108static struct hda_verb alc880_uniwill_init_verbs[] = {
2109 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2110
2111 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2112 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2113 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2114 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2115 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2116 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2117 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2118 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2119 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2120 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2121 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2122 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2123 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2124 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2125
2126 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2127 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2128 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2129 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2130 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2131 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2132 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
2133 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
2134 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2135
2136 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2137 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
2138
2139 { }
2140};
2141
2142/*
2143* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02002144* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02002145 */
2146static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
2147 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2148
2149 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2150 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2151 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2152 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2153 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2154 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2155 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2156 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2157 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2158 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2159 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
2160 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
2161
2162 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2163 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2164 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2165 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2166 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2167 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2168
2169 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2170 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
2171
2172 { }
2173};
2174
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002175static struct hda_verb alc880_beep_init_verbs[] = {
2176 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
2177 { }
2178};
2179
Kailang Yangccc656c2006-10-17 12:32:26 +02002180/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002181static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02002182{
2183 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002184 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002185
2186 present = snd_hda_codec_read(codec, 0x14, 0,
2187 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002188 bits = present ? HDA_AMP_MUTE : 0;
2189 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
2190 HDA_AMP_MUTE, bits);
2191 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
2192 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002193}
2194
2195/* auto-toggle front mic */
2196static void alc880_uniwill_mic_automute(struct hda_codec *codec)
2197{
2198 unsigned int present;
2199 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002200
2201 present = snd_hda_codec_read(codec, 0x18, 0,
2202 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002203 bits = present ? HDA_AMP_MUTE : 0;
2204 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002205}
2206
2207static void alc880_uniwill_automute(struct hda_codec *codec)
2208{
2209 alc880_uniwill_hp_automute(codec);
2210 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02002211}
2212
2213static void alc880_uniwill_unsol_event(struct hda_codec *codec,
2214 unsigned int res)
2215{
2216 /* Looks like the unsol event is incompatible with the standard
2217 * definition. 4bit tag is placed at 28 bit!
2218 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02002219 switch (res >> 28) {
2220 case ALC880_HP_EVENT:
2221 alc880_uniwill_hp_automute(codec);
2222 break;
2223 case ALC880_MIC_EVENT:
2224 alc880_uniwill_mic_automute(codec);
2225 break;
2226 }
Kailang Yangccc656c2006-10-17 12:32:26 +02002227}
2228
2229static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
2230{
2231 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002232 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02002233
2234 present = snd_hda_codec_read(codec, 0x14, 0,
2235 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002236 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02002237 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02002238}
2239
2240static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
2241{
2242 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02002243
Kailang Yangccc656c2006-10-17 12:32:26 +02002244 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02002245 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
2246 present &= HDA_AMP_VOLMASK;
2247 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
2248 HDA_AMP_VOLMASK, present);
2249 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
2250 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02002251}
Takashi Iwai47fd8302007-08-10 17:11:07 +02002252
Kailang Yangccc656c2006-10-17 12:32:26 +02002253static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
2254 unsigned int res)
2255{
2256 /* Looks like the unsol event is incompatible with the standard
2257 * definition. 4bit tag is placed at 28 bit!
2258 */
2259 if ((res >> 28) == ALC880_HP_EVENT)
2260 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002261 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02002262 alc880_uniwill_p53_dcvol_automute(codec);
2263}
2264
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002265/*
2266 * F1734 pin configuration:
2267 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2268 */
2269static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002270 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002271 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2272 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2273 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2274 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2275
2276 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2277 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2278 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2279 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2280
2281 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2282 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002283 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002284 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2285 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2286 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2287 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2288 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2289 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002290
Takashi Iwai937b4162008-02-11 14:52:36 +01002291 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2292 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2293
Takashi Iwai16ded522005-06-10 19:58:24 +02002294 { }
2295};
2296
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002297/*
2298 * ASUS pin configuration:
2299 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2300 */
2301static struct hda_verb alc880_pin_asus_init_verbs[] = {
2302 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2303 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2304 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2305 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2306
2307 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2308 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2309 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2310 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2311 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2312 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2313 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2314 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2315
2316 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2317 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2318 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2319 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2320 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2321 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2322 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2323 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2324 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002325
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002326 { }
2327};
2328
2329/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002330#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2331#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002332
Kailang Yangdf694da2005-12-05 19:42:22 +01002333/* Clevo m520g init */
2334static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2335 /* headphone output */
2336 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2337 /* line-out */
2338 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2339 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2340 /* Line-in */
2341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2343 /* CD */
2344 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2345 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2346 /* Mic1 (rear panel) */
2347 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2348 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2349 /* Mic2 (front panel) */
2350 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2351 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2352 /* headphone */
2353 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2354 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2355 /* change to EAPD mode */
2356 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2357 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2358
2359 { }
2360};
2361
2362static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002363 /* change to EAPD mode */
2364 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2365 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2366
Kailang Yangdf694da2005-12-05 19:42:22 +01002367 /* Headphone output */
2368 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2369 /* Front output*/
2370 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2371 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2372
2373 /* Line In pin widget for input */
2374 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2375 /* CD pin widget for input */
2376 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2377 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2378 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2379
2380 /* change to EAPD mode */
2381 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2382 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2383
2384 { }
2385};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002386
2387/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002388 * LG m1 express dual
2389 *
2390 * Pin assignment:
2391 * Rear Line-In/Out (blue): 0x14
2392 * Build-in Mic-In: 0x15
2393 * Speaker-out: 0x17
2394 * HP-Out (green): 0x1b
2395 * Mic-In/Out (red): 0x19
2396 * SPDIF-Out: 0x1e
2397 */
2398
2399/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2400static hda_nid_t alc880_lg_dac_nids[3] = {
2401 0x05, 0x02, 0x03
2402};
2403
2404/* seems analog CD is not working */
2405static struct hda_input_mux alc880_lg_capture_source = {
2406 .num_items = 3,
2407 .items = {
2408 { "Mic", 0x1 },
2409 { "Line", 0x5 },
2410 { "Internal Mic", 0x6 },
2411 },
2412};
2413
2414/* 2,4,6 channel modes */
2415static struct hda_verb alc880_lg_ch2_init[] = {
2416 /* set line-in and mic-in to input */
2417 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2418 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2419 { }
2420};
2421
2422static struct hda_verb alc880_lg_ch4_init[] = {
2423 /* set line-in to out and mic-in to input */
2424 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2425 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2426 { }
2427};
2428
2429static struct hda_verb alc880_lg_ch6_init[] = {
2430 /* set line-in and mic-in to output */
2431 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2432 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2433 { }
2434};
2435
2436static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2437 { 2, alc880_lg_ch2_init },
2438 { 4, alc880_lg_ch4_init },
2439 { 6, alc880_lg_ch6_init },
2440};
2441
2442static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002443 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2444 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002445 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2446 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2447 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2448 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2449 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2450 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2451 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2452 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2453 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2454 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2455 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2456 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2457 {
2458 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2459 .name = "Channel Mode",
2460 .info = alc_ch_mode_info,
2461 .get = alc_ch_mode_get,
2462 .put = alc_ch_mode_put,
2463 },
2464 { } /* end */
2465};
2466
2467static struct hda_verb alc880_lg_init_verbs[] = {
2468 /* set capture source to mic-in */
2469 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2470 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2471 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2472 /* mute all amp mixer inputs */
2473 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002474 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2475 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002476 /* line-in to input */
2477 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2479 /* built-in mic */
2480 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2481 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2482 /* speaker-out */
2483 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2484 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2485 /* mic-in to input */
2486 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2487 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2488 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2489 /* HP-out */
2490 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2491 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2492 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2493 /* jack sense */
2494 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2495 { }
2496};
2497
2498/* toggle speaker-output according to the hp-jack state */
2499static void alc880_lg_automute(struct hda_codec *codec)
2500{
2501 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002502 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002503
2504 present = snd_hda_codec_read(codec, 0x1b, 0,
2505 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002506 bits = present ? HDA_AMP_MUTE : 0;
2507 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2508 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002509}
2510
2511static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2512{
2513 /* Looks like the unsol event is incompatible with the standard
2514 * definition. 4bit tag is placed at 28 bit!
2515 */
2516 if ((res >> 28) == 0x01)
2517 alc880_lg_automute(codec);
2518}
2519
2520/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002521 * LG LW20
2522 *
2523 * Pin assignment:
2524 * Speaker-out: 0x14
2525 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002526 * Built-in Mic-In: 0x19
2527 * Line-In: 0x1b
2528 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002529 * SPDIF-Out: 0x1e
2530 */
2531
Takashi Iwaid6815182006-03-23 16:06:23 +01002532static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002533 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002534 .items = {
2535 { "Mic", 0x0 },
2536 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002537 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002538 },
2539};
2540
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002541#define alc880_lg_lw_modes alc880_threestack_modes
2542
Takashi Iwaid6815182006-03-23 16:06:23 +01002543static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002544 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2545 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2546 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2547 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2548 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2549 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2550 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2551 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2552 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2553 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002554 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2555 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2556 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2557 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002558 {
2559 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2560 .name = "Channel Mode",
2561 .info = alc_ch_mode_info,
2562 .get = alc_ch_mode_get,
2563 .put = alc_ch_mode_put,
2564 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002565 { } /* end */
2566};
2567
2568static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002569 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2570 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2571 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2572
Takashi Iwaid6815182006-03-23 16:06:23 +01002573 /* set capture source to mic-in */
2574 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2575 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2576 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002577 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002578 /* speaker-out */
2579 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2580 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2581 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002582 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2583 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2584 /* mic-in to input */
2585 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2586 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2587 /* built-in mic */
2588 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2589 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2590 /* jack sense */
2591 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2592 { }
2593};
2594
2595/* toggle speaker-output according to the hp-jack state */
2596static void alc880_lg_lw_automute(struct hda_codec *codec)
2597{
2598 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002599 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002600
2601 present = snd_hda_codec_read(codec, 0x1b, 0,
2602 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002603 bits = present ? HDA_AMP_MUTE : 0;
2604 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2605 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002606}
2607
2608static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2609{
2610 /* Looks like the unsol event is incompatible with the standard
2611 * definition. 4bit tag is placed at 28 bit!
2612 */
2613 if ((res >> 28) == 0x01)
2614 alc880_lg_lw_automute(codec);
2615}
2616
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002617static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2618 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2619 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2620 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2621 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2622 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2623 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2624 { } /* end */
2625};
2626
2627static struct hda_input_mux alc880_medion_rim_capture_source = {
2628 .num_items = 2,
2629 .items = {
2630 { "Mic", 0x0 },
2631 { "Internal Mic", 0x1 },
2632 },
2633};
2634
2635static struct hda_verb alc880_medion_rim_init_verbs[] = {
2636 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2637
2638 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2639 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2640
2641 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2644 /* Mic2 (as headphone out) for HP output */
2645 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2646 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2647 /* Internal Speaker */
2648 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2649 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2650
2651 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2652 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2653
2654 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2655 { }
2656};
2657
2658/* toggle speaker-output according to the hp-jack state */
2659static void alc880_medion_rim_automute(struct hda_codec *codec)
2660{
2661 unsigned int present;
2662 unsigned char bits;
2663
2664 present = snd_hda_codec_read(codec, 0x14, 0,
2665 AC_VERB_GET_PIN_SENSE, 0)
2666 & AC_PINSENSE_PRESENCE;
2667 bits = present ? HDA_AMP_MUTE : 0;
2668 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2669 HDA_AMP_MUTE, bits);
2670 if (present)
2671 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2672 else
2673 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2674}
2675
2676static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2677 unsigned int res)
2678{
2679 /* Looks like the unsol event is incompatible with the standard
2680 * definition. 4bit tag is placed at 28 bit!
2681 */
2682 if ((res >> 28) == ALC880_HP_EVENT)
2683 alc880_medion_rim_automute(codec);
2684}
2685
Takashi Iwaicb53c622007-08-10 17:21:45 +02002686#ifdef CONFIG_SND_HDA_POWER_SAVE
2687static struct hda_amp_list alc880_loopbacks[] = {
2688 { 0x0b, HDA_INPUT, 0 },
2689 { 0x0b, HDA_INPUT, 1 },
2690 { 0x0b, HDA_INPUT, 2 },
2691 { 0x0b, HDA_INPUT, 3 },
2692 { 0x0b, HDA_INPUT, 4 },
2693 { } /* end */
2694};
2695
2696static struct hda_amp_list alc880_lg_loopbacks[] = {
2697 { 0x0b, HDA_INPUT, 1 },
2698 { 0x0b, HDA_INPUT, 6 },
2699 { 0x0b, HDA_INPUT, 7 },
2700 { } /* end */
2701};
2702#endif
2703
Takashi Iwaid6815182006-03-23 16:06:23 +01002704/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002705 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002706 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002707
Linus Torvalds1da177e2005-04-16 15:20:36 -07002708static int alc_init(struct hda_codec *codec)
2709{
2710 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002711 unsigned int i;
2712
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002713 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002714 if (codec->vendor_id == 0x10ec0888)
2715 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002716
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002717 for (i = 0; i < spec->num_init_verbs; i++)
2718 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002719
2720 if (spec->init_hook)
2721 spec->init_hook(codec);
2722
Linus Torvalds1da177e2005-04-16 15:20:36 -07002723 return 0;
2724}
2725
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002726static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2727{
2728 struct alc_spec *spec = codec->spec;
2729
2730 if (spec->unsol_event)
2731 spec->unsol_event(codec, res);
2732}
2733
Takashi Iwaicb53c622007-08-10 17:21:45 +02002734#ifdef CONFIG_SND_HDA_POWER_SAVE
2735static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2736{
2737 struct alc_spec *spec = codec->spec;
2738 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2739}
2740#endif
2741
Linus Torvalds1da177e2005-04-16 15:20:36 -07002742/*
2743 * Analog playback callbacks
2744 */
2745static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2746 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002747 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002748{
2749 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002750 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2751 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002752}
2753
2754static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2755 struct hda_codec *codec,
2756 unsigned int stream_tag,
2757 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002758 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002759{
2760 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002761 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2762 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002763}
2764
2765static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2766 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002767 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002768{
2769 struct alc_spec *spec = codec->spec;
2770 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2771}
2772
2773/*
2774 * Digital out
2775 */
2776static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2777 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002778 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002779{
2780 struct alc_spec *spec = codec->spec;
2781 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2782}
2783
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002784static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2785 struct hda_codec *codec,
2786 unsigned int stream_tag,
2787 unsigned int format,
2788 struct snd_pcm_substream *substream)
2789{
2790 struct alc_spec *spec = codec->spec;
2791 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2792 stream_tag, format, substream);
2793}
2794
Linus Torvalds1da177e2005-04-16 15:20:36 -07002795static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2796 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002797 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002798{
2799 struct alc_spec *spec = codec->spec;
2800 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2801}
2802
2803/*
2804 * Analog capture
2805 */
Takashi Iwai63300792008-01-24 15:31:36 +01002806static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002807 struct hda_codec *codec,
2808 unsigned int stream_tag,
2809 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002810 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002811{
2812 struct alc_spec *spec = codec->spec;
2813
Takashi Iwai63300792008-01-24 15:31:36 +01002814 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002815 stream_tag, 0, format);
2816 return 0;
2817}
2818
Takashi Iwai63300792008-01-24 15:31:36 +01002819static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002820 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002821 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002822{
2823 struct alc_spec *spec = codec->spec;
2824
Takashi Iwai888afa12008-03-18 09:57:50 +01002825 snd_hda_codec_cleanup_stream(codec,
2826 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002827 return 0;
2828}
2829
2830
2831/*
2832 */
2833static struct hda_pcm_stream alc880_pcm_analog_playback = {
2834 .substreams = 1,
2835 .channels_min = 2,
2836 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002837 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002838 .ops = {
2839 .open = alc880_playback_pcm_open,
2840 .prepare = alc880_playback_pcm_prepare,
2841 .cleanup = alc880_playback_pcm_cleanup
2842 },
2843};
2844
2845static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002846 .substreams = 1,
2847 .channels_min = 2,
2848 .channels_max = 2,
2849 /* NID is set in alc_build_pcms */
2850};
2851
2852static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2853 .substreams = 1,
2854 .channels_min = 2,
2855 .channels_max = 2,
2856 /* NID is set in alc_build_pcms */
2857};
2858
2859static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2860 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002861 .channels_min = 2,
2862 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002863 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002864 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002865 .prepare = alc880_alt_capture_pcm_prepare,
2866 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002867 },
2868};
2869
2870static struct hda_pcm_stream alc880_pcm_digital_playback = {
2871 .substreams = 1,
2872 .channels_min = 2,
2873 .channels_max = 2,
2874 /* NID is set in alc_build_pcms */
2875 .ops = {
2876 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002877 .close = alc880_dig_playback_pcm_close,
2878 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002879 },
2880};
2881
2882static struct hda_pcm_stream alc880_pcm_digital_capture = {
2883 .substreams = 1,
2884 .channels_min = 2,
2885 .channels_max = 2,
2886 /* NID is set in alc_build_pcms */
2887};
2888
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002889/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002890static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002891 .substreams = 0,
2892 .channels_min = 0,
2893 .channels_max = 0,
2894};
2895
Linus Torvalds1da177e2005-04-16 15:20:36 -07002896static int alc_build_pcms(struct hda_codec *codec)
2897{
2898 struct alc_spec *spec = codec->spec;
2899 struct hda_pcm *info = spec->pcm_rec;
2900 int i;
2901
2902 codec->num_pcms = 1;
2903 codec->pcm_info = info;
2904
2905 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002906 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002907 if (snd_BUG_ON(!spec->multiout.dac_nids))
2908 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002909 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2910 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2911 }
2912 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002913 if (snd_BUG_ON(!spec->adc_nids))
2914 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002915 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2916 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2917 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002918
Takashi Iwai4a471b72005-12-07 13:56:29 +01002919 if (spec->channel_mode) {
2920 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2921 for (i = 0; i < spec->num_channel_mode; i++) {
2922 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2923 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2924 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002925 }
2926 }
2927
Takashi Iwaie08a0072006-09-07 17:52:14 +02002928 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002929 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002930 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002931 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002932 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002933 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002934 if (spec->multiout.dig_out_nid &&
2935 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002936 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2937 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2938 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002939 if (spec->dig_in_nid &&
2940 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2942 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2943 }
Takashi Iwai963f8032008-08-11 10:04:40 +02002944 /* FIXME: do we need this for all Realtek codec models? */
2945 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002946 }
2947
Takashi Iwaie08a0072006-09-07 17:52:14 +02002948 /* If the use of more than one ADC is requested for the current
2949 * model, configure a second analog capture-only PCM.
2950 */
2951 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002952 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2953 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002954 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002955 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002956 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002957 if (spec->alt_dac_nid) {
2958 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2959 *spec->stream_analog_alt_playback;
2960 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2961 spec->alt_dac_nid;
2962 } else {
2963 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2964 alc_pcm_null_stream;
2965 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2966 }
2967 if (spec->num_adc_nids > 1) {
2968 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2969 *spec->stream_analog_alt_capture;
2970 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2971 spec->adc_nids[1];
2972 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2973 spec->num_adc_nids - 1;
2974 } else {
2975 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2976 alc_pcm_null_stream;
2977 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002978 }
2979 }
2980
Linus Torvalds1da177e2005-04-16 15:20:36 -07002981 return 0;
2982}
2983
Takashi Iwai603c4012008-07-30 15:01:44 +02002984static void alc_free_kctls(struct hda_codec *codec)
2985{
2986 struct alc_spec *spec = codec->spec;
2987
2988 if (spec->kctls.list) {
2989 struct snd_kcontrol_new *kctl = spec->kctls.list;
2990 int i;
2991 for (i = 0; i < spec->kctls.used; i++)
2992 kfree(kctl[i].name);
2993 }
2994 snd_array_free(&spec->kctls);
2995}
2996
Linus Torvalds1da177e2005-04-16 15:20:36 -07002997static void alc_free(struct hda_codec *codec)
2998{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002999 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003000
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003001 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003002 return;
3003
Takashi Iwai603c4012008-07-30 15:01:44 +02003004 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003005 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02003006 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003007}
3008
Takashi Iwaie044c392008-10-27 16:56:24 +01003009#ifdef SND_HDA_NEEDS_RESUME
3010static void store_pin_configs(struct hda_codec *codec)
3011{
3012 struct alc_spec *spec = codec->spec;
3013 hda_nid_t nid, end_nid;
3014
3015 end_nid = codec->start_nid + codec->num_nodes;
3016 for (nid = codec->start_nid; nid < end_nid; nid++) {
3017 unsigned int wid_caps = get_wcaps(codec, nid);
3018 unsigned int wid_type =
3019 (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
3020 if (wid_type != AC_WID_PIN)
3021 continue;
3022 if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
3023 break;
3024 spec->pin_nids[spec->num_pins] = nid;
3025 spec->pin_cfgs[spec->num_pins] =
3026 snd_hda_codec_read(codec, nid, 0,
3027 AC_VERB_GET_CONFIG_DEFAULT, 0);
3028 spec->num_pins++;
3029 }
3030}
3031
3032static void resume_pin_configs(struct hda_codec *codec)
3033{
3034 struct alc_spec *spec = codec->spec;
3035 int i;
3036
3037 for (i = 0; i < spec->num_pins; i++) {
3038 hda_nid_t pin_nid = spec->pin_nids[i];
3039 unsigned int pin_config = spec->pin_cfgs[i];
3040 snd_hda_codec_write(codec, pin_nid, 0,
3041 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
3042 pin_config & 0x000000ff);
3043 snd_hda_codec_write(codec, pin_nid, 0,
3044 AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
3045 (pin_config & 0x0000ff00) >> 8);
3046 snd_hda_codec_write(codec, pin_nid, 0,
3047 AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
3048 (pin_config & 0x00ff0000) >> 16);
3049 snd_hda_codec_write(codec, pin_nid, 0,
3050 AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
3051 pin_config >> 24);
3052 }
3053}
3054
3055static int alc_resume(struct hda_codec *codec)
3056{
3057 resume_pin_configs(codec);
3058 codec->patch_ops.init(codec);
3059 snd_hda_codec_resume_amp(codec);
3060 snd_hda_codec_resume_cache(codec);
3061 return 0;
3062}
3063#else
3064#define store_pin_configs(codec)
3065#endif
3066
Linus Torvalds1da177e2005-04-16 15:20:36 -07003067/*
3068 */
3069static struct hda_codec_ops alc_patch_ops = {
3070 .build_controls = alc_build_controls,
3071 .build_pcms = alc_build_pcms,
3072 .init = alc_init,
3073 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003074 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01003075#ifdef SND_HDA_NEEDS_RESUME
3076 .resume = alc_resume,
3077#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02003078#ifdef CONFIG_SND_HDA_POWER_SAVE
3079 .check_power_status = alc_check_power_status,
3080#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003081};
3082
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003083
3084/*
3085 * Test configuration for debugging
3086 *
3087 * Almost all inputs/outputs are enabled. I/O pins can be configured via
3088 * enum controls.
3089 */
3090#ifdef CONFIG_SND_DEBUG
3091static hda_nid_t alc880_test_dac_nids[4] = {
3092 0x02, 0x03, 0x04, 0x05
3093};
3094
3095static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003096 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003097 .items = {
3098 { "In-1", 0x0 },
3099 { "In-2", 0x1 },
3100 { "In-3", 0x2 },
3101 { "In-4", 0x3 },
3102 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003103 { "Front", 0x5 },
3104 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003105 },
3106};
3107
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003108static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003109 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003110 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003111 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02003112 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003113};
3114
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003115static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
3116 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003117{
3118 static char *texts[] = {
3119 "N/A", "Line Out", "HP Out",
3120 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
3121 };
3122 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3123 uinfo->count = 1;
3124 uinfo->value.enumerated.items = 8;
3125 if (uinfo->value.enumerated.item >= 8)
3126 uinfo->value.enumerated.item = 7;
3127 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3128 return 0;
3129}
3130
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003131static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
3132 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003133{
3134 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3135 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3136 unsigned int pin_ctl, item = 0;
3137
3138 pin_ctl = snd_hda_codec_read(codec, nid, 0,
3139 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3140 if (pin_ctl & AC_PINCTL_OUT_EN) {
3141 if (pin_ctl & AC_PINCTL_HP_EN)
3142 item = 2;
3143 else
3144 item = 1;
3145 } else if (pin_ctl & AC_PINCTL_IN_EN) {
3146 switch (pin_ctl & AC_PINCTL_VREFEN) {
3147 case AC_PINCTL_VREF_HIZ: item = 3; break;
3148 case AC_PINCTL_VREF_50: item = 4; break;
3149 case AC_PINCTL_VREF_GRD: item = 5; break;
3150 case AC_PINCTL_VREF_80: item = 6; break;
3151 case AC_PINCTL_VREF_100: item = 7; break;
3152 }
3153 }
3154 ucontrol->value.enumerated.item[0] = item;
3155 return 0;
3156}
3157
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003158static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
3159 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003160{
3161 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3162 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3163 static unsigned int ctls[] = {
3164 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
3165 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
3166 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
3167 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
3168 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
3169 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
3170 };
3171 unsigned int old_ctl, new_ctl;
3172
3173 old_ctl = snd_hda_codec_read(codec, nid, 0,
3174 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
3175 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
3176 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003177 int val;
3178 snd_hda_codec_write_cache(codec, nid, 0,
3179 AC_VERB_SET_PIN_WIDGET_CONTROL,
3180 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003181 val = ucontrol->value.enumerated.item[0] >= 3 ?
3182 HDA_AMP_MUTE : 0;
3183 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
3184 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003185 return 1;
3186 }
3187 return 0;
3188}
3189
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003190static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
3191 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003192{
3193 static char *texts[] = {
3194 "Front", "Surround", "CLFE", "Side"
3195 };
3196 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
3197 uinfo->count = 1;
3198 uinfo->value.enumerated.items = 4;
3199 if (uinfo->value.enumerated.item >= 4)
3200 uinfo->value.enumerated.item = 3;
3201 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
3202 return 0;
3203}
3204
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003205static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
3206 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003207{
3208 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3209 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3210 unsigned int sel;
3211
3212 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
3213 ucontrol->value.enumerated.item[0] = sel & 3;
3214 return 0;
3215}
3216
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003217static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
3218 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003219{
3220 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
3221 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
3222 unsigned int sel;
3223
3224 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
3225 if (ucontrol->value.enumerated.item[0] != sel) {
3226 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02003227 snd_hda_codec_write_cache(codec, nid, 0,
3228 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003229 return 1;
3230 }
3231 return 0;
3232}
3233
3234#define PIN_CTL_TEST(xname,nid) { \
3235 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3236 .name = xname, \
3237 .info = alc_test_pin_ctl_info, \
3238 .get = alc_test_pin_ctl_get, \
3239 .put = alc_test_pin_ctl_put, \
3240 .private_value = nid \
3241 }
3242
3243#define PIN_SRC_TEST(xname,nid) { \
3244 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3245 .name = xname, \
3246 .info = alc_test_pin_src_info, \
3247 .get = alc_test_pin_src_get, \
3248 .put = alc_test_pin_src_put, \
3249 .private_value = nid \
3250 }
3251
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003252static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003253 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3254 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
3255 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
3256 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01003257 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3258 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
3259 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
3260 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003261 PIN_CTL_TEST("Front Pin Mode", 0x14),
3262 PIN_CTL_TEST("Surround Pin Mode", 0x15),
3263 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
3264 PIN_CTL_TEST("Side Pin Mode", 0x17),
3265 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
3266 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
3267 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
3268 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
3269 PIN_SRC_TEST("In-1 Pin Source", 0x18),
3270 PIN_SRC_TEST("In-2 Pin Source", 0x19),
3271 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
3272 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
3273 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
3274 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
3275 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
3276 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
3277 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
3278 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
3279 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
3280 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
3281 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
3282 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003283 {
3284 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3285 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01003286 .info = alc_ch_mode_info,
3287 .get = alc_ch_mode_get,
3288 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003289 },
3290 { } /* end */
3291};
3292
3293static struct hda_verb alc880_test_init_verbs[] = {
3294 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3296 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3298 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3300 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3301 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3302 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003303 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02003304 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3305 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3306 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3307 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003308 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003309 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3310 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3311 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3312 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003313 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003314 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3315 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3316 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3317 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003318 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02003319 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3320 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02003321 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3322 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3323 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003324 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02003325 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3326 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3327 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3328 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003329 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02003330 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003331 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003332 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003333 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003334 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003335 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003336 /* Analog input/passthru */
3337 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3338 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3339 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3340 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3341 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003342 { }
3343};
3344#endif
3345
Linus Torvalds1da177e2005-04-16 15:20:36 -07003346/*
3347 */
3348
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003349static const char *alc880_models[ALC880_MODEL_LAST] = {
3350 [ALC880_3ST] = "3stack",
3351 [ALC880_TCL_S700] = "tcl",
3352 [ALC880_3ST_DIG] = "3stack-digout",
3353 [ALC880_CLEVO] = "clevo",
3354 [ALC880_5ST] = "5stack",
3355 [ALC880_5ST_DIG] = "5stack-digout",
3356 [ALC880_W810] = "w810",
3357 [ALC880_Z71V] = "z71v",
3358 [ALC880_6ST] = "6stack",
3359 [ALC880_6ST_DIG] = "6stack-digout",
3360 [ALC880_ASUS] = "asus",
3361 [ALC880_ASUS_W1V] = "asus-w1v",
3362 [ALC880_ASUS_DIG] = "asus-dig",
3363 [ALC880_ASUS_DIG2] = "asus-dig2",
3364 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003365 [ALC880_UNIWILL_P53] = "uniwill-p53",
3366 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003367 [ALC880_F1734] = "F1734",
3368 [ALC880_LG] = "lg",
3369 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003370 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003371#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003372 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003373#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003374 [ALC880_AUTO] = "auto",
3375};
3376
3377static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003378 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003379 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3380 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3381 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3382 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3383 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3384 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3385 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3386 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003387 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3388 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003389 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3390 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3391 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3392 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3393 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3394 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3395 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3396 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3397 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3398 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003399 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003400 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3401 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3402 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003403 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003404 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003405 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3406 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003407 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3408 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003409 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3410 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3411 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3412 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003413 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3414 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003415 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003416 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003417 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003418 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003419 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3420 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003421 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003422 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003423 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003424 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003425 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003426 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003427 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003428 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003429 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003430 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3431 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003432 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003433 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3434 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3435 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3436 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003437 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3438 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003439 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003440 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003441 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3442 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003443 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3444 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3445 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003446 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3447 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3448 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003449 {}
3450};
3451
Takashi Iwai16ded522005-06-10 19:58:24 +02003452/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003453 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003454 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003455static struct alc_config_preset alc880_presets[] = {
3456 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003457 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003458 .init_verbs = { alc880_volume_init_verbs,
3459 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003460 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003461 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003462 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3463 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003464 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003465 .input_mux = &alc880_capture_source,
3466 },
3467 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003468 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003469 .init_verbs = { alc880_volume_init_verbs,
3470 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003471 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003472 .dac_nids = alc880_dac_nids,
3473 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003474 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3475 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003476 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003477 .input_mux = &alc880_capture_source,
3478 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003479 [ALC880_TCL_S700] = {
3480 .mixers = { alc880_tcl_s700_mixer },
3481 .init_verbs = { alc880_volume_init_verbs,
3482 alc880_pin_tcl_S700_init_verbs,
3483 alc880_gpio2_init_verbs },
3484 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3485 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01003486 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
3487 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01003488 .hp_nid = 0x03,
3489 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3490 .channel_mode = alc880_2_jack_modes,
3491 .input_mux = &alc880_capture_source,
3492 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003493 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003494 .mixers = { alc880_three_stack_mixer,
3495 alc880_five_stack_mixer},
3496 .init_verbs = { alc880_volume_init_verbs,
3497 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003498 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3499 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003500 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3501 .channel_mode = alc880_fivestack_modes,
3502 .input_mux = &alc880_capture_source,
3503 },
3504 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003505 .mixers = { alc880_three_stack_mixer,
3506 alc880_five_stack_mixer },
3507 .init_verbs = { alc880_volume_init_verbs,
3508 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003509 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3510 .dac_nids = alc880_dac_nids,
3511 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003512 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3513 .channel_mode = alc880_fivestack_modes,
3514 .input_mux = &alc880_capture_source,
3515 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003516 [ALC880_6ST] = {
3517 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003518 .init_verbs = { alc880_volume_init_verbs,
3519 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003520 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3521 .dac_nids = alc880_6st_dac_nids,
3522 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3523 .channel_mode = alc880_sixstack_modes,
3524 .input_mux = &alc880_6stack_capture_source,
3525 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003526 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003527 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003528 .init_verbs = { alc880_volume_init_verbs,
3529 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003530 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3531 .dac_nids = alc880_6st_dac_nids,
3532 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003533 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3534 .channel_mode = alc880_sixstack_modes,
3535 .input_mux = &alc880_6stack_capture_source,
3536 },
3537 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003538 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003539 .init_verbs = { alc880_volume_init_verbs,
3540 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003541 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003542 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3543 .dac_nids = alc880_w810_dac_nids,
3544 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003545 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3546 .channel_mode = alc880_w810_modes,
3547 .input_mux = &alc880_capture_source,
3548 },
3549 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003550 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003551 .init_verbs = { alc880_volume_init_verbs,
3552 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003553 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3554 .dac_nids = alc880_z71v_dac_nids,
3555 .dig_out_nid = ALC880_DIGOUT_NID,
3556 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003557 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3558 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003559 .input_mux = &alc880_capture_source,
3560 },
3561 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003562 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003563 .init_verbs = { alc880_volume_init_verbs,
3564 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003565 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3566 .dac_nids = alc880_f1734_dac_nids,
3567 .hp_nid = 0x02,
3568 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3569 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003570 .input_mux = &alc880_f1734_capture_source,
3571 .unsol_event = alc880_uniwill_p53_unsol_event,
3572 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003573 },
3574 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003575 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003576 .init_verbs = { alc880_volume_init_verbs,
3577 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003578 alc880_gpio1_init_verbs },
3579 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3580 .dac_nids = alc880_asus_dac_nids,
3581 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3582 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003583 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003584 .input_mux = &alc880_capture_source,
3585 },
3586 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003587 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003588 .init_verbs = { alc880_volume_init_verbs,
3589 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003590 alc880_gpio1_init_verbs },
3591 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3592 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003593 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003594 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3595 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003596 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003597 .input_mux = &alc880_capture_source,
3598 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003599 [ALC880_ASUS_DIG2] = {
3600 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003601 .init_verbs = { alc880_volume_init_verbs,
3602 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003603 alc880_gpio2_init_verbs }, /* use GPIO2 */
3604 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3605 .dac_nids = alc880_asus_dac_nids,
3606 .dig_out_nid = ALC880_DIGOUT_NID,
3607 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3608 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003609 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003610 .input_mux = &alc880_capture_source,
3611 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003612 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003613 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003614 .init_verbs = { alc880_volume_init_verbs,
3615 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003616 alc880_gpio1_init_verbs },
3617 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3618 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003619 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003620 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3621 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003622 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003623 .input_mux = &alc880_capture_source,
3624 },
3625 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003626 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003627 .init_verbs = { alc880_volume_init_verbs,
3628 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003629 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3630 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003631 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003632 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3633 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003634 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003635 .input_mux = &alc880_capture_source,
3636 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003637 [ALC880_UNIWILL] = {
3638 .mixers = { alc880_uniwill_mixer },
3639 .init_verbs = { alc880_volume_init_verbs,
3640 alc880_uniwill_init_verbs },
3641 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3642 .dac_nids = alc880_asus_dac_nids,
3643 .dig_out_nid = ALC880_DIGOUT_NID,
3644 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3645 .channel_mode = alc880_threestack_modes,
3646 .need_dac_fix = 1,
3647 .input_mux = &alc880_capture_source,
3648 .unsol_event = alc880_uniwill_unsol_event,
3649 .init_hook = alc880_uniwill_automute,
3650 },
3651 [ALC880_UNIWILL_P53] = {
3652 .mixers = { alc880_uniwill_p53_mixer },
3653 .init_verbs = { alc880_volume_init_verbs,
3654 alc880_uniwill_p53_init_verbs },
3655 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3656 .dac_nids = alc880_asus_dac_nids,
3657 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003658 .channel_mode = alc880_threestack_modes,
3659 .input_mux = &alc880_capture_source,
3660 .unsol_event = alc880_uniwill_p53_unsol_event,
3661 .init_hook = alc880_uniwill_p53_hp_automute,
3662 },
3663 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003664 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003665 alc880_pcbeep_mixer, },
3666 .init_verbs = { alc880_volume_init_verbs,
3667 alc880_uniwill_p53_init_verbs,
3668 alc880_beep_init_verbs },
3669 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3670 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003671 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003672 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3673 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003674 .input_mux = &alc880_capture_source,
3675 .unsol_event = alc880_uniwill_p53_unsol_event,
3676 .init_hook = alc880_uniwill_p53_hp_automute,
3677 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003678 [ALC880_CLEVO] = {
3679 .mixers = { alc880_three_stack_mixer },
3680 .init_verbs = { alc880_volume_init_verbs,
3681 alc880_pin_clevo_init_verbs },
3682 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3683 .dac_nids = alc880_dac_nids,
3684 .hp_nid = 0x03,
3685 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3686 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003687 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003688 .input_mux = &alc880_capture_source,
3689 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003690 [ALC880_LG] = {
3691 .mixers = { alc880_lg_mixer },
3692 .init_verbs = { alc880_volume_init_verbs,
3693 alc880_lg_init_verbs },
3694 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3695 .dac_nids = alc880_lg_dac_nids,
3696 .dig_out_nid = ALC880_DIGOUT_NID,
3697 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3698 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003699 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003700 .input_mux = &alc880_lg_capture_source,
3701 .unsol_event = alc880_lg_unsol_event,
3702 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003703#ifdef CONFIG_SND_HDA_POWER_SAVE
3704 .loopbacks = alc880_lg_loopbacks,
3705#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003706 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003707 [ALC880_LG_LW] = {
3708 .mixers = { alc880_lg_lw_mixer },
3709 .init_verbs = { alc880_volume_init_verbs,
3710 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003711 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003712 .dac_nids = alc880_dac_nids,
3713 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003714 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3715 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003716 .input_mux = &alc880_lg_lw_capture_source,
3717 .unsol_event = alc880_lg_lw_unsol_event,
3718 .init_hook = alc880_lg_lw_automute,
3719 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003720 [ALC880_MEDION_RIM] = {
3721 .mixers = { alc880_medion_rim_mixer },
3722 .init_verbs = { alc880_volume_init_verbs,
3723 alc880_medion_rim_init_verbs,
3724 alc_gpio2_init_verbs },
3725 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3726 .dac_nids = alc880_dac_nids,
3727 .dig_out_nid = ALC880_DIGOUT_NID,
3728 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3729 .channel_mode = alc880_2_jack_modes,
3730 .input_mux = &alc880_medion_rim_capture_source,
3731 .unsol_event = alc880_medion_rim_unsol_event,
3732 .init_hook = alc880_medion_rim_automute,
3733 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003734#ifdef CONFIG_SND_DEBUG
3735 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003736 .mixers = { alc880_test_mixer },
3737 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003738 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3739 .dac_nids = alc880_test_dac_nids,
3740 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003741 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3742 .channel_mode = alc880_test_modes,
3743 .input_mux = &alc880_test_capture_source,
3744 },
3745#endif
3746};
3747
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003748/*
3749 * Automatic parse of I/O pins from the BIOS configuration
3750 */
3751
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003752enum {
3753 ALC_CTL_WIDGET_VOL,
3754 ALC_CTL_WIDGET_MUTE,
3755 ALC_CTL_BIND_MUTE,
3756};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003757static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003758 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3759 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003760 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003761};
3762
3763/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003764static int add_control(struct alc_spec *spec, int type, const char *name,
3765 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003766{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003767 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003768
Takashi Iwai603c4012008-07-30 15:01:44 +02003769 snd_array_init(&spec->kctls, sizeof(*knew), 32);
3770 knew = snd_array_new(&spec->kctls);
3771 if (!knew)
3772 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003773 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003774 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003775 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003776 return -ENOMEM;
3777 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003778 return 0;
3779}
3780
3781#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3782#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3783#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3784#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3785#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3786#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3787#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3788#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3789#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3790#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3791#define ALC880_PIN_CD_NID 0x1c
3792
3793/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003794static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3795 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003796{
3797 hda_nid_t nid;
3798 int assigned[4];
3799 int i, j;
3800
3801 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003802 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003803
3804 /* check the pins hardwired to audio widget */
3805 for (i = 0; i < cfg->line_outs; i++) {
3806 nid = cfg->line_out_pins[i];
3807 if (alc880_is_fixed_pin(nid)) {
3808 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003809 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003810 assigned[idx] = 1;
3811 }
3812 }
3813 /* left pins can be connect to any audio widget */
3814 for (i = 0; i < cfg->line_outs; i++) {
3815 nid = cfg->line_out_pins[i];
3816 if (alc880_is_fixed_pin(nid))
3817 continue;
3818 /* search for an empty channel */
3819 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003820 if (!assigned[j]) {
3821 spec->multiout.dac_nids[i] =
3822 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003823 assigned[j] = 1;
3824 break;
3825 }
3826 }
3827 }
3828 spec->multiout.num_dacs = cfg->line_outs;
3829 return 0;
3830}
3831
3832/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003833static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3834 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003835{
3836 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003837 static const char *chname[4] = {
3838 "Front", "Surround", NULL /*CLFE*/, "Side"
3839 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003840 hda_nid_t nid;
3841 int i, err;
3842
3843 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003844 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003845 continue;
3846 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3847 if (i == 2) {
3848 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003849 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3850 "Center Playback Volume",
3851 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3852 HDA_OUTPUT));
3853 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003854 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003855 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3856 "LFE Playback Volume",
3857 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3858 HDA_OUTPUT));
3859 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003860 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003861 err = add_control(spec, ALC_CTL_BIND_MUTE,
3862 "Center Playback Switch",
3863 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3864 HDA_INPUT));
3865 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003866 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003867 err = add_control(spec, ALC_CTL_BIND_MUTE,
3868 "LFE Playback Switch",
3869 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3870 HDA_INPUT));
3871 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003872 return err;
3873 } else {
3874 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003875 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3876 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3877 HDA_OUTPUT));
3878 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003879 return err;
3880 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003881 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3882 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3883 HDA_INPUT));
3884 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003885 return err;
3886 }
3887 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003888 return 0;
3889}
3890
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003891/* add playback controls for speaker and HP outputs */
3892static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3893 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003894{
3895 hda_nid_t nid;
3896 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003897 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003898
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003899 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003900 return 0;
3901
3902 if (alc880_is_fixed_pin(pin)) {
3903 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003904 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003905 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003906 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003907 else
3908 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003909 /* control HP volume/switch on the output mixer amp */
3910 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003911 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003912 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3913 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3914 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003915 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003916 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003917 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3918 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3919 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003920 return err;
3921 } else if (alc880_is_multi_pin(pin)) {
3922 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003923 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003924 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003925 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3926 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3927 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003928 return err;
3929 }
3930 return 0;
3931}
3932
3933/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003934static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3935 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003936 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003937{
3938 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003939 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003940
3941 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003942 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3943 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3944 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003945 return err;
3946 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003947 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3948 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3949 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003950 return err;
3951 return 0;
3952}
3953
3954/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003955static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3956 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003957{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003958 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003959 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003960
3961 for (i = 0; i < AUTO_PIN_LAST; i++) {
3962 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003963 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003964 err = new_analog_input(spec, cfg->input_pins[i],
3965 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003966 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003967 if (err < 0)
3968 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003969 imux->items[imux->num_items].label =
3970 auto_pin_cfg_labels[i];
3971 imux->items[imux->num_items].index =
3972 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003973 imux->num_items++;
3974 }
3975 }
3976 return 0;
3977}
3978
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003979static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3980 unsigned int pin_type)
3981{
3982 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3983 pin_type);
3984 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003985 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3986 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003987}
3988
Kailang Yangdf694da2005-12-05 19:42:22 +01003989static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3990 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003991 int dac_idx)
3992{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003993 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003994 /* need the manual connection? */
3995 if (alc880_is_multi_pin(nid)) {
3996 struct alc_spec *spec = codec->spec;
3997 int idx = alc880_multi_pin_idx(nid);
3998 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3999 AC_VERB_SET_CONNECT_SEL,
4000 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
4001 }
4002}
4003
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004004static int get_pin_type(int line_out_type)
4005{
4006 if (line_out_type == AUTO_PIN_HP_OUT)
4007 return PIN_HP;
4008 else
4009 return PIN_OUT;
4010}
4011
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004012static void alc880_auto_init_multi_out(struct hda_codec *codec)
4013{
4014 struct alc_spec *spec = codec->spec;
4015 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02004016
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004017 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004018 for (i = 0; i < spec->autocfg.line_outs; i++) {
4019 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02004020 int pin_type = get_pin_type(spec->autocfg.line_out_type);
4021 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004022 }
4023}
4024
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004025static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004026{
4027 struct alc_spec *spec = codec->spec;
4028 hda_nid_t pin;
4029
Takashi Iwai82bc9552006-03-21 11:24:42 +01004030 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004031 if (pin) /* connect to front */
4032 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02004033 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004034 if (pin) /* connect to front */
4035 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
4036}
4037
4038static void alc880_auto_init_analog_input(struct hda_codec *codec)
4039{
4040 struct alc_spec *spec = codec->spec;
4041 int i;
4042
4043 for (i = 0; i < AUTO_PIN_LAST; i++) {
4044 hda_nid_t nid = spec->autocfg.input_pins[i];
4045 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004046 snd_hda_codec_write(codec, nid, 0,
4047 AC_VERB_SET_PIN_WIDGET_CONTROL,
4048 i <= AUTO_PIN_FRONT_MIC ?
4049 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004050 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004051 snd_hda_codec_write(codec, nid, 0,
4052 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004053 AMP_OUT_MUTE);
4054 }
4055 }
4056}
4057
4058/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004059/* return 1 if successful, 0 if the proper config is not found,
4060 * or a negative error code
4061 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004062static int alc880_parse_auto_config(struct hda_codec *codec)
4063{
4064 struct alc_spec *spec = codec->spec;
4065 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01004066 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004067
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004068 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
4069 alc880_ignore);
4070 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004071 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004072 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004073 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01004074
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004075 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
4076 if (err < 0)
4077 return err;
4078 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
4079 if (err < 0)
4080 return err;
4081 err = alc880_auto_create_extra_out(spec,
4082 spec->autocfg.speaker_pins[0],
4083 "Speaker");
4084 if (err < 0)
4085 return err;
4086 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
4087 "Headphone");
4088 if (err < 0)
4089 return err;
4090 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
4091 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004092 return err;
4093
4094 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
4095
4096 if (spec->autocfg.dig_out_pin)
4097 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
4098 if (spec->autocfg.dig_in_pin)
4099 spec->dig_in_nid = ALC880_DIGIN_NID;
4100
Takashi Iwai603c4012008-07-30 15:01:44 +02004101 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01004102 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004103
Takashi Iwaid88897e2008-10-31 15:01:37 +01004104 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004105
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004106 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004107 spec->input_mux = &spec->private_imux;
4108
Takashi Iwaie044c392008-10-27 16:56:24 +01004109 store_pin_configs(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004110 return 1;
4111}
4112
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004113/* additional initialization for auto-configuration model */
4114static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004115{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004116 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004117 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004118 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004119 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01004120 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02004121 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004122}
4123
4124/*
4125 * OK, here we have finally the patch for ALC880
4126 */
4127
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004128static void set_capture_mixer(struct alc_spec *spec)
4129{
4130 static struct snd_kcontrol_new *caps[3] = {
4131 alc_capture_mixer1,
4132 alc_capture_mixer2,
4133 alc_capture_mixer3,
4134 };
4135 if (spec->num_adc_nids > 0 && spec->num_adc_nids < 3)
4136 spec->cap_mixer = caps[spec->num_adc_nids - 1];
4137}
4138
Linus Torvalds1da177e2005-04-16 15:20:36 -07004139static int patch_alc880(struct hda_codec *codec)
4140{
4141 struct alc_spec *spec;
4142 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01004143 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004144
Takashi Iwaie560d8d2005-09-09 14:21:46 +02004145 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004146 if (spec == NULL)
4147 return -ENOMEM;
4148
4149 codec->spec = spec;
4150
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004151 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
4152 alc880_models,
4153 alc880_cfg_tbl);
4154 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004155 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
4156 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004157 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004158 }
4159
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004160 if (board_config == ALC880_AUTO) {
4161 /* automatic parse from the BIOS config */
4162 err = alc880_parse_auto_config(codec);
4163 if (err < 0) {
4164 alc_free(codec);
4165 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004166 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004167 printk(KERN_INFO
4168 "hda_codec: Cannot set up configuration "
4169 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004170 board_config = ALC880_3ST;
4171 }
4172 }
4173
Kailang Yangdf694da2005-12-05 19:42:22 +01004174 if (board_config != ALC880_AUTO)
4175 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004176
4177 spec->stream_name_analog = "ALC880 Analog";
4178 spec->stream_analog_playback = &alc880_pcm_analog_playback;
4179 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01004180 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004181
4182 spec->stream_name_digital = "ALC880 Digital";
4183 spec->stream_digital_playback = &alc880_pcm_digital_playback;
4184 spec->stream_digital_capture = &alc880_pcm_digital_capture;
4185
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004186 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004187 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01004188 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004189 /* get type */
4190 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004191 if (wcap != AC_WID_AUD_IN) {
4192 spec->adc_nids = alc880_adc_nids_alt;
4193 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004194 } else {
4195 spec->adc_nids = alc880_adc_nids;
4196 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004197 }
4198 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004199 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004200
Takashi Iwai2134ea42008-01-10 16:53:55 +01004201 spec->vmaster_nid = 0x0c;
4202
Linus Torvalds1da177e2005-04-16 15:20:36 -07004203 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004204 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004205 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02004206#ifdef CONFIG_SND_HDA_POWER_SAVE
4207 if (!spec->loopback.amplist)
4208 spec->loopback.amplist = alc880_loopbacks;
4209#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07004210
4211 return 0;
4212}
4213
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004214
Linus Torvalds1da177e2005-04-16 15:20:36 -07004215/*
4216 * ALC260 support
4217 */
4218
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004219static hda_nid_t alc260_dac_nids[1] = {
4220 /* front */
4221 0x02,
4222};
4223
4224static hda_nid_t alc260_adc_nids[1] = {
4225 /* ADC0 */
4226 0x04,
4227};
4228
Kailang Yangdf694da2005-12-05 19:42:22 +01004229static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004230 /* ADC1 */
4231 0x05,
4232};
4233
Jonathan Woithed57fdac2006-02-28 11:38:35 +01004234/* NIDs used when simultaneous access to both ADCs makes sense. Note that
4235 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
4236 */
4237static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004238 /* ADC0, ADC1 */
4239 0x04, 0x05
4240};
4241
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004242#define ALC260_DIGOUT_NID 0x03
4243#define ALC260_DIGIN_NID 0x06
4244
4245static struct hda_input_mux alc260_capture_source = {
4246 .num_items = 4,
4247 .items = {
4248 { "Mic", 0x0 },
4249 { "Front Mic", 0x1 },
4250 { "Line", 0x2 },
4251 { "CD", 0x4 },
4252 },
4253};
4254
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004255/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004256 * headphone jack and the internal CD lines since these are the only pins at
4257 * which audio can appear. For flexibility, also allow the option of
4258 * recording the mixer output on the second ADC (ADC0 doesn't have a
4259 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004260 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004261static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
4262 {
4263 .num_items = 3,
4264 .items = {
4265 { "Mic/Line", 0x0 },
4266 { "CD", 0x4 },
4267 { "Headphone", 0x2 },
4268 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004269 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004270 {
4271 .num_items = 4,
4272 .items = {
4273 { "Mic/Line", 0x0 },
4274 { "CD", 0x4 },
4275 { "Headphone", 0x2 },
4276 { "Mixer", 0x5 },
4277 },
4278 },
4279
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004280};
4281
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004282/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
4283 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004284 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004285static struct hda_input_mux alc260_acer_capture_sources[2] = {
4286 {
4287 .num_items = 4,
4288 .items = {
4289 { "Mic", 0x0 },
4290 { "Line", 0x2 },
4291 { "CD", 0x4 },
4292 { "Headphone", 0x5 },
4293 },
4294 },
4295 {
4296 .num_items = 5,
4297 .items = {
4298 { "Mic", 0x0 },
4299 { "Line", 0x2 },
4300 { "CD", 0x4 },
4301 { "Headphone", 0x6 },
4302 { "Mixer", 0x5 },
4303 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004304 },
4305};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004306/*
4307 * This is just place-holder, so there's something for alc_build_pcms to look
4308 * at when it calculates the maximum number of channels. ALC260 has no mixer
4309 * element which allows changing the channel mode, so the verb list is
4310 * never used.
4311 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004312static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004313 { 2, NULL },
4314};
4315
Kailang Yangdf694da2005-12-05 19:42:22 +01004316
4317/* Mixer combinations
4318 *
4319 * basic: base_output + input + pc_beep + capture
4320 * HP: base_output + input + capture_alt
4321 * HP_3013: hp_3013 + input + capture
4322 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004323 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004324 */
4325
4326static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004327 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004328 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004329 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4330 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4331 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4332 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4333 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004334};
Kailang Yangdf694da2005-12-05 19:42:22 +01004335
4336static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004337 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4338 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4339 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4340 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4341 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4342 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4343 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4344 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004345 { } /* end */
4346};
4347
Kailang Yangdf694da2005-12-05 19:42:22 +01004348static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4349 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4350 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4351 { } /* end */
4352};
4353
Takashi Iwaibec15c32008-01-28 18:16:30 +01004354/* update HP, line and mono out pins according to the master switch */
4355static void alc260_hp_master_update(struct hda_codec *codec,
4356 hda_nid_t hp, hda_nid_t line,
4357 hda_nid_t mono)
4358{
4359 struct alc_spec *spec = codec->spec;
4360 unsigned int val = spec->master_sw ? PIN_HP : 0;
4361 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004362 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004363 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004364 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004365 val);
4366 /* mono (speaker) depending on the HP jack sense */
4367 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004368 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01004369 val);
4370}
4371
4372static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4373 struct snd_ctl_elem_value *ucontrol)
4374{
4375 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4376 struct alc_spec *spec = codec->spec;
4377 *ucontrol->value.integer.value = spec->master_sw;
4378 return 0;
4379}
4380
4381static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4382 struct snd_ctl_elem_value *ucontrol)
4383{
4384 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4385 struct alc_spec *spec = codec->spec;
4386 int val = !!*ucontrol->value.integer.value;
4387 hda_nid_t hp, line, mono;
4388
4389 if (val == spec->master_sw)
4390 return 0;
4391 spec->master_sw = val;
4392 hp = (kcontrol->private_value >> 16) & 0xff;
4393 line = (kcontrol->private_value >> 8) & 0xff;
4394 mono = kcontrol->private_value & 0xff;
4395 alc260_hp_master_update(codec, hp, line, mono);
4396 return 1;
4397}
4398
4399static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4400 {
4401 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4402 .name = "Master Playback Switch",
4403 .info = snd_ctl_boolean_mono_info,
4404 .get = alc260_hp_master_sw_get,
4405 .put = alc260_hp_master_sw_put,
4406 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4407 },
4408 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4409 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4410 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4411 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4412 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4413 HDA_OUTPUT),
4414 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4415 { } /* end */
4416};
4417
4418static struct hda_verb alc260_hp_unsol_verbs[] = {
4419 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4420 {},
4421};
4422
4423static void alc260_hp_automute(struct hda_codec *codec)
4424{
4425 struct alc_spec *spec = codec->spec;
4426 unsigned int present;
4427
4428 present = snd_hda_codec_read(codec, 0x10, 0,
4429 AC_VERB_GET_PIN_SENSE, 0);
4430 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4431 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4432}
4433
4434static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4435{
4436 if ((res >> 26) == ALC880_HP_EVENT)
4437 alc260_hp_automute(codec);
4438}
4439
Kailang Yangdf694da2005-12-05 19:42:22 +01004440static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004441 {
4442 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4443 .name = "Master Playback Switch",
4444 .info = snd_ctl_boolean_mono_info,
4445 .get = alc260_hp_master_sw_get,
4446 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004447 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01004448 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004449 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4450 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4451 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4452 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4453 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4454 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004455 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4456 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004457 { } /* end */
4458};
4459
Kailang Yang3f878302008-08-26 13:02:23 +02004460static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4461 .ops = &snd_hda_bind_vol,
4462 .values = {
4463 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4464 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4465 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4466 0
4467 },
4468};
4469
4470static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4471 .ops = &snd_hda_bind_sw,
4472 .values = {
4473 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4474 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4475 0
4476 },
4477};
4478
4479static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4480 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4481 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4482 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4483 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4484 { } /* end */
4485};
4486
Takashi Iwaibec15c32008-01-28 18:16:30 +01004487static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4488 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4489 {},
4490};
4491
4492static void alc260_hp_3013_automute(struct hda_codec *codec)
4493{
4494 struct alc_spec *spec = codec->spec;
4495 unsigned int present;
4496
4497 present = snd_hda_codec_read(codec, 0x15, 0,
4498 AC_VERB_GET_PIN_SENSE, 0);
4499 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01004500 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01004501}
4502
4503static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4504 unsigned int res)
4505{
4506 if ((res >> 26) == ALC880_HP_EVENT)
4507 alc260_hp_3013_automute(codec);
4508}
4509
Kailang Yang3f878302008-08-26 13:02:23 +02004510static void alc260_hp_3012_automute(struct hda_codec *codec)
4511{
4512 unsigned int present, bits;
4513
4514 present = snd_hda_codec_read(codec, 0x10, 0,
4515 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4516
4517 bits = present ? 0 : PIN_OUT;
4518 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4519 bits);
4520 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4521 bits);
4522 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4523 bits);
4524}
4525
4526static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4527 unsigned int res)
4528{
4529 if ((res >> 26) == ALC880_HP_EVENT)
4530 alc260_hp_3012_automute(codec);
4531}
4532
4533/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004534 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4535 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004536static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004537 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004538 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004539 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004540 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4541 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4542 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4543 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004544 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004545 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4546 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004547 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4548 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004549 { } /* end */
4550};
4551
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004552/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4553 * versions of the ALC260 don't act on requests to enable mic bias from NID
4554 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4555 * datasheet doesn't mention this restriction. At this stage it's not clear
4556 * whether this behaviour is intentional or is a hardware bug in chip
4557 * revisions available in early 2006. Therefore for now allow the
4558 * "Headphone Jack Mode" control to span all choices, but if it turns out
4559 * that the lack of mic bias for this NID is intentional we could change the
4560 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4561 *
4562 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4563 * don't appear to make the mic bias available from the "line" jack, even
4564 * though the NID used for this jack (0x14) can supply it. The theory is
4565 * that perhaps Acer have included blocking capacitors between the ALC260
4566 * and the output jack. If this turns out to be the case for all such
4567 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4568 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004569 *
4570 * The C20x Tablet series have a mono internal speaker which is controlled
4571 * via the chip's Mono sum widget and pin complex, so include the necessary
4572 * controls for such models. On models without a "mono speaker" the control
4573 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004574 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004575static struct snd_kcontrol_new alc260_acer_mixer[] = {
4576 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4577 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004578 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004579 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004580 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004581 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004582 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004583 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4584 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4585 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4586 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4587 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4588 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4589 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4590 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4591 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4592 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4593 { } /* end */
4594};
4595
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004596/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4597 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4598 */
4599static struct snd_kcontrol_new alc260_will_mixer[] = {
4600 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4601 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4602 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4603 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4604 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4605 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4606 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4607 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4608 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4609 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4610 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4611 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4612 { } /* end */
4613};
4614
4615/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4616 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4617 */
4618static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4619 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4620 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4621 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4622 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4623 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4624 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4625 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4626 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4627 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4628 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4629 { } /* end */
4630};
4631
Kailang Yangdf694da2005-12-05 19:42:22 +01004632/*
4633 * initialization verbs
4634 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004635static struct hda_verb alc260_init_verbs[] = {
4636 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004637 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004638 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004639 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004640 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004641 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004642 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004643 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004644 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004646 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004647 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004648 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004649 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004650 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004651 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004652 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004653 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4654 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004655 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004656 /* set connection select to line in (default select for this ADC) */
4657 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004658 /* mute capture amp left and right */
4659 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4660 /* set connection select to line in (default select for this ADC) */
4661 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004662 /* set vol=0 Line-Out mixer amp left and right */
4663 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4664 /* unmute pin widget amp left and right (no gain on this amp) */
4665 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4666 /* set vol=0 HP mixer amp left and right */
4667 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4668 /* unmute pin widget amp left and right (no gain on this amp) */
4669 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4670 /* set vol=0 Mono mixer amp left and right */
4671 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4672 /* unmute pin widget amp left and right (no gain on this amp) */
4673 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4674 /* unmute LINE-2 out pin */
4675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004676 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4677 * Line In 2 = 0x03
4678 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004679 /* mute analog inputs */
4680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4681 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4682 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4683 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4684 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004685 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004686 /* mute Front out path */
4687 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4688 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4689 /* mute Headphone out path */
4690 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4691 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4692 /* mute Mono out path */
4693 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4694 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004695 { }
4696};
4697
Takashi Iwai474167d2006-05-17 17:17:43 +02004698#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004699static struct hda_verb alc260_hp_init_verbs[] = {
4700 /* Headphone and output */
4701 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4702 /* mono output */
4703 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4704 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4705 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4706 /* Mic2 (front panel) pin widget for input and vref at 80% */
4707 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4708 /* Line In pin widget for input */
4709 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4710 /* Line-2 pin widget for output */
4711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4712 /* CD pin widget for input */
4713 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4714 /* unmute amp left and right */
4715 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4716 /* set connection select to line in (default select for this ADC) */
4717 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4718 /* unmute Line-Out mixer amp left and right (volume = 0) */
4719 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4720 /* mute pin widget amp left and right (no gain on this amp) */
4721 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4722 /* unmute HP mixer amp left and right (volume = 0) */
4723 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4724 /* mute pin widget amp left and right (no gain on this amp) */
4725 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004726 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4727 * Line In 2 = 0x03
4728 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004729 /* mute analog inputs */
4730 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4731 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4732 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4733 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4734 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004735 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4736 /* Unmute Front out path */
4737 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4738 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4739 /* Unmute Headphone out path */
4740 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4741 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4742 /* Unmute Mono out path */
4743 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4744 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4745 { }
4746};
Takashi Iwai474167d2006-05-17 17:17:43 +02004747#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004748
4749static struct hda_verb alc260_hp_3013_init_verbs[] = {
4750 /* Line out and output */
4751 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4752 /* mono output */
4753 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4754 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4755 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4756 /* Mic2 (front panel) pin widget for input and vref at 80% */
4757 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4758 /* Line In pin widget for input */
4759 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4760 /* Headphone pin widget for output */
4761 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4762 /* CD pin widget for input */
4763 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4764 /* unmute amp left and right */
4765 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4766 /* set connection select to line in (default select for this ADC) */
4767 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4768 /* unmute Line-Out mixer amp left and right (volume = 0) */
4769 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4770 /* mute pin widget amp left and right (no gain on this amp) */
4771 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4772 /* unmute HP mixer amp left and right (volume = 0) */
4773 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4774 /* mute pin widget amp left and right (no gain on this amp) */
4775 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004776 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4777 * Line In 2 = 0x03
4778 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004779 /* mute analog inputs */
4780 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4781 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4782 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4783 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4784 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004785 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4786 /* Unmute Front out path */
4787 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4788 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4789 /* Unmute Headphone out path */
4790 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4791 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4792 /* Unmute Mono out path */
4793 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4794 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4795 { }
4796};
4797
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004798/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004799 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4800 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004801 */
4802static struct hda_verb alc260_fujitsu_init_verbs[] = {
4803 /* Disable all GPIOs */
4804 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4805 /* Internal speaker is connected to headphone pin */
4806 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4807 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4808 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004809 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4810 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4811 /* Ensure all other unused pins are disabled and muted. */
4812 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4813 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004814 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004815 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004816 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004817 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4818 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4819 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004820
Jonathan Woithef7ace402006-02-28 11:46:14 +01004821 /* Disable digital (SPDIF) pins */
4822 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4823 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004824
Kailang Yangea1fb292008-08-26 12:58:38 +02004825 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004826 * when acting as an output.
4827 */
4828 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4829
4830 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004831 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4832 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4833 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4834 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4835 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4836 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4837 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4838 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4839 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004840
Jonathan Woithef7ace402006-02-28 11:46:14 +01004841 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4842 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4843 /* Unmute Line1 pin widget output buffer since it starts as an output.
4844 * If the pin mode is changed by the user the pin mode control will
4845 * take care of enabling the pin's input/output buffers as needed.
4846 * Therefore there's no need to enable the input buffer at this
4847 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004848 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004849 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02004850 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004851 * mixer ctrl)
4852 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004853 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004854
Jonathan Woithef7ace402006-02-28 11:46:14 +01004855 /* Mute capture amp left and right */
4856 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02004857 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01004858 * in (on mic1 pin)
4859 */
4860 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004861
Jonathan Woithef7ace402006-02-28 11:46:14 +01004862 /* Do the same for the second ADC: mute capture input amp and
4863 * set ADC connection to line in (on mic1 pin)
4864 */
4865 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4866 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004867
Jonathan Woithef7ace402006-02-28 11:46:14 +01004868 /* Mute all inputs to mixer widget (even unconnected ones) */
4869 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4870 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4871 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4872 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4873 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4874 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4875 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4876 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004877
4878 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004879};
4880
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004881/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4882 * similar laptops (adapted from Fujitsu init verbs).
4883 */
4884static struct hda_verb alc260_acer_init_verbs[] = {
4885 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4886 * the headphone jack. Turn this on and rely on the standard mute
4887 * methods whenever the user wants to turn these outputs off.
4888 */
4889 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4890 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4891 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4892 /* Internal speaker/Headphone jack is connected to Line-out pin */
4893 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4894 /* Internal microphone/Mic jack is connected to Mic1 pin */
4895 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4896 /* Line In jack is connected to Line1 pin */
4897 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004898 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4899 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004900 /* Ensure all other unused pins are disabled and muted. */
4901 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4902 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004903 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4904 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4905 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4906 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4907 /* Disable digital (SPDIF) pins */
4908 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4909 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4910
Kailang Yangea1fb292008-08-26 12:58:38 +02004911 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004912 * bus when acting as outputs.
4913 */
4914 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4915 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4916
4917 /* Start with output sum widgets muted and their output gains at min */
4918 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4919 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4920 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4921 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4922 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4923 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4924 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4925 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4926 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4927
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004928 /* Unmute Line-out pin widget amp left and right
4929 * (no equiv mixer ctrl)
4930 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004931 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004932 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4933 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004934 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4935 * inputs. If the pin mode is changed by the user the pin mode control
4936 * will take care of enabling the pin's input/output buffers as needed.
4937 * Therefore there's no need to enable the input buffer at this
4938 * stage.
4939 */
4940 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4941 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4942
4943 /* Mute capture amp left and right */
4944 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4945 /* Set ADC connection select to match default mixer setting - mic
4946 * (on mic1 pin)
4947 */
4948 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4949
4950 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004951 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004952 */
4953 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004954 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004955
4956 /* Mute all inputs to mixer widget (even unconnected ones) */
4957 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4958 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4959 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4960 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4961 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4962 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4963 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4964 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4965
4966 { }
4967};
4968
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004969static struct hda_verb alc260_will_verbs[] = {
4970 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4971 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4972 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4973 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4974 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4975 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4976 {}
4977};
4978
4979static struct hda_verb alc260_replacer_672v_verbs[] = {
4980 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4981 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4982 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4983
4984 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4985 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4986 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4987
4988 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4989 {}
4990};
4991
4992/* toggle speaker-output according to the hp-jack state */
4993static void alc260_replacer_672v_automute(struct hda_codec *codec)
4994{
4995 unsigned int present;
4996
4997 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4998 present = snd_hda_codec_read(codec, 0x0f, 0,
4999 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
5000 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005001 snd_hda_codec_write_cache(codec, 0x01, 0,
5002 AC_VERB_SET_GPIO_DATA, 1);
5003 snd_hda_codec_write_cache(codec, 0x0f, 0,
5004 AC_VERB_SET_PIN_WIDGET_CONTROL,
5005 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005006 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005007 snd_hda_codec_write_cache(codec, 0x01, 0,
5008 AC_VERB_SET_GPIO_DATA, 0);
5009 snd_hda_codec_write_cache(codec, 0x0f, 0,
5010 AC_VERB_SET_PIN_WIDGET_CONTROL,
5011 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005012 }
5013}
5014
5015static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
5016 unsigned int res)
5017{
5018 if ((res >> 26) == ALC880_HP_EVENT)
5019 alc260_replacer_672v_automute(codec);
5020}
5021
Kailang Yang3f878302008-08-26 13:02:23 +02005022static struct hda_verb alc260_hp_dc7600_verbs[] = {
5023 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
5024 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
5025 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5026 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5027 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5028 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5029 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5030 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5031 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5032 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5033 {}
5034};
5035
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005036/* Test configuration for debugging, modelled after the ALC880 test
5037 * configuration.
5038 */
5039#ifdef CONFIG_SND_DEBUG
5040static hda_nid_t alc260_test_dac_nids[1] = {
5041 0x02,
5042};
5043static hda_nid_t alc260_test_adc_nids[2] = {
5044 0x04, 0x05,
5045};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005046/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02005047 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005048 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005049 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005050static struct hda_input_mux alc260_test_capture_sources[2] = {
5051 {
5052 .num_items = 7,
5053 .items = {
5054 { "MIC1 pin", 0x0 },
5055 { "MIC2 pin", 0x1 },
5056 { "LINE1 pin", 0x2 },
5057 { "LINE2 pin", 0x3 },
5058 { "CD pin", 0x4 },
5059 { "LINE-OUT pin", 0x5 },
5060 { "HP-OUT pin", 0x6 },
5061 },
5062 },
5063 {
5064 .num_items = 8,
5065 .items = {
5066 { "MIC1 pin", 0x0 },
5067 { "MIC2 pin", 0x1 },
5068 { "LINE1 pin", 0x2 },
5069 { "LINE2 pin", 0x3 },
5070 { "CD pin", 0x4 },
5071 { "Mixer", 0x5 },
5072 { "LINE-OUT pin", 0x6 },
5073 { "HP-OUT pin", 0x7 },
5074 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005075 },
5076};
5077static struct snd_kcontrol_new alc260_test_mixer[] = {
5078 /* Output driver widgets */
5079 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5080 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5081 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5082 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
5083 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5084 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
5085
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005086 /* Modes for retasking pin widgets
5087 * Note: the ALC260 doesn't seem to act on requests to enable mic
5088 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
5089 * mention this restriction. At this stage it's not clear whether
5090 * this behaviour is intentional or is a hardware bug in chip
5091 * revisions available at least up until early 2006. Therefore for
5092 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
5093 * choices, but if it turns out that the lack of mic bias for these
5094 * NIDs is intentional we could change their modes from
5095 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5096 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005097 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
5098 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
5099 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
5100 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
5101 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
5102 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
5103
5104 /* Loopback mixer controls */
5105 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
5106 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
5107 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
5108 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
5109 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
5110 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
5111 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
5112 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
5113 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5114 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5115 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
5116 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
5117 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
5118 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
5119 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
5120 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005121
5122 /* Controls for GPIO pins, assuming they are configured as outputs */
5123 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
5124 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
5125 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
5126 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
5127
Jonathan Woithe92621f12006-02-28 11:47:47 +01005128 /* Switches to allow the digital IO pins to be enabled. The datasheet
5129 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02005130 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01005131 */
5132 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
5133 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
5134
Jonathan Woithef8225f62008-01-08 12:16:54 +01005135 /* A switch allowing EAPD to be enabled. Some laptops seem to use
5136 * this output to turn on an external amplifier.
5137 */
5138 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
5139 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
5140
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005141 { } /* end */
5142};
5143static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01005144 /* Enable all GPIOs as outputs with an initial value of 0 */
5145 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
5146 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
5147 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
5148
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005149 /* Enable retasking pins as output, initially without power amp */
5150 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5151 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5152 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5154 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5155 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5156
Jonathan Woithe92621f12006-02-28 11:47:47 +01005157 /* Disable digital (SPDIF) pins initially, but users can enable
5158 * them via a mixer switch. In the case of SPDIF-out, this initverb
5159 * payload also sets the generation to 0, output to be in "consumer"
5160 * PCM format, copyright asserted, no pre-emphasis and no validity
5161 * control.
5162 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005163 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
5164 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
5165
Kailang Yangea1fb292008-08-26 12:58:38 +02005166 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005167 * OUT1 sum bus when acting as an output.
5168 */
5169 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
5170 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
5171 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
5172 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
5173
5174 /* Start with output sum widgets muted and their output gains at min */
5175 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5176 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5177 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5178 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5179 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5180 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5181 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5182 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5183 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5184
Jonathan Woithecdcd9262006-02-28 11:36:42 +01005185 /* Unmute retasking pin widget output buffers since the default
5186 * state appears to be output. As the pin mode is changed by the
5187 * user the pin mode control will take care of enabling the pin's
5188 * input/output buffers as needed.
5189 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005190 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5191 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5192 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5193 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5194 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5195 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5196 /* Also unmute the mono-out pin widget */
5197 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5198
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005199 /* Mute capture amp left and right */
5200 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01005201 /* Set ADC connection select to match default mixer setting (mic1
5202 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005203 */
5204 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5205
5206 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01005207 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005208 */
5209 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5210 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5211
5212 /* Mute all inputs to mixer widget (even unconnected ones) */
5213 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
5214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
5215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
5216 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
5217 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
5218 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
5219 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
5220 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
5221
5222 { }
5223};
5224#endif
5225
Takashi Iwai63300792008-01-24 15:31:36 +01005226#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
5227#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07005228
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005229#define alc260_pcm_digital_playback alc880_pcm_digital_playback
5230#define alc260_pcm_digital_capture alc880_pcm_digital_capture
5231
Kailang Yangdf694da2005-12-05 19:42:22 +01005232/*
5233 * for BIOS auto-configuration
5234 */
5235
5236static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02005237 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01005238{
5239 hda_nid_t nid_vol;
5240 unsigned long vol_val, sw_val;
5241 char name[32];
5242 int err;
5243
5244 if (nid >= 0x0f && nid < 0x11) {
5245 nid_vol = nid - 0x7;
5246 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5247 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5248 } else if (nid == 0x11) {
5249 nid_vol = nid - 0x7;
5250 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
5251 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
5252 } else if (nid >= 0x12 && nid <= 0x15) {
5253 nid_vol = 0x08;
5254 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
5255 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
5256 } else
5257 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02005258
Takashi Iwai863b4512008-10-21 17:01:47 +02005259 if (!(*vol_bits & (1 << nid_vol))) {
5260 /* first control for the volume widget */
5261 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
5262 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
5263 if (err < 0)
5264 return err;
5265 *vol_bits |= (1 << nid_vol);
5266 }
Kailang Yangdf694da2005-12-05 19:42:22 +01005267 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005268 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
5269 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005270 return err;
5271 return 1;
5272}
5273
5274/* add playback controls from the parsed DAC table */
5275static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
5276 const struct auto_pin_cfg *cfg)
5277{
5278 hda_nid_t nid;
5279 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02005280 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005281
5282 spec->multiout.num_dacs = 1;
5283 spec->multiout.dac_nids = spec->private_dac_nids;
5284 spec->multiout.dac_nids[0] = 0x02;
5285
5286 nid = cfg->line_out_pins[0];
5287 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005288 err = alc260_add_playback_controls(spec, nid, "Front", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005289 if (err < 0)
5290 return err;
5291 }
5292
Takashi Iwai82bc9552006-03-21 11:24:42 +01005293 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005294 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005295 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005296 if (err < 0)
5297 return err;
5298 }
5299
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005300 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005301 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02005302 err = alc260_add_playback_controls(spec, nid, "Headphone",
5303 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01005304 if (err < 0)
5305 return err;
5306 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005307 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005308}
5309
5310/* create playback/capture controls for input pins */
5311static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5312 const struct auto_pin_cfg *cfg)
5313{
Kailang Yangdf694da2005-12-05 19:42:22 +01005314 struct hda_input_mux *imux = &spec->private_imux;
5315 int i, err, idx;
5316
5317 for (i = 0; i < AUTO_PIN_LAST; i++) {
5318 if (cfg->input_pins[i] >= 0x12) {
5319 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005320 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005321 auto_pin_cfg_labels[i], idx,
5322 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005323 if (err < 0)
5324 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005325 imux->items[imux->num_items].label =
5326 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005327 imux->items[imux->num_items].index = idx;
5328 imux->num_items++;
5329 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005330 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005331 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005332 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005333 auto_pin_cfg_labels[i], idx,
5334 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005335 if (err < 0)
5336 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005337 imux->items[imux->num_items].label =
5338 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005339 imux->items[imux->num_items].index = idx;
5340 imux->num_items++;
5341 }
5342 }
5343 return 0;
5344}
5345
5346static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5347 hda_nid_t nid, int pin_type,
5348 int sel_idx)
5349{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005350 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005351 /* need the manual connection? */
5352 if (nid >= 0x12) {
5353 int idx = nid - 0x12;
5354 snd_hda_codec_write(codec, idx + 0x0b, 0,
5355 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005356 }
5357}
5358
5359static void alc260_auto_init_multi_out(struct hda_codec *codec)
5360{
5361 struct alc_spec *spec = codec->spec;
5362 hda_nid_t nid;
5363
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005364 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005365 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005366 if (nid) {
5367 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5368 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5369 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005370
Takashi Iwai82bc9552006-03-21 11:24:42 +01005371 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005372 if (nid)
5373 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5374
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005375 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005376 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005377 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005378}
Kailang Yangdf694da2005-12-05 19:42:22 +01005379
5380#define ALC260_PIN_CD_NID 0x16
5381static void alc260_auto_init_analog_input(struct hda_codec *codec)
5382{
5383 struct alc_spec *spec = codec->spec;
5384 int i;
5385
5386 for (i = 0; i < AUTO_PIN_LAST; i++) {
5387 hda_nid_t nid = spec->autocfg.input_pins[i];
5388 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005389 snd_hda_codec_write(codec, nid, 0,
5390 AC_VERB_SET_PIN_WIDGET_CONTROL,
5391 i <= AUTO_PIN_FRONT_MIC ?
5392 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005393 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005394 snd_hda_codec_write(codec, nid, 0,
5395 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005396 AMP_OUT_MUTE);
5397 }
5398 }
5399}
5400
5401/*
5402 * generic initialization of ADC, input mixers and output mixers
5403 */
5404static struct hda_verb alc260_volume_init_verbs[] = {
5405 /*
5406 * Unmute ADC0-1 and set the default input to mic-in
5407 */
5408 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5409 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5410 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5411 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005412
Kailang Yangdf694da2005-12-05 19:42:22 +01005413 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5414 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005415 * Note: PASD motherboards uses the Line In 2 as the input for
5416 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005417 */
5418 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005419 /* mute analog inputs */
5420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5423 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5424 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005425
5426 /*
5427 * Set up output mixers (0x08 - 0x0a)
5428 */
5429 /* set vol=0 to output mixers */
5430 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5431 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5432 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5433 /* set up input amps for analog loopback */
5434 /* Amp Indices: DAC = 0, mixer = 1 */
5435 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5436 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5437 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5438 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5439 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5440 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005441
Kailang Yangdf694da2005-12-05 19:42:22 +01005442 { }
5443};
5444
5445static int alc260_parse_auto_config(struct hda_codec *codec)
5446{
5447 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005448 int err;
5449 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5450
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005451 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5452 alc260_ignore);
5453 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005454 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005455 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5456 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005457 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02005458 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01005459 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005460 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5461 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005462 return err;
5463
5464 spec->multiout.max_channels = 2;
5465
5466 if (spec->autocfg.dig_out_pin)
5467 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02005468 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005469 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01005470
Takashi Iwaid88897e2008-10-31 15:01:37 +01005471 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01005472
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005473 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005474 spec->input_mux = &spec->private_imux;
5475
Takashi Iwaie044c392008-10-27 16:56:24 +01005476 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005477 return 1;
5478}
5479
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005480/* additional initialization for auto-configuration model */
5481static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005482{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005483 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005484 alc260_auto_init_multi_out(codec);
5485 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005486 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005487 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005488}
5489
Takashi Iwaicb53c622007-08-10 17:21:45 +02005490#ifdef CONFIG_SND_HDA_POWER_SAVE
5491static struct hda_amp_list alc260_loopbacks[] = {
5492 { 0x07, HDA_INPUT, 0 },
5493 { 0x07, HDA_INPUT, 1 },
5494 { 0x07, HDA_INPUT, 2 },
5495 { 0x07, HDA_INPUT, 3 },
5496 { 0x07, HDA_INPUT, 4 },
5497 { } /* end */
5498};
5499#endif
5500
Kailang Yangdf694da2005-12-05 19:42:22 +01005501/*
5502 * ALC260 configurations
5503 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005504static const char *alc260_models[ALC260_MODEL_LAST] = {
5505 [ALC260_BASIC] = "basic",
5506 [ALC260_HP] = "hp",
5507 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02005508 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005509 [ALC260_FUJITSU_S702X] = "fujitsu",
5510 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005511 [ALC260_WILL] = "will",
5512 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005513#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005514 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005515#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005516 [ALC260_AUTO] = "auto",
5517};
5518
5519static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005520 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005521 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005522 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005523 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005524 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005525 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005526 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005527 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5528 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5529 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5530 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5531 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5532 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5533 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5534 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5535 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005536 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005537 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005538 {}
5539};
5540
Kailang Yangdf694da2005-12-05 19:42:22 +01005541static struct alc_config_preset alc260_presets[] = {
5542 [ALC260_BASIC] = {
5543 .mixers = { alc260_base_output_mixer,
5544 alc260_input_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005545 alc260_pc_beep_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005546 .init_verbs = { alc260_init_verbs },
5547 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5548 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005549 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Kailang Yangdf694da2005-12-05 19:42:22 +01005550 .adc_nids = alc260_adc_nids,
5551 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5552 .channel_mode = alc260_modes,
5553 .input_mux = &alc260_capture_source,
5554 },
5555 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005556 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005557 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005558 .init_verbs = { alc260_init_verbs,
5559 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005560 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5561 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005562 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5563 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005564 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5565 .channel_mode = alc260_modes,
5566 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005567 .unsol_event = alc260_hp_unsol_event,
5568 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005569 },
Kailang Yang3f878302008-08-26 13:02:23 +02005570 [ALC260_HP_DC7600] = {
5571 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005572 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02005573 .init_verbs = { alc260_init_verbs,
5574 alc260_hp_dc7600_verbs },
5575 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5576 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005577 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5578 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02005579 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5580 .channel_mode = alc260_modes,
5581 .input_mux = &alc260_capture_source,
5582 .unsol_event = alc260_hp_3012_unsol_event,
5583 .init_hook = alc260_hp_3012_automute,
5584 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005585 [ALC260_HP_3013] = {
5586 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005587 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005588 .init_verbs = { alc260_hp_3013_init_verbs,
5589 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005590 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5591 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005592 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
5593 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01005594 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5595 .channel_mode = alc260_modes,
5596 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005597 .unsol_event = alc260_hp_3013_unsol_event,
5598 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005599 },
5600 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005601 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01005602 .init_verbs = { alc260_fujitsu_init_verbs },
5603 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5604 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005605 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5606 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005607 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5608 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005609 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5610 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005611 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005612 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005613 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005614 .init_verbs = { alc260_acer_init_verbs },
5615 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5616 .dac_nids = alc260_dac_nids,
5617 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5618 .adc_nids = alc260_dual_adc_nids,
5619 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5620 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005621 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5622 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005623 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005624 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005625 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005626 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5627 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5628 .dac_nids = alc260_dac_nids,
5629 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5630 .adc_nids = alc260_adc_nids,
5631 .dig_out_nid = ALC260_DIGOUT_NID,
5632 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5633 .channel_mode = alc260_modes,
5634 .input_mux = &alc260_capture_source,
5635 },
5636 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005637 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005638 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5639 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5640 .dac_nids = alc260_dac_nids,
5641 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5642 .adc_nids = alc260_adc_nids,
5643 .dig_out_nid = ALC260_DIGOUT_NID,
5644 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5645 .channel_mode = alc260_modes,
5646 .input_mux = &alc260_capture_source,
5647 .unsol_event = alc260_replacer_672v_unsol_event,
5648 .init_hook = alc260_replacer_672v_automute,
5649 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005650#ifdef CONFIG_SND_DEBUG
5651 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005652 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005653 .init_verbs = { alc260_test_init_verbs },
5654 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5655 .dac_nids = alc260_test_dac_nids,
5656 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5657 .adc_nids = alc260_test_adc_nids,
5658 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5659 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005660 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5661 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005662 },
5663#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005664};
5665
Linus Torvalds1da177e2005-04-16 15:20:36 -07005666static int patch_alc260(struct hda_codec *codec)
5667{
5668 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005669 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005670
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005671 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005672 if (spec == NULL)
5673 return -ENOMEM;
5674
5675 codec->spec = spec;
5676
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005677 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5678 alc260_models,
5679 alc260_cfg_tbl);
5680 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005681 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5682 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005683 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005684 }
5685
Kailang Yangdf694da2005-12-05 19:42:22 +01005686 if (board_config == ALC260_AUTO) {
5687 /* automatic parse from the BIOS config */
5688 err = alc260_parse_auto_config(codec);
5689 if (err < 0) {
5690 alc_free(codec);
5691 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005692 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005693 printk(KERN_INFO
5694 "hda_codec: Cannot set up configuration "
5695 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005696 board_config = ALC260_BASIC;
5697 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005698 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005699
Kailang Yangdf694da2005-12-05 19:42:22 +01005700 if (board_config != ALC260_AUTO)
5701 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005702
5703 spec->stream_name_analog = "ALC260 Analog";
5704 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5705 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5706
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005707 spec->stream_name_digital = "ALC260 Digital";
5708 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5709 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5710
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01005711 if (!spec->adc_nids && spec->input_mux) {
5712 /* check whether NID 0x04 is valid */
5713 unsigned int wcap = get_wcaps(codec, 0x04);
5714 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
5715 /* get type */
5716 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
5717 spec->adc_nids = alc260_adc_nids_alt;
5718 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5719 } else {
5720 spec->adc_nids = alc260_adc_nids;
5721 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5722 }
5723 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005724 set_capture_mixer(spec);
5725
Takashi Iwai2134ea42008-01-10 16:53:55 +01005726 spec->vmaster_nid = 0x08;
5727
Linus Torvalds1da177e2005-04-16 15:20:36 -07005728 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005729 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005730 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005731#ifdef CONFIG_SND_HDA_POWER_SAVE
5732 if (!spec->loopback.amplist)
5733 spec->loopback.amplist = alc260_loopbacks;
5734#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005735
5736 return 0;
5737}
5738
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005739
Linus Torvalds1da177e2005-04-16 15:20:36 -07005740/*
5741 * ALC882 support
5742 *
5743 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5744 * configuration. Each pin widget can choose any input DACs and a mixer.
5745 * Each ADC is connected from a mixer of all inputs. This makes possible
5746 * 6-channel independent captures.
5747 *
5748 * In addition, an independent DAC for the multi-playback (not used in this
5749 * driver yet).
5750 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005751#define ALC882_DIGOUT_NID 0x06
5752#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005753
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005754static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005755 { 8, NULL }
5756};
5757
5758static hda_nid_t alc882_dac_nids[4] = {
5759 /* front, rear, clfe, rear_surr */
5760 0x02, 0x03, 0x04, 0x05
5761};
5762
Kailang Yangdf694da2005-12-05 19:42:22 +01005763/* identical with ALC880 */
5764#define alc882_adc_nids alc880_adc_nids
5765#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005766
Takashi Iwaie1406342008-02-11 18:32:32 +01005767static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5768static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5769
Linus Torvalds1da177e2005-04-16 15:20:36 -07005770/* input MUX */
5771/* FIXME: should be a matrix-type input source selection */
5772
5773static struct hda_input_mux alc882_capture_source = {
5774 .num_items = 4,
5775 .items = {
5776 { "Mic", 0x0 },
5777 { "Front Mic", 0x1 },
5778 { "Line", 0x2 },
5779 { "CD", 0x4 },
5780 },
5781};
Kailang Yangdf694da2005-12-05 19:42:22 +01005782/*
Kailang Yang272a5272007-05-14 11:00:38 +02005783 * 2ch mode
5784 */
5785static struct hda_verb alc882_3ST_ch2_init[] = {
5786 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5787 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5788 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5789 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5790 { } /* end */
5791};
5792
5793/*
5794 * 6ch mode
5795 */
5796static struct hda_verb alc882_3ST_ch6_init[] = {
5797 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5798 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5799 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5800 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5801 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5802 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5803 { } /* end */
5804};
5805
5806static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5807 { 2, alc882_3ST_ch2_init },
5808 { 6, alc882_3ST_ch6_init },
5809};
5810
5811/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005812 * 6ch mode
5813 */
5814static struct hda_verb alc882_sixstack_ch6_init[] = {
5815 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5816 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5817 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5818 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5819 { } /* end */
5820};
5821
5822/*
5823 * 8ch mode
5824 */
5825static struct hda_verb alc882_sixstack_ch8_init[] = {
5826 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5827 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5828 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5829 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5830 { } /* end */
5831};
5832
5833static struct hda_channel_mode alc882_sixstack_modes[2] = {
5834 { 6, alc882_sixstack_ch6_init },
5835 { 8, alc882_sixstack_ch8_init },
5836};
5837
Takashi Iwai87350ad2007-08-16 18:19:38 +02005838/*
5839 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5840 */
5841
5842/*
5843 * 2ch mode
5844 */
5845static struct hda_verb alc885_mbp_ch2_init[] = {
5846 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5847 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5848 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5849 { } /* end */
5850};
5851
5852/*
5853 * 6ch mode
5854 */
5855static struct hda_verb alc885_mbp_ch6_init[] = {
5856 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5857 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5858 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5859 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5860 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5861 { } /* end */
5862};
5863
5864static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5865 { 2, alc885_mbp_ch2_init },
5866 { 6, alc885_mbp_ch6_init },
5867};
5868
5869
Linus Torvalds1da177e2005-04-16 15:20:36 -07005870/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5871 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5872 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005873static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005874 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005875 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005876 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005877 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005878 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5879 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005880 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5881 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005882 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005883 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005884 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5885 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5886 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5887 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5888 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5889 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005890 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005891 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5892 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005893 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005894 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5895 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5896 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005897 { } /* end */
5898};
5899
Takashi Iwai87350ad2007-08-16 18:19:38 +02005900static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005901 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5902 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5903 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5904 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5905 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5906 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005907 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5908 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005909 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005910 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5911 { } /* end */
5912};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005913static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5914 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5915 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5916 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5917 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5918 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5919 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5921 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5922 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5923 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5924 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5925 { } /* end */
5926};
5927
Kailang Yang272a5272007-05-14 11:00:38 +02005928static struct snd_kcontrol_new alc882_targa_mixer[] = {
5929 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5930 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5931 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5932 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5933 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5934 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5935 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5936 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5937 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005938 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005939 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5940 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005941 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005942 { } /* end */
5943};
5944
5945/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5946 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5947 */
5948static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5949 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5950 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5951 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5952 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5953 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5954 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5955 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5956 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5957 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5958 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005961 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005962 { } /* end */
5963};
5964
Takashi Iwai914759b2007-09-06 14:52:04 +02005965static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5966 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5967 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5968 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5969 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5970 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5971 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5972 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5974 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5976 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5977 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5978 { } /* end */
5979};
5980
Kailang Yangdf694da2005-12-05 19:42:22 +01005981static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5982 {
5983 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5984 .name = "Channel Mode",
5985 .info = alc_ch_mode_info,
5986 .get = alc_ch_mode_get,
5987 .put = alc_ch_mode_put,
5988 },
5989 { } /* end */
5990};
5991
Linus Torvalds1da177e2005-04-16 15:20:36 -07005992static struct hda_verb alc882_init_verbs[] = {
5993 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005994 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5995 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5996 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005997 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005998 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5999 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6000 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006001 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006002 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6003 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6004 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006005 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02006006 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6007 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6008 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006009
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006010 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006011 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006012 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006013 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006014 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006015 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006017 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006018 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006019 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006020 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006021 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006022 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02006023 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02006024 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006025 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006026 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006027 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006028 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6029 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006030 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006031 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6032 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006033 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006034 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6035 /* Line-2 In: Headphone output (output 0 - 0x0c) */
6036 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6037 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6038 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006039 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006040 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006041
6042 /* FIXME: use matrix-type input source selection */
6043 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6044 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02006045 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6046 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6047 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006049 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006050 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6051 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6052 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6053 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006054 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006055 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6056 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6057 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6058 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6059 /* ADC1: mute amp left and right */
6060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006061 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006062 /* ADC2: mute amp left and right */
6063 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006064 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02006065 /* ADC3: mute amp left and right */
6066 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02006067 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006068
6069 { }
6070};
6071
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006072static struct hda_verb alc882_eapd_verbs[] = {
6073 /* change to EAPD mode */
6074 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006075 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006076 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006077};
6078
Tobin Davis9102cd12006-12-15 10:02:12 +01006079/* Mac Pro test */
6080static struct snd_kcontrol_new alc882_macpro_mixer[] = {
6081 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6082 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6083 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
6084 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
6085 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
6086 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
6087 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
6088 { } /* end */
6089};
6090
6091static struct hda_verb alc882_macpro_init_verbs[] = {
6092 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6093 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6094 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6095 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6096 /* Front Pin: output 0 (0x0c) */
6097 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6098 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6099 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6100 /* Front Mic pin: input vref at 80% */
6101 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6102 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6103 /* Speaker: output */
6104 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6105 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6106 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
6107 /* Headphone output (output 0 - 0x0c) */
6108 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6109 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6110 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6111
6112 /* FIXME: use matrix-type input source selection */
6113 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6114 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6115 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6116 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6117 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6118 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6119 /* Input mixer2 */
6120 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6121 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6122 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6123 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6124 /* Input mixer3 */
6125 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6126 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6127 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6128 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6129 /* ADC1: mute amp left and right */
6130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6131 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6132 /* ADC2: mute amp left and right */
6133 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6134 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6135 /* ADC3: mute amp left and right */
6136 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6137 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6138
6139 { }
6140};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006141
Takashi Iwai87350ad2007-08-16 18:19:38 +02006142/* Macbook Pro rev3 */
6143static struct hda_verb alc885_mbp3_init_verbs[] = {
6144 /* Front mixer: unmute input/output amp left and right (volume = 0) */
6145 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6146 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6147 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6148 /* Rear mixer */
6149 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6150 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6151 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6152 /* Front Pin: output 0 (0x0c) */
6153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6154 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6155 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6156 /* HP Pin: output 0 (0x0d) */
6157 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6158 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6159 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
6160 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6161 /* Mic (rear) pin: input vref at 80% */
6162 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6163 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6164 /* Front Mic pin: input vref at 80% */
6165 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6166 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6167 /* Line In pin: use output 1 when in LineOut mode */
6168 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6169 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6170 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
6171
6172 /* FIXME: use matrix-type input source selection */
6173 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6174 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6175 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6176 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6177 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6178 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6179 /* Input mixer2 */
6180 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6181 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6182 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6183 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6184 /* Input mixer3 */
6185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6186 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6187 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
6189 /* ADC1: mute amp left and right */
6190 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6191 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6192 /* ADC2: mute amp left and right */
6193 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6194 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6195 /* ADC3: mute amp left and right */
6196 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6197 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6198
6199 { }
6200};
6201
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006202/* iMac 24 mixer. */
6203static struct snd_kcontrol_new alc885_imac24_mixer[] = {
6204 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6205 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
6206 { } /* end */
6207};
6208
6209/* iMac 24 init verbs. */
6210static struct hda_verb alc885_imac24_init_verbs[] = {
6211 /* Internal speakers: output 0 (0x0c) */
6212 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6213 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6214 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
6215 /* Internal speakers: output 0 (0x0c) */
6216 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6217 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6218 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
6219 /* Headphone: output 0 (0x0c) */
6220 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6222 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6223 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6224 /* Front Mic: input vref at 80% */
6225 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6226 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
6227 { }
6228};
6229
6230/* Toggle speaker-output according to the hp-jack state */
6231static void alc885_imac24_automute(struct hda_codec *codec)
6232{
6233 unsigned int present;
6234
6235 present = snd_hda_codec_read(codec, 0x14, 0,
6236 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006237 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
6238 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6239 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
6240 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006241}
6242
6243/* Processes unsolicited events. */
6244static void alc885_imac24_unsol_event(struct hda_codec *codec,
6245 unsigned int res)
6246{
6247 /* Headphone insertion or removal. */
6248 if ((res >> 26) == ALC880_HP_EVENT)
6249 alc885_imac24_automute(codec);
6250}
6251
Takashi Iwai87350ad2007-08-16 18:19:38 +02006252static void alc885_mbp3_automute(struct hda_codec *codec)
6253{
6254 unsigned int present;
6255
6256 present = snd_hda_codec_read(codec, 0x15, 0,
6257 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6258 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6259 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6260 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6261 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6262
6263}
6264static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6265 unsigned int res)
6266{
6267 /* Headphone insertion or removal. */
6268 if ((res >> 26) == ALC880_HP_EVENT)
6269 alc885_mbp3_automute(codec);
6270}
6271
6272
Kailang Yang272a5272007-05-14 11:00:38 +02006273static struct hda_verb alc882_targa_verbs[] = {
6274 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6275 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6276
6277 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6278 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006279
Kailang Yang272a5272007-05-14 11:00:38 +02006280 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6281 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6282 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6283
6284 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6285 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6286 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6287 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6288 { } /* end */
6289};
6290
6291/* toggle speaker-output according to the hp-jack state */
6292static void alc882_targa_automute(struct hda_codec *codec)
6293{
6294 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006295
Kailang Yang272a5272007-05-14 11:00:38 +02006296 present = snd_hda_codec_read(codec, 0x14, 0,
6297 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006298 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6299 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006300 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6301 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006302}
6303
6304static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6305{
6306 /* Looks like the unsol event is incompatible with the standard
6307 * definition. 4bit tag is placed at 26 bit!
6308 */
6309 if (((res >> 26) == ALC880_HP_EVENT)) {
6310 alc882_targa_automute(codec);
6311 }
6312}
6313
6314static struct hda_verb alc882_asus_a7j_verbs[] = {
6315 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6316 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6317
6318 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6319 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6320 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006321
Kailang Yang272a5272007-05-14 11:00:38 +02006322 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6323 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6324 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6325
6326 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6327 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6328 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6329 { } /* end */
6330};
6331
Takashi Iwai914759b2007-09-06 14:52:04 +02006332static struct hda_verb alc882_asus_a7m_verbs[] = {
6333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6335
6336 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6337 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6338 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006339
Takashi Iwai914759b2007-09-06 14:52:04 +02006340 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6341 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6342 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6343
6344 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6345 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6346 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6347 { } /* end */
6348};
6349
Tobin Davis9102cd12006-12-15 10:02:12 +01006350static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6351{
6352 unsigned int gpiostate, gpiomask, gpiodir;
6353
6354 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6355 AC_VERB_GET_GPIO_DATA, 0);
6356
6357 if (!muted)
6358 gpiostate |= (1 << pin);
6359 else
6360 gpiostate &= ~(1 << pin);
6361
6362 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6363 AC_VERB_GET_GPIO_MASK, 0);
6364 gpiomask |= (1 << pin);
6365
6366 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6367 AC_VERB_GET_GPIO_DIRECTION, 0);
6368 gpiodir |= (1 << pin);
6369
6370
6371 snd_hda_codec_write(codec, codec->afg, 0,
6372 AC_VERB_SET_GPIO_MASK, gpiomask);
6373 snd_hda_codec_write(codec, codec->afg, 0,
6374 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6375
6376 msleep(1);
6377
6378 snd_hda_codec_write(codec, codec->afg, 0,
6379 AC_VERB_SET_GPIO_DATA, gpiostate);
6380}
6381
Takashi Iwai7debbe52007-08-16 15:01:03 +02006382/* set up GPIO at initialization */
6383static void alc885_macpro_init_hook(struct hda_codec *codec)
6384{
6385 alc882_gpio_mute(codec, 0, 0);
6386 alc882_gpio_mute(codec, 1, 0);
6387}
6388
6389/* set up GPIO and update auto-muting at initialization */
6390static void alc885_imac24_init_hook(struct hda_codec *codec)
6391{
6392 alc885_macpro_init_hook(codec);
6393 alc885_imac24_automute(codec);
6394}
6395
Kailang Yangdf694da2005-12-05 19:42:22 +01006396/*
6397 * generic initialization of ADC, input mixers and output mixers
6398 */
6399static struct hda_verb alc882_auto_init_verbs[] = {
6400 /*
6401 * Unmute ADC0-2 and set the default input to mic-in
6402 */
6403 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6405 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6406 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6407 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6408 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6409
Takashi Iwaicb53c622007-08-10 17:21:45 +02006410 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006411 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006412 * Note: PASD motherboards uses the Line In 2 as the input for
6413 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006414 */
6415 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006416 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6417 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6418 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6419 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6420 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006421
6422 /*
6423 * Set up output mixers (0x0c - 0x0f)
6424 */
6425 /* set vol=0 to output mixers */
6426 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6427 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6428 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6429 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6430 /* set up input amps for analog loopback */
6431 /* Amp Indices: DAC = 0, mixer = 1 */
6432 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6433 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6434 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6435 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6436 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6437 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6438 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6439 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6440 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6441 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6442
6443 /* FIXME: use matrix-type input source selection */
6444 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6445 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6446 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6447 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6448 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6449 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6450 /* Input mixer2 */
6451 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6452 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6455 /* Input mixer3 */
6456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6460
6461 { }
6462};
6463
Takashi Iwaicb53c622007-08-10 17:21:45 +02006464#ifdef CONFIG_SND_HDA_POWER_SAVE
6465#define alc882_loopbacks alc880_loopbacks
6466#endif
6467
Kailang Yangdf694da2005-12-05 19:42:22 +01006468/* pcm configuration: identiacal with ALC880 */
6469#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6470#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6471#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6472#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6473
6474/*
6475 * configuration and preset
6476 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006477static const char *alc882_models[ALC882_MODEL_LAST] = {
6478 [ALC882_3ST_DIG] = "3stack-dig",
6479 [ALC882_6ST_DIG] = "6stack-dig",
6480 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006481 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006482 [ALC882_TARGA] = "targa",
6483 [ALC882_ASUS_A7J] = "asus-a7j",
6484 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006485 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006486 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006487 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006488 [ALC882_AUTO] = "auto",
6489};
6490
6491static struct snd_pci_quirk alc882_cfg_tbl[] = {
6492 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006493 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006494 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006495 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006496 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006497 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006498 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006499 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006500 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006501 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6502 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6503 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006504 {}
6505};
6506
6507static struct alc_config_preset alc882_presets[] = {
6508 [ALC882_3ST_DIG] = {
6509 .mixers = { alc882_base_mixer },
6510 .init_verbs = { alc882_init_verbs },
6511 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6512 .dac_nids = alc882_dac_nids,
6513 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006514 .dig_in_nid = ALC882_DIGIN_NID,
6515 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6516 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006517 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006518 .input_mux = &alc882_capture_source,
6519 },
6520 [ALC882_6ST_DIG] = {
6521 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6522 .init_verbs = { alc882_init_verbs },
6523 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6524 .dac_nids = alc882_dac_nids,
6525 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006526 .dig_in_nid = ALC882_DIGIN_NID,
6527 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6528 .channel_mode = alc882_sixstack_modes,
6529 .input_mux = &alc882_capture_source,
6530 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006531 [ALC882_ARIMA] = {
6532 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6533 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6534 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6535 .dac_nids = alc882_dac_nids,
6536 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6537 .channel_mode = alc882_sixstack_modes,
6538 .input_mux = &alc882_capture_source,
6539 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006540 [ALC882_W2JC] = {
6541 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6542 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6543 alc880_gpio1_init_verbs },
6544 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6545 .dac_nids = alc882_dac_nids,
6546 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6547 .channel_mode = alc880_threestack_modes,
6548 .need_dac_fix = 1,
6549 .input_mux = &alc882_capture_source,
6550 .dig_out_nid = ALC882_DIGOUT_NID,
6551 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006552 [ALC885_MBP3] = {
6553 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6554 .init_verbs = { alc885_mbp3_init_verbs,
6555 alc880_gpio1_init_verbs },
6556 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6557 .dac_nids = alc882_dac_nids,
6558 .channel_mode = alc885_mbp_6ch_modes,
6559 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6560 .input_mux = &alc882_capture_source,
6561 .dig_out_nid = ALC882_DIGOUT_NID,
6562 .dig_in_nid = ALC882_DIGIN_NID,
6563 .unsol_event = alc885_mbp3_unsol_event,
6564 .init_hook = alc885_mbp3_automute,
6565 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006566 [ALC885_MACPRO] = {
6567 .mixers = { alc882_macpro_mixer },
6568 .init_verbs = { alc882_macpro_init_verbs },
6569 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6570 .dac_nids = alc882_dac_nids,
6571 .dig_out_nid = ALC882_DIGOUT_NID,
6572 .dig_in_nid = ALC882_DIGIN_NID,
6573 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6574 .channel_mode = alc882_ch_modes,
6575 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006576 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006577 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006578 [ALC885_IMAC24] = {
6579 .mixers = { alc885_imac24_mixer },
6580 .init_verbs = { alc885_imac24_init_verbs },
6581 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6582 .dac_nids = alc882_dac_nids,
6583 .dig_out_nid = ALC882_DIGOUT_NID,
6584 .dig_in_nid = ALC882_DIGIN_NID,
6585 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6586 .channel_mode = alc882_ch_modes,
6587 .input_mux = &alc882_capture_source,
6588 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006589 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006590 },
Kailang Yang272a5272007-05-14 11:00:38 +02006591 [ALC882_TARGA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006592 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006593 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6594 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6595 .dac_nids = alc882_dac_nids,
6596 .dig_out_nid = ALC882_DIGOUT_NID,
6597 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6598 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006599 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006600 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6601 .channel_mode = alc882_3ST_6ch_modes,
6602 .need_dac_fix = 1,
6603 .input_mux = &alc882_capture_source,
6604 .unsol_event = alc882_targa_unsol_event,
6605 .init_hook = alc882_targa_automute,
6606 },
6607 [ALC882_ASUS_A7J] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006608 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Kailang Yang272a5272007-05-14 11:00:38 +02006609 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6610 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6611 .dac_nids = alc882_dac_nids,
6612 .dig_out_nid = ALC882_DIGOUT_NID,
6613 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6614 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006615 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006616 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6617 .channel_mode = alc882_3ST_6ch_modes,
6618 .need_dac_fix = 1,
6619 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006620 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006621 [ALC882_ASUS_A7M] = {
6622 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6623 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6624 alc880_gpio1_init_verbs,
6625 alc882_asus_a7m_verbs },
6626 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6627 .dac_nids = alc882_dac_nids,
6628 .dig_out_nid = ALC882_DIGOUT_NID,
6629 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6630 .channel_mode = alc880_threestack_modes,
6631 .need_dac_fix = 1,
6632 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006633 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006634};
6635
6636
6637/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006638 * Pin config fixes
6639 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006640enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006641 PINFIX_ABIT_AW9D_MAX
6642};
6643
6644static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6645 { 0x15, 0x01080104 }, /* side */
6646 { 0x16, 0x01011012 }, /* rear */
6647 { 0x17, 0x01016011 }, /* clfe */
6648 { }
6649};
6650
6651static const struct alc_pincfg *alc882_pin_fixes[] = {
6652 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6653};
6654
6655static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6656 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6657 {}
6658};
6659
6660/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006661 * BIOS auto configuration
6662 */
6663static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6664 hda_nid_t nid, int pin_type,
6665 int dac_idx)
6666{
6667 /* set as output */
6668 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006669 int idx;
6670
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006671 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006672 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6673 idx = 4;
6674 else
6675 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006676 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6677
6678}
6679
6680static void alc882_auto_init_multi_out(struct hda_codec *codec)
6681{
6682 struct alc_spec *spec = codec->spec;
6683 int i;
6684
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006685 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006686 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006687 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006688 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006689 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006690 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006691 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006692 }
6693}
6694
6695static void alc882_auto_init_hp_out(struct hda_codec *codec)
6696{
6697 struct alc_spec *spec = codec->spec;
6698 hda_nid_t pin;
6699
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006700 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006701 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006702 /* use dac 0 */
6703 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006704 pin = spec->autocfg.speaker_pins[0];
6705 if (pin)
6706 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006707}
6708
6709#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6710#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6711
6712static void alc882_auto_init_analog_input(struct hda_codec *codec)
6713{
6714 struct alc_spec *spec = codec->spec;
6715 int i;
6716
6717 for (i = 0; i < AUTO_PIN_LAST; i++) {
6718 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006719 unsigned int vref;
6720 if (!nid)
6721 continue;
6722 vref = PIN_IN;
6723 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006724 unsigned int pincap;
6725 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6726 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006727 AC_PINCAP_VREF_80)
6728 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006729 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006730 snd_hda_codec_write(codec, nid, 0,
6731 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6732 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6733 snd_hda_codec_write(codec, nid, 0,
6734 AC_VERB_SET_AMP_GAIN_MUTE,
6735 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006736 }
6737}
6738
Takashi Iwaif511b012008-08-15 16:46:42 +02006739static void alc882_auto_init_input_src(struct hda_codec *codec)
6740{
6741 struct alc_spec *spec = codec->spec;
6742 const struct hda_input_mux *imux = spec->input_mux;
6743 int c;
6744
6745 for (c = 0; c < spec->num_adc_nids; c++) {
6746 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6747 hda_nid_t nid = spec->capsrc_nids[c];
6748 int conns, mute, idx, item;
6749
6750 conns = snd_hda_get_connections(codec, nid, conn_list,
6751 ARRAY_SIZE(conn_list));
6752 if (conns < 0)
6753 continue;
6754 for (idx = 0; idx < conns; idx++) {
6755 /* if the current connection is the selected one,
6756 * unmute it as default - otherwise mute it
6757 */
6758 mute = AMP_IN_MUTE(idx);
6759 for (item = 0; item < imux->num_items; item++) {
6760 if (imux->items[item].index == idx) {
6761 if (spec->cur_mux[c] == item)
6762 mute = AMP_IN_UNMUTE(idx);
6763 break;
6764 }
6765 }
6766 snd_hda_codec_write(codec, nid, 0,
6767 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6768 }
6769 }
6770}
6771
Takashi Iwai776e1842007-08-29 15:07:11 +02006772/* add mic boosts if needed */
6773static int alc_auto_add_mic_boost(struct hda_codec *codec)
6774{
6775 struct alc_spec *spec = codec->spec;
6776 int err;
6777 hda_nid_t nid;
6778
6779 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006780 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006781 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6782 "Mic Boost",
6783 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6784 if (err < 0)
6785 return err;
6786 }
6787 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006788 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006789 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6790 "Front Mic Boost",
6791 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6792 if (err < 0)
6793 return err;
6794 }
6795 return 0;
6796}
6797
Kailang Yangdf694da2005-12-05 19:42:22 +01006798/* almost identical with ALC880 parser... */
6799static int alc882_parse_auto_config(struct hda_codec *codec)
6800{
6801 struct alc_spec *spec = codec->spec;
6802 int err = alc880_parse_auto_config(codec);
6803
6804 if (err < 0)
6805 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006806 else if (!err)
6807 return 0; /* no config found */
6808
6809 err = alc_auto_add_mic_boost(codec);
6810 if (err < 0)
6811 return err;
6812
6813 /* hack - override the init verbs */
6814 spec->init_verbs[0] = alc882_auto_init_verbs;
6815
6816 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006817}
6818
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006819/* additional initialization for auto-configuration model */
6820static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006821{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006822 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006823 alc882_auto_init_multi_out(codec);
6824 alc882_auto_init_hp_out(codec);
6825 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006826 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006827 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006828 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006829}
6830
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006831static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6832
Linus Torvalds1da177e2005-04-16 15:20:36 -07006833static int patch_alc882(struct hda_codec *codec)
6834{
6835 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006836 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006837
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006838 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006839 if (spec == NULL)
6840 return -ENOMEM;
6841
Linus Torvalds1da177e2005-04-16 15:20:36 -07006842 codec->spec = spec;
6843
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006844 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6845 alc882_models,
6846 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006847
Kailang Yangdf694da2005-12-05 19:42:22 +01006848 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006849 /* Pick up systems that don't supply PCI SSID */
6850 switch (codec->subsystem_id) {
6851 case 0x106b0c00: /* Mac Pro */
6852 board_config = ALC885_MACPRO;
6853 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006854 case 0x106b1000: /* iMac 24 */
Peter Korsgaardf3911c52008-09-27 09:13:45 +02006855 case 0x106b2800: /* AppleTV */
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006856 board_config = ALC885_IMAC24;
6857 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006858 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
David Woodhouse9c95c432008-09-18 13:37:13 -07006859 case 0x106b00a4: /* MacbookPro4,1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006860 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006861 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006862 board_config = ALC885_MBP3;
6863 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006864 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006865 /* ALC889A is handled better as ALC888-compatible */
Clive Messer669faba2008-09-30 15:49:13 +02006866 if (codec->revision_id == 0x100101 ||
6867 codec->revision_id == 0x100103) {
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006868 alc_free(codec);
6869 return patch_alc883(codec);
6870 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006871 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6872 "trying auto-probe from BIOS...\n");
6873 board_config = ALC882_AUTO;
6874 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006875 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006876
Takashi Iwaif95474e2007-07-10 00:47:43 +02006877 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6878
Kailang Yangdf694da2005-12-05 19:42:22 +01006879 if (board_config == ALC882_AUTO) {
6880 /* automatic parse from the BIOS config */
6881 err = alc882_parse_auto_config(codec);
6882 if (err < 0) {
6883 alc_free(codec);
6884 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006885 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006886 printk(KERN_INFO
6887 "hda_codec: Cannot set up configuration "
6888 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006889 board_config = ALC882_3ST_DIG;
6890 }
6891 }
6892
6893 if (board_config != ALC882_AUTO)
6894 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006895
Kailang Yang2f893282008-05-27 12:14:47 +02006896 if (codec->vendor_id == 0x10ec0885) {
6897 spec->stream_name_analog = "ALC885 Analog";
6898 spec->stream_name_digital = "ALC885 Digital";
6899 } else {
6900 spec->stream_name_analog = "ALC882 Analog";
6901 spec->stream_name_digital = "ALC882 Digital";
6902 }
6903
Kailang Yangdf694da2005-12-05 19:42:22 +01006904 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6905 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006906 /* FIXME: setup DAC5 */
6907 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6908 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006909
Kailang Yangdf694da2005-12-05 19:42:22 +01006910 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6911 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006912
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01006913 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006914 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006915 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006916 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006917 /* get type */
6918 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006919 if (wcap != AC_WID_AUD_IN) {
6920 spec->adc_nids = alc882_adc_nids_alt;
6921 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006922 spec->capsrc_nids = alc882_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +01006923 } else {
6924 spec->adc_nids = alc882_adc_nids;
6925 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006926 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006927 }
6928 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006929 set_capture_mixer(spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006930
Takashi Iwai2134ea42008-01-10 16:53:55 +01006931 spec->vmaster_nid = 0x0c;
6932
Linus Torvalds1da177e2005-04-16 15:20:36 -07006933 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006934 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006935 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006936#ifdef CONFIG_SND_HDA_POWER_SAVE
6937 if (!spec->loopback.amplist)
6938 spec->loopback.amplist = alc882_loopbacks;
6939#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006940
6941 return 0;
6942}
6943
6944/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006945 * ALC883 support
6946 *
6947 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6948 * configuration. Each pin widget can choose any input DACs and a mixer.
6949 * Each ADC is connected from a mixer of all inputs. This makes possible
6950 * 6-channel independent captures.
6951 *
6952 * In addition, an independent DAC for the multi-playback (not used in this
6953 * driver yet).
6954 */
6955#define ALC883_DIGOUT_NID 0x06
6956#define ALC883_DIGIN_NID 0x0a
6957
Wu Fengguang3ab90932008-11-17 09:51:09 +01006958#define ALC1200_DIGOUT_NID 0x10
6959
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006960static hda_nid_t alc883_dac_nids[4] = {
6961 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006962 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006963};
6964
6965static hda_nid_t alc883_adc_nids[2] = {
6966 /* ADC1-2 */
6967 0x08, 0x09,
6968};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006969
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006970static hda_nid_t alc883_adc_nids_alt[1] = {
6971 /* ADC1 */
6972 0x08,
6973};
6974
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08006975static hda_nid_t alc883_adc_nids_rev[2] = {
6976 /* ADC2-1 */
6977 0x09, 0x08
6978};
6979
Takashi Iwaie1406342008-02-11 18:32:32 +01006980static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6981
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08006982static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
6983
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006984/* input MUX */
6985/* FIXME: should be a matrix-type input source selection */
6986
6987static struct hda_input_mux alc883_capture_source = {
6988 .num_items = 4,
6989 .items = {
6990 { "Mic", 0x0 },
6991 { "Front Mic", 0x1 },
6992 { "Line", 0x2 },
6993 { "CD", 0x4 },
6994 },
6995};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006996
Jiang zhe17bba1b2008-06-04 12:11:07 +02006997static struct hda_input_mux alc883_3stack_6ch_intel = {
6998 .num_items = 4,
6999 .items = {
7000 { "Mic", 0x1 },
7001 { "Front Mic", 0x0 },
7002 { "Line", 0x2 },
7003 { "CD", 0x4 },
7004 },
7005};
7006
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007007static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7008 .num_items = 2,
7009 .items = {
7010 { "Mic", 0x1 },
7011 { "Line", 0x2 },
7012 },
7013};
7014
Kailang Yang272a5272007-05-14 11:00:38 +02007015static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7016 .num_items = 4,
7017 .items = {
7018 { "Mic", 0x0 },
7019 { "iMic", 0x1 },
7020 { "Line", 0x2 },
7021 { "CD", 0x4 },
7022 },
7023};
7024
Jiang zhefb97dc62008-03-06 11:07:11 +01007025static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7026 .num_items = 2,
7027 .items = {
7028 { "Mic", 0x0 },
7029 { "Int Mic", 0x1 },
7030 },
7031};
7032
Kailang Yange2757d52008-08-26 13:17:46 +02007033static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7034 .num_items = 3,
7035 .items = {
7036 { "Mic", 0x0 },
7037 { "Front Mic", 0x1 },
7038 { "Line", 0x4 },
7039 },
7040};
7041
7042static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7043 .num_items = 2,
7044 .items = {
7045 { "Mic", 0x0 },
7046 { "Line", 0x2 },
7047 },
7048};
7049
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007050/*
7051 * 2ch mode
7052 */
7053static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7054 { 2, NULL }
7055};
7056
7057/*
7058 * 2ch mode
7059 */
7060static struct hda_verb alc883_3ST_ch2_init[] = {
7061 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7062 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7063 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7064 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7065 { } /* end */
7066};
7067
7068/*
Tobin Davisb2011312007-09-17 12:45:11 +02007069 * 4ch mode
7070 */
7071static struct hda_verb alc883_3ST_ch4_init[] = {
7072 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7073 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7074 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7075 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7076 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7077 { } /* end */
7078};
7079
7080/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007081 * 6ch mode
7082 */
7083static struct hda_verb alc883_3ST_ch6_init[] = {
7084 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7085 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7086 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7087 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7088 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7089 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7090 { } /* end */
7091};
7092
Tobin Davisb2011312007-09-17 12:45:11 +02007093static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007094 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02007095 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007096 { 6, alc883_3ST_ch6_init },
7097};
7098
7099/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02007100 * 2ch mode
7101 */
7102static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7103 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7104 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7105 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7106 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7107 { } /* end */
7108};
7109
7110/*
7111 * 4ch mode
7112 */
7113static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7114 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7115 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7116 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7117 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7118 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7119 { } /* end */
7120};
7121
7122/*
7123 * 6ch mode
7124 */
7125static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7126 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7127 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7128 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7129 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7130 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7131 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7132 { } /* end */
7133};
7134
7135static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7136 { 2, alc883_3ST_ch2_intel_init },
7137 { 4, alc883_3ST_ch4_intel_init },
7138 { 6, alc883_3ST_ch6_intel_init },
7139};
7140
7141/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007142 * 6ch mode
7143 */
7144static struct hda_verb alc883_sixstack_ch6_init[] = {
7145 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7146 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7147 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7148 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7149 { } /* end */
7150};
7151
7152/*
7153 * 8ch mode
7154 */
7155static struct hda_verb alc883_sixstack_ch8_init[] = {
7156 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7157 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7158 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7159 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7160 { } /* end */
7161};
7162
7163static struct hda_channel_mode alc883_sixstack_modes[2] = {
7164 { 6, alc883_sixstack_ch6_init },
7165 { 8, alc883_sixstack_ch8_init },
7166};
7167
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007168static struct hda_verb alc883_medion_eapd_verbs[] = {
7169 /* eanable EAPD on medion laptop */
7170 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7171 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
7172 { }
7173};
7174
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007175/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7176 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7177 */
7178
7179static struct snd_kcontrol_new alc883_base_mixer[] = {
7180 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7181 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7182 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7183 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7184 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7185 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7186 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7187 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7188 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7189 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7190 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7191 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7192 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7193 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7194 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7195 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007196 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007197 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7198 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007199 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007200 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7201 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7202 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007203 { } /* end */
7204};
7205
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007206static struct snd_kcontrol_new alc883_mitac_mixer[] = {
7207 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7208 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7209 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7210 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7211 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7212 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7213 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7214 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7215 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7216 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7217 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7218 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7219 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007220 { } /* end */
7221};
7222
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007223static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007224 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7225 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7226 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7227 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7228 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7229 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7230 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7231 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7232 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7233 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01007234 { } /* end */
7235};
7236
Jiang zhefb97dc62008-03-06 11:07:11 +01007237static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7238 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7239 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7240 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7241 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7242 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7243 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7245 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7246 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7247 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01007248 { } /* end */
7249};
7250
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007251static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7252 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7253 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7254 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7255 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7256 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7257 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7258 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7259 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007260 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007261 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7262 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007263 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007264 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7265 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7266 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007267 { } /* end */
7268};
7269
7270static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7271 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7272 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7273 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7274 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7275 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7276 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7277 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7278 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7279 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7280 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7281 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7282 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7283 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7284 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007285 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007286 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7287 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007288 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007289 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7290 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7291 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007292 { } /* end */
7293};
7294
Jiang zhe17bba1b2008-06-04 12:11:07 +02007295static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7296 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7297 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7298 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7299 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7300 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7301 HDA_OUTPUT),
7302 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7303 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7304 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7305 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7306 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7307 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7308 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7309 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7310 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7311 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7312 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7313 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7314 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7315 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7316 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7317 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02007318 { } /* end */
7319};
7320
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007321static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007322 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007323 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007324 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007325 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007326 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7327 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007328 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7329 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007330 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7331 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7332 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7333 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7334 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7335 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007336 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007337 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7338 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007339 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007340 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7341 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7342 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007343 { } /* end */
7344};
7345
Kailang Yangccc656c2006-10-17 12:32:26 +02007346static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7347 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7348 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7349 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7350 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7351 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7352 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7353 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7354 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7355 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7356 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7357 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7358 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7359 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7360 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007361 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007362 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007363 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007364};
Kailang Yangccc656c2006-10-17 12:32:26 +02007365
7366static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7367 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7368 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7369 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7370 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7371 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7372 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007373 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007374 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007375 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7376 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7377 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007378 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007379};
Kailang Yangccc656c2006-10-17 12:32:26 +02007380
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007381static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7382 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7383 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007384 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7385 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007386 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7387 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7388 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7389 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007390 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007391};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007392
Kailang Yang272a5272007-05-14 11:00:38 +02007393static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7394 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7395 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7396 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7397 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7398 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7399 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7400 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7401 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7402 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007403 { } /* end */
7404};
7405
7406static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7407 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7408 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7409 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7410 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7411 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7412 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7413 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7414 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7415 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007416 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007417};
Kailang Yang272a5272007-05-14 11:00:38 +02007418
Tobin Davis2880a862007-08-07 11:50:26 +02007419static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007420 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7421 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007422 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007423 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7424 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007425 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7426 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7427 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007428 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007429};
Tobin Davis2880a862007-08-07 11:50:26 +02007430
Kailang Yange2757d52008-08-26 13:17:46 +02007431static struct snd_kcontrol_new alc888_lenovo_sky_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", 0x0e, 0x0, HDA_OUTPUT),
7435 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
7436 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
7437 0x0d, 1, 0x0, HDA_OUTPUT),
7438 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
7439 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
7440 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
7441 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
7442 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
7443 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7444 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
7445 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7446 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7447 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7448 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7449 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7450 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7451 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7452 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7453 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
7454 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02007455 { } /* end */
7456};
7457
7458static struct hda_bind_ctls alc883_bind_cap_vol = {
7459 .ops = &snd_hda_bind_vol,
7460 .values = {
7461 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7462 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7463 0
7464 },
7465};
7466
7467static struct hda_bind_ctls alc883_bind_cap_switch = {
7468 .ops = &snd_hda_bind_sw,
7469 .values = {
7470 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
7471 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
7472 0
7473 },
7474};
7475
7476static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
7477 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7478 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7479 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7480 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7481 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7482 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7483 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7484 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007485 { } /* end */
7486};
7487
7488static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02007489 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
7490 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
7491 {
7492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7493 /* .name = "Capture Source", */
7494 .name = "Input Source",
7495 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01007496 .info = alc_mux_enum_info,
7497 .get = alc_mux_enum_get,
7498 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02007499 },
7500 { } /* end */
7501};
7502
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007503static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7504 {
7505 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7506 .name = "Channel Mode",
7507 .info = alc_ch_mode_info,
7508 .get = alc_ch_mode_get,
7509 .put = alc_ch_mode_put,
7510 },
7511 { } /* end */
7512};
7513
7514static struct hda_verb alc883_init_verbs[] = {
7515 /* ADC1: mute amp left and right */
Kailang Yange2757d52008-08-26 13:17:46 +02007516 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007517 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7518 /* ADC2: mute amp left and right */
7519 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7520 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7521 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7522 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7524 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7525 /* Rear mixer */
7526 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7527 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7528 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7529 /* CLFE mixer */
7530 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7531 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7532 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7533 /* Side mixer */
7534 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7535 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7536 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7537
Takashi Iwaicb53c622007-08-10 17:21:45 +02007538 /* mute analog input loopbacks */
7539 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7540 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7541 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007544
7545 /* Front Pin: output 0 (0x0c) */
7546 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7547 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7548 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7549 /* Rear Pin: output 1 (0x0d) */
7550 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7551 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7552 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7553 /* CLFE Pin: output 2 (0x0e) */
7554 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7555 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7556 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7557 /* Side Pin: output 3 (0x0f) */
7558 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7559 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7560 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7561 /* Mic (rear) pin: input vref at 80% */
7562 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7563 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7564 /* Front Mic pin: input vref at 80% */
7565 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7566 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7567 /* Line In pin: input */
7568 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7569 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7570 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7571 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7572 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7573 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7574 /* CD pin widget for input */
7575 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7576
7577 /* FIXME: use matrix-type input source selection */
7578 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7579 /* Input mixer2 */
7580 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007581 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7582 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7583 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007584 /* Input mixer3 */
7585 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yange2757d52008-08-26 13:17:46 +02007586 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7587 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7588 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007589 { }
7590};
7591
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007592/* toggle speaker-output according to the hp-jack state */
7593static void alc883_mitac_hp_automute(struct hda_codec *codec)
7594{
7595 unsigned int present;
7596
7597 present = snd_hda_codec_read(codec, 0x15, 0,
7598 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7599 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7600 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7601 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7602 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7603}
7604
7605/* auto-toggle front mic */
7606/*
7607static void alc883_mitac_mic_automute(struct hda_codec *codec)
7608{
7609 unsigned int present;
7610 unsigned char bits;
7611
7612 present = snd_hda_codec_read(codec, 0x18, 0,
7613 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7614 bits = present ? HDA_AMP_MUTE : 0;
7615 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7616}
7617*/
7618
7619static void alc883_mitac_automute(struct hda_codec *codec)
7620{
7621 alc883_mitac_hp_automute(codec);
7622 /* alc883_mitac_mic_automute(codec); */
7623}
7624
7625static void alc883_mitac_unsol_event(struct hda_codec *codec,
7626 unsigned int res)
7627{
7628 switch (res >> 26) {
7629 case ALC880_HP_EVENT:
7630 alc883_mitac_hp_automute(codec);
7631 break;
7632 case ALC880_MIC_EVENT:
7633 /* alc883_mitac_mic_automute(codec); */
7634 break;
7635 }
7636}
7637
7638static struct hda_verb alc883_mitac_verbs[] = {
7639 /* HP */
7640 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7641 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7642 /* Subwoofer */
7643 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7644 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7645
7646 /* enable unsolicited event */
7647 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7648 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7649
7650 { } /* end */
7651};
7652
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007653static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007654 /* HP */
7655 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7656 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7657 /* Int speaker */
7658 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7660
7661 /* enable unsolicited event */
7662 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007663 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007664
7665 { } /* end */
7666};
7667
Jiang zhefb97dc62008-03-06 11:07:11 +01007668static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7669 /* HP */
7670 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7671 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7672 /* Subwoofer */
7673 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7674 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7675
7676 /* enable unsolicited event */
7677 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7678
7679 { } /* end */
7680};
7681
Kailang Yangccc656c2006-10-17 12:32:26 +02007682static struct hda_verb alc883_tagra_verbs[] = {
7683 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7684 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7685
7686 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7687 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007688
Kailang Yangccc656c2006-10-17 12:32:26 +02007689 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7690 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7691 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7692
7693 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007694 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7695 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7696 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007697
7698 { } /* end */
7699};
7700
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007701static struct hda_verb alc883_lenovo_101e_verbs[] = {
7702 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7703 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7704 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7705 { } /* end */
7706};
7707
Kailang Yang272a5272007-05-14 11:00:38 +02007708static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7709 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7710 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7711 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7712 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7713 { } /* end */
7714};
7715
7716static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7717 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7718 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7719 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7720 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7721 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7722 { } /* end */
7723};
7724
Kailang Yang189609a2007-08-20 11:31:23 +02007725static struct hda_verb alc883_haier_w66_verbs[] = {
7726 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7727 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7728
7729 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7730
7731 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7732 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7733 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7734 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7735 { } /* end */
7736};
7737
Kailang Yange2757d52008-08-26 13:17:46 +02007738static struct hda_verb alc888_lenovo_sky_verbs[] = {
7739 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7740 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7741 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7742 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7743 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7744 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7745 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
7746 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7747 { } /* end */
7748};
7749
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007750static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007751 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007752 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7753 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007754 { }
7755};
7756
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007757static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007758 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7759 { }
7760};
7761
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007762static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007763 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7764 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7765 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7766 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7767 { }
7768};
7769
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007770static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007771 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7772 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7773 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7774 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7775 { }
7776};
7777
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007778static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7779 { 2, alc888_3st_hp_2ch_init },
7780 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007781};
7782
Kailang Yang272a5272007-05-14 11:00:38 +02007783/* toggle front-jack and RCA according to the hp-jack state */
7784static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7785{
7786 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007787
Kailang Yang272a5272007-05-14 11:00:38 +02007788 present = snd_hda_codec_read(codec, 0x1b, 0,
7789 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007790 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7791 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7792 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7793 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007794}
7795
7796/* toggle RCA according to the front-jack state */
7797static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7798{
7799 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007800
Kailang Yang272a5272007-05-14 11:00:38 +02007801 present = snd_hda_codec_read(codec, 0x14, 0,
7802 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007803 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7804 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007805}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007806
Kailang Yang272a5272007-05-14 11:00:38 +02007807static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7808 unsigned int res)
7809{
7810 if ((res >> 26) == ALC880_HP_EVENT)
7811 alc888_lenovo_ms7195_front_automute(codec);
7812 if ((res >> 26) == ALC880_FRONT_EVENT)
7813 alc888_lenovo_ms7195_rca_automute(codec);
7814}
7815
7816static struct hda_verb alc883_medion_md2_verbs[] = {
7817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7819
7820 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7821
7822 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7823 { } /* end */
7824};
7825
7826/* toggle speaker-output according to the hp-jack state */
7827static void alc883_medion_md2_automute(struct hda_codec *codec)
7828{
7829 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007830
Kailang Yang272a5272007-05-14 11:00:38 +02007831 present = snd_hda_codec_read(codec, 0x14, 0,
7832 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007833 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7834 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007835}
7836
7837static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7838 unsigned int res)
7839{
7840 if ((res >> 26) == ALC880_HP_EVENT)
7841 alc883_medion_md2_automute(codec);
7842}
7843
Kailang Yangccc656c2006-10-17 12:32:26 +02007844/* toggle speaker-output according to the hp-jack state */
7845static void alc883_tagra_automute(struct hda_codec *codec)
7846{
7847 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007848 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007849
7850 present = snd_hda_codec_read(codec, 0x14, 0,
7851 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007852 bits = present ? HDA_AMP_MUTE : 0;
7853 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7854 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007855 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7856 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007857}
7858
7859static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7860{
7861 if ((res >> 26) == ALC880_HP_EVENT)
7862 alc883_tagra_automute(codec);
7863}
7864
Jiang zhe368c7a92008-03-04 11:20:33 +01007865/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007866static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007867{
7868 unsigned int present;
7869 unsigned char bits;
7870
7871 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7872 & AC_PINSENSE_PRESENCE;
7873 bits = present ? HDA_AMP_MUTE : 0;
7874 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7875 HDA_AMP_MUTE, bits);
7876}
7877
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007878static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7879{
7880 unsigned int present;
7881
7882 present = snd_hda_codec_read(codec, 0x18, 0,
7883 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7884 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7885 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7886}
7887
7888static void alc883_clevo_m720_automute(struct hda_codec *codec)
7889{
7890 alc883_clevo_m720_hp_automute(codec);
7891 alc883_clevo_m720_mic_automute(codec);
7892}
7893
7894static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007895 unsigned int res)
7896{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007897 switch (res >> 26) {
7898 case ALC880_HP_EVENT:
7899 alc883_clevo_m720_hp_automute(codec);
7900 break;
7901 case ALC880_MIC_EVENT:
7902 alc883_clevo_m720_mic_automute(codec);
7903 break;
7904 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007905}
7906
Jiang zhefb97dc62008-03-06 11:07:11 +01007907/* toggle speaker-output according to the hp-jack state */
7908static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7909{
7910 unsigned int present;
7911 unsigned char bits;
7912
7913 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7914 & AC_PINSENSE_PRESENCE;
7915 bits = present ? HDA_AMP_MUTE : 0;
7916 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7917 HDA_AMP_MUTE, bits);
7918}
7919
7920static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7921 unsigned int res)
7922{
7923 if ((res >> 26) == ALC880_HP_EVENT)
7924 alc883_2ch_fujitsu_pi2515_automute(codec);
7925}
7926
Kailang Yang189609a2007-08-20 11:31:23 +02007927static void alc883_haier_w66_automute(struct hda_codec *codec)
7928{
7929 unsigned int present;
7930 unsigned char bits;
7931
7932 present = snd_hda_codec_read(codec, 0x1b, 0,
7933 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7934 bits = present ? 0x80 : 0;
7935 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7936 0x80, bits);
7937}
7938
7939static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7940 unsigned int res)
7941{
7942 if ((res >> 26) == ALC880_HP_EVENT)
7943 alc883_haier_w66_automute(codec);
7944}
7945
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007946static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7947{
7948 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007949 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007950
7951 present = snd_hda_codec_read(codec, 0x14, 0,
7952 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007953 bits = present ? HDA_AMP_MUTE : 0;
7954 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7955 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007956}
7957
7958static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7959{
7960 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007961 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007962
7963 present = snd_hda_codec_read(codec, 0x1b, 0,
7964 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007965 bits = present ? HDA_AMP_MUTE : 0;
7966 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7967 HDA_AMP_MUTE, bits);
7968 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7969 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007970}
7971
7972static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7973 unsigned int res)
7974{
7975 if ((res >> 26) == ALC880_HP_EVENT)
7976 alc883_lenovo_101e_all_automute(codec);
7977 if ((res >> 26) == ALC880_FRONT_EVENT)
7978 alc883_lenovo_101e_ispeaker_automute(codec);
7979}
7980
Takashi Iwai676a9b52007-08-16 15:23:35 +02007981/* toggle speaker-output according to the hp-jack state */
7982static void alc883_acer_aspire_automute(struct hda_codec *codec)
7983{
7984 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007985
Takashi Iwai676a9b52007-08-16 15:23:35 +02007986 present = snd_hda_codec_read(codec, 0x14, 0,
7987 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7988 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7989 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7990 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7991 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7992}
7993
7994static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7995 unsigned int res)
7996{
7997 if ((res >> 26) == ALC880_HP_EVENT)
7998 alc883_acer_aspire_automute(codec);
7999}
8000
Kailang Yangd1a991a2007-08-15 16:21:59 +02008001static struct hda_verb alc883_acer_eapd_verbs[] = {
8002 /* HP Pin: output 0 (0x0c) */
8003 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8004 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8005 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8006 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02008007 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8008 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008009 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008010 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
8011 /* eanable EAPD on medion laptop */
8012 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8013 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02008014 /* enable unsolicited event */
8015 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02008016 { }
8017};
8018
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008019static void alc888_6st_dell_front_automute(struct hda_codec *codec)
8020{
8021 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02008022
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008023 present = snd_hda_codec_read(codec, 0x1b, 0,
8024 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8025 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8026 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8027 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8028 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8029 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8030 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8031 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8032 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
8033}
8034
8035static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
8036 unsigned int res)
8037{
8038 switch (res >> 26) {
8039 case ALC880_HP_EVENT:
8040 printk("hp_event\n");
8041 alc888_6st_dell_front_automute(codec);
8042 break;
8043 }
8044}
8045
Kailang Yange2757d52008-08-26 13:17:46 +02008046static void alc888_lenovo_sky_front_automute(struct hda_codec *codec)
8047{
8048 unsigned int mute;
8049 unsigned int present;
8050
8051 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
8052 present = snd_hda_codec_read(codec, 0x1b, 0,
8053 AC_VERB_GET_PIN_SENSE, 0);
8054 present = (present & 0x80000000) != 0;
8055 if (present) {
8056 /* mute internal speaker */
8057 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8058 HDA_AMP_MUTE, HDA_AMP_MUTE);
8059 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8060 HDA_AMP_MUTE, HDA_AMP_MUTE);
8061 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8062 HDA_AMP_MUTE, HDA_AMP_MUTE);
8063 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8064 HDA_AMP_MUTE, HDA_AMP_MUTE);
8065 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8066 HDA_AMP_MUTE, HDA_AMP_MUTE);
8067 } else {
8068 /* unmute internal speaker if necessary */
8069 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
8070 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8071 HDA_AMP_MUTE, mute);
8072 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
8073 HDA_AMP_MUTE, mute);
8074 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
8075 HDA_AMP_MUTE, mute);
8076 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
8077 HDA_AMP_MUTE, mute);
8078 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
8079 HDA_AMP_MUTE, mute);
8080 }
8081}
8082
8083static void alc883_lenovo_sky_unsol_event(struct hda_codec *codec,
8084 unsigned int res)
8085{
8086 if ((res >> 26) == ALC880_HP_EVENT)
8087 alc888_lenovo_sky_front_automute(codec);
8088}
8089
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008090/*
8091 * generic initialization of ADC, input mixers and output mixers
8092 */
8093static struct hda_verb alc883_auto_init_verbs[] = {
8094 /*
8095 * Unmute ADC0-2 and set the default input to mic-in
8096 */
8097 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8098 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8099 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8100 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8101
Takashi Iwaicb53c622007-08-10 17:21:45 +02008102 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008103 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008104 * Note: PASD motherboards uses the Line In 2 as the input for
8105 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008106 */
8107 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008108 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8109 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8110 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8111 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008113
8114 /*
8115 * Set up output mixers (0x0c - 0x0f)
8116 */
8117 /* set vol=0 to output mixers */
8118 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8119 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8121 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8122 /* set up input amps for analog loopback */
8123 /* Amp Indices: DAC = 0, mixer = 1 */
8124 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8125 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8126 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8127 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8128 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8129 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8130 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8131 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8132 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8133 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8134
8135 /* FIXME: use matrix-type input source selection */
8136 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8137 /* Input mixer1 */
8138 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8139 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8140 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008141 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008142 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
8143 /* Input mixer2 */
8144 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8145 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8146 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008147 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01008148 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008149
8150 { }
8151};
8152
Kailang Yange2757d52008-08-26 13:17:46 +02008153static struct hda_verb alc888_asus_m90v_verbs[] = {
8154 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8155 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8156 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8157 /* enable unsolicited event */
8158 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8159 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
8160 { } /* end */
8161};
8162
8163static void alc883_nb_mic_automute(struct hda_codec *codec)
8164{
8165 unsigned int present;
8166
8167 present = snd_hda_codec_read(codec, 0x18, 0,
8168 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
8169 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8170 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
8171 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
8172 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
8173}
8174
8175static void alc883_M90V_speaker_automute(struct hda_codec *codec)
8176{
8177 unsigned int present;
8178 unsigned char bits;
8179
8180 present = snd_hda_codec_read(codec, 0x1b, 0,
8181 AC_VERB_GET_PIN_SENSE, 0)
8182 & AC_PINSENSE_PRESENCE;
8183 bits = present ? 0 : PIN_OUT;
8184 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8185 bits);
8186 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8187 bits);
8188 snd_hda_codec_write(codec, 0x16, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8189 bits);
8190}
8191
8192static void alc883_mode2_unsol_event(struct hda_codec *codec,
8193 unsigned int res)
8194{
8195 switch (res >> 26) {
8196 case ALC880_HP_EVENT:
8197 alc883_M90V_speaker_automute(codec);
8198 break;
8199 case ALC880_MIC_EVENT:
8200 alc883_nb_mic_automute(codec);
8201 break;
8202 }
8203}
8204
8205static void alc883_mode2_inithook(struct hda_codec *codec)
8206{
8207 alc883_M90V_speaker_automute(codec);
8208 alc883_nb_mic_automute(codec);
8209}
8210
8211static struct hda_verb alc888_asus_eee1601_verbs[] = {
8212 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8213 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8214 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8216 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8217 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
8218 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
8219 /* enable unsolicited event */
8220 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8221 { } /* end */
8222};
8223
8224static void alc883_eee1601_speaker_automute(struct hda_codec *codec)
8225{
8226 unsigned int present;
8227 unsigned char bits;
8228
8229 present = snd_hda_codec_read(codec, 0x14, 0,
8230 AC_VERB_GET_PIN_SENSE, 0)
8231 & AC_PINSENSE_PRESENCE;
8232 bits = present ? 0 : PIN_OUT;
8233 snd_hda_codec_write(codec, 0x1b, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
8234 bits);
8235}
8236
8237static void alc883_eee1601_unsol_event(struct hda_codec *codec,
8238 unsigned int res)
8239{
8240 switch (res >> 26) {
8241 case ALC880_HP_EVENT:
8242 alc883_eee1601_speaker_automute(codec);
8243 break;
8244 }
8245}
8246
8247static void alc883_eee1601_inithook(struct hda_codec *codec)
8248{
8249 alc883_eee1601_speaker_automute(codec);
8250}
8251
Takashi Iwaicb53c622007-08-10 17:21:45 +02008252#ifdef CONFIG_SND_HDA_POWER_SAVE
8253#define alc883_loopbacks alc880_loopbacks
8254#endif
8255
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008256/* pcm configuration: identiacal with ALC880 */
8257#define alc883_pcm_analog_playback alc880_pcm_analog_playback
8258#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01008259#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008260#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8261#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8262
8263/*
8264 * configuration and preset
8265 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008266static const char *alc883_models[ALC883_MODEL_LAST] = {
8267 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8268 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8269 [ALC883_3ST_6ch] = "3stack-6ch",
8270 [ALC883_6ST_DIG] = "6stack-dig",
8271 [ALC883_TARGA_DIG] = "targa-dig",
8272 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008273 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008274 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008275 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008276 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008277 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008278 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008279 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008280 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8281 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02008282 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02008283 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008284 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008285 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008286 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008287 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008288 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008289 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Wu Fengguang3ab90932008-11-17 09:51:09 +01008290 [ALC1200_ASUS_P5Q] = "asus-p5q",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008291 [ALC883_AUTO] = "auto",
8292};
8293
8294static struct snd_pci_quirk alc883_cfg_tbl[] = {
8295 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008296 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01008297 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008298 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8299 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008300 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008301 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
8302 ALC888_ACER_ASPIRE_4930G),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008303 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008304 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008305 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008306 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8307 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008308 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Kailang Yanga01c30c2008-10-15 11:14:58 +02008309 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008310 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01008311 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02008312 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Travis Place97ec7102008-05-23 18:31:46 +02008313 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008314 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008315 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8316 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02008317 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008318 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008319 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008320 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8321 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8322 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008323 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008324 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008325 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008326 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8327 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8328 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8329 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8330 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8331 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8332 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8333 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8334 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008335 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8336 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008337 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008338 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008339 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008340 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008341 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008342 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008343 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8344 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008345 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008346 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008347 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008348 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02008349 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008350 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008351 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8352 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02008353 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02008354 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01008355 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008356 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008357 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008358 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8359 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008360 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008361 {}
8362};
8363
8364static struct alc_config_preset alc883_presets[] = {
8365 [ALC883_3ST_2ch_DIG] = {
8366 .mixers = { alc883_3ST_2ch_mixer },
8367 .init_verbs = { alc883_init_verbs },
8368 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8369 .dac_nids = alc883_dac_nids,
8370 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008371 .dig_in_nid = ALC883_DIGIN_NID,
8372 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8373 .channel_mode = alc883_3ST_2ch_modes,
8374 .input_mux = &alc883_capture_source,
8375 },
8376 [ALC883_3ST_6ch_DIG] = {
8377 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8378 .init_verbs = { alc883_init_verbs },
8379 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8380 .dac_nids = alc883_dac_nids,
8381 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008382 .dig_in_nid = ALC883_DIGIN_NID,
8383 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8384 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008385 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008386 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008387 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008388 [ALC883_3ST_6ch] = {
8389 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8390 .init_verbs = { alc883_init_verbs },
8391 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8392 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008393 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8394 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008395 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008396 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008397 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008398 [ALC883_3ST_6ch_INTEL] = {
8399 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8400 .init_verbs = { alc883_init_verbs },
8401 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8402 .dac_nids = alc883_dac_nids,
8403 .dig_out_nid = ALC883_DIGOUT_NID,
8404 .dig_in_nid = ALC883_DIGIN_NID,
8405 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8406 .channel_mode = alc883_3ST_6ch_intel_modes,
8407 .need_dac_fix = 1,
8408 .input_mux = &alc883_3stack_6ch_intel,
8409 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008410 [ALC883_6ST_DIG] = {
8411 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8412 .init_verbs = { alc883_init_verbs },
8413 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8414 .dac_nids = alc883_dac_nids,
8415 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008416 .dig_in_nid = ALC883_DIGIN_NID,
8417 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8418 .channel_mode = alc883_sixstack_modes,
8419 .input_mux = &alc883_capture_source,
8420 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008421 [ALC883_TARGA_DIG] = {
8422 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8423 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8424 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8425 .dac_nids = alc883_dac_nids,
8426 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008427 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8428 .channel_mode = alc883_3ST_6ch_modes,
8429 .need_dac_fix = 1,
8430 .input_mux = &alc883_capture_source,
8431 .unsol_event = alc883_tagra_unsol_event,
8432 .init_hook = alc883_tagra_automute,
8433 },
8434 [ALC883_TARGA_2ch_DIG] = {
8435 .mixers = { alc883_tagra_2ch_mixer},
8436 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8437 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8438 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008439 .adc_nids = alc883_adc_nids_alt,
8440 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangccc656c2006-10-17 12:32:26 +02008441 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008442 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8443 .channel_mode = alc883_3ST_2ch_modes,
8444 .input_mux = &alc883_capture_source,
8445 .unsol_event = alc883_tagra_unsol_event,
8446 .init_hook = alc883_tagra_automute,
8447 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008448 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008449 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008450 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8451 * and the headphone jack. Turn this on and rely on the
8452 * standard mute methods whenever the user wants to turn
8453 * these outputs off.
8454 */
8455 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8456 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8457 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008458 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8459 .channel_mode = alc883_3ST_2ch_modes,
8460 .input_mux = &alc883_capture_source,
8461 },
Tobin Davis2880a862007-08-07 11:50:26 +02008462 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008463 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008464 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008465 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8466 .dac_nids = alc883_dac_nids,
8467 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008468 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8469 .channel_mode = alc883_3ST_2ch_modes,
8470 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008471 .unsol_event = alc883_acer_aspire_unsol_event,
8472 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008473 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08008474 [ALC888_ACER_ASPIRE_4930G] = {
8475 .mixers = { alc888_acer_aspire_4930g_mixer,
8476 alc883_chmode_mixer },
8477 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
8478 alc888_acer_aspire_4930g_verbs },
8479 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8480 .dac_nids = alc883_dac_nids,
8481 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
8482 .adc_nids = alc883_adc_nids_rev,
8483 .capsrc_nids = alc883_capsrc_nids_rev,
8484 .dig_out_nid = ALC883_DIGOUT_NID,
8485 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8486 .channel_mode = alc883_3ST_6ch_modes,
8487 .need_dac_fix = 1,
8488 .num_mux_defs =
8489 ARRAY_SIZE(alc888_acer_aspire_4930g_capture_source),
8490 .input_mux = alc888_acer_aspire_4930g_capture_source,
8491 .unsol_event = alc888_acer_aspire_4930g_unsol_event,
8492 .init_hook = alc888_acer_aspire_4930g_automute,
8493 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008494 [ALC883_MEDION] = {
8495 .mixers = { alc883_fivestack_mixer,
8496 alc883_chmode_mixer },
8497 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008498 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008499 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8500 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008501 .adc_nids = alc883_adc_nids_alt,
8502 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Tobin Davisc07584c2006-10-13 12:32:16 +02008503 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8504 .channel_mode = alc883_sixstack_modes,
8505 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008506 },
Kailang Yang272a5272007-05-14 11:00:38 +02008507 [ALC883_MEDION_MD2] = {
8508 .mixers = { alc883_medion_md2_mixer},
8509 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8510 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8511 .dac_nids = alc883_dac_nids,
8512 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008513 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8514 .channel_mode = alc883_3ST_2ch_modes,
8515 .input_mux = &alc883_capture_source,
8516 .unsol_event = alc883_medion_md2_unsol_event,
8517 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008518 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008519 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008520 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008521 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8522 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8523 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008524 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8525 .channel_mode = alc883_3ST_2ch_modes,
8526 .input_mux = &alc883_capture_source,
8527 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008528 [ALC883_CLEVO_M720] = {
8529 .mixers = { alc883_clevo_m720_mixer },
8530 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008531 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8532 .dac_nids = alc883_dac_nids,
8533 .dig_out_nid = ALC883_DIGOUT_NID,
8534 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8535 .channel_mode = alc883_3ST_2ch_modes,
8536 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008537 .unsol_event = alc883_clevo_m720_unsol_event,
8538 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008539 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008540 [ALC883_LENOVO_101E_2ch] = {
8541 .mixers = { alc883_lenovo_101e_2ch_mixer},
8542 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8543 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8544 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008545 .adc_nids = alc883_adc_nids_alt,
8546 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008547 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8548 .channel_mode = alc883_3ST_2ch_modes,
8549 .input_mux = &alc883_lenovo_101e_capture_source,
8550 .unsol_event = alc883_lenovo_101e_unsol_event,
8551 .init_hook = alc883_lenovo_101e_all_automute,
8552 },
Kailang Yang272a5272007-05-14 11:00:38 +02008553 [ALC883_LENOVO_NB0763] = {
8554 .mixers = { alc883_lenovo_nb0763_mixer },
8555 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8556 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8557 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008558 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8559 .channel_mode = alc883_3ST_2ch_modes,
8560 .need_dac_fix = 1,
8561 .input_mux = &alc883_lenovo_nb0763_capture_source,
8562 .unsol_event = alc883_medion_md2_unsol_event,
8563 .init_hook = alc883_medion_md2_automute,
8564 },
8565 [ALC888_LENOVO_MS7195_DIG] = {
8566 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8567 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8568 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8569 .dac_nids = alc883_dac_nids,
8570 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008571 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8572 .channel_mode = alc883_3ST_6ch_modes,
8573 .need_dac_fix = 1,
8574 .input_mux = &alc883_capture_source,
8575 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8576 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008577 },
8578 [ALC883_HAIER_W66] = {
8579 .mixers = { alc883_tagra_2ch_mixer},
8580 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8581 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8582 .dac_nids = alc883_dac_nids,
8583 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008584 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8585 .channel_mode = alc883_3ST_2ch_modes,
8586 .input_mux = &alc883_capture_source,
8587 .unsol_event = alc883_haier_w66_unsol_event,
8588 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008589 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008590 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008591 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008592 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008593 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8594 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008595 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8596 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008597 .need_dac_fix = 1,
8598 .input_mux = &alc883_capture_source,
8599 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008600 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008601 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008602 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8603 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8604 .dac_nids = alc883_dac_nids,
8605 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008606 .dig_in_nid = ALC883_DIGIN_NID,
8607 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8608 .channel_mode = alc883_sixstack_modes,
8609 .input_mux = &alc883_capture_source,
8610 .unsol_event = alc888_6st_dell_unsol_event,
8611 .init_hook = alc888_6st_dell_front_automute,
8612 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008613 [ALC883_MITAC] = {
8614 .mixers = { alc883_mitac_mixer },
8615 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8616 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8617 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008618 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8619 .channel_mode = alc883_3ST_2ch_modes,
8620 .input_mux = &alc883_capture_source,
8621 .unsol_event = alc883_mitac_unsol_event,
8622 .init_hook = alc883_mitac_automute,
8623 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008624 [ALC883_FUJITSU_PI2515] = {
8625 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8626 .init_verbs = { alc883_init_verbs,
8627 alc883_2ch_fujitsu_pi2515_verbs},
8628 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8629 .dac_nids = alc883_dac_nids,
8630 .dig_out_nid = ALC883_DIGOUT_NID,
8631 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8632 .channel_mode = alc883_3ST_2ch_modes,
8633 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8634 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8635 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8636 },
Kailang Yange2757d52008-08-26 13:17:46 +02008637 [ALC888_LENOVO_SKY] = {
8638 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
8639 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
8640 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8641 .dac_nids = alc883_dac_nids,
8642 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +02008643 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8644 .channel_mode = alc883_sixstack_modes,
8645 .need_dac_fix = 1,
8646 .input_mux = &alc883_lenovo_sky_capture_source,
8647 .unsol_event = alc883_lenovo_sky_unsol_event,
8648 .init_hook = alc888_lenovo_sky_front_automute,
8649 },
8650 [ALC888_ASUS_M90V] = {
8651 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8652 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
8653 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8654 .dac_nids = alc883_dac_nids,
8655 .dig_out_nid = ALC883_DIGOUT_NID,
8656 .dig_in_nid = ALC883_DIGIN_NID,
8657 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8658 .channel_mode = alc883_3ST_6ch_modes,
8659 .need_dac_fix = 1,
8660 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8661 .unsol_event = alc883_mode2_unsol_event,
8662 .init_hook = alc883_mode2_inithook,
8663 },
8664 [ALC888_ASUS_EEE1601] = {
8665 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008666 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +02008667 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
8668 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8669 .dac_nids = alc883_dac_nids,
8670 .dig_out_nid = ALC883_DIGOUT_NID,
8671 .dig_in_nid = ALC883_DIGIN_NID,
8672 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8673 .channel_mode = alc883_3ST_2ch_modes,
8674 .need_dac_fix = 1,
8675 .input_mux = &alc883_asus_eee1601_capture_source,
8676 .unsol_event = alc883_eee1601_unsol_event,
8677 .init_hook = alc883_eee1601_inithook,
8678 },
Wu Fengguang3ab90932008-11-17 09:51:09 +01008679 [ALC1200_ASUS_P5Q] = {
8680 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8681 .init_verbs = { alc883_init_verbs },
8682 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8683 .dac_nids = alc883_dac_nids,
8684 .dig_out_nid = ALC1200_DIGOUT_NID,
8685 .dig_in_nid = ALC883_DIGIN_NID,
8686 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8687 .channel_mode = alc883_sixstack_modes,
8688 .input_mux = &alc883_capture_source,
8689 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008690};
8691
8692
8693/*
8694 * BIOS auto configuration
8695 */
8696static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8697 hda_nid_t nid, int pin_type,
8698 int dac_idx)
8699{
8700 /* set as output */
8701 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008702 int idx;
8703
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008704 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008705 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8706 idx = 4;
8707 else
8708 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008709 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8710
8711}
8712
8713static void alc883_auto_init_multi_out(struct hda_codec *codec)
8714{
8715 struct alc_spec *spec = codec->spec;
8716 int i;
8717
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008718 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008719 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008720 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008721 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008722 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008723 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008724 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008725 }
8726}
8727
8728static void alc883_auto_init_hp_out(struct hda_codec *codec)
8729{
8730 struct alc_spec *spec = codec->spec;
8731 hda_nid_t pin;
8732
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008733 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008734 if (pin) /* connect to front */
8735 /* use dac 0 */
8736 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008737 pin = spec->autocfg.speaker_pins[0];
8738 if (pin)
8739 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008740}
8741
8742#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8743#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8744
8745static void alc883_auto_init_analog_input(struct hda_codec *codec)
8746{
8747 struct alc_spec *spec = codec->spec;
8748 int i;
8749
8750 for (i = 0; i < AUTO_PIN_LAST; i++) {
8751 hda_nid_t nid = spec->autocfg.input_pins[i];
8752 if (alc883_is_input_pin(nid)) {
8753 snd_hda_codec_write(codec, nid, 0,
8754 AC_VERB_SET_PIN_WIDGET_CONTROL,
8755 (i <= AUTO_PIN_FRONT_MIC ?
8756 PIN_VREF80 : PIN_IN));
8757 if (nid != ALC883_PIN_CD_NID)
8758 snd_hda_codec_write(codec, nid, 0,
8759 AC_VERB_SET_AMP_GAIN_MUTE,
8760 AMP_OUT_MUTE);
8761 }
8762 }
8763}
8764
Takashi Iwaif511b012008-08-15 16:46:42 +02008765#define alc883_auto_init_input_src alc882_auto_init_input_src
8766
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008767/* almost identical with ALC880 parser... */
8768static int alc883_parse_auto_config(struct hda_codec *codec)
8769{
8770 struct alc_spec *spec = codec->spec;
8771 int err = alc880_parse_auto_config(codec);
8772
8773 if (err < 0)
8774 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008775 else if (!err)
8776 return 0; /* no config found */
8777
8778 err = alc_auto_add_mic_boost(codec);
8779 if (err < 0)
8780 return err;
8781
8782 /* hack - override the init verbs */
8783 spec->init_verbs[0] = alc883_auto_init_verbs;
Takashi Iwai776e1842007-08-29 15:07:11 +02008784
8785 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008786}
8787
8788/* additional initialization for auto-configuration model */
8789static void alc883_auto_init(struct hda_codec *codec)
8790{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008791 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008792 alc883_auto_init_multi_out(codec);
8793 alc883_auto_init_hp_out(codec);
8794 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008795 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008796 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02008797 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008798}
8799
8800static int patch_alc883(struct hda_codec *codec)
8801{
8802 struct alc_spec *spec;
8803 int err, board_config;
8804
8805 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8806 if (spec == NULL)
8807 return -ENOMEM;
8808
8809 codec->spec = spec;
8810
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008811 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8812
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008813 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8814 alc883_models,
8815 alc883_cfg_tbl);
8816 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008817 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8818 "trying auto-probe from BIOS...\n");
8819 board_config = ALC883_AUTO;
8820 }
8821
8822 if (board_config == ALC883_AUTO) {
8823 /* automatic parse from the BIOS config */
8824 err = alc883_parse_auto_config(codec);
8825 if (err < 0) {
8826 alc_free(codec);
8827 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008828 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008829 printk(KERN_INFO
8830 "hda_codec: Cannot set up configuration "
8831 "from BIOS. Using base mode...\n");
8832 board_config = ALC883_3ST_2ch_DIG;
8833 }
8834 }
8835
8836 if (board_config != ALC883_AUTO)
8837 setup_preset(spec, &alc883_presets[board_config]);
8838
Kailang Yang2f893282008-05-27 12:14:47 +02008839 switch (codec->vendor_id) {
8840 case 0x10ec0888:
Kailang Yang44426082008-10-15 11:18:05 +02008841 if (codec->revision_id == 0x100101) {
8842 spec->stream_name_analog = "ALC1200 Analog";
8843 spec->stream_name_digital = "ALC1200 Digital";
8844 } else {
8845 spec->stream_name_analog = "ALC888 Analog";
8846 spec->stream_name_digital = "ALC888 Digital";
8847 }
Kailang Yang2f893282008-05-27 12:14:47 +02008848 break;
8849 case 0x10ec0889:
8850 spec->stream_name_analog = "ALC889 Analog";
8851 spec->stream_name_digital = "ALC889 Digital";
8852 break;
8853 default:
8854 spec->stream_name_analog = "ALC883 Analog";
8855 spec->stream_name_digital = "ALC883 Digital";
8856 break;
8857 }
8858
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008859 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8860 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008861 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008862
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008863 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8864 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8865
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008866 if (!spec->num_adc_nids) {
8867 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8868 spec->adc_nids = alc883_adc_nids;
8869 }
8870 if (!spec->capsrc_nids)
8871 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01008872 spec->is_mix_capture = 1; /* matrix-style capture */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01008873 if (!spec->cap_mixer)
8874 set_capture_mixer(spec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008875
Takashi Iwai2134ea42008-01-10 16:53:55 +01008876 spec->vmaster_nid = 0x0c;
8877
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008878 codec->patch_ops = alc_patch_ops;
8879 if (board_config == ALC883_AUTO)
8880 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008881
Takashi Iwaicb53c622007-08-10 17:21:45 +02008882#ifdef CONFIG_SND_HDA_POWER_SAVE
8883 if (!spec->loopback.amplist)
8884 spec->loopback.amplist = alc883_loopbacks;
8885#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008886
8887 return 0;
8888}
8889
8890/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008891 * ALC262 support
8892 */
8893
8894#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8895#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8896
8897#define alc262_dac_nids alc260_dac_nids
8898#define alc262_adc_nids alc882_adc_nids
8899#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008900#define alc262_capsrc_nids alc882_capsrc_nids
8901#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008902
8903#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008904#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008905
Kailang Yang4e555fe2008-08-26 13:05:55 +02008906static hda_nid_t alc262_dmic_adc_nids[1] = {
8907 /* ADC0 */
8908 0x09
8909};
8910
8911static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
8912
Kailang Yangdf694da2005-12-05 19:42:22 +01008913static struct snd_kcontrol_new alc262_base_mixer[] = {
8914 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8915 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8916 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8917 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8918 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8919 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8920 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8921 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008922 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008923 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8924 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008925 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008926 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008927 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008928 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8929 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8930 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8931 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008932 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008933};
8934
Kailang Yangccc656c2006-10-17 12:32:26 +02008935static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8936 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8937 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8938 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8939 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8940 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8941 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8943 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008944 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008945 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8946 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008947 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008948 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008949 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008950 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8951 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8952 { } /* end */
8953};
8954
Takashi Iwaice875f02008-01-28 18:17:43 +01008955/* update HP, line and mono-out pins according to the master switch */
8956static void alc262_hp_master_update(struct hda_codec *codec)
8957{
8958 struct alc_spec *spec = codec->spec;
8959 int val = spec->master_sw;
8960
8961 /* HP & line-out */
8962 snd_hda_codec_write_cache(codec, 0x1b, 0,
8963 AC_VERB_SET_PIN_WIDGET_CONTROL,
8964 val ? PIN_HP : 0);
8965 snd_hda_codec_write_cache(codec, 0x15, 0,
8966 AC_VERB_SET_PIN_WIDGET_CONTROL,
8967 val ? PIN_HP : 0);
8968 /* mono (speaker) depending on the HP jack sense */
8969 val = val && !spec->jack_present;
8970 snd_hda_codec_write_cache(codec, 0x16, 0,
8971 AC_VERB_SET_PIN_WIDGET_CONTROL,
8972 val ? PIN_OUT : 0);
8973}
8974
8975static void alc262_hp_bpc_automute(struct hda_codec *codec)
8976{
8977 struct alc_spec *spec = codec->spec;
8978 unsigned int presence;
8979 presence = snd_hda_codec_read(codec, 0x1b, 0,
8980 AC_VERB_GET_PIN_SENSE, 0);
8981 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8982 alc262_hp_master_update(codec);
8983}
8984
8985static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8986{
8987 if ((res >> 26) != ALC880_HP_EVENT)
8988 return;
8989 alc262_hp_bpc_automute(codec);
8990}
8991
8992static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8993{
8994 struct alc_spec *spec = codec->spec;
8995 unsigned int presence;
8996 presence = snd_hda_codec_read(codec, 0x15, 0,
8997 AC_VERB_GET_PIN_SENSE, 0);
8998 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8999 alc262_hp_master_update(codec);
9000}
9001
9002static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
9003 unsigned int res)
9004{
9005 if ((res >> 26) != ALC880_HP_EVENT)
9006 return;
9007 alc262_hp_wildwest_automute(codec);
9008}
9009
9010static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
9011 struct snd_ctl_elem_value *ucontrol)
9012{
9013 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9014 struct alc_spec *spec = codec->spec;
9015 *ucontrol->value.integer.value = spec->master_sw;
9016 return 0;
9017}
9018
9019static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
9020 struct snd_ctl_elem_value *ucontrol)
9021{
9022 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9023 struct alc_spec *spec = codec->spec;
9024 int val = !!*ucontrol->value.integer.value;
9025
9026 if (val == spec->master_sw)
9027 return 0;
9028 spec->master_sw = val;
9029 alc262_hp_master_update(codec);
9030 return 1;
9031}
9032
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009033static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009034 {
9035 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9036 .name = "Master Playback Switch",
9037 .info = snd_ctl_boolean_mono_info,
9038 .get = alc262_hp_master_sw_get,
9039 .put = alc262_hp_master_sw_put,
9040 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009041 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9042 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9043 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009044 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9045 HDA_OUTPUT),
9046 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9047 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009048 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9049 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009050 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009051 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9052 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009053 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009054 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9055 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9056 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9057 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9058 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9059 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9060 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
9061 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
9062 { } /* end */
9063};
9064
Kailang Yangcd7509a2007-01-26 18:33:17 +01009065static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01009066 {
9067 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9068 .name = "Master Playback Switch",
9069 .info = snd_ctl_boolean_mono_info,
9070 .get = alc262_hp_master_sw_get,
9071 .put = alc262_hp_master_sw_put,
9072 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01009073 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9074 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9075 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9076 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01009077 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
9078 HDA_OUTPUT),
9079 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
9080 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009081 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
9082 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009083 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009084 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9085 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9086 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9087 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9088 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
9089 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
9090 { } /* end */
9091};
9092
9093static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
9094 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9095 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01009096 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009097 { } /* end */
9098};
9099
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009100/* mute/unmute internal speaker according to the hp jack and mute state */
9101static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
9102{
9103 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009104
9105 if (force || !spec->sense_updated) {
9106 unsigned int present;
9107 present = snd_hda_codec_read(codec, 0x15, 0,
9108 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01009109 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009110 spec->sense_updated = 1;
9111 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01009112 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
9113 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009114}
9115
9116static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
9117 unsigned int res)
9118{
9119 if ((res >> 26) != ALC880_HP_EVENT)
9120 return;
9121 alc262_hp_t5735_automute(codec, 1);
9122}
9123
9124static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
9125{
9126 alc262_hp_t5735_automute(codec, 1);
9127}
9128
9129static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01009130 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9131 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009132 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9136 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9137 { } /* end */
9138};
9139
9140static struct hda_verb alc262_hp_t5735_verbs[] = {
9141 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9143
9144 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9145 { }
9146};
9147
Kailang Yang8c427222008-01-10 13:03:59 +01009148static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01009149 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9150 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009151 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9152 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01009153 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
9154 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
9155 { } /* end */
9156};
9157
9158static struct hda_verb alc262_hp_rp5700_verbs[] = {
9159 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9160 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9161 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9162 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9163 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9164 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9166 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9167 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
9169 {}
9170};
9171
9172static struct hda_input_mux alc262_hp_rp5700_capture_source = {
9173 .num_items = 1,
9174 .items = {
9175 { "Line", 0x1 },
9176 },
9177};
9178
Takashi Iwai0724ea22007-08-23 00:31:43 +02009179/* bind hp and internal speaker mute (with plug check) */
9180static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
9181 struct snd_ctl_elem_value *ucontrol)
9182{
9183 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9184 long *valp = ucontrol->value.integer.value;
9185 int change;
9186
9187 /* change hp mute */
9188 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
9189 HDA_AMP_MUTE,
9190 valp[0] ? 0 : HDA_AMP_MUTE);
9191 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
9192 HDA_AMP_MUTE,
9193 valp[1] ? 0 : HDA_AMP_MUTE);
9194 if (change) {
9195 /* change speaker according to HP jack state */
9196 struct alc_spec *spec = codec->spec;
9197 unsigned int mute;
9198 if (spec->jack_present)
9199 mute = HDA_AMP_MUTE;
9200 else
9201 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
9202 HDA_OUTPUT, 0);
9203 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9204 HDA_AMP_MUTE, mute);
9205 }
9206 return change;
9207}
Takashi Iwai5b319542007-07-26 11:49:22 +02009208
Kailang Yang272a5272007-05-14 11:00:38 +02009209static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02009210 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9211 {
9212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9213 .name = "Master Playback Switch",
9214 .info = snd_hda_mixer_amp_switch_info,
9215 .get = snd_hda_mixer_amp_switch_get,
9216 .put = alc262_sony_master_sw_put,
9217 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9218 },
Kailang Yang272a5272007-05-14 11:00:38 +02009219 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9220 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9221 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9222 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9223 { } /* end */
9224};
9225
Kailang Yang83c34212007-07-05 11:43:05 +02009226static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
9227 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9228 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9229 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9230 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9232 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9233 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9234 { } /* end */
9235};
Kailang Yang272a5272007-05-14 11:00:38 +02009236
Kailang Yangdf694da2005-12-05 19:42:22 +01009237#define alc262_capture_mixer alc882_capture_mixer
9238#define alc262_capture_alt_mixer alc882_capture_alt_mixer
9239
9240/*
9241 * generic initialization of ADC, input mixers and output mixers
9242 */
9243static struct hda_verb alc262_init_verbs[] = {
9244 /*
9245 * Unmute ADC0-2 and set the default input to mic-in
9246 */
9247 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9249 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9250 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9251 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9252 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9253
Takashi Iwaicb53c622007-08-10 17:21:45 +02009254 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009255 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009256 * Note: PASD motherboards uses the Line In 2 as the input for
9257 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009258 */
9259 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009260 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9261 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9262 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9263 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009265
9266 /*
9267 * Set up output mixers (0x0c - 0x0e)
9268 */
9269 /* set vol=0 to output mixers */
9270 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9271 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9272 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9273 /* set up input amps for analog loopback */
9274 /* Amp Indices: DAC = 0, mixer = 1 */
9275 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9276 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9277 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9278 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9279 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9280 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9281
9282 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9283 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9284 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
9285 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9286 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9287 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9288
9289 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9290 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9291 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9292 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9293 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02009294
Kailang Yangdf694da2005-12-05 19:42:22 +01009295 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9296 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02009297
Kailang Yangdf694da2005-12-05 19:42:22 +01009298 /* FIXME: use matrix-type input source selection */
9299 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9300 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9301 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9302 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9303 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9304 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9305 /* Input mixer2 */
9306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9308 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9310 /* Input mixer3 */
9311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01009315
9316 { }
9317};
9318
Kailang Yang4e555fe2008-08-26 13:05:55 +02009319static struct hda_verb alc262_eapd_verbs[] = {
9320 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
9321 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
9322 { }
9323};
9324
Kailang Yangccc656c2006-10-17 12:32:26 +02009325static struct hda_verb alc262_hippo_unsol_verbs[] = {
9326 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9327 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9328 {}
9329};
9330
9331static struct hda_verb alc262_hippo1_unsol_verbs[] = {
9332 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9333 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9334 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
9335
9336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9337 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9338 {}
9339};
9340
Kailang Yang272a5272007-05-14 11:00:38 +02009341static struct hda_verb alc262_sony_unsol_verbs[] = {
9342 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
9343 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9344 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
9345
9346 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9347 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09009348 {}
Kailang Yang272a5272007-05-14 11:00:38 +02009349};
9350
Kailang Yang4e555fe2008-08-26 13:05:55 +02009351static struct hda_input_mux alc262_dmic_capture_source = {
9352 .num_items = 2,
9353 .items = {
9354 { "Int DMic", 0x9 },
9355 { "Mic", 0x0 },
9356 },
9357};
9358
9359static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
9360 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9361 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9362 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9363 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9364 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009365 { } /* end */
9366};
9367
9368static struct hda_verb alc262_toshiba_s06_verbs[] = {
9369 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9370 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9371 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9372 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9373 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9374 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9375 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9376 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9377 {}
9378};
9379
9380static void alc262_dmic_automute(struct hda_codec *codec)
9381{
9382 unsigned int present;
9383
9384 present = snd_hda_codec_read(codec, 0x18, 0,
9385 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9386 snd_hda_codec_write(codec, 0x22, 0,
9387 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9388}
9389
9390/* toggle speaker-output according to the hp-jack state */
9391static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9392{
9393 unsigned int present;
9394 unsigned char bits;
9395
9396 present = snd_hda_codec_read(codec, 0x15, 0,
9397 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9398 bits = present ? 0 : PIN_OUT;
9399 snd_hda_codec_write(codec, 0x14, 0,
9400 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9401}
9402
9403
9404
9405/* unsolicited event for HP jack sensing */
9406static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9407 unsigned int res)
9408{
9409 if ((res >> 26) == ALC880_HP_EVENT)
9410 alc262_toshiba_s06_speaker_automute(codec);
9411 if ((res >> 26) == ALC880_MIC_EVENT)
9412 alc262_dmic_automute(codec);
9413
9414}
9415
9416static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9417{
9418 alc262_toshiba_s06_speaker_automute(codec);
9419 alc262_dmic_automute(codec);
9420}
9421
Kailang Yangccc656c2006-10-17 12:32:26 +02009422/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009423static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009424{
9425 struct alc_spec *spec = codec->spec;
9426 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009427 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009428
Takashi Iwai5b319542007-07-26 11:49:22 +02009429 /* need to execute and sync at first */
9430 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9431 present = snd_hda_codec_read(codec, 0x15, 0,
9432 AC_VERB_GET_PIN_SENSE, 0);
9433 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009434 if (spec->jack_present) {
9435 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009436 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9437 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009438 } else {
9439 /* unmute internal speaker if necessary */
9440 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009441 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9442 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009443 }
9444}
9445
9446/* unsolicited event for HP jack sensing */
9447static void alc262_hippo_unsol_event(struct hda_codec *codec,
9448 unsigned int res)
9449{
9450 if ((res >> 26) != ALC880_HP_EVENT)
9451 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009452 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009453}
9454
Takashi Iwai5b319542007-07-26 11:49:22 +02009455static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009456{
Kailang Yangccc656c2006-10-17 12:32:26 +02009457 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009458 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009459
Takashi Iwai5b319542007-07-26 11:49:22 +02009460 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9461 present = snd_hda_codec_read(codec, 0x1b, 0,
9462 AC_VERB_GET_PIN_SENSE, 0);
9463 present = (present & 0x80000000) != 0;
9464 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009465 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009466 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9467 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009468 } else {
9469 /* unmute internal speaker if necessary */
9470 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009471 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9472 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009473 }
9474}
9475
9476/* unsolicited event for HP jack sensing */
9477static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9478 unsigned int res)
9479{
9480 if ((res >> 26) != ALC880_HP_EVENT)
9481 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009482 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009483}
9484
Takashi Iwai834be882006-03-01 14:16:17 +01009485/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009486 * nec model
9487 * 0x15 = headphone
9488 * 0x16 = internal speaker
9489 * 0x18 = external mic
9490 */
9491
9492static struct snd_kcontrol_new alc262_nec_mixer[] = {
9493 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9494 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9495
9496 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9497 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9498 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9499
9500 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9501 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9502 { } /* end */
9503};
9504
9505static struct hda_verb alc262_nec_verbs[] = {
9506 /* Unmute Speaker */
9507 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9508
9509 /* Headphone */
9510 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9511 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9512
9513 /* External mic to headphone */
9514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9515 /* External mic to speaker */
9516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9517 {}
9518};
9519
9520/*
Takashi Iwai834be882006-03-01 14:16:17 +01009521 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009522 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9523 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009524 */
9525
9526#define ALC_HP_EVENT 0x37
9527
9528static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9529 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9530 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009531 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9532 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009533 {}
9534};
9535
Jiang zhe0e31daf2008-03-20 12:12:39 +01009536static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9537 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9539 {}
9540};
9541
Takashi Iwai834be882006-03-01 14:16:17 +01009542static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009543 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009544 .items = {
9545 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009546 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009547 { "CD", 0x4 },
9548 },
9549};
9550
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009551static struct hda_input_mux alc262_HP_capture_source = {
9552 .num_items = 5,
9553 .items = {
9554 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009555 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009556 { "Line", 0x2 },
9557 { "CD", 0x4 },
9558 { "AUX IN", 0x6 },
9559 },
9560};
9561
zhejiangaccbe492007-08-31 12:36:05 +02009562static struct hda_input_mux alc262_HP_D7000_capture_source = {
9563 .num_items = 4,
9564 .items = {
9565 { "Mic", 0x0 },
9566 { "Front Mic", 0x2 },
9567 { "Line", 0x1 },
9568 { "CD", 0x4 },
9569 },
9570};
9571
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009572/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009573static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9574{
9575 struct alc_spec *spec = codec->spec;
9576 unsigned int mute;
9577
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009578 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009579 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009580 /* need to execute and sync at first */
9581 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009582 /* check laptop HP jack */
9583 present = snd_hda_codec_read(codec, 0x14, 0,
9584 AC_VERB_GET_PIN_SENSE, 0);
9585 /* need to execute and sync at first */
9586 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9587 /* check docking HP jack */
9588 present |= snd_hda_codec_read(codec, 0x1b, 0,
9589 AC_VERB_GET_PIN_SENSE, 0);
9590 if (present & AC_PINSENSE_PRESENCE)
9591 spec->jack_present = 1;
9592 else
9593 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009594 spec->sense_updated = 1;
9595 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009596 /* unmute internal speaker only if both HPs are unplugged and
9597 * master switch is on
9598 */
9599 if (spec->jack_present)
9600 mute = HDA_AMP_MUTE;
9601 else
Takashi Iwai834be882006-03-01 14:16:17 +01009602 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009603 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9604 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009605}
9606
9607/* unsolicited event for HP jack sensing */
9608static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9609 unsigned int res)
9610{
9611 if ((res >> 26) != ALC_HP_EVENT)
9612 return;
9613 alc262_fujitsu_automute(codec, 1);
9614}
9615
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009616static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9617{
9618 alc262_fujitsu_automute(codec, 1);
9619}
9620
Takashi Iwai834be882006-03-01 14:16:17 +01009621/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009622static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9623 .ops = &snd_hda_bind_vol,
9624 .values = {
9625 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9626 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9627 0
9628 },
9629};
Takashi Iwai834be882006-03-01 14:16:17 +01009630
Jiang zhe0e31daf2008-03-20 12:12:39 +01009631/* mute/unmute internal speaker according to the hp jack and mute state */
9632static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9633{
9634 struct alc_spec *spec = codec->spec;
9635 unsigned int mute;
9636
9637 if (force || !spec->sense_updated) {
9638 unsigned int present_int_hp;
9639 /* need to execute and sync at first */
9640 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9641 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9642 AC_VERB_GET_PIN_SENSE, 0);
9643 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9644 spec->sense_updated = 1;
9645 }
9646 if (spec->jack_present) {
9647 /* mute internal speaker */
9648 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9649 HDA_AMP_MUTE, HDA_AMP_MUTE);
9650 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9651 HDA_AMP_MUTE, HDA_AMP_MUTE);
9652 } else {
9653 /* unmute internal speaker if necessary */
9654 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9655 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9656 HDA_AMP_MUTE, mute);
9657 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9658 HDA_AMP_MUTE, mute);
9659 }
9660}
9661
9662/* unsolicited event for HP jack sensing */
9663static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9664 unsigned int res)
9665{
9666 if ((res >> 26) != ALC_HP_EVENT)
9667 return;
9668 alc262_lenovo_3000_automute(codec, 1);
9669}
9670
Takashi Iwai834be882006-03-01 14:16:17 +01009671/* bind hp and internal speaker mute (with plug check) */
9672static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9673 struct snd_ctl_elem_value *ucontrol)
9674{
9675 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9676 long *valp = ucontrol->value.integer.value;
9677 int change;
9678
Tony Vroon5d9fab22008-03-14 17:09:18 +01009679 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9680 HDA_AMP_MUTE,
9681 valp ? 0 : HDA_AMP_MUTE);
9682 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9683 HDA_AMP_MUTE,
9684 valp ? 0 : HDA_AMP_MUTE);
9685
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009686 if (change)
9687 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009688 return change;
9689}
9690
9691static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009692 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009693 {
9694 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9695 .name = "Master Playback Switch",
9696 .info = snd_hda_mixer_amp_switch_info,
9697 .get = snd_hda_mixer_amp_switch_get,
9698 .put = alc262_fujitsu_master_sw_put,
9699 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9700 },
9701 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9702 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009703 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9704 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009705 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009708 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9709 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9710 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009711 { } /* end */
9712};
9713
Jiang zhe0e31daf2008-03-20 12:12:39 +01009714/* bind hp and internal speaker mute (with plug check) */
9715static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9716 struct snd_ctl_elem_value *ucontrol)
9717{
9718 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9719 long *valp = ucontrol->value.integer.value;
9720 int change;
9721
9722 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9723 HDA_AMP_MUTE,
9724 valp ? 0 : HDA_AMP_MUTE);
9725
9726 if (change)
9727 alc262_lenovo_3000_automute(codec, 0);
9728 return change;
9729}
9730
9731static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9732 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9733 {
9734 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9735 .name = "Master Playback Switch",
9736 .info = snd_hda_mixer_amp_switch_info,
9737 .get = snd_hda_mixer_amp_switch_get,
9738 .put = alc262_lenovo_3000_master_sw_put,
9739 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9740 },
9741 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9742 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9743 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9744 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9745 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9746 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9747 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9748 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9749 { } /* end */
9750};
9751
Hiroshi Miura9f99a632008-08-28 16:09:06 +02009752static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
9753 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9754 {
9755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9756 .name = "Master Playback Switch",
9757 .info = snd_hda_mixer_amp_switch_info,
9758 .get = snd_hda_mixer_amp_switch_get,
9759 .put = alc262_sony_master_sw_put,
9760 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
9761 },
9762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9763 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9764 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9765 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9766 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9767 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9768 { } /* end */
9769};
9770
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009771/* additional init verbs for Benq laptops */
9772static struct hda_verb alc262_EAPD_verbs[] = {
9773 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9774 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9775 {}
9776};
9777
Kailang Yang83c34212007-07-05 11:43:05 +02009778static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9779 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9780 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9781
9782 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9783 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9784 {}
9785};
9786
Tobin Davisf651b502007-10-26 12:40:47 +02009787/* Samsung Q1 Ultra Vista model setup */
9788static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009789 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9790 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9792 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9793 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009794 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009795 { } /* end */
9796};
9797
9798static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009799 /* output mixer */
9800 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9801 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9802 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9803 /* speaker */
9804 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9805 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9806 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9807 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9808 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009809 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009810 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9811 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9812 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9813 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9814 /* internal mic */
9815 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9816 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9817 /* ADC, choose mic */
9818 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9819 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9820 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9821 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9822 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9823 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9824 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9825 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9826 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9827 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009828 {}
9829};
9830
Tobin Davisf651b502007-10-26 12:40:47 +02009831/* mute/unmute internal speaker according to the hp jack and mute state */
9832static void alc262_ultra_automute(struct hda_codec *codec)
9833{
9834 struct alc_spec *spec = codec->spec;
9835 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009836
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009837 mute = 0;
9838 /* auto-mute only when HP is used as HP */
9839 if (!spec->cur_mux[0]) {
9840 unsigned int present;
9841 /* need to execute and sync at first */
9842 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9843 present = snd_hda_codec_read(codec, 0x15, 0,
9844 AC_VERB_GET_PIN_SENSE, 0);
9845 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9846 if (spec->jack_present)
9847 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009848 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009849 /* mute/unmute internal speaker */
9850 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9851 HDA_AMP_MUTE, mute);
9852 /* mute/unmute HP */
9853 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9854 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009855}
9856
9857/* unsolicited event for HP jack sensing */
9858static void alc262_ultra_unsol_event(struct hda_codec *codec,
9859 unsigned int res)
9860{
9861 if ((res >> 26) != ALC880_HP_EVENT)
9862 return;
9863 alc262_ultra_automute(codec);
9864}
9865
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009866static struct hda_input_mux alc262_ultra_capture_source = {
9867 .num_items = 2,
9868 .items = {
9869 { "Mic", 0x1 },
9870 { "Headphone", 0x7 },
9871 },
9872};
9873
9874static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9875 struct snd_ctl_elem_value *ucontrol)
9876{
9877 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9878 struct alc_spec *spec = codec->spec;
9879 int ret;
9880
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009881 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009882 if (!ret)
9883 return 0;
9884 /* reprogram the HP pin as mic or HP according to the input source */
9885 snd_hda_codec_write_cache(codec, 0x15, 0,
9886 AC_VERB_SET_PIN_WIDGET_CONTROL,
9887 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9888 alc262_ultra_automute(codec); /* mute/unmute HP */
9889 return ret;
9890}
9891
9892static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9893 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9894 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9895 {
9896 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9897 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009898 .info = alc_mux_enum_info,
9899 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009900 .put = alc262_ultra_mux_enum_put,
9901 },
9902 { } /* end */
9903};
9904
Kailang Yangdf694da2005-12-05 19:42:22 +01009905/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009906static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9907 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009908{
9909 hda_nid_t nid;
9910 int err;
9911
9912 spec->multiout.num_dacs = 1; /* only use one dac */
9913 spec->multiout.dac_nids = spec->private_dac_nids;
9914 spec->multiout.dac_nids[0] = 2;
9915
9916 nid = cfg->line_out_pins[0];
9917 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009918 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9919 "Front Playback Volume",
9920 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9921 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009922 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009923 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9924 "Front Playback Switch",
9925 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9926 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009927 return err;
9928 }
9929
Takashi Iwai82bc9552006-03-21 11:24:42 +01009930 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009931 if (nid) {
9932 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009933 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9934 "Speaker Playback Volume",
9935 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9936 HDA_OUTPUT));
9937 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009938 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009939 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9940 "Speaker Playback Switch",
9941 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9942 HDA_OUTPUT));
9943 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009944 return err;
9945 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009946 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9947 "Speaker Playback Switch",
9948 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9949 HDA_OUTPUT));
9950 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009951 return err;
9952 }
9953 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009954 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009955 if (nid) {
9956 /* spec->multiout.hp_nid = 2; */
9957 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009958 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9959 "Headphone Playback Volume",
9960 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9961 HDA_OUTPUT));
9962 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009963 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009964 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9965 "Headphone Playback Switch",
9966 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9967 HDA_OUTPUT));
9968 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009969 return err;
9970 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009971 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9972 "Headphone Playback Switch",
9973 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9974 HDA_OUTPUT));
9975 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009976 return err;
9977 }
9978 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009979 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009980}
9981
9982/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009983#define alc262_auto_create_analog_input_ctls \
9984 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009985
9986/*
9987 * generic initialization of ADC, input mixers and output mixers
9988 */
9989static struct hda_verb alc262_volume_init_verbs[] = {
9990 /*
9991 * Unmute ADC0-2 and set the default input to mic-in
9992 */
9993 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9994 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9995 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9996 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9997 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9998 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9999
Takashi Iwaicb53c622007-08-10 17:21:45 +020010000 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010010001 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010002 * Note: PASD motherboards uses the Line In 2 as the input for
10003 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010010004 */
10005 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10007 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10008 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10009 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10010 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010010011
10012 /*
10013 * Set up output mixers (0x0c - 0x0f)
10014 */
10015 /* set vol=0 to output mixers */
10016 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10017 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10018 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020010019
Kailang Yangdf694da2005-12-05 19:42:22 +010010020 /* set up input amps for analog loopback */
10021 /* Amp Indices: DAC = 0, mixer = 1 */
10022 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10023 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10024 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10025 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10026 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10027 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10028
10029 /* FIXME: use matrix-type input source selection */
10030 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10031 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10032 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10033 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10034 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10035 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10036 /* Input mixer2 */
10037 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10038 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10039 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10040 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10041 /* Input mixer3 */
10042 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10043 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
10044 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
10045 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
10046
10047 { }
10048};
10049
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010050static struct hda_verb alc262_HP_BPC_init_verbs[] = {
10051 /*
10052 * Unmute ADC0-2 and set the default input to mic-in
10053 */
10054 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10055 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10056 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10057 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10058 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10059 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10060
Takashi Iwaicb53c622007-08-10 17:21:45 +020010061 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010062 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010063 * Note: PASD motherboards uses the Line In 2 as the input for
10064 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010065 */
10066 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010067 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10068 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10069 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10070 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10071 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10072 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10073 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020010074
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010075 /*
10076 * Set up output mixers (0x0c - 0x0e)
10077 */
10078 /* set vol=0 to output mixers */
10079 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10080 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10081 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10082
10083 /* set up input amps for analog loopback */
10084 /* Amp Indices: DAC = 0, mixer = 1 */
10085 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10086 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10087 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10088 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10089 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10090 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10091
Takashi Iwaice875f02008-01-28 18:17:43 +010010092 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010093 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10094 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
10095
10096 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10097 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10098
10099 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10100 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10101
10102 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10103 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10104 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10105 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10106 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10107
10108 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10109 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10110 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10111 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10112 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10113 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10114
10115
10116 /* FIXME: use matrix-type input source selection */
10117 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10118 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10119 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10120 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10121 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10122 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10123 /* Input mixer2 */
10124 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10125 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10126 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10127 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10128 /* Input mixer3 */
10129 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10130 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10131 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10132 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10133
Takashi Iwaice875f02008-01-28 18:17:43 +010010134 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10135
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010136 { }
10137};
10138
Kailang Yangcd7509a2007-01-26 18:33:17 +010010139static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
10140 /*
10141 * Unmute ADC0-2 and set the default input to mic-in
10142 */
10143 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
10144 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10145 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
10146 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10147 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
10148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10149
Takashi Iwaicb53c622007-08-10 17:21:45 +020010150 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010010151 * mixer widget
10152 * Note: PASD motherboards uses the Line In 2 as the input for front
10153 * panel mic (mic 2)
10154 */
10155 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020010156 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
10157 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10158 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
10159 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
10160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
10161 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
10162 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
10163 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010010164 /*
10165 * Set up output mixers (0x0c - 0x0e)
10166 */
10167 /* set vol=0 to output mixers */
10168 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10169 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10171
10172 /* set up input amps for analog loopback */
10173 /* Amp Indices: DAC = 0, mixer = 1 */
10174 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10176 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10177 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10178 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10179 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10180
10181
10182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
10183 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
10184 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
10185 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
10186 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10187 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
10188 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
10189
10190 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10191 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10192
10193 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
10194 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
10195
10196 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
10197 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10198 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
10200 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10201 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
10202
10203 /* FIXME: use matrix-type input source selection */
10204 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
10205 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
10206 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
10207 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
10208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
10209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
10210 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
10211 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10212 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
10213 /* Input mixer2 */
10214 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10215 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10216 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10217 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10218 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10219 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10220 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10221 /* Input mixer3 */
10222 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
10223 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
10224 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
10225 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
10226 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
10227 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
10228 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
10229
Takashi Iwaice875f02008-01-28 18:17:43 +010010230 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10231
Kailang Yangcd7509a2007-01-26 18:33:17 +010010232 { }
10233};
10234
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010235static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
10236
10237 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
10238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
10239 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
10240
10241 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
10242 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
10243 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10244 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
10245
10246 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
10247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
10248 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
10249 {}
10250};
10251
10252
Takashi Iwaicb53c622007-08-10 17:21:45 +020010253#ifdef CONFIG_SND_HDA_POWER_SAVE
10254#define alc262_loopbacks alc880_loopbacks
10255#endif
10256
Kailang Yangdf694da2005-12-05 19:42:22 +010010257/* pcm configuration: identiacal with ALC880 */
10258#define alc262_pcm_analog_playback alc880_pcm_analog_playback
10259#define alc262_pcm_analog_capture alc880_pcm_analog_capture
10260#define alc262_pcm_digital_playback alc880_pcm_digital_playback
10261#define alc262_pcm_digital_capture alc880_pcm_digital_capture
10262
10263/*
10264 * BIOS auto configuration
10265 */
10266static int alc262_parse_auto_config(struct hda_codec *codec)
10267{
10268 struct alc_spec *spec = codec->spec;
10269 int err;
10270 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
10271
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010272 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10273 alc262_ignore);
10274 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010275 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010276 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010010277 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010278 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
10279 if (err < 0)
10280 return err;
10281 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
10282 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010010283 return err;
10284
10285 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10286
10287 if (spec->autocfg.dig_out_pin)
10288 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
10289 if (spec->autocfg.dig_in_pin)
10290 spec->dig_in_nid = ALC262_DIGIN_NID;
10291
Takashi Iwai603c4012008-07-30 15:01:44 +020010292 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010010293 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010010294
Takashi Iwaid88897e2008-10-31 15:01:37 +010010295 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020010296 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010010297 spec->input_mux = &spec->private_imux;
10298
Takashi Iwai776e1842007-08-29 15:07:11 +020010299 err = alc_auto_add_mic_boost(codec);
10300 if (err < 0)
10301 return err;
10302
Takashi Iwaie044c392008-10-27 16:56:24 +010010303 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010304 return 1;
10305}
10306
10307#define alc262_auto_init_multi_out alc882_auto_init_multi_out
10308#define alc262_auto_init_hp_out alc882_auto_init_hp_out
10309#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020010310#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010010311
10312
10313/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010314static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010010315{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010316 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010010317 alc262_auto_init_multi_out(codec);
10318 alc262_auto_init_hp_out(codec);
10319 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020010320 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010321 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010322 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010323}
10324
10325/*
10326 * configuration and preset
10327 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010328static const char *alc262_models[ALC262_MODEL_LAST] = {
10329 [ALC262_BASIC] = "basic",
10330 [ALC262_HIPPO] = "hippo",
10331 [ALC262_HIPPO_1] = "hippo_1",
10332 [ALC262_FUJITSU] = "fujitsu",
10333 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010010334 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010010335 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010010336 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010337 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020010338 [ALC262_BENQ_T31] = "benq-t31",
10339 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020010340 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010341 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020010342 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010010343 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010344 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010345 [ALC262_AUTO] = "auto",
10346};
10347
10348static struct snd_pci_quirk alc262_cfg_tbl[] = {
10349 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010350 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010351 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010352 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010353 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
10354 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +020010355 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010356 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010357 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +010010358 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010359 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010360 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010361 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010362 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010363 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010364 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010365 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010010366 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010367 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
10368 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
10369 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010370 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
10371 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010010372 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010373 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010374 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010375 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10376 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
10377 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +090010378 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010379 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020010380 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010381 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010010382 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010383 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010384 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +010010385 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010386 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010387 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010388 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010389 {}
10390};
10391
10392static struct alc_config_preset alc262_presets[] = {
10393 [ALC262_BASIC] = {
10394 .mixers = { alc262_base_mixer },
10395 .init_verbs = { alc262_init_verbs },
10396 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10397 .dac_nids = alc262_dac_nids,
10398 .hp_nid = 0x03,
10399 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10400 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010401 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010402 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010403 [ALC262_HIPPO] = {
10404 .mixers = { alc262_base_mixer },
10405 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10406 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10407 .dac_nids = alc262_dac_nids,
10408 .hp_nid = 0x03,
10409 .dig_out_nid = ALC262_DIGOUT_NID,
10410 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10411 .channel_mode = alc262_modes,
10412 .input_mux = &alc262_capture_source,
10413 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010414 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010415 },
10416 [ALC262_HIPPO_1] = {
10417 .mixers = { alc262_hippo1_mixer },
10418 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10419 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10420 .dac_nids = alc262_dac_nids,
10421 .hp_nid = 0x02,
10422 .dig_out_nid = ALC262_DIGOUT_NID,
10423 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10424 .channel_mode = alc262_modes,
10425 .input_mux = &alc262_capture_source,
10426 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010427 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010428 },
Takashi Iwai834be882006-03-01 14:16:17 +010010429 [ALC262_FUJITSU] = {
10430 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010431 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10432 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010433 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10434 .dac_nids = alc262_dac_nids,
10435 .hp_nid = 0x03,
10436 .dig_out_nid = ALC262_DIGOUT_NID,
10437 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10438 .channel_mode = alc262_modes,
10439 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010440 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010441 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010442 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010443 [ALC262_HP_BPC] = {
10444 .mixers = { alc262_HP_BPC_mixer },
10445 .init_verbs = { alc262_HP_BPC_init_verbs },
10446 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10447 .dac_nids = alc262_dac_nids,
10448 .hp_nid = 0x03,
10449 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10450 .channel_mode = alc262_modes,
10451 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010452 .unsol_event = alc262_hp_bpc_unsol_event,
10453 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010454 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010455 [ALC262_HP_BPC_D7000_WF] = {
10456 .mixers = { alc262_HP_BPC_WildWest_mixer },
10457 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10458 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10459 .dac_nids = alc262_dac_nids,
10460 .hp_nid = 0x03,
10461 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10462 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010463 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010464 .unsol_event = alc262_hp_wildwest_unsol_event,
10465 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010466 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010467 [ALC262_HP_BPC_D7000_WL] = {
10468 .mixers = { alc262_HP_BPC_WildWest_mixer,
10469 alc262_HP_BPC_WildWest_option_mixer },
10470 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10471 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10472 .dac_nids = alc262_dac_nids,
10473 .hp_nid = 0x03,
10474 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10475 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010476 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010477 .unsol_event = alc262_hp_wildwest_unsol_event,
10478 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010479 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010480 [ALC262_HP_TC_T5735] = {
10481 .mixers = { alc262_hp_t5735_mixer },
10482 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10483 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10484 .dac_nids = alc262_dac_nids,
10485 .hp_nid = 0x03,
10486 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10487 .channel_mode = alc262_modes,
10488 .input_mux = &alc262_capture_source,
10489 .unsol_event = alc262_hp_t5735_unsol_event,
10490 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010491 },
10492 [ALC262_HP_RP5700] = {
10493 .mixers = { alc262_hp_rp5700_mixer },
10494 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10495 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10496 .dac_nids = alc262_dac_nids,
10497 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10498 .channel_mode = alc262_modes,
10499 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010500 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010501 [ALC262_BENQ_ED8] = {
10502 .mixers = { alc262_base_mixer },
10503 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10504 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10505 .dac_nids = alc262_dac_nids,
10506 .hp_nid = 0x03,
10507 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10508 .channel_mode = alc262_modes,
10509 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010510 },
Kailang Yang272a5272007-05-14 11:00:38 +020010511 [ALC262_SONY_ASSAMD] = {
10512 .mixers = { alc262_sony_mixer },
10513 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10514 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10515 .dac_nids = alc262_dac_nids,
10516 .hp_nid = 0x02,
10517 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10518 .channel_mode = alc262_modes,
10519 .input_mux = &alc262_capture_source,
10520 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010521 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010522 },
10523 [ALC262_BENQ_T31] = {
10524 .mixers = { alc262_benq_t31_mixer },
10525 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10526 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10527 .dac_nids = alc262_dac_nids,
10528 .hp_nid = 0x03,
10529 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10530 .channel_mode = alc262_modes,
10531 .input_mux = &alc262_capture_source,
10532 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010533 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010534 },
Tobin Davisf651b502007-10-26 12:40:47 +020010535 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010536 .mixers = { alc262_ultra_mixer },
10537 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010538 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010539 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10540 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010541 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10542 .channel_mode = alc262_modes,
10543 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010544 .adc_nids = alc262_adc_nids, /* ADC0 */
10545 .capsrc_nids = alc262_capsrc_nids,
10546 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010547 .unsol_event = alc262_ultra_unsol_event,
10548 .init_hook = alc262_ultra_automute,
10549 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010550 [ALC262_LENOVO_3000] = {
10551 .mixers = { alc262_lenovo_3000_mixer },
10552 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10553 alc262_lenovo_3000_unsol_verbs },
10554 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10555 .dac_nids = alc262_dac_nids,
10556 .hp_nid = 0x03,
10557 .dig_out_nid = ALC262_DIGOUT_NID,
10558 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10559 .channel_mode = alc262_modes,
10560 .input_mux = &alc262_fujitsu_capture_source,
10561 .unsol_event = alc262_lenovo_3000_unsol_event,
10562 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010563 [ALC262_NEC] = {
10564 .mixers = { alc262_nec_mixer },
10565 .init_verbs = { alc262_nec_verbs },
10566 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10567 .dac_nids = alc262_dac_nids,
10568 .hp_nid = 0x03,
10569 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10570 .channel_mode = alc262_modes,
10571 .input_mux = &alc262_capture_source,
10572 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010573 [ALC262_TOSHIBA_S06] = {
10574 .mixers = { alc262_toshiba_s06_mixer },
10575 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10576 alc262_eapd_verbs },
10577 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10578 .capsrc_nids = alc262_dmic_capsrc_nids,
10579 .dac_nids = alc262_dac_nids,
10580 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10581 .dig_out_nid = ALC262_DIGOUT_NID,
10582 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10583 .channel_mode = alc262_modes,
10584 .input_mux = &alc262_dmic_capture_source,
10585 .unsol_event = alc262_toshiba_s06_unsol_event,
10586 .init_hook = alc262_toshiba_s06_init_hook,
10587 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020010588 [ALC262_TOSHIBA_RX1] = {
10589 .mixers = { alc262_toshiba_rx1_mixer },
10590 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
10591 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10592 .dac_nids = alc262_dac_nids,
10593 .hp_nid = 0x03,
10594 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10595 .channel_mode = alc262_modes,
10596 .input_mux = &alc262_capture_source,
10597 .unsol_event = alc262_hippo_unsol_event,
10598 .init_hook = alc262_hippo_automute,
10599 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010600};
10601
10602static int patch_alc262(struct hda_codec *codec)
10603{
10604 struct alc_spec *spec;
10605 int board_config;
10606 int err;
10607
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010608 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010609 if (spec == NULL)
10610 return -ENOMEM;
10611
10612 codec->spec = spec;
10613#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010614 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10615 * under-run
10616 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010617 {
10618 int tmp;
10619 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10620 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10621 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10622 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10623 }
10624#endif
10625
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010626 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10627
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010628 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10629 alc262_models,
10630 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010631
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010632 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010633 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10634 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010635 board_config = ALC262_AUTO;
10636 }
10637
10638 if (board_config == ALC262_AUTO) {
10639 /* automatic parse from the BIOS config */
10640 err = alc262_parse_auto_config(codec);
10641 if (err < 0) {
10642 alc_free(codec);
10643 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010644 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010645 printk(KERN_INFO
10646 "hda_codec: Cannot set up configuration "
10647 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010648 board_config = ALC262_BASIC;
10649 }
10650 }
10651
10652 if (board_config != ALC262_AUTO)
10653 setup_preset(spec, &alc262_presets[board_config]);
10654
10655 spec->stream_name_analog = "ALC262 Analog";
10656 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10657 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010658
Kailang Yangdf694da2005-12-05 19:42:22 +010010659 spec->stream_name_digital = "ALC262 Digital";
10660 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10661 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10662
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010010663 spec->is_mix_capture = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010664 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010665 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010666 unsigned int wcap = get_wcaps(codec, 0x07);
10667
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010668 /* get type */
10669 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010670 if (wcap != AC_WID_AUD_IN) {
10671 spec->adc_nids = alc262_adc_nids_alt;
10672 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010673 spec->capsrc_nids = alc262_capsrc_nids_alt;
Kailang Yangdf694da2005-12-05 19:42:22 +010010674 } else {
10675 spec->adc_nids = alc262_adc_nids;
10676 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010677 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010678 }
10679 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010680 if (!spec->cap_mixer)
10681 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010010682
Takashi Iwai2134ea42008-01-10 16:53:55 +010010683 spec->vmaster_nid = 0x0c;
10684
Kailang Yangdf694da2005-12-05 19:42:22 +010010685 codec->patch_ops = alc_patch_ops;
10686 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010687 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010688#ifdef CONFIG_SND_HDA_POWER_SAVE
10689 if (!spec->loopback.amplist)
10690 spec->loopback.amplist = alc262_loopbacks;
10691#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020010692
Kailang Yangdf694da2005-12-05 19:42:22 +010010693 return 0;
10694}
10695
Kailang Yangdf694da2005-12-05 19:42:22 +010010696/*
Kailang Yanga361d842007-06-05 12:30:55 +020010697 * ALC268 channel source setting (2 channel)
10698 */
10699#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10700#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010701
Kailang Yanga361d842007-06-05 12:30:55 +020010702static hda_nid_t alc268_dac_nids[2] = {
10703 /* front, hp */
10704 0x02, 0x03
10705};
10706
10707static hda_nid_t alc268_adc_nids[2] = {
10708 /* ADC0-1 */
10709 0x08, 0x07
10710};
10711
10712static hda_nid_t alc268_adc_nids_alt[1] = {
10713 /* ADC0 */
10714 0x08
10715};
10716
Takashi Iwaie1406342008-02-11 18:32:32 +010010717static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10718
Kailang Yanga361d842007-06-05 12:30:55 +020010719static struct snd_kcontrol_new alc268_base_mixer[] = {
10720 /* output mixer control */
10721 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10722 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10723 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10724 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010725 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10726 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10727 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010728 { }
10729};
10730
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010731/* bind Beep switches of both NID 0x0f and 0x10 */
10732static struct hda_bind_ctls alc268_bind_beep_sw = {
10733 .ops = &snd_hda_bind_sw,
10734 .values = {
10735 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10736 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10737 0
10738 },
10739};
10740
10741static struct snd_kcontrol_new alc268_beep_mixer[] = {
10742 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10743 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10744 { }
10745};
10746
Kailang Yangd1a991a2007-08-15 16:21:59 +020010747static struct hda_verb alc268_eapd_verbs[] = {
10748 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10749 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10750 { }
10751};
10752
Takashi Iwaid2738092007-08-16 14:59:45 +020010753/* Toshiba specific */
10754#define alc268_toshiba_automute alc262_hippo_automute
10755
10756static struct hda_verb alc268_toshiba_verbs[] = {
10757 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10758 { } /* end */
10759};
10760
Kailang Yang8ef355d2008-08-26 13:10:22 +020010761static struct hda_input_mux alc268_acer_lc_capture_source = {
10762 .num_items = 2,
10763 .items = {
10764 { "i-Mic", 0x6 },
10765 { "E-Mic", 0x0 },
10766 },
10767};
10768
Takashi Iwaid2738092007-08-16 14:59:45 +020010769/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010770/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010771static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10772 .ops = &snd_hda_bind_vol,
10773 .values = {
10774 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10775 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10776 0
10777 },
10778};
10779
Takashi Iwai889c4392007-08-23 18:56:52 +020010780/* mute/unmute internal speaker according to the hp jack and mute state */
10781static void alc268_acer_automute(struct hda_codec *codec, int force)
10782{
10783 struct alc_spec *spec = codec->spec;
10784 unsigned int mute;
10785
10786 if (force || !spec->sense_updated) {
10787 unsigned int present;
10788 present = snd_hda_codec_read(codec, 0x14, 0,
10789 AC_VERB_GET_PIN_SENSE, 0);
10790 spec->jack_present = (present & 0x80000000) != 0;
10791 spec->sense_updated = 1;
10792 }
10793 if (spec->jack_present)
10794 mute = HDA_AMP_MUTE; /* mute internal speaker */
10795 else /* unmute internal speaker if necessary */
10796 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10797 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10798 HDA_AMP_MUTE, mute);
10799}
10800
10801
10802/* bind hp and internal speaker mute (with plug check) */
10803static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10804 struct snd_ctl_elem_value *ucontrol)
10805{
10806 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10807 long *valp = ucontrol->value.integer.value;
10808 int change;
10809
10810 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10811 HDA_AMP_MUTE,
10812 valp[0] ? 0 : HDA_AMP_MUTE);
10813 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10814 HDA_AMP_MUTE,
10815 valp[1] ? 0 : HDA_AMP_MUTE);
10816 if (change)
10817 alc268_acer_automute(codec, 0);
10818 return change;
10819}
Takashi Iwaid2738092007-08-16 14:59:45 +020010820
Kailang Yang8ef355d2008-08-26 13:10:22 +020010821static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
10822 /* output mixer control */
10823 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10824 {
10825 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10826 .name = "Master Playback Switch",
10827 .info = snd_hda_mixer_amp_switch_info,
10828 .get = snd_hda_mixer_amp_switch_get,
10829 .put = alc268_acer_master_sw_put,
10830 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10831 },
10832 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
10833 { }
10834};
10835
Takashi Iwaid2738092007-08-16 14:59:45 +020010836static struct snd_kcontrol_new alc268_acer_mixer[] = {
10837 /* output mixer control */
10838 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10839 {
10840 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10841 .name = "Master Playback Switch",
10842 .info = snd_hda_mixer_amp_switch_info,
10843 .get = snd_hda_mixer_amp_switch_get,
10844 .put = alc268_acer_master_sw_put,
10845 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10846 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010847 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10848 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10849 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010850 { }
10851};
10852
Takashi Iwaic238b4f2008-11-05 14:57:20 +010010853static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
10854 /* output mixer control */
10855 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10856 {
10857 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10858 .name = "Master Playback Switch",
10859 .info = snd_hda_mixer_amp_switch_info,
10860 .get = snd_hda_mixer_amp_switch_get,
10861 .put = alc268_acer_master_sw_put,
10862 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10863 },
10864 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10865 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
10866 { }
10867};
10868
Kailang Yang8ef355d2008-08-26 13:10:22 +020010869static struct hda_verb alc268_acer_aspire_one_verbs[] = {
10870 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10871 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10872 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10873 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10874 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
10875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
10876 { }
10877};
10878
Takashi Iwaid2738092007-08-16 14:59:45 +020010879static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010880 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10881 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010882 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010884 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10885 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010886 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10887 { }
10888};
10889
10890/* unsolicited event for HP jack sensing */
10891static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10892 unsigned int res)
10893{
Takashi Iwai889c4392007-08-23 18:56:52 +020010894 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010895 return;
10896 alc268_toshiba_automute(codec);
10897}
10898
10899static void alc268_acer_unsol_event(struct hda_codec *codec,
10900 unsigned int res)
10901{
Takashi Iwai889c4392007-08-23 18:56:52 +020010902 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010903 return;
10904 alc268_acer_automute(codec, 1);
10905}
10906
Takashi Iwai889c4392007-08-23 18:56:52 +020010907static void alc268_acer_init_hook(struct hda_codec *codec)
10908{
10909 alc268_acer_automute(codec, 1);
10910}
10911
Kailang Yang8ef355d2008-08-26 13:10:22 +020010912/* toggle speaker-output according to the hp-jack state */
10913static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
10914{
10915 unsigned int present;
10916 unsigned char bits;
10917
10918 present = snd_hda_codec_read(codec, 0x15, 0,
10919 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10920 bits = present ? AMP_IN_MUTE(0) : 0;
10921 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
10922 AMP_IN_MUTE(0), bits);
10923 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
10924 AMP_IN_MUTE(0), bits);
10925}
10926
10927
10928static void alc268_acer_mic_automute(struct hda_codec *codec)
10929{
10930 unsigned int present;
10931
10932 present = snd_hda_codec_read(codec, 0x18, 0,
10933 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10934 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
10935 present ? 0x0 : 0x6);
10936}
10937
10938static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
10939 unsigned int res)
10940{
10941 if ((res >> 26) == ALC880_HP_EVENT)
10942 alc268_aspire_one_speaker_automute(codec);
10943 if ((res >> 26) == ALC880_MIC_EVENT)
10944 alc268_acer_mic_automute(codec);
10945}
10946
10947static void alc268_acer_lc_init_hook(struct hda_codec *codec)
10948{
10949 alc268_aspire_one_speaker_automute(codec);
10950 alc268_acer_mic_automute(codec);
10951}
10952
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010953static struct snd_kcontrol_new alc268_dell_mixer[] = {
10954 /* output mixer control */
10955 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10956 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10957 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10958 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10959 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10960 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10961 { }
10962};
10963
10964static struct hda_verb alc268_dell_verbs[] = {
10965 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10966 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10967 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10968 { }
10969};
10970
10971/* mute/unmute internal speaker according to the hp jack and mute state */
10972static void alc268_dell_automute(struct hda_codec *codec)
10973{
10974 unsigned int present;
10975 unsigned int mute;
10976
10977 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10978 if (present & 0x80000000)
10979 mute = HDA_AMP_MUTE;
10980 else
10981 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10982 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10983 HDA_AMP_MUTE, mute);
10984}
10985
10986static void alc268_dell_unsol_event(struct hda_codec *codec,
10987 unsigned int res)
10988{
10989 if ((res >> 26) != ALC880_HP_EVENT)
10990 return;
10991 alc268_dell_automute(codec);
10992}
10993
10994#define alc268_dell_init_hook alc268_dell_automute
10995
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010996static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10997 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10998 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10999 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
11000 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11001 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11002 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
11003 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
11004 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11005 { }
11006};
11007
11008static struct hda_verb alc267_quanta_il1_verbs[] = {
11009 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11010 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
11011 { }
11012};
11013
11014static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
11015{
11016 unsigned int present;
11017
11018 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
11019 & AC_PINSENSE_PRESENCE;
11020 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11021 present ? 0 : PIN_OUT);
11022}
11023
11024static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
11025{
11026 unsigned int present;
11027
11028 present = snd_hda_codec_read(codec, 0x18, 0,
11029 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11030 snd_hda_codec_write(codec, 0x23, 0,
11031 AC_VERB_SET_CONNECT_SEL,
11032 present ? 0x00 : 0x01);
11033}
11034
11035static void alc267_quanta_il1_automute(struct hda_codec *codec)
11036{
11037 alc267_quanta_il1_hp_automute(codec);
11038 alc267_quanta_il1_mic_automute(codec);
11039}
11040
11041static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
11042 unsigned int res)
11043{
11044 switch (res >> 26) {
11045 case ALC880_HP_EVENT:
11046 alc267_quanta_il1_hp_automute(codec);
11047 break;
11048 case ALC880_MIC_EVENT:
11049 alc267_quanta_il1_mic_automute(codec);
11050 break;
11051 }
11052}
11053
Kailang Yanga361d842007-06-05 12:30:55 +020011054/*
11055 * generic initialization of ADC, input mixers and output mixers
11056 */
11057static struct hda_verb alc268_base_init_verbs[] = {
11058 /* Unmute DAC0-1 and set vol = 0 */
11059 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11060 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11061 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11062 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11063 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11064 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11065
11066 /*
11067 * Set up output mixers (0x0c - 0x0e)
11068 */
11069 /* set vol=0 to output mixers */
11070 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11072 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11073 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
11074
11075 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11076 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11077
11078 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11079 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11080 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11081 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11082 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11083 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11084 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11085 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11086
11087 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11088 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11089 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11090 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11091 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11092 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11093 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011094
11095 /* set PCBEEP vol = 0, mute connections */
11096 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11097 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11098 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011099
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011100 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020011101
Jiang Zhea9b3aa82007-12-20 13:13:13 +010011102 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
11103 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11104 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
11105 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020011106
Kailang Yanga361d842007-06-05 12:30:55 +020011107 { }
11108};
11109
11110/*
11111 * generic initialization of ADC, input mixers and output mixers
11112 */
11113static struct hda_verb alc268_volume_init_verbs[] = {
11114 /* set output DAC */
11115 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11116 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11117 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11118 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11119
11120 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11121 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11122 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11123 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11124 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11125
11126 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11127 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11128 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11129 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11130 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11131
11132 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11133 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11134 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11135 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11136
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011137 /* set PCBEEP vol = 0, mute connections */
11138 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11139 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11140 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020011141
11142 { }
11143};
11144
Kailang Yanga361d842007-06-05 12:30:55 +020011145static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
11146 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11147 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11148 {
11149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11150 /* The multiple "Capture Source" controls confuse alsamixer
11151 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011152 */
11153 /* .name = "Capture Source", */
11154 .name = "Input Source",
11155 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011156 .info = alc_mux_enum_info,
11157 .get = alc_mux_enum_get,
11158 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011159 },
11160 { } /* end */
11161};
11162
11163static struct snd_kcontrol_new alc268_capture_mixer[] = {
11164 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11165 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
11166 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
11167 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
11168 {
11169 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11170 /* The multiple "Capture Source" controls confuse alsamixer
11171 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020011172 */
11173 /* .name = "Capture Source", */
11174 .name = "Input Source",
11175 .count = 2,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011176 .info = alc_mux_enum_info,
11177 .get = alc_mux_enum_get,
11178 .put = alc_mux_enum_put,
Kailang Yanga361d842007-06-05 12:30:55 +020011179 },
11180 { } /* end */
11181};
11182
11183static struct hda_input_mux alc268_capture_source = {
11184 .num_items = 4,
11185 .items = {
11186 { "Mic", 0x0 },
11187 { "Front Mic", 0x1 },
11188 { "Line", 0x2 },
11189 { "CD", 0x3 },
11190 },
11191};
11192
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011193static struct hda_input_mux alc268_acer_capture_source = {
11194 .num_items = 3,
11195 .items = {
11196 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011197 { "Internal Mic", 0x1 },
11198 { "Line", 0x2 },
11199 },
11200};
11201
11202static struct hda_input_mux alc268_acer_dmic_capture_source = {
11203 .num_items = 3,
11204 .items = {
11205 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011206 { "Internal Mic", 0x6 },
11207 { "Line", 0x2 },
11208 },
11209};
11210
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011211#ifdef CONFIG_SND_DEBUG
11212static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011213 /* Volume widgets */
11214 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11215 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
11216 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
11217 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
11218 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
11219 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
11220 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
11221 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
11222 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
11223 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
11224 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
11225 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
11226 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010011227 /* The below appears problematic on some hardwares */
11228 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011229 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
11230 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
11231 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
11232 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
11233
11234 /* Modes for retasking pin widgets */
11235 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
11236 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
11237 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
11238 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
11239
11240 /* Controls for GPIO pins, assuming they are configured as outputs */
11241 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
11242 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
11243 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
11244 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
11245
11246 /* Switches to allow the digital SPDIF output pin to be enabled.
11247 * The ALC268 does not have an SPDIF input.
11248 */
11249 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
11250
11251 /* A switch allowing EAPD to be enabled. Some laptops seem to use
11252 * this output to turn on an external amplifier.
11253 */
11254 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
11255 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
11256
11257 { } /* end */
11258};
11259#endif
11260
Kailang Yanga361d842007-06-05 12:30:55 +020011261/* create input playback/capture controls for the given pin */
11262static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
11263 const char *ctlname, int idx)
11264{
11265 char name[32];
11266 int err;
11267
11268 sprintf(name, "%s Playback Volume", ctlname);
11269 if (nid == 0x14) {
11270 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11271 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
11272 HDA_OUTPUT));
11273 if (err < 0)
11274 return err;
11275 } else if (nid == 0x15) {
11276 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
11277 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
11278 HDA_OUTPUT));
11279 if (err < 0)
11280 return err;
11281 } else
11282 return -1;
11283 sprintf(name, "%s Playback Switch", ctlname);
11284 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
11285 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
11286 if (err < 0)
11287 return err;
11288 return 0;
11289}
11290
11291/* add playback controls from the parsed DAC table */
11292static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
11293 const struct auto_pin_cfg *cfg)
11294{
11295 hda_nid_t nid;
11296 int err;
11297
11298 spec->multiout.num_dacs = 2; /* only use one dac */
11299 spec->multiout.dac_nids = spec->private_dac_nids;
11300 spec->multiout.dac_nids[0] = 2;
11301 spec->multiout.dac_nids[1] = 3;
11302
11303 nid = cfg->line_out_pins[0];
11304 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020011305 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020011306
11307 nid = cfg->speaker_pins[0];
11308 if (nid == 0x1d) {
11309 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11310 "Speaker Playback Volume",
11311 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
11312 if (err < 0)
11313 return err;
11314 }
11315 nid = cfg->hp_pins[0];
11316 if (nid)
11317 alc268_new_analog_output(spec, nid, "Headphone", 0);
11318
11319 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
11320 if (nid == 0x16) {
11321 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11322 "Mono Playback Switch",
11323 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
11324 if (err < 0)
11325 return err;
11326 }
Kailang Yangea1fb292008-08-26 12:58:38 +020011327 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020011328}
11329
11330/* create playback/capture controls for input pins */
11331static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
11332 const struct auto_pin_cfg *cfg)
11333{
11334 struct hda_input_mux *imux = &spec->private_imux;
11335 int i, idx1;
11336
11337 for (i = 0; i < AUTO_PIN_LAST; i++) {
11338 switch(cfg->input_pins[i]) {
11339 case 0x18:
11340 idx1 = 0; /* Mic 1 */
11341 break;
11342 case 0x19:
11343 idx1 = 1; /* Mic 2 */
11344 break;
11345 case 0x1a:
11346 idx1 = 2; /* Line In */
11347 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020011348 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020011349 idx1 = 3; /* CD */
11350 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010011351 case 0x12:
11352 case 0x13:
11353 idx1 = 6; /* digital mics */
11354 break;
Kailang Yanga361d842007-06-05 12:30:55 +020011355 default:
11356 continue;
11357 }
11358 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
11359 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020011360 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020011361 }
11362 return 0;
11363}
11364
11365static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
11366{
11367 struct alc_spec *spec = codec->spec;
11368 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11369 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11370 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11371 unsigned int dac_vol1, dac_vol2;
11372
11373 if (speaker_nid) {
11374 snd_hda_codec_write(codec, speaker_nid, 0,
11375 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
11376 snd_hda_codec_write(codec, 0x0f, 0,
11377 AC_VERB_SET_AMP_GAIN_MUTE,
11378 AMP_IN_UNMUTE(1));
11379 snd_hda_codec_write(codec, 0x10, 0,
11380 AC_VERB_SET_AMP_GAIN_MUTE,
11381 AMP_IN_UNMUTE(1));
11382 } else {
11383 snd_hda_codec_write(codec, 0x0f, 0,
11384 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11385 snd_hda_codec_write(codec, 0x10, 0,
11386 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
11387 }
11388
11389 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020011390 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011391 dac_vol2 = AMP_OUT_ZERO;
11392 else if (line_nid == 0x15)
11393 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020011394 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020011395 dac_vol2 = AMP_OUT_ZERO;
11396 else if (hp_nid == 0x15)
11397 dac_vol1 = AMP_OUT_ZERO;
11398 if (line_nid != 0x16 || hp_nid != 0x16 ||
11399 spec->autocfg.line_out_pins[1] != 0x16 ||
11400 spec->autocfg.line_out_pins[2] != 0x16)
11401 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
11402
11403 snd_hda_codec_write(codec, 0x02, 0,
11404 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
11405 snd_hda_codec_write(codec, 0x03, 0,
11406 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
11407}
11408
11409/* pcm configuration: identiacal with ALC880 */
11410#define alc268_pcm_analog_playback alc880_pcm_analog_playback
11411#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010011412#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020011413#define alc268_pcm_digital_playback alc880_pcm_digital_playback
11414
11415/*
11416 * BIOS auto configuration
11417 */
11418static int alc268_parse_auto_config(struct hda_codec *codec)
11419{
11420 struct alc_spec *spec = codec->spec;
11421 int err;
11422 static hda_nid_t alc268_ignore[] = { 0 };
11423
11424 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11425 alc268_ignore);
11426 if (err < 0)
11427 return err;
11428 if (!spec->autocfg.line_outs)
11429 return 0; /* can't find valid BIOS pin config */
11430
11431 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11432 if (err < 0)
11433 return err;
11434 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11435 if (err < 0)
11436 return err;
11437
11438 spec->multiout.max_channels = 2;
11439
11440 /* digital only support output */
11441 if (spec->autocfg.dig_out_pin)
11442 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11443
Takashi Iwai603c4012008-07-30 15:01:44 +020011444 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011445 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020011446
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011447 if (spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010011448 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011449
Takashi Iwaid88897e2008-10-31 15:01:37 +010011450 add_verb(spec, alc268_volume_init_verbs);
Kailang Yanga361d842007-06-05 12:30:55 +020011451 spec->num_mux_defs = 1;
11452 spec->input_mux = &spec->private_imux;
11453
Takashi Iwai776e1842007-08-29 15:07:11 +020011454 err = alc_auto_add_mic_boost(codec);
11455 if (err < 0)
11456 return err;
11457
Takashi Iwaie044c392008-10-27 16:56:24 +010011458 store_pin_configs(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011459 return 1;
11460}
11461
11462#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11463#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11464#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11465
11466/* init callback for auto-configuration model -- overriding the default init */
11467static void alc268_auto_init(struct hda_codec *codec)
11468{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011469 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011470 alc268_auto_init_multi_out(codec);
11471 alc268_auto_init_hp_out(codec);
11472 alc268_auto_init_mono_speaker_out(codec);
11473 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011474 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020011475 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011476}
11477
11478/*
11479 * configuration and preset
11480 */
11481static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011482 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011483 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011484 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011485 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011486 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011487 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011488 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011489 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011490#ifdef CONFIG_SND_DEBUG
11491 [ALC268_TEST] = "test",
11492#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011493 [ALC268_AUTO] = "auto",
11494};
11495
11496static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011497 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011498 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011499 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011500 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011501 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011502 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11503 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011504 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011505 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011506 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011507 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011508 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Travis Place2346d0c2008-09-01 08:24:00 +020011509 SND_PCI_QUIRK(0x1179, 0xff64, "TOSHIBA L305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011510 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011511 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011512 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011513 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011514 {}
11515};
11516
11517static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011518 [ALC267_QUANTA_IL1] = {
11519 .mixers = { alc267_quanta_il1_mixer },
11520 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11521 alc267_quanta_il1_verbs },
11522 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11523 .dac_nids = alc268_dac_nids,
11524 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11525 .adc_nids = alc268_adc_nids_alt,
11526 .hp_nid = 0x03,
11527 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11528 .channel_mode = alc268_modes,
11529 .input_mux = &alc268_capture_source,
11530 .unsol_event = alc267_quanta_il1_unsol_event,
11531 .init_hook = alc267_quanta_il1_automute,
11532 },
Kailang Yanga361d842007-06-05 12:30:55 +020011533 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011534 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11535 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011536 .init_verbs = { alc268_base_init_verbs },
11537 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11538 .dac_nids = alc268_dac_nids,
11539 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11540 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011541 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011542 .hp_nid = 0x03,
11543 .dig_out_nid = ALC268_DIGOUT_NID,
11544 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11545 .channel_mode = alc268_modes,
11546 .input_mux = &alc268_capture_source,
11547 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011548 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011549 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11550 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011551 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11552 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011553 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11554 .dac_nids = alc268_dac_nids,
11555 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11556 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011557 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011558 .hp_nid = 0x03,
11559 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11560 .channel_mode = alc268_modes,
11561 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011562 .unsol_event = alc268_toshiba_unsol_event,
11563 .init_hook = alc268_toshiba_automute,
11564 },
11565 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011566 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11567 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011568 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11569 alc268_acer_verbs },
11570 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11571 .dac_nids = alc268_dac_nids,
11572 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11573 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011574 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011575 .hp_nid = 0x02,
11576 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11577 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011578 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011579 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011580 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011581 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010011582 [ALC268_ACER_DMIC] = {
11583 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
11584 alc268_beep_mixer },
11585 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11586 alc268_acer_verbs },
11587 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11588 .dac_nids = alc268_dac_nids,
11589 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11590 .adc_nids = alc268_adc_nids_alt,
11591 .capsrc_nids = alc268_capsrc_nids,
11592 .hp_nid = 0x02,
11593 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11594 .channel_mode = alc268_modes,
11595 .input_mux = &alc268_acer_dmic_capture_source,
11596 .unsol_event = alc268_acer_unsol_event,
11597 .init_hook = alc268_acer_init_hook,
11598 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011599 [ALC268_ACER_ASPIRE_ONE] = {
11600 .mixers = { alc268_acer_aspire_one_mixer,
11601 alc268_capture_alt_mixer },
11602 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11603 alc268_acer_aspire_one_verbs },
11604 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11605 .dac_nids = alc268_dac_nids,
11606 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11607 .adc_nids = alc268_adc_nids_alt,
11608 .capsrc_nids = alc268_capsrc_nids,
11609 .hp_nid = 0x03,
11610 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11611 .channel_mode = alc268_modes,
11612 .input_mux = &alc268_acer_lc_capture_source,
11613 .unsol_event = alc268_acer_lc_unsol_event,
11614 .init_hook = alc268_acer_lc_init_hook,
11615 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011616 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011617 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011618 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11619 alc268_dell_verbs },
11620 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11621 .dac_nids = alc268_dac_nids,
11622 .hp_nid = 0x02,
11623 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11624 .channel_mode = alc268_modes,
11625 .unsol_event = alc268_dell_unsol_event,
11626 .init_hook = alc268_dell_init_hook,
11627 .input_mux = &alc268_capture_source,
11628 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011629 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011630 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11631 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011632 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11633 alc268_toshiba_verbs },
11634 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11635 .dac_nids = alc268_dac_nids,
11636 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11637 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011638 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011639 .hp_nid = 0x03,
11640 .dig_out_nid = ALC268_DIGOUT_NID,
11641 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11642 .channel_mode = alc268_modes,
11643 .input_mux = &alc268_capture_source,
11644 .unsol_event = alc268_toshiba_unsol_event,
11645 .init_hook = alc268_toshiba_automute
11646 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011647#ifdef CONFIG_SND_DEBUG
11648 [ALC268_TEST] = {
11649 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11650 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11651 alc268_volume_init_verbs },
11652 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11653 .dac_nids = alc268_dac_nids,
11654 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11655 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011656 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011657 .hp_nid = 0x03,
11658 .dig_out_nid = ALC268_DIGOUT_NID,
11659 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11660 .channel_mode = alc268_modes,
11661 .input_mux = &alc268_capture_source,
11662 },
11663#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011664};
11665
11666static int patch_alc268(struct hda_codec *codec)
11667{
11668 struct alc_spec *spec;
11669 int board_config;
11670 int err;
11671
11672 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11673 if (spec == NULL)
11674 return -ENOMEM;
11675
11676 codec->spec = spec;
11677
11678 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11679 alc268_models,
11680 alc268_cfg_tbl);
11681
11682 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11683 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11684 "trying auto-probe from BIOS...\n");
11685 board_config = ALC268_AUTO;
11686 }
11687
11688 if (board_config == ALC268_AUTO) {
11689 /* automatic parse from the BIOS config */
11690 err = alc268_parse_auto_config(codec);
11691 if (err < 0) {
11692 alc_free(codec);
11693 return err;
11694 } else if (!err) {
11695 printk(KERN_INFO
11696 "hda_codec: Cannot set up configuration "
11697 "from BIOS. Using base mode...\n");
11698 board_config = ALC268_3ST;
11699 }
11700 }
11701
11702 if (board_config != ALC268_AUTO)
11703 setup_preset(spec, &alc268_presets[board_config]);
11704
Kailang Yang2f893282008-05-27 12:14:47 +020011705 if (codec->vendor_id == 0x10ec0267) {
11706 spec->stream_name_analog = "ALC267 Analog";
11707 spec->stream_name_digital = "ALC267 Digital";
11708 } else {
11709 spec->stream_name_analog = "ALC268 Analog";
11710 spec->stream_name_digital = "ALC268 Digital";
11711 }
11712
Kailang Yanga361d842007-06-05 12:30:55 +020011713 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11714 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011715 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011716
Kailang Yanga361d842007-06-05 12:30:55 +020011717 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11718
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011719 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11720 /* override the amp caps for beep generator */
11721 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11722 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11723 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11724 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11725 (0 << AC_AMPCAP_MUTE_SHIFT));
11726
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011727 if (!spec->adc_nids && spec->input_mux) {
11728 /* check whether NID 0x07 is valid */
11729 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011730 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011731
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011732 /* get type */
11733 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011734 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011735 spec->adc_nids = alc268_adc_nids_alt;
11736 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011737 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011738 } else {
11739 spec->adc_nids = alc268_adc_nids;
11740 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010011741 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020011742 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011743 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011744 /* set default input source */
11745 for (i = 0; i < spec->num_adc_nids; i++)
11746 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11747 0, AC_VERB_SET_CONNECT_SEL,
11748 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011749 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011750
11751 spec->vmaster_nid = 0x02;
11752
Kailang Yanga361d842007-06-05 12:30:55 +020011753 codec->patch_ops = alc_patch_ops;
11754 if (board_config == ALC268_AUTO)
11755 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011756
Kailang Yanga361d842007-06-05 12:30:55 +020011757 return 0;
11758}
11759
11760/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011761 * ALC269 channel source setting (2 channel)
11762 */
11763#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11764
11765#define alc269_dac_nids alc260_dac_nids
11766
11767static hda_nid_t alc269_adc_nids[1] = {
11768 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011769 0x08,
11770};
11771
Takashi Iwaie01bf502008-08-21 16:25:07 +020011772static hda_nid_t alc269_capsrc_nids[1] = {
11773 0x23,
11774};
11775
11776/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11777 * not a mux!
11778 */
11779
Kailang Yangf53281e2008-07-18 12:36:43 +020011780static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11781 .num_items = 2,
11782 .items = {
11783 { "i-Mic", 0x5 },
11784 { "e-Mic", 0x0 },
11785 },
11786};
11787
11788static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11789 .num_items = 2,
11790 .items = {
11791 { "i-Mic", 0x1 },
11792 { "e-Mic", 0x0 },
11793 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011794};
11795
11796#define alc269_modes alc260_modes
11797#define alc269_capture_source alc880_lg_lw_capture_source
11798
11799static struct snd_kcontrol_new alc269_base_mixer[] = {
11800 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11801 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11802 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11803 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11804 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11805 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020011806 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11807 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011808 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11809 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11810 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11811 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11812 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11813 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11814 { } /* end */
11815};
11816
Kailang Yang60db6b52008-08-26 13:13:00 +020011817static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
11818 /* output mixer control */
11819 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11820 {
11821 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11822 .name = "Master Playback Switch",
11823 .info = snd_hda_mixer_amp_switch_info,
11824 .get = snd_hda_mixer_amp_switch_get,
11825 .put = alc268_acer_master_sw_put,
11826 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11827 },
11828 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11829 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11830 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11831 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11832 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11833 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11834 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
11835 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
11836 { }
11837};
11838
Tony Vroon64154832008-11-06 15:08:49 +000011839static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
11840 /* output mixer control */
11841 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11842 {
11843 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11844 .name = "Master Playback Switch",
11845 .info = snd_hda_mixer_amp_switch_info,
11846 .get = snd_hda_mixer_amp_switch_get,
11847 .put = alc268_acer_master_sw_put,
11848 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11849 },
11850 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11851 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11852 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11853 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11854 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11855 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11856 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
11857 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
11858 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
11859 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
11860 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
11861 { }
11862};
11863
Kailang Yangf53281e2008-07-18 12:36:43 +020011864/* bind volumes of both NID 0x0c and 0x0d */
11865static struct hda_bind_ctls alc269_epc_bind_vol = {
11866 .ops = &snd_hda_bind_vol,
11867 .values = {
11868 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11869 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11870 0
11871 },
11872};
11873
11874static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11875 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11876 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11877 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11878 { } /* end */
11879};
11880
Kailang Yangf6a92242007-12-13 16:52:54 +010011881/* capture mixer elements */
Kailang Yangf53281e2008-07-18 12:36:43 +020011882static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11883 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11884 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010011885 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11886 { } /* end */
11887};
11888
11889/* FSC amilo */
11890static struct snd_kcontrol_new alc269_fujitsu_mixer[] = {
11891 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11893 HDA_BIND_VOL("PCM Playback Volume", &alc269_epc_bind_vol),
Kailang Yangf53281e2008-07-18 12:36:43 +020011894 { } /* end */
11895};
11896
Takashi Iwai2005af22008-08-20 18:38:26 +020011897/* beep control */
11898static struct snd_kcontrol_new alc269_beep_mixer[] = {
11899 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11900 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
11901 { } /* end */
11902};
11903
Kailang Yang60db6b52008-08-26 13:13:00 +020011904static struct hda_verb alc269_quanta_fl1_verbs[] = {
11905 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11906 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11907 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11908 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11909 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11910 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11911 { }
11912};
11913
Tony Vroon64154832008-11-06 15:08:49 +000011914static struct hda_verb alc269_lifebook_verbs[] = {
11915 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11916 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
11917 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11918 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11919 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11920 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11921 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11922 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11923 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11924 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11925 { }
11926};
11927
Kailang Yang60db6b52008-08-26 13:13:00 +020011928/* toggle speaker-output according to the hp-jack state */
11929static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
11930{
11931 unsigned int present;
11932 unsigned char bits;
11933
11934 present = snd_hda_codec_read(codec, 0x15, 0,
11935 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11936 bits = present ? AMP_IN_MUTE(0) : 0;
11937 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11938 AMP_IN_MUTE(0), bits);
11939 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11940 AMP_IN_MUTE(0), bits);
11941
11942 snd_hda_codec_write(codec, 0x20, 0,
11943 AC_VERB_SET_COEF_INDEX, 0x0c);
11944 snd_hda_codec_write(codec, 0x20, 0,
11945 AC_VERB_SET_PROC_COEF, 0x680);
11946
11947 snd_hda_codec_write(codec, 0x20, 0,
11948 AC_VERB_SET_COEF_INDEX, 0x0c);
11949 snd_hda_codec_write(codec, 0x20, 0,
11950 AC_VERB_SET_PROC_COEF, 0x480);
11951}
11952
Tony Vroon64154832008-11-06 15:08:49 +000011953/* toggle speaker-output according to the hp-jacks state */
11954static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
11955{
11956 unsigned int present;
11957 unsigned char bits;
11958
11959 /* Check laptop headphone socket */
11960 present = snd_hda_codec_read(codec, 0x15, 0,
11961 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11962
11963 /* Check port replicator headphone socket */
11964 present |= snd_hda_codec_read(codec, 0x1a, 0,
11965 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11966
11967 bits = present ? AMP_IN_MUTE(0) : 0;
11968 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11969 AMP_IN_MUTE(0), bits);
11970 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11971 AMP_IN_MUTE(0), bits);
11972
11973 snd_hda_codec_write(codec, 0x20, 0,
11974 AC_VERB_SET_COEF_INDEX, 0x0c);
11975 snd_hda_codec_write(codec, 0x20, 0,
11976 AC_VERB_SET_PROC_COEF, 0x680);
11977
11978 snd_hda_codec_write(codec, 0x20, 0,
11979 AC_VERB_SET_COEF_INDEX, 0x0c);
11980 snd_hda_codec_write(codec, 0x20, 0,
11981 AC_VERB_SET_PROC_COEF, 0x480);
11982}
11983
Kailang Yang60db6b52008-08-26 13:13:00 +020011984static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
11985{
11986 unsigned int present;
11987
11988 present = snd_hda_codec_read(codec, 0x18, 0,
11989 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11990 snd_hda_codec_write(codec, 0x23, 0,
11991 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
11992}
11993
Tony Vroon64154832008-11-06 15:08:49 +000011994static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
11995{
11996 unsigned int present_laptop;
11997 unsigned int present_dock;
11998
11999 present_laptop = snd_hda_codec_read(codec, 0x18, 0,
12000 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12001
12002 present_dock = snd_hda_codec_read(codec, 0x1b, 0,
12003 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12004
12005 /* Laptop mic port overrides dock mic port, design decision */
12006 if (present_dock)
12007 snd_hda_codec_write(codec, 0x23, 0,
12008 AC_VERB_SET_CONNECT_SEL, 0x3);
12009 if (present_laptop)
12010 snd_hda_codec_write(codec, 0x23, 0,
12011 AC_VERB_SET_CONNECT_SEL, 0x0);
12012 if (!present_dock && !present_laptop)
12013 snd_hda_codec_write(codec, 0x23, 0,
12014 AC_VERB_SET_CONNECT_SEL, 0x1);
12015}
12016
Kailang Yang60db6b52008-08-26 13:13:00 +020012017static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
12018 unsigned int res)
12019{
12020 if ((res >> 26) == ALC880_HP_EVENT)
12021 alc269_quanta_fl1_speaker_automute(codec);
12022 if ((res >> 26) == ALC880_MIC_EVENT)
12023 alc269_quanta_fl1_mic_automute(codec);
12024}
12025
Tony Vroon64154832008-11-06 15:08:49 +000012026static void alc269_lifebook_unsol_event(struct hda_codec *codec,
12027 unsigned int res)
12028{
12029 if ((res >> 26) == ALC880_HP_EVENT)
12030 alc269_lifebook_speaker_automute(codec);
12031 if ((res >> 26) == ALC880_MIC_EVENT)
12032 alc269_lifebook_mic_autoswitch(codec);
12033}
12034
Kailang Yang60db6b52008-08-26 13:13:00 +020012035static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
12036{
12037 alc269_quanta_fl1_speaker_automute(codec);
12038 alc269_quanta_fl1_mic_automute(codec);
12039}
12040
Tony Vroon64154832008-11-06 15:08:49 +000012041static void alc269_lifebook_init_hook(struct hda_codec *codec)
12042{
12043 alc269_lifebook_speaker_automute(codec);
12044 alc269_lifebook_mic_autoswitch(codec);
12045}
12046
Kailang Yang60db6b52008-08-26 13:13:00 +020012047static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
12048 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12049 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
12050 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12051 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
12052 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12053 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12054 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12055 {}
12056};
12057
12058static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
12059 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12060 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
12061 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
12062 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
12063 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
12064 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12065 {}
12066};
12067
12068/* toggle speaker-output according to the hp-jack state */
12069static void alc269_speaker_automute(struct hda_codec *codec)
12070{
12071 unsigned int present;
12072 unsigned char bits;
12073
12074 present = snd_hda_codec_read(codec, 0x15, 0,
12075 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12076 bits = present ? AMP_IN_MUTE(0) : 0;
12077 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
12078 AMP_IN_MUTE(0), bits);
12079 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
12080 AMP_IN_MUTE(0), bits);
12081}
12082
12083static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
12084{
12085 unsigned int present;
12086
12087 present = snd_hda_codec_read(codec, 0x18, 0,
12088 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12089 snd_hda_codec_write(codec, 0x23, 0,
12090 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
12091}
12092
12093static void alc269_eeepc_amic_automute(struct hda_codec *codec)
12094{
12095 unsigned int present;
12096
12097 present = snd_hda_codec_read(codec, 0x18, 0,
12098 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
12099 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12100 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
12101 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12102 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
12103}
12104
12105/* unsolicited event for HP jack sensing */
12106static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
12107 unsigned int res)
12108{
12109 if ((res >> 26) == ALC880_HP_EVENT)
12110 alc269_speaker_automute(codec);
12111
12112 if ((res >> 26) == ALC880_MIC_EVENT)
12113 alc269_eeepc_dmic_automute(codec);
12114}
12115
12116static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
12117{
12118 alc269_speaker_automute(codec);
12119 alc269_eeepc_dmic_automute(codec);
12120}
12121
12122/* unsolicited event for HP jack sensing */
12123static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
12124 unsigned int res)
12125{
12126 if ((res >> 26) == ALC880_HP_EVENT)
12127 alc269_speaker_automute(codec);
12128
12129 if ((res >> 26) == ALC880_MIC_EVENT)
12130 alc269_eeepc_amic_automute(codec);
12131}
12132
12133static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
12134{
12135 alc269_speaker_automute(codec);
12136 alc269_eeepc_amic_automute(codec);
12137}
12138
Kailang Yangf6a92242007-12-13 16:52:54 +010012139/*
12140 * generic initialization of ADC, input mixers and output mixers
12141 */
12142static struct hda_verb alc269_init_verbs[] = {
12143 /*
12144 * Unmute ADC0 and set the default input to mic-in
12145 */
Kailang Yang60db6b52008-08-26 13:13:00 +020012146 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012147
12148 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
12149 * analog-loopback mixer widget
12150 * Note: PASD motherboards uses the Line In 2 as the input for
12151 * front panel mic (mic 2)
12152 */
12153 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
12154 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12155 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12156 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12157 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12158 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12159
12160 /*
12161 * Set up output mixers (0x0c - 0x0e)
12162 */
12163 /* set vol=0 to output mixers */
12164 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12165 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12166
12167 /* set up input amps for analog loopback */
12168 /* Amp Indices: DAC = 0, mixer = 1 */
12169 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12170 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12171 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12172 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12173 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12174 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12175
12176 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12177 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
12178 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
12179 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12180 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
12181 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12182 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
12183
12184 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12185 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12186 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12187 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12188 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12189 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12190 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12191
12192 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
12193 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12194
12195 /* FIXME: use matrix-type input source selection */
12196 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
12197 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020012198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010012200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12202
12203 /* set EAPD */
12204 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12205 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12206 { }
12207};
12208
12209/* add playback controls from the parsed DAC table */
12210static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
12211 const struct auto_pin_cfg *cfg)
12212{
12213 hda_nid_t nid;
12214 int err;
12215
12216 spec->multiout.num_dacs = 1; /* only use one dac */
12217 spec->multiout.dac_nids = spec->private_dac_nids;
12218 spec->multiout.dac_nids[0] = 2;
12219
12220 nid = cfg->line_out_pins[0];
12221 if (nid) {
12222 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12223 "Front Playback Volume",
12224 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
12225 if (err < 0)
12226 return err;
12227 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12228 "Front Playback Switch",
12229 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12230 if (err < 0)
12231 return err;
12232 }
12233
12234 nid = cfg->speaker_pins[0];
12235 if (nid) {
12236 if (!cfg->line_out_pins[0]) {
12237 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12238 "Speaker Playback Volume",
12239 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12240 HDA_OUTPUT));
12241 if (err < 0)
12242 return err;
12243 }
12244 if (nid == 0x16) {
12245 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12246 "Speaker Playback Switch",
12247 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12248 HDA_OUTPUT));
12249 if (err < 0)
12250 return err;
12251 } else {
12252 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12253 "Speaker Playback Switch",
12254 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12255 HDA_OUTPUT));
12256 if (err < 0)
12257 return err;
12258 }
12259 }
12260 nid = cfg->hp_pins[0];
12261 if (nid) {
12262 /* spec->multiout.hp_nid = 2; */
12263 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
12264 err = add_control(spec, ALC_CTL_WIDGET_VOL,
12265 "Headphone Playback Volume",
12266 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
12267 HDA_OUTPUT));
12268 if (err < 0)
12269 return err;
12270 }
12271 if (nid == 0x16) {
12272 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12273 "Headphone Playback Switch",
12274 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12275 HDA_OUTPUT));
12276 if (err < 0)
12277 return err;
12278 } else {
12279 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12280 "Headphone Playback Switch",
12281 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12282 HDA_OUTPUT));
12283 if (err < 0)
12284 return err;
12285 }
12286 }
12287 return 0;
12288}
12289
Takashi Iwaiee956e02008-10-31 17:16:31 +010012290static int alc269_auto_create_analog_input_ctls(struct alc_spec *spec,
12291 const struct auto_pin_cfg *cfg)
12292{
12293 int err;
12294
12295 err = alc880_auto_create_analog_input_ctls(spec, cfg);
12296 if (err < 0)
12297 return err;
12298 /* digital-mic input pin is excluded in alc880_auto_create..()
12299 * because it's under 0x18
12300 */
12301 if (cfg->input_pins[AUTO_PIN_MIC] == 0x12 ||
12302 cfg->input_pins[AUTO_PIN_FRONT_MIC] == 0x12) {
12303 struct hda_input_mux *imux = &spec->private_imux;
12304 imux->items[imux->num_items].label = "Int Mic";
12305 imux->items[imux->num_items].index = 0x05;
12306 imux->num_items++;
12307 }
12308 return 0;
12309}
Kailang Yangf6a92242007-12-13 16:52:54 +010012310
12311#ifdef CONFIG_SND_HDA_POWER_SAVE
12312#define alc269_loopbacks alc880_loopbacks
12313#endif
12314
12315/* pcm configuration: identiacal with ALC880 */
12316#define alc269_pcm_analog_playback alc880_pcm_analog_playback
12317#define alc269_pcm_analog_capture alc880_pcm_analog_capture
12318#define alc269_pcm_digital_playback alc880_pcm_digital_playback
12319#define alc269_pcm_digital_capture alc880_pcm_digital_capture
12320
12321/*
12322 * BIOS auto configuration
12323 */
12324static int alc269_parse_auto_config(struct hda_codec *codec)
12325{
12326 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020012327 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010012328 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
12329
12330 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12331 alc269_ignore);
12332 if (err < 0)
12333 return err;
12334
12335 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
12336 if (err < 0)
12337 return err;
12338 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
12339 if (err < 0)
12340 return err;
12341
12342 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12343
12344 if (spec->autocfg.dig_out_pin)
12345 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
12346
Takashi Iwai603c4012008-07-30 15:01:44 +020012347 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012348 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010012349
Takashi Iwai2005af22008-08-20 18:38:26 +020012350 /* create a beep mixer control if the pin 0x1d isn't assigned */
12351 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
12352 if (spec->autocfg.input_pins[i] == 0x1d)
12353 break;
12354 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
Takashi Iwaid88897e2008-10-31 15:01:37 +010012355 add_mixer(spec, alc269_beep_mixer);
Takashi Iwai2005af22008-08-20 18:38:26 +020012356
Takashi Iwaid88897e2008-10-31 15:01:37 +010012357 add_verb(spec, alc269_init_verbs);
Kailang Yangf6a92242007-12-13 16:52:54 +010012358 spec->num_mux_defs = 1;
12359 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020012360 /* set default input source */
12361 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
12362 0, AC_VERB_SET_CONNECT_SEL,
12363 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010012364
12365 err = alc_auto_add_mic_boost(codec);
12366 if (err < 0)
12367 return err;
12368
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012369 if (!spec->cap_mixer)
12370 set_capture_mixer(spec);
Kailang Yangf53281e2008-07-18 12:36:43 +020012371
Takashi Iwaie044c392008-10-27 16:56:24 +010012372 store_pin_configs(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012373 return 1;
12374}
12375
12376#define alc269_auto_init_multi_out alc882_auto_init_multi_out
12377#define alc269_auto_init_hp_out alc882_auto_init_hp_out
12378#define alc269_auto_init_analog_input alc882_auto_init_analog_input
12379
12380
12381/* init callback for auto-configuration model -- overriding the default init */
12382static void alc269_auto_init(struct hda_codec *codec)
12383{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012384 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010012385 alc269_auto_init_multi_out(codec);
12386 alc269_auto_init_hp_out(codec);
12387 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012388 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012389 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012390}
12391
12392/*
12393 * configuration and preset
12394 */
12395static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012396 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012397 [ALC269_QUANTA_FL1] = "quanta",
12398 [ALC269_ASUS_EEEPC_P703] = "eeepc-p703",
Takashi Iwai26f5df22008-11-03 17:39:46 +010012399 [ALC269_ASUS_EEEPC_P901] = "eeepc-p901",
Tony Vroon64154832008-11-06 15:08:49 +000012400 [ALC269_FUJITSU] = "fujitsu",
12401 [ALC269_LIFEBOOK] = "lifebook"
Kailang Yangf6a92242007-12-13 16:52:54 +010012402};
12403
12404static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020012405 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020012406 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
12407 ALC269_ASUS_EEEPC_P703),
12408 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
12409 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020012410 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
12411 ALC269_ASUS_EEEPC_P901),
Takashi Iwai26f5df22008-11-03 17:39:46 +010012412 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
Tony Vroon64154832008-11-06 15:08:49 +000012413 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yangf6a92242007-12-13 16:52:54 +010012414 {}
12415};
12416
12417static struct alc_config_preset alc269_presets[] = {
12418 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012419 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010012420 .init_verbs = { alc269_init_verbs },
12421 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12422 .dac_nids = alc269_dac_nids,
12423 .hp_nid = 0x03,
12424 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12425 .channel_mode = alc269_modes,
12426 .input_mux = &alc269_capture_source,
12427 },
Kailang Yang60db6b52008-08-26 13:13:00 +020012428 [ALC269_QUANTA_FL1] = {
12429 .mixers = { alc269_quanta_fl1_mixer },
12430 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
12431 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12432 .dac_nids = alc269_dac_nids,
12433 .hp_nid = 0x03,
12434 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12435 .channel_mode = alc269_modes,
12436 .input_mux = &alc269_capture_source,
12437 .unsol_event = alc269_quanta_fl1_unsol_event,
12438 .init_hook = alc269_quanta_fl1_init_hook,
12439 },
Kailang Yangf53281e2008-07-18 12:36:43 +020012440 [ALC269_ASUS_EEEPC_P703] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012441 .mixers = { alc269_eeepc_mixer },
12442 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012443 .init_verbs = { alc269_init_verbs,
12444 alc269_eeepc_amic_init_verbs },
12445 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12446 .dac_nids = alc269_dac_nids,
12447 .hp_nid = 0x03,
12448 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12449 .channel_mode = alc269_modes,
12450 .input_mux = &alc269_eeepc_amic_capture_source,
12451 .unsol_event = alc269_eeepc_amic_unsol_event,
12452 .init_hook = alc269_eeepc_amic_inithook,
12453 },
12454 [ALC269_ASUS_EEEPC_P901] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012455 .mixers = { alc269_eeepc_mixer },
12456 .cap_mixer = alc269_epc_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020012457 .init_verbs = { alc269_init_verbs,
12458 alc269_eeepc_dmic_init_verbs },
12459 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12460 .dac_nids = alc269_dac_nids,
12461 .hp_nid = 0x03,
12462 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12463 .channel_mode = alc269_modes,
12464 .input_mux = &alc269_eeepc_dmic_capture_source,
12465 .unsol_event = alc269_eeepc_dmic_unsol_event,
12466 .init_hook = alc269_eeepc_dmic_inithook,
12467 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010012468 [ALC269_FUJITSU] = {
12469 .mixers = { alc269_fujitsu_mixer, alc269_beep_mixer },
12470 .cap_mixer = alc269_epc_capture_mixer,
12471 .init_verbs = { alc269_init_verbs,
12472 alc269_eeepc_dmic_init_verbs },
12473 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12474 .dac_nids = alc269_dac_nids,
12475 .hp_nid = 0x03,
12476 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12477 .channel_mode = alc269_modes,
12478 .input_mux = &alc269_eeepc_dmic_capture_source,
12479 .unsol_event = alc269_eeepc_dmic_unsol_event,
12480 .init_hook = alc269_eeepc_dmic_inithook,
12481 },
Tony Vroon64154832008-11-06 15:08:49 +000012482 [ALC269_LIFEBOOK] = {
12483 .mixers = { alc269_lifebook_mixer },
12484 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
12485 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
12486 .dac_nids = alc269_dac_nids,
12487 .hp_nid = 0x03,
12488 .num_channel_mode = ARRAY_SIZE(alc269_modes),
12489 .channel_mode = alc269_modes,
12490 .input_mux = &alc269_capture_source,
12491 .unsol_event = alc269_lifebook_unsol_event,
12492 .init_hook = alc269_lifebook_init_hook,
12493 },
Kailang Yangf6a92242007-12-13 16:52:54 +010012494};
12495
12496static int patch_alc269(struct hda_codec *codec)
12497{
12498 struct alc_spec *spec;
12499 int board_config;
12500 int err;
12501
12502 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
12503 if (spec == NULL)
12504 return -ENOMEM;
12505
12506 codec->spec = spec;
12507
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012508 alc_fix_pll_init(codec, 0x20, 0x04, 15);
12509
Kailang Yangf6a92242007-12-13 16:52:54 +010012510 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
12511 alc269_models,
12512 alc269_cfg_tbl);
12513
12514 if (board_config < 0) {
12515 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
12516 "trying auto-probe from BIOS...\n");
12517 board_config = ALC269_AUTO;
12518 }
12519
12520 if (board_config == ALC269_AUTO) {
12521 /* automatic parse from the BIOS config */
12522 err = alc269_parse_auto_config(codec);
12523 if (err < 0) {
12524 alc_free(codec);
12525 return err;
12526 } else if (!err) {
12527 printk(KERN_INFO
12528 "hda_codec: Cannot set up configuration "
12529 "from BIOS. Using base mode...\n");
12530 board_config = ALC269_BASIC;
12531 }
12532 }
12533
12534 if (board_config != ALC269_AUTO)
12535 setup_preset(spec, &alc269_presets[board_config]);
12536
12537 spec->stream_name_analog = "ALC269 Analog";
12538 spec->stream_analog_playback = &alc269_pcm_analog_playback;
12539 spec->stream_analog_capture = &alc269_pcm_analog_capture;
12540
12541 spec->stream_name_digital = "ALC269 Digital";
12542 spec->stream_digital_playback = &alc269_pcm_digital_playback;
12543 spec->stream_digital_capture = &alc269_pcm_digital_capture;
12544
12545 spec->adc_nids = alc269_adc_nids;
12546 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020012547 spec->capsrc_nids = alc269_capsrc_nids;
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012548 if (!spec->cap_mixer)
12549 set_capture_mixer(spec);
Kailang Yangf6a92242007-12-13 16:52:54 +010012550
12551 codec->patch_ops = alc_patch_ops;
12552 if (board_config == ALC269_AUTO)
12553 spec->init_hook = alc269_auto_init;
12554#ifdef CONFIG_SND_HDA_POWER_SAVE
12555 if (!spec->loopback.amplist)
12556 spec->loopback.amplist = alc269_loopbacks;
12557#endif
12558
12559 return 0;
12560}
12561
12562/*
Kailang Yangdf694da2005-12-05 19:42:22 +010012563 * ALC861 channel source setting (2/6 channel selection for 3-stack)
12564 */
12565
12566/*
12567 * set the path ways for 2 channel output
12568 * need to set the codec line out and mic 1 pin widgets to inputs
12569 */
12570static struct hda_verb alc861_threestack_ch2_init[] = {
12571 /* set pin widget 1Ah (line in) for input */
12572 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012573 /* set pin widget 18h (mic1/2) for input, for mic also enable
12574 * the vref
12575 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012576 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12577
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012578 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12579#if 0
12580 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12581 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12582#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012583 { } /* end */
12584};
12585/*
12586 * 6ch mode
12587 * need to set the codec line out and mic 1 pin widgets to outputs
12588 */
12589static struct hda_verb alc861_threestack_ch6_init[] = {
12590 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12591 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12592 /* set pin widget 18h (mic1) for output (CLFE)*/
12593 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12594
12595 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012596 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012597
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012598 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12599#if 0
12600 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12601 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12602#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012603 { } /* end */
12604};
12605
12606static struct hda_channel_mode alc861_threestack_modes[2] = {
12607 { 2, alc861_threestack_ch2_init },
12608 { 6, alc861_threestack_ch6_init },
12609};
Takashi Iwai22309c32006-08-09 16:57:28 +020012610/* Set mic1 as input and unmute the mixer */
12611static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12612 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12613 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12614 { } /* end */
12615};
12616/* Set mic1 as output and mute mixer */
12617static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12618 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12619 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12620 { } /* end */
12621};
12622
12623static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12624 { 2, alc861_uniwill_m31_ch2_init },
12625 { 4, alc861_uniwill_m31_ch4_init },
12626};
Kailang Yangdf694da2005-12-05 19:42:22 +010012627
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012628/* Set mic1 and line-in as input and unmute the mixer */
12629static struct hda_verb alc861_asus_ch2_init[] = {
12630 /* set pin widget 1Ah (line in) for input */
12631 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012632 /* set pin widget 18h (mic1/2) for input, for mic also enable
12633 * the vref
12634 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012635 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12636
12637 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12638#if 0
12639 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12640 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12641#endif
12642 { } /* end */
12643};
12644/* Set mic1 nad line-in as output and mute mixer */
12645static struct hda_verb alc861_asus_ch6_init[] = {
12646 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12647 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12648 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12649 /* set pin widget 18h (mic1) for output (CLFE)*/
12650 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12651 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12652 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12653 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12654
12655 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12656#if 0
12657 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12658 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12659#endif
12660 { } /* end */
12661};
12662
12663static struct hda_channel_mode alc861_asus_modes[2] = {
12664 { 2, alc861_asus_ch2_init },
12665 { 6, alc861_asus_ch6_init },
12666};
12667
Kailang Yangdf694da2005-12-05 19:42:22 +010012668/* patch-ALC861 */
12669
12670static struct snd_kcontrol_new alc861_base_mixer[] = {
12671 /* output mixer control */
12672 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12673 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12674 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12675 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12676 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12677
12678 /*Input mixer control */
12679 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12680 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12681 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12682 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12683 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12684 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12685 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12686 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12687 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12688 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012689
Kailang Yangdf694da2005-12-05 19:42:22 +010012690 { } /* end */
12691};
12692
12693static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12694 /* output mixer control */
12695 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12696 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12697 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12698 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12699 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12700
12701 /* Input mixer control */
12702 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12703 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12704 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12705 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12706 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12707 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12708 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12709 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12710 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12711 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012712
Kailang Yangdf694da2005-12-05 19:42:22 +010012713 {
12714 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12715 .name = "Channel Mode",
12716 .info = alc_ch_mode_info,
12717 .get = alc_ch_mode_get,
12718 .put = alc_ch_mode_put,
12719 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12720 },
12721 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012722};
12723
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012724static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012725 /* output mixer control */
12726 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12727 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12728 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012729
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012730 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012731};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012732
Takashi Iwai22309c32006-08-09 16:57:28 +020012733static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12734 /* output mixer control */
12735 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12736 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12737 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12738 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12739 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12740
12741 /* Input mixer control */
12742 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12743 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12744 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12745 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12746 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12747 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12748 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12749 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12750 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12751 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012752
Takashi Iwai22309c32006-08-09 16:57:28 +020012753 {
12754 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12755 .name = "Channel Mode",
12756 .info = alc_ch_mode_info,
12757 .get = alc_ch_mode_get,
12758 .put = alc_ch_mode_put,
12759 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12760 },
12761 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012762};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012763
12764static struct snd_kcontrol_new alc861_asus_mixer[] = {
12765 /* output mixer control */
12766 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12767 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12768 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12769 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12770 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12771
12772 /* Input mixer control */
12773 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12774 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12775 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12776 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12777 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12778 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12779 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12780 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12781 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012782 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12783
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012784 {
12785 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12786 .name = "Channel Mode",
12787 .info = alc_ch_mode_info,
12788 .get = alc_ch_mode_get,
12789 .put = alc_ch_mode_put,
12790 .private_value = ARRAY_SIZE(alc861_asus_modes),
12791 },
12792 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012793};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012794
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012795/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012796static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012797 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12798 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12799 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12800 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12801 { }
12802};
12803
Kailang Yangdf694da2005-12-05 19:42:22 +010012804/*
12805 * generic initialization of ADC, input mixers and output mixers
12806 */
12807static struct hda_verb alc861_base_init_verbs[] = {
12808 /*
12809 * Unmute ADC0 and set the default input to mic-in
12810 */
12811 /* port-A for surround (rear panel) */
12812 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12813 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
12814 /* port-B for mic-in (rear panel) with vref */
12815 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12816 /* port-C for line-in (rear panel) */
12817 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12818 /* port-D for Front */
12819 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12820 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12821 /* port-E for HP out (front panel) */
12822 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12823 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012824 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012825 /* port-F for mic-in (front panel) with vref */
12826 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12827 /* port-G for CLFE (rear panel) */
12828 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12829 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
12830 /* port-H for side (rear panel) */
12831 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12832 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
12833 /* CD-in */
12834 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12835 /* route front mic to ADC1*/
12836 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12837 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012838
Kailang Yangdf694da2005-12-05 19:42:22 +010012839 /* Unmute DAC0~3 & spdif out*/
12840 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12841 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12842 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12843 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12844 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012845
Kailang Yangdf694da2005-12-05 19:42:22 +010012846 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12847 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12848 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12849 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12850 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012851
Kailang Yangdf694da2005-12-05 19:42:22 +010012852 /* Unmute Stereo Mixer 15 */
12853 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12854 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12855 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012856 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012857
12858 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12859 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12860 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12861 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12862 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12863 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12864 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12865 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012866 /* hp used DAC 3 (Front) */
12867 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012868 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12869
12870 { }
12871};
12872
12873static struct hda_verb alc861_threestack_init_verbs[] = {
12874 /*
12875 * Unmute ADC0 and set the default input to mic-in
12876 */
12877 /* port-A for surround (rear panel) */
12878 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12879 /* port-B for mic-in (rear panel) with vref */
12880 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12881 /* port-C for line-in (rear panel) */
12882 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12883 /* port-D for Front */
12884 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12885 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12886 /* port-E for HP out (front panel) */
12887 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12888 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012889 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012890 /* port-F for mic-in (front panel) with vref */
12891 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12892 /* port-G for CLFE (rear panel) */
12893 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12894 /* port-H for side (rear panel) */
12895 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12896 /* CD-in */
12897 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12898 /* route front mic to ADC1*/
12899 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12900 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12901 /* Unmute DAC0~3 & spdif out*/
12902 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12903 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12904 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12905 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12906 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012907
Kailang Yangdf694da2005-12-05 19:42:22 +010012908 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12909 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12910 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12911 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12912 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012913
Kailang Yangdf694da2005-12-05 19:42:22 +010012914 /* Unmute Stereo Mixer 15 */
12915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12916 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12917 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012918 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012919
12920 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12921 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12922 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12923 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12924 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12925 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12926 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12927 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012928 /* hp used DAC 3 (Front) */
12929 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012930 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12931 { }
12932};
Takashi Iwai22309c32006-08-09 16:57:28 +020012933
12934static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
12935 /*
12936 * Unmute ADC0 and set the default input to mic-in
12937 */
12938 /* port-A for surround (rear panel) */
12939 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12940 /* port-B for mic-in (rear panel) with vref */
12941 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12942 /* port-C for line-in (rear panel) */
12943 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12944 /* port-D for Front */
12945 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12946 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12947 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012948 /* this has to be set to VREF80 */
12949 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012950 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012951 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012952 /* port-F for mic-in (front panel) with vref */
12953 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12954 /* port-G for CLFE (rear panel) */
12955 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12956 /* port-H for side (rear panel) */
12957 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12958 /* CD-in */
12959 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12960 /* route front mic to ADC1*/
12961 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12962 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12963 /* Unmute DAC0~3 & spdif out*/
12964 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12965 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12966 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12967 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12968 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012969
Takashi Iwai22309c32006-08-09 16:57:28 +020012970 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12971 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12972 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12973 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12974 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012975
Takashi Iwai22309c32006-08-09 16:57:28 +020012976 /* Unmute Stereo Mixer 15 */
12977 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12978 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012980 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012981
12982 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12983 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12984 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12985 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12986 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12987 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12988 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12989 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012990 /* hp used DAC 3 (Front) */
12991 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012992 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12993 { }
12994};
12995
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012996static struct hda_verb alc861_asus_init_verbs[] = {
12997 /*
12998 * Unmute ADC0 and set the default input to mic-in
12999 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013000 /* port-A for surround (rear panel)
13001 * according to codec#0 this is the HP jack
13002 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013003 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
13004 /* route front PCM to HP */
13005 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
13006 /* port-B for mic-in (rear panel) with vref */
13007 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13008 /* port-C for line-in (rear panel) */
13009 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13010 /* port-D for Front */
13011 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13012 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
13013 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013014 /* this has to be set to VREF80 */
13015 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013016 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010013017 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013018 /* port-F for mic-in (front panel) with vref */
13019 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
13020 /* port-G for CLFE (rear panel) */
13021 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13022 /* port-H for side (rear panel) */
13023 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
13024 /* CD-in */
13025 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
13026 /* route front mic to ADC1*/
13027 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
13028 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13029 /* Unmute DAC0~3 & spdif out*/
13030 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13031 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13032 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13033 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13035 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13036 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13037 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13038 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13039 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013040
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013041 /* Unmute Stereo Mixer 15 */
13042 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13043 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13044 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013045 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013046
13047 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13048 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13049 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13050 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13051 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13052 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13053 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13054 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013055 /* hp used DAC 3 (Front) */
13056 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013057 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13058 { }
13059};
13060
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013061/* additional init verbs for ASUS laptops */
13062static struct hda_verb alc861_asus_laptop_init_verbs[] = {
13063 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
13064 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
13065 { }
13066};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013067
Kailang Yangdf694da2005-12-05 19:42:22 +010013068/*
13069 * generic initialization of ADC, input mixers and output mixers
13070 */
13071static struct hda_verb alc861_auto_init_verbs[] = {
13072 /*
13073 * Unmute ADC0 and set the default input to mic-in
13074 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013075 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010013076 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013077
Kailang Yangdf694da2005-12-05 19:42:22 +010013078 /* Unmute DAC0~3 & spdif out*/
13079 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13080 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13081 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13082 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13083 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020013084
Kailang Yangdf694da2005-12-05 19:42:22 +010013085 /* Unmute Mixer 14 (mic) 1c (Line in)*/
13086 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13087 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13088 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13089 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013090
Kailang Yangdf694da2005-12-05 19:42:22 +010013091 /* Unmute Stereo Mixer 15 */
13092 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13093 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13094 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13095 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
13096
13097 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13098 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13099 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13100 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13101 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13102 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13103 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13104 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13105
13106 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13107 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013108 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13109 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013110 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13111 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013112 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
13113 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010013114
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013115 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013116
13117 { }
13118};
13119
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013120static struct hda_verb alc861_toshiba_init_verbs[] = {
13121 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013122
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013123 { }
13124};
13125
13126/* toggle speaker-output according to the hp-jack state */
13127static void alc861_toshiba_automute(struct hda_codec *codec)
13128{
13129 unsigned int present;
13130
13131 present = snd_hda_codec_read(codec, 0x0f, 0,
13132 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013133 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
13134 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
13135 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
13136 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013137}
13138
13139static void alc861_toshiba_unsol_event(struct hda_codec *codec,
13140 unsigned int res)
13141{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013142 if ((res >> 26) == ALC880_HP_EVENT)
13143 alc861_toshiba_automute(codec);
13144}
13145
Kailang Yangdf694da2005-12-05 19:42:22 +010013146/* pcm configuration: identiacal with ALC880 */
13147#define alc861_pcm_analog_playback alc880_pcm_analog_playback
13148#define alc861_pcm_analog_capture alc880_pcm_analog_capture
13149#define alc861_pcm_digital_playback alc880_pcm_digital_playback
13150#define alc861_pcm_digital_capture alc880_pcm_digital_capture
13151
13152
13153#define ALC861_DIGOUT_NID 0x07
13154
13155static struct hda_channel_mode alc861_8ch_modes[1] = {
13156 { 8, NULL }
13157};
13158
13159static hda_nid_t alc861_dac_nids[4] = {
13160 /* front, surround, clfe, side */
13161 0x03, 0x06, 0x05, 0x04
13162};
13163
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013164static hda_nid_t alc660_dac_nids[3] = {
13165 /* front, clfe, surround */
13166 0x03, 0x05, 0x06
13167};
13168
Kailang Yangdf694da2005-12-05 19:42:22 +010013169static hda_nid_t alc861_adc_nids[1] = {
13170 /* ADC0-2 */
13171 0x08,
13172};
13173
13174static struct hda_input_mux alc861_capture_source = {
13175 .num_items = 5,
13176 .items = {
13177 { "Mic", 0x0 },
13178 { "Front Mic", 0x3 },
13179 { "Line", 0x1 },
13180 { "CD", 0x4 },
13181 { "Mixer", 0x5 },
13182 },
13183};
13184
13185/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013186static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
13187 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013188{
13189 int i;
13190 hda_nid_t nid;
13191
13192 spec->multiout.dac_nids = spec->private_dac_nids;
13193 for (i = 0; i < cfg->line_outs; i++) {
13194 nid = cfg->line_out_pins[i];
13195 if (nid) {
13196 if (i >= ARRAY_SIZE(alc861_dac_nids))
13197 continue;
13198 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
13199 }
13200 }
13201 spec->multiout.num_dacs = cfg->line_outs;
13202 return 0;
13203}
13204
13205/* add playback controls from the parsed DAC table */
13206static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
13207 const struct auto_pin_cfg *cfg)
13208{
13209 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013210 static const char *chname[4] = {
13211 "Front", "Surround", NULL /*CLFE*/, "Side"
13212 };
Kailang Yangdf694da2005-12-05 19:42:22 +010013213 hda_nid_t nid;
13214 int i, idx, err;
13215
13216 for (i = 0; i < cfg->line_outs; i++) {
13217 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013218 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010013219 continue;
13220 if (nid == 0x05) {
13221 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013222 err = add_control(spec, ALC_CTL_BIND_MUTE,
13223 "Center Playback Switch",
13224 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
13225 HDA_OUTPUT));
13226 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013227 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013228 err = add_control(spec, ALC_CTL_BIND_MUTE,
13229 "LFE Playback Switch",
13230 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
13231 HDA_OUTPUT));
13232 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013233 return err;
13234 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013235 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
13236 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010013237 if (nid == alc861_dac_nids[idx])
13238 break;
13239 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013240 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13241 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
13242 HDA_OUTPUT));
13243 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013244 return err;
13245 }
13246 }
13247 return 0;
13248}
13249
13250static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
13251{
13252 int err;
13253 hda_nid_t nid;
13254
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013255 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010013256 return 0;
13257
13258 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
13259 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013260 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
13261 "Headphone Playback Switch",
13262 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
13263 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013264 return err;
13265 spec->multiout.hp_nid = nid;
13266 }
13267 return 0;
13268}
13269
13270/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013271static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
13272 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010013273{
Kailang Yangdf694da2005-12-05 19:42:22 +010013274 struct hda_input_mux *imux = &spec->private_imux;
13275 int i, err, idx, idx1;
13276
13277 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013278 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010013279 case 0x0c:
13280 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013281 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013282 break;
13283 case 0x0f:
13284 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013285 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013286 break;
13287 case 0x0d:
13288 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013289 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013290 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013291 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010013292 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013293 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010013294 break;
13295 case 0x11:
13296 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013297 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010013298 break;
13299 default:
13300 continue;
13301 }
13302
Takashi Iwai4a471b72005-12-07 13:56:29 +010013303 err = new_analog_input(spec, cfg->input_pins[i],
13304 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010013305 if (err < 0)
13306 return err;
13307
Takashi Iwai4a471b72005-12-07 13:56:29 +010013308 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010013309 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013310 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010013311 }
13312 return 0;
13313}
13314
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013315static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
13316 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010013317 int pin_type, int dac_idx)
13318{
Jacek Luczak564c5be2008-05-03 18:41:23 +020013319 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
13320 pin_type);
13321 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
13322 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010013323}
13324
13325static void alc861_auto_init_multi_out(struct hda_codec *codec)
13326{
13327 struct alc_spec *spec = codec->spec;
13328 int i;
13329
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013330 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010013331 for (i = 0; i < spec->autocfg.line_outs; i++) {
13332 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013333 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010013334 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013335 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013336 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010013337 }
13338}
13339
13340static void alc861_auto_init_hp_out(struct hda_codec *codec)
13341{
13342 struct alc_spec *spec = codec->spec;
13343 hda_nid_t pin;
13344
Takashi Iwaieb06ed82006-09-20 17:10:27 +020013345 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010013346 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013347 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
13348 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013349 pin = spec->autocfg.speaker_pins[0];
13350 if (pin)
13351 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010013352}
13353
13354static void alc861_auto_init_analog_input(struct hda_codec *codec)
13355{
13356 struct alc_spec *spec = codec->spec;
13357 int i;
13358
13359 for (i = 0; i < AUTO_PIN_LAST; i++) {
13360 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013361 if (nid >= 0x0c && nid <= 0x11) {
13362 snd_hda_codec_write(codec, nid, 0,
13363 AC_VERB_SET_PIN_WIDGET_CONTROL,
13364 i <= AUTO_PIN_FRONT_MIC ?
13365 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010013366 }
13367 }
13368}
13369
13370/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013371/* return 1 if successful, 0 if the proper config is not found,
13372 * or a negative error code
13373 */
Kailang Yangdf694da2005-12-05 19:42:22 +010013374static int alc861_parse_auto_config(struct hda_codec *codec)
13375{
13376 struct alc_spec *spec = codec->spec;
13377 int err;
13378 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
13379
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013380 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13381 alc861_ignore);
13382 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013383 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013384 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010013385 return 0; /* can't find valid BIOS pin config */
13386
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013387 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
13388 if (err < 0)
13389 return err;
13390 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
13391 if (err < 0)
13392 return err;
13393 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
13394 if (err < 0)
13395 return err;
13396 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
13397 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010013398 return err;
13399
13400 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
13401
13402 if (spec->autocfg.dig_out_pin)
13403 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
13404
Takashi Iwai603c4012008-07-30 15:01:44 +020013405 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013406 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010013407
Takashi Iwaid88897e2008-10-31 15:01:37 +010013408 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010013409
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020013410 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010013411 spec->input_mux = &spec->private_imux;
13412
13413 spec->adc_nids = alc861_adc_nids;
13414 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010013415 set_capture_mixer(spec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013416
Takashi Iwaie044c392008-10-27 16:56:24 +010013417 store_pin_configs(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013418 return 1;
13419}
13420
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013421/* additional initialization for auto-configuration model */
13422static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010013423{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013424 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013425 alc861_auto_init_multi_out(codec);
13426 alc861_auto_init_hp_out(codec);
13427 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013428 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013429 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010013430}
13431
Takashi Iwaicb53c622007-08-10 17:21:45 +020013432#ifdef CONFIG_SND_HDA_POWER_SAVE
13433static struct hda_amp_list alc861_loopbacks[] = {
13434 { 0x15, HDA_INPUT, 0 },
13435 { 0x15, HDA_INPUT, 1 },
13436 { 0x15, HDA_INPUT, 2 },
13437 { 0x15, HDA_INPUT, 3 },
13438 { } /* end */
13439};
13440#endif
13441
Kailang Yangdf694da2005-12-05 19:42:22 +010013442
13443/*
13444 * configuration and preset
13445 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013446static const char *alc861_models[ALC861_MODEL_LAST] = {
13447 [ALC861_3ST] = "3stack",
13448 [ALC660_3ST] = "3stack-660",
13449 [ALC861_3ST_DIG] = "3stack-dig",
13450 [ALC861_6ST_DIG] = "6stack-dig",
13451 [ALC861_UNIWILL_M31] = "uniwill-m31",
13452 [ALC861_TOSHIBA] = "toshiba",
13453 [ALC861_ASUS] = "asus",
13454 [ALC861_ASUS_LAPTOP] = "asus-laptop",
13455 [ALC861_AUTO] = "auto",
13456};
13457
13458static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010013459 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013460 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13461 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
13462 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013463 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020013464 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010013465 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020013466 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
13467 * Any other models that need this preset?
13468 */
13469 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020013470 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
13471 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013472 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
13473 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
13474 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
13475 /* FIXME: the below seems conflict */
13476 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
13477 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
13478 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010013479 {}
13480};
13481
13482static struct alc_config_preset alc861_presets[] = {
13483 [ALC861_3ST] = {
13484 .mixers = { alc861_3ST_mixer },
13485 .init_verbs = { alc861_threestack_init_verbs },
13486 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13487 .dac_nids = alc861_dac_nids,
13488 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13489 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013490 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013491 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13492 .adc_nids = alc861_adc_nids,
13493 .input_mux = &alc861_capture_source,
13494 },
13495 [ALC861_3ST_DIG] = {
13496 .mixers = { alc861_base_mixer },
13497 .init_verbs = { alc861_threestack_init_verbs },
13498 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13499 .dac_nids = alc861_dac_nids,
13500 .dig_out_nid = ALC861_DIGOUT_NID,
13501 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13502 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013503 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010013504 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13505 .adc_nids = alc861_adc_nids,
13506 .input_mux = &alc861_capture_source,
13507 },
13508 [ALC861_6ST_DIG] = {
13509 .mixers = { alc861_base_mixer },
13510 .init_verbs = { alc861_base_init_verbs },
13511 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13512 .dac_nids = alc861_dac_nids,
13513 .dig_out_nid = ALC861_DIGOUT_NID,
13514 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13515 .channel_mode = alc861_8ch_modes,
13516 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13517 .adc_nids = alc861_adc_nids,
13518 .input_mux = &alc861_capture_source,
13519 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013520 [ALC660_3ST] = {
13521 .mixers = { alc861_3ST_mixer },
13522 .init_verbs = { alc861_threestack_init_verbs },
13523 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13524 .dac_nids = alc660_dac_nids,
13525 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13526 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013527 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013528 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13529 .adc_nids = alc861_adc_nids,
13530 .input_mux = &alc861_capture_source,
13531 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013532 [ALC861_UNIWILL_M31] = {
13533 .mixers = { alc861_uniwill_m31_mixer },
13534 .init_verbs = { alc861_uniwill_m31_init_verbs },
13535 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13536 .dac_nids = alc861_dac_nids,
13537 .dig_out_nid = ALC861_DIGOUT_NID,
13538 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13539 .channel_mode = alc861_uniwill_m31_modes,
13540 .need_dac_fix = 1,
13541 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13542 .adc_nids = alc861_adc_nids,
13543 .input_mux = &alc861_capture_source,
13544 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013545 [ALC861_TOSHIBA] = {
13546 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013547 .init_verbs = { alc861_base_init_verbs,
13548 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013549 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13550 .dac_nids = alc861_dac_nids,
13551 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13552 .channel_mode = alc883_3ST_2ch_modes,
13553 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13554 .adc_nids = alc861_adc_nids,
13555 .input_mux = &alc861_capture_source,
13556 .unsol_event = alc861_toshiba_unsol_event,
13557 .init_hook = alc861_toshiba_automute,
13558 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013559 [ALC861_ASUS] = {
13560 .mixers = { alc861_asus_mixer },
13561 .init_verbs = { alc861_asus_init_verbs },
13562 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13563 .dac_nids = alc861_dac_nids,
13564 .dig_out_nid = ALC861_DIGOUT_NID,
13565 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13566 .channel_mode = alc861_asus_modes,
13567 .need_dac_fix = 1,
13568 .hp_nid = 0x06,
13569 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13570 .adc_nids = alc861_adc_nids,
13571 .input_mux = &alc861_capture_source,
13572 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013573 [ALC861_ASUS_LAPTOP] = {
13574 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13575 .init_verbs = { alc861_asus_init_verbs,
13576 alc861_asus_laptop_init_verbs },
13577 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13578 .dac_nids = alc861_dac_nids,
13579 .dig_out_nid = ALC861_DIGOUT_NID,
13580 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13581 .channel_mode = alc883_3ST_2ch_modes,
13582 .need_dac_fix = 1,
13583 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13584 .adc_nids = alc861_adc_nids,
13585 .input_mux = &alc861_capture_source,
13586 },
13587};
Kailang Yangdf694da2005-12-05 19:42:22 +010013588
13589
13590static int patch_alc861(struct hda_codec *codec)
13591{
13592 struct alc_spec *spec;
13593 int board_config;
13594 int err;
13595
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013596 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013597 if (spec == NULL)
13598 return -ENOMEM;
13599
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013600 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013601
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013602 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13603 alc861_models,
13604 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013605
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013606 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013607 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13608 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013609 board_config = ALC861_AUTO;
13610 }
13611
13612 if (board_config == ALC861_AUTO) {
13613 /* automatic parse from the BIOS config */
13614 err = alc861_parse_auto_config(codec);
13615 if (err < 0) {
13616 alc_free(codec);
13617 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013618 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013619 printk(KERN_INFO
13620 "hda_codec: Cannot set up configuration "
13621 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013622 board_config = ALC861_3ST_DIG;
13623 }
13624 }
13625
13626 if (board_config != ALC861_AUTO)
13627 setup_preset(spec, &alc861_presets[board_config]);
13628
13629 spec->stream_name_analog = "ALC861 Analog";
13630 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13631 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13632
13633 spec->stream_name_digital = "ALC861 Digital";
13634 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13635 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13636
Takashi Iwai2134ea42008-01-10 16:53:55 +010013637 spec->vmaster_nid = 0x03;
13638
Kailang Yangdf694da2005-12-05 19:42:22 +010013639 codec->patch_ops = alc_patch_ops;
13640 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013641 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013642#ifdef CONFIG_SND_HDA_POWER_SAVE
13643 if (!spec->loopback.amplist)
13644 spec->loopback.amplist = alc861_loopbacks;
13645#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013646
Kailang Yangdf694da2005-12-05 19:42:22 +010013647 return 0;
13648}
13649
13650/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013651 * ALC861-VD support
13652 *
13653 * Based on ALC882
13654 *
13655 * In addition, an independent DAC
13656 */
13657#define ALC861VD_DIGOUT_NID 0x06
13658
13659static hda_nid_t alc861vd_dac_nids[4] = {
13660 /* front, surr, clfe, side surr */
13661 0x02, 0x03, 0x04, 0x05
13662};
13663
13664/* dac_nids for ALC660vd are in a different order - according to
13665 * Realtek's driver.
13666 * This should probably tesult in a different mixer for 6stack models
13667 * of ALC660vd codecs, but for now there is only 3stack mixer
13668 * - and it is the same as in 861vd.
13669 * adc_nids in ALC660vd are (is) the same as in 861vd
13670 */
13671static hda_nid_t alc660vd_dac_nids[3] = {
13672 /* front, rear, clfe, rear_surr */
13673 0x02, 0x04, 0x03
13674};
13675
13676static hda_nid_t alc861vd_adc_nids[1] = {
13677 /* ADC0 */
13678 0x09,
13679};
13680
Takashi Iwaie1406342008-02-11 18:32:32 +010013681static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13682
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013683/* input MUX */
13684/* FIXME: should be a matrix-type input source selection */
13685static struct hda_input_mux alc861vd_capture_source = {
13686 .num_items = 4,
13687 .items = {
13688 { "Mic", 0x0 },
13689 { "Front Mic", 0x1 },
13690 { "Line", 0x2 },
13691 { "CD", 0x4 },
13692 },
13693};
13694
Kailang Yang272a5272007-05-14 11:00:38 +020013695static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013696 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013697 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013698 { "Ext Mic", 0x0 },
13699 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013700 },
13701};
13702
Kailang Yangd1a991a2007-08-15 16:21:59 +020013703static struct hda_input_mux alc861vd_hp_capture_source = {
13704 .num_items = 2,
13705 .items = {
13706 { "Front Mic", 0x0 },
13707 { "ATAPI Mic", 0x1 },
13708 },
13709};
13710
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013711/*
13712 * 2ch mode
13713 */
13714static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13715 { 2, NULL }
13716};
13717
13718/*
13719 * 6ch mode
13720 */
13721static struct hda_verb alc861vd_6stack_ch6_init[] = {
13722 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13723 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13724 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13725 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13726 { } /* end */
13727};
13728
13729/*
13730 * 8ch mode
13731 */
13732static struct hda_verb alc861vd_6stack_ch8_init[] = {
13733 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13734 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13735 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13736 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13737 { } /* end */
13738};
13739
13740static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13741 { 6, alc861vd_6stack_ch6_init },
13742 { 8, alc861vd_6stack_ch8_init },
13743};
13744
13745static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13746 {
13747 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13748 .name = "Channel Mode",
13749 .info = alc_ch_mode_info,
13750 .get = alc_ch_mode_get,
13751 .put = alc_ch_mode_put,
13752 },
13753 { } /* end */
13754};
13755
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013756/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13757 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13758 */
13759static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13760 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13761 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13762
13763 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13764 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13765
13766 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13767 HDA_OUTPUT),
13768 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13769 HDA_OUTPUT),
13770 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13771 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13772
13773 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13774 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13775
13776 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13777
13778 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13779 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13780 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13781
13782 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13783 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13784 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13785
13786 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13787 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13788
13789 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13790 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13791
13792 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13793 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13794
13795 { } /* end */
13796};
13797
13798static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13799 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13800 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13801
13802 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13803
13804 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13805 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13806 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13807
13808 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13809 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13810 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13811
13812 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13813 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13814
13815 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13816 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13817
13818 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13819 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13820
13821 { } /* end */
13822};
13823
Kailang Yangbdd148a2007-05-08 15:19:08 +020013824static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
13825 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13826 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
13827 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13828
13829 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13830
13831 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13832 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13833 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13834
13835 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13836 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13837 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13838
13839 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13840 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13841
13842 { } /* end */
13843};
13844
Tobin Davisb419f342008-03-07 11:57:51 +010013845/* Pin assignment: Speaker=0x14, HP = 0x15,
13846 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020013847 */
13848static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010013849 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13850 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013851 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13852 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010013853 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13854 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13855 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13856 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13857 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13858 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13859 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
13860 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013861 { } /* end */
13862};
13863
Kailang Yangd1a991a2007-08-15 16:21:59 +020013864/* Pin assignment: Speaker=0x14, Line-out = 0x15,
13865 * Front Mic=0x18, ATAPI Mic = 0x19,
13866 */
13867static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
13868 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13869 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13870 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13871 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
13872 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13873 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13874 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13875 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013876
Kailang Yangd1a991a2007-08-15 16:21:59 +020013877 { } /* end */
13878};
13879
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013880/*
13881 * generic initialization of ADC, input mixers and output mixers
13882 */
13883static struct hda_verb alc861vd_volume_init_verbs[] = {
13884 /*
13885 * Unmute ADC0 and set the default input to mic-in
13886 */
13887 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13888 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13889
13890 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
13891 * the analog-loopback mixer widget
13892 */
13893 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013894 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13895 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13896 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13897 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13898 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013899
13900 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020013901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13903 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013904 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013905
13906 /*
13907 * Set up output mixers (0x02 - 0x05)
13908 */
13909 /* set vol=0 to output mixers */
13910 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13911 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13912 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13913 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13914
13915 /* set up input amps for analog loopback */
13916 /* Amp Indices: DAC = 0, mixer = 1 */
13917 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13918 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13919 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13920 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13921 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13922 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13924 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13925
13926 { }
13927};
13928
13929/*
13930 * 3-stack pin configuration:
13931 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13932 */
13933static struct hda_verb alc861vd_3stack_init_verbs[] = {
13934 /*
13935 * Set pin mode and muting
13936 */
13937 /* set front pin widgets 0x14 for output */
13938 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13939 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13940 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13941
13942 /* Mic (rear) pin: input vref at 80% */
13943 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13944 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13945 /* Front Mic pin: input vref at 80% */
13946 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13947 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13948 /* Line In pin: input */
13949 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13950 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13951 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13952 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13953 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13954 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13955 /* CD pin widget for input */
13956 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13957
13958 { }
13959};
13960
13961/*
13962 * 6-stack pin configuration:
13963 */
13964static struct hda_verb alc861vd_6stack_init_verbs[] = {
13965 /*
13966 * Set pin mode and muting
13967 */
13968 /* set front pin widgets 0x14 for output */
13969 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13970 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13971 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13972
13973 /* Rear Pin: output 1 (0x0d) */
13974 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13975 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13976 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13977 /* CLFE Pin: output 2 (0x0e) */
13978 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13979 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13980 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13981 /* Side Pin: output 3 (0x0f) */
13982 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13983 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13984 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13985
13986 /* Mic (rear) pin: input vref at 80% */
13987 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13988 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13989 /* Front Mic pin: input vref at 80% */
13990 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13991 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13992 /* Line In pin: input */
13993 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13994 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13995 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13996 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13997 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13998 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13999 /* CD pin widget for input */
14000 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14001
14002 { }
14003};
14004
Kailang Yangbdd148a2007-05-08 15:19:08 +020014005static struct hda_verb alc861vd_eapd_verbs[] = {
14006 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14007 { }
14008};
14009
Kailang Yangf9423e72008-05-27 12:32:25 +020014010static struct hda_verb alc660vd_eapd_verbs[] = {
14011 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14012 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14013 { }
14014};
14015
Kailang Yangbdd148a2007-05-08 15:19:08 +020014016static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
14017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14019 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
14020 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020014021 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020014022 {}
14023};
14024
14025/* toggle speaker-output according to the hp-jack state */
14026static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
14027{
14028 unsigned int present;
14029 unsigned char bits;
14030
14031 present = snd_hda_codec_read(codec, 0x1b, 0,
14032 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014033 bits = present ? HDA_AMP_MUTE : 0;
14034 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14035 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014036}
14037
14038static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
14039{
14040 unsigned int present;
14041 unsigned char bits;
14042
14043 present = snd_hda_codec_read(codec, 0x18, 0,
14044 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014045 bits = present ? HDA_AMP_MUTE : 0;
14046 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
14047 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020014048}
14049
14050static void alc861vd_lenovo_automute(struct hda_codec *codec)
14051{
14052 alc861vd_lenovo_hp_automute(codec);
14053 alc861vd_lenovo_mic_automute(codec);
14054}
14055
14056static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
14057 unsigned int res)
14058{
14059 switch (res >> 26) {
14060 case ALC880_HP_EVENT:
14061 alc861vd_lenovo_hp_automute(codec);
14062 break;
14063 case ALC880_MIC_EVENT:
14064 alc861vd_lenovo_mic_automute(codec);
14065 break;
14066 }
14067}
14068
Kailang Yang272a5272007-05-14 11:00:38 +020014069static struct hda_verb alc861vd_dallas_verbs[] = {
14070 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14071 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14072 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14073 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14074
14075 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14076 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14077 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14078 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14079 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14080 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14081 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14082 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014083
Kailang Yang272a5272007-05-14 11:00:38 +020014084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14085 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14086 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14088 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14089 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14090 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14091 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14092
14093 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14094 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14095 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
14096 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14097 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14098 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14099 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14100 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14101
14102 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14103 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14104 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14105 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
14106
14107 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020014108 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020014109 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14110
14111 { } /* end */
14112};
14113
14114/* toggle speaker-output according to the hp-jack state */
14115static void alc861vd_dallas_automute(struct hda_codec *codec)
14116{
14117 unsigned int present;
14118
14119 present = snd_hda_codec_read(codec, 0x15, 0,
14120 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014121 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14122 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020014123}
14124
14125static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
14126{
14127 if ((res >> 26) == ALC880_HP_EVENT)
14128 alc861vd_dallas_automute(codec);
14129}
14130
Takashi Iwaicb53c622007-08-10 17:21:45 +020014131#ifdef CONFIG_SND_HDA_POWER_SAVE
14132#define alc861vd_loopbacks alc880_loopbacks
14133#endif
14134
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014135/* pcm configuration: identiacal with ALC880 */
14136#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
14137#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
14138#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
14139#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
14140
14141/*
14142 * configuration and preset
14143 */
14144static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
14145 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014146 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010014147 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014148 [ALC861VD_3ST] = "3stack",
14149 [ALC861VD_3ST_DIG] = "3stack-digout",
14150 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020014151 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020014152 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020014153 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014154 [ALC861VD_AUTO] = "auto",
14155};
14156
14157static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014158 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
14159 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010014160 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014161 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Takashi Iwai13c94742008-11-05 08:06:08 +010014162 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020014163 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014164 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014165 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020014166 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020014167 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020014168 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010014169 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020014170 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014171 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
14172 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020014173 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020014174 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014175 {}
14176};
14177
14178static struct alc_config_preset alc861vd_presets[] = {
14179 [ALC660VD_3ST] = {
14180 .mixers = { alc861vd_3st_mixer },
14181 .init_verbs = { alc861vd_volume_init_verbs,
14182 alc861vd_3stack_init_verbs },
14183 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14184 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014185 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14186 .channel_mode = alc861vd_3stack_2ch_modes,
14187 .input_mux = &alc861vd_capture_source,
14188 },
Mike Crash6963f842007-06-25 12:12:51 +020014189 [ALC660VD_3ST_DIG] = {
14190 .mixers = { alc861vd_3st_mixer },
14191 .init_verbs = { alc861vd_volume_init_verbs,
14192 alc861vd_3stack_init_verbs },
14193 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14194 .dac_nids = alc660vd_dac_nids,
14195 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020014196 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14197 .channel_mode = alc861vd_3stack_2ch_modes,
14198 .input_mux = &alc861vd_capture_source,
14199 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014200 [ALC861VD_3ST] = {
14201 .mixers = { alc861vd_3st_mixer },
14202 .init_verbs = { alc861vd_volume_init_verbs,
14203 alc861vd_3stack_init_verbs },
14204 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14205 .dac_nids = alc861vd_dac_nids,
14206 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14207 .channel_mode = alc861vd_3stack_2ch_modes,
14208 .input_mux = &alc861vd_capture_source,
14209 },
14210 [ALC861VD_3ST_DIG] = {
14211 .mixers = { alc861vd_3st_mixer },
14212 .init_verbs = { alc861vd_volume_init_verbs,
14213 alc861vd_3stack_init_verbs },
14214 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14215 .dac_nids = alc861vd_dac_nids,
14216 .dig_out_nid = ALC861VD_DIGOUT_NID,
14217 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14218 .channel_mode = alc861vd_3stack_2ch_modes,
14219 .input_mux = &alc861vd_capture_source,
14220 },
14221 [ALC861VD_6ST_DIG] = {
14222 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
14223 .init_verbs = { alc861vd_volume_init_verbs,
14224 alc861vd_6stack_init_verbs },
14225 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14226 .dac_nids = alc861vd_dac_nids,
14227 .dig_out_nid = ALC861VD_DIGOUT_NID,
14228 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
14229 .channel_mode = alc861vd_6stack_modes,
14230 .input_mux = &alc861vd_capture_source,
14231 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020014232 [ALC861VD_LENOVO] = {
14233 .mixers = { alc861vd_lenovo_mixer },
14234 .init_verbs = { alc861vd_volume_init_verbs,
14235 alc861vd_3stack_init_verbs,
14236 alc861vd_eapd_verbs,
14237 alc861vd_lenovo_unsol_verbs },
14238 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14239 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014240 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14241 .channel_mode = alc861vd_3stack_2ch_modes,
14242 .input_mux = &alc861vd_capture_source,
14243 .unsol_event = alc861vd_lenovo_unsol_event,
14244 .init_hook = alc861vd_lenovo_automute,
14245 },
Kailang Yang272a5272007-05-14 11:00:38 +020014246 [ALC861VD_DALLAS] = {
14247 .mixers = { alc861vd_dallas_mixer },
14248 .init_verbs = { alc861vd_dallas_verbs },
14249 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14250 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020014251 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14252 .channel_mode = alc861vd_3stack_2ch_modes,
14253 .input_mux = &alc861vd_dallas_capture_source,
14254 .unsol_event = alc861vd_dallas_unsol_event,
14255 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014256 },
14257 [ALC861VD_HP] = {
14258 .mixers = { alc861vd_hp_mixer },
14259 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
14260 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
14261 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014262 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020014263 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14264 .channel_mode = alc861vd_3stack_2ch_modes,
14265 .input_mux = &alc861vd_hp_capture_source,
14266 .unsol_event = alc861vd_dallas_unsol_event,
14267 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020014268 },
Takashi Iwai13c94742008-11-05 08:06:08 +010014269 [ALC660VD_ASUS_V1S] = {
14270 .mixers = { alc861vd_lenovo_mixer },
14271 .init_verbs = { alc861vd_volume_init_verbs,
14272 alc861vd_3stack_init_verbs,
14273 alc861vd_eapd_verbs,
14274 alc861vd_lenovo_unsol_verbs },
14275 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
14276 .dac_nids = alc660vd_dac_nids,
14277 .dig_out_nid = ALC861VD_DIGOUT_NID,
14278 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
14279 .channel_mode = alc861vd_3stack_2ch_modes,
14280 .input_mux = &alc861vd_capture_source,
14281 .unsol_event = alc861vd_lenovo_unsol_event,
14282 .init_hook = alc861vd_lenovo_automute,
14283 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014284};
14285
14286/*
14287 * BIOS auto configuration
14288 */
14289static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
14290 hda_nid_t nid, int pin_type, int dac_idx)
14291{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014292 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014293}
14294
14295static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
14296{
14297 struct alc_spec *spec = codec->spec;
14298 int i;
14299
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014300 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014301 for (i = 0; i <= HDA_SIDE; i++) {
14302 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014303 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014304 if (nid)
14305 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020014306 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014307 }
14308}
14309
14310
14311static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
14312{
14313 struct alc_spec *spec = codec->spec;
14314 hda_nid_t pin;
14315
14316 pin = spec->autocfg.hp_pins[0];
14317 if (pin) /* connect to front and use dac 0 */
14318 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014319 pin = spec->autocfg.speaker_pins[0];
14320 if (pin)
14321 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014322}
14323
14324#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
14325#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
14326
14327static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
14328{
14329 struct alc_spec *spec = codec->spec;
14330 int i;
14331
14332 for (i = 0; i < AUTO_PIN_LAST; i++) {
14333 hda_nid_t nid = spec->autocfg.input_pins[i];
14334 if (alc861vd_is_input_pin(nid)) {
14335 snd_hda_codec_write(codec, nid, 0,
14336 AC_VERB_SET_PIN_WIDGET_CONTROL,
14337 i <= AUTO_PIN_FRONT_MIC ?
14338 PIN_VREF80 : PIN_IN);
14339 if (nid != ALC861VD_PIN_CD_NID)
14340 snd_hda_codec_write(codec, nid, 0,
14341 AC_VERB_SET_AMP_GAIN_MUTE,
14342 AMP_OUT_MUTE);
14343 }
14344 }
14345}
14346
Takashi Iwaif511b012008-08-15 16:46:42 +020014347#define alc861vd_auto_init_input_src alc882_auto_init_input_src
14348
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014349#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
14350#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
14351
14352/* add playback controls from the parsed DAC table */
14353/* Based on ALC880 version. But ALC861VD has separate,
14354 * different NIDs for mute/unmute switch and volume control */
14355static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
14356 const struct auto_pin_cfg *cfg)
14357{
14358 char name[32];
14359 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
14360 hda_nid_t nid_v, nid_s;
14361 int i, err;
14362
14363 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014364 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014365 continue;
14366 nid_v = alc861vd_idx_to_mixer_vol(
14367 alc880_dac_to_idx(
14368 spec->multiout.dac_nids[i]));
14369 nid_s = alc861vd_idx_to_mixer_switch(
14370 alc880_dac_to_idx(
14371 spec->multiout.dac_nids[i]));
14372
14373 if (i == 2) {
14374 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014375 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14376 "Center Playback Volume",
14377 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
14378 HDA_OUTPUT));
14379 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014380 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014381 err = add_control(spec, ALC_CTL_WIDGET_VOL,
14382 "LFE Playback Volume",
14383 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
14384 HDA_OUTPUT));
14385 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014386 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014387 err = add_control(spec, ALC_CTL_BIND_MUTE,
14388 "Center Playback Switch",
14389 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
14390 HDA_INPUT));
14391 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014392 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014393 err = add_control(spec, ALC_CTL_BIND_MUTE,
14394 "LFE Playback Switch",
14395 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
14396 HDA_INPUT));
14397 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014398 return err;
14399 } else {
14400 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014401 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14402 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
14403 HDA_OUTPUT));
14404 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014405 return err;
14406 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014407 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020014408 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014409 HDA_INPUT));
14410 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014411 return err;
14412 }
14413 }
14414 return 0;
14415}
14416
14417/* add playback controls for speaker and HP outputs */
14418/* Based on ALC880 version. But ALC861VD has separate,
14419 * different NIDs for mute/unmute switch and volume control */
14420static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
14421 hda_nid_t pin, const char *pfx)
14422{
14423 hda_nid_t nid_v, nid_s;
14424 int err;
14425 char name[32];
14426
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014427 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014428 return 0;
14429
14430 if (alc880_is_fixed_pin(pin)) {
14431 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
14432 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014433 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014434 spec->multiout.hp_nid = nid_v;
14435 else
14436 spec->multiout.extra_out_nid[0] = nid_v;
14437 /* control HP volume/switch on the output mixer amp */
14438 nid_v = alc861vd_idx_to_mixer_vol(
14439 alc880_fixed_pin_idx(pin));
14440 nid_s = alc861vd_idx_to_mixer_switch(
14441 alc880_fixed_pin_idx(pin));
14442
14443 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014444 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
14445 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
14446 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014447 return err;
14448 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014449 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
14450 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
14451 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014452 return err;
14453 } else if (alc880_is_multi_pin(pin)) {
14454 /* set manual connection */
14455 /* we have only a switch on HP-out PIN */
14456 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014457 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
14458 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
14459 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014460 return err;
14461 }
14462 return 0;
14463}
14464
14465/* parse the BIOS configuration and set up the alc_spec
14466 * return 1 if successful, 0 if the proper config is not found,
14467 * or a negative error code
14468 * Based on ALC880 version - had to change it to override
14469 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
14470static int alc861vd_parse_auto_config(struct hda_codec *codec)
14471{
14472 struct alc_spec *spec = codec->spec;
14473 int err;
14474 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
14475
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014476 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14477 alc861vd_ignore);
14478 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014479 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014480 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014481 return 0; /* can't find valid BIOS pin config */
14482
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014483 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
14484 if (err < 0)
14485 return err;
14486 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
14487 if (err < 0)
14488 return err;
14489 err = alc861vd_auto_create_extra_out(spec,
14490 spec->autocfg.speaker_pins[0],
14491 "Speaker");
14492 if (err < 0)
14493 return err;
14494 err = alc861vd_auto_create_extra_out(spec,
14495 spec->autocfg.hp_pins[0],
14496 "Headphone");
14497 if (err < 0)
14498 return err;
14499 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
14500 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014501 return err;
14502
14503 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14504
14505 if (spec->autocfg.dig_out_pin)
14506 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14507
Takashi Iwai603c4012008-07-30 15:01:44 +020014508 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014509 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014510
Takashi Iwaid88897e2008-10-31 15:01:37 +010014511 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014512
14513 spec->num_mux_defs = 1;
14514 spec->input_mux = &spec->private_imux;
14515
Takashi Iwai776e1842007-08-29 15:07:11 +020014516 err = alc_auto_add_mic_boost(codec);
14517 if (err < 0)
14518 return err;
14519
Takashi Iwaie044c392008-10-27 16:56:24 +010014520 store_pin_configs(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014521 return 1;
14522}
14523
14524/* additional initialization for auto-configuration model */
14525static void alc861vd_auto_init(struct hda_codec *codec)
14526{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014527 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014528 alc861vd_auto_init_multi_out(codec);
14529 alc861vd_auto_init_hp_out(codec);
14530 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014531 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014532 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014533 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014534}
14535
14536static int patch_alc861vd(struct hda_codec *codec)
14537{
14538 struct alc_spec *spec;
14539 int err, board_config;
14540
14541 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14542 if (spec == NULL)
14543 return -ENOMEM;
14544
14545 codec->spec = spec;
14546
14547 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14548 alc861vd_models,
14549 alc861vd_cfg_tbl);
14550
14551 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14552 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14553 "ALC861VD, trying auto-probe from BIOS...\n");
14554 board_config = ALC861VD_AUTO;
14555 }
14556
14557 if (board_config == ALC861VD_AUTO) {
14558 /* automatic parse from the BIOS config */
14559 err = alc861vd_parse_auto_config(codec);
14560 if (err < 0) {
14561 alc_free(codec);
14562 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014563 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014564 printk(KERN_INFO
14565 "hda_codec: Cannot set up configuration "
14566 "from BIOS. Using base mode...\n");
14567 board_config = ALC861VD_3ST;
14568 }
14569 }
14570
14571 if (board_config != ALC861VD_AUTO)
14572 setup_preset(spec, &alc861vd_presets[board_config]);
14573
Kailang Yang2f893282008-05-27 12:14:47 +020014574 if (codec->vendor_id == 0x10ec0660) {
14575 spec->stream_name_analog = "ALC660-VD Analog";
14576 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014577 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010014578 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020014579 } else {
14580 spec->stream_name_analog = "ALC861VD Analog";
14581 spec->stream_name_digital = "ALC861VD Digital";
14582 }
14583
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014584 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14585 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14586
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014587 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14588 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14589
14590 spec->adc_nids = alc861vd_adc_nids;
14591 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014592 spec->capsrc_nids = alc861vd_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010014593 spec->is_mix_capture = 1;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014594
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014595 set_capture_mixer(spec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014596
Takashi Iwai2134ea42008-01-10 16:53:55 +010014597 spec->vmaster_nid = 0x02;
14598
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014599 codec->patch_ops = alc_patch_ops;
14600
14601 if (board_config == ALC861VD_AUTO)
14602 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014603#ifdef CONFIG_SND_HDA_POWER_SAVE
14604 if (!spec->loopback.amplist)
14605 spec->loopback.amplist = alc861vd_loopbacks;
14606#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014607
14608 return 0;
14609}
14610
14611/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014612 * ALC662 support
14613 *
14614 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14615 * configuration. Each pin widget can choose any input DACs and a mixer.
14616 * Each ADC is connected from a mixer of all inputs. This makes possible
14617 * 6-channel independent captures.
14618 *
14619 * In addition, an independent DAC for the multi-playback (not used in this
14620 * driver yet).
14621 */
14622#define ALC662_DIGOUT_NID 0x06
14623#define ALC662_DIGIN_NID 0x0a
14624
14625static hda_nid_t alc662_dac_nids[4] = {
14626 /* front, rear, clfe, rear_surr */
14627 0x02, 0x03, 0x04
14628};
14629
14630static hda_nid_t alc662_adc_nids[1] = {
14631 /* ADC1-2 */
14632 0x09,
14633};
Takashi Iwaie1406342008-02-11 18:32:32 +010014634
Kailang Yang77a261b2008-02-19 11:38:05 +010014635static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014636
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014637/* input MUX */
14638/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014639static struct hda_input_mux alc662_capture_source = {
14640 .num_items = 4,
14641 .items = {
14642 { "Mic", 0x0 },
14643 { "Front Mic", 0x1 },
14644 { "Line", 0x2 },
14645 { "CD", 0x4 },
14646 },
14647};
14648
14649static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14650 .num_items = 2,
14651 .items = {
14652 { "Mic", 0x1 },
14653 { "Line", 0x2 },
14654 },
14655};
Kailang Yang291702f2007-10-16 14:28:03 +020014656
14657static struct hda_input_mux alc662_eeepc_capture_source = {
14658 .num_items = 2,
14659 .items = {
14660 { "i-Mic", 0x1 },
14661 { "e-Mic", 0x0 },
14662 },
14663};
14664
Kailang Yang6dda9f42008-05-27 12:05:31 +020014665static struct hda_input_mux alc663_capture_source = {
14666 .num_items = 3,
14667 .items = {
14668 { "Mic", 0x0 },
14669 { "Front Mic", 0x1 },
14670 { "Line", 0x2 },
14671 },
14672};
14673
14674static struct hda_input_mux alc663_m51va_capture_source = {
14675 .num_items = 2,
14676 .items = {
14677 { "Ext-Mic", 0x0 },
14678 { "D-Mic", 0x9 },
14679 },
14680};
14681
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014682/*
14683 * 2ch mode
14684 */
14685static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14686 { 2, NULL }
14687};
14688
14689/*
14690 * 2ch mode
14691 */
14692static struct hda_verb alc662_3ST_ch2_init[] = {
14693 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14694 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14695 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14696 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14697 { } /* end */
14698};
14699
14700/*
14701 * 6ch mode
14702 */
14703static struct hda_verb alc662_3ST_ch6_init[] = {
14704 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14705 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14706 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14707 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14708 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14709 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14710 { } /* end */
14711};
14712
14713static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14714 { 2, alc662_3ST_ch2_init },
14715 { 6, alc662_3ST_ch6_init },
14716};
14717
14718/*
14719 * 2ch mode
14720 */
14721static struct hda_verb alc662_sixstack_ch6_init[] = {
14722 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14723 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14724 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14725 { } /* end */
14726};
14727
14728/*
14729 * 6ch mode
14730 */
14731static struct hda_verb alc662_sixstack_ch8_init[] = {
14732 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14733 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14734 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14735 { } /* end */
14736};
14737
14738static struct hda_channel_mode alc662_5stack_modes[2] = {
14739 { 2, alc662_sixstack_ch6_init },
14740 { 6, alc662_sixstack_ch8_init },
14741};
14742
14743/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14744 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14745 */
14746
14747static struct snd_kcontrol_new alc662_base_mixer[] = {
14748 /* output mixer control */
14749 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014750 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014751 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014752 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014753 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14754 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014755 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14756 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014757 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14758
14759 /*Input mixer control */
14760 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14761 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14762 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14763 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14764 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14765 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14766 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14767 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014768 { } /* end */
14769};
14770
14771static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14772 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014773 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014774 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14775 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14776 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14777 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14778 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14779 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14780 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14781 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14782 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14783 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14784 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014785 { } /* end */
14786};
14787
14788static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14789 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014790 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014791 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014792 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014793 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14794 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014795 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14796 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014797 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14798 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14799 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14800 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14801 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14804 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14805 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14806 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14807 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014808 { } /* end */
14809};
14810
14811static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
14812 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14813 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014814 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14815 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014816 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14817 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14818 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14819 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14820 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014821 { } /* end */
14822};
14823
Kailang Yang291702f2007-10-16 14:28:03 +020014824static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010014825 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014826
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010014827 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14828 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014829
14830 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
14831 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14832 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14833
14834 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
14835 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14836 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14837 { } /* end */
14838};
14839
Kailang Yang8c427222008-01-10 13:03:59 +010014840static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010014841 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14842 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014843 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14844 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
14845 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14846 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
14847 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
14848 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014849 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014850 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
14851 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14852 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14853 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14854 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14855 { } /* end */
14856};
14857
Kailang Yangf1d4e282008-08-26 14:03:29 +020014858static struct hda_bind_ctls alc663_asus_bind_master_vol = {
14859 .ops = &snd_hda_bind_vol,
14860 .values = {
14861 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14862 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
14863 0
14864 },
14865};
14866
14867static struct hda_bind_ctls alc663_asus_one_bind_switch = {
14868 .ops = &snd_hda_bind_sw,
14869 .values = {
14870 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14871 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14872 0
14873 },
14874};
14875
Kailang Yang6dda9f42008-05-27 12:05:31 +020014876static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020014877 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14878 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
14879 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14880 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14881 { } /* end */
14882};
14883
14884static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
14885 .ops = &snd_hda_bind_sw,
14886 .values = {
14887 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14888 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14889 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
14890 0
14891 },
14892};
14893
14894static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
14895 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14896 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
14897 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14898 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14899 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14900 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14901
14902 { } /* end */
14903};
14904
14905static struct hda_bind_ctls alc663_asus_four_bind_switch = {
14906 .ops = &snd_hda_bind_sw,
14907 .values = {
14908 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14909 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
14910 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
14911 0
14912 },
14913};
14914
14915static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
14916 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14917 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
14918 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14919 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14920 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14921 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14922 { } /* end */
14923};
14924
14925static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014926 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14927 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014928 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14929 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14930 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14931 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14932 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14933 { } /* end */
14934};
14935
14936static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
14937 .ops = &snd_hda_bind_vol,
14938 .values = {
14939 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
14940 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
14941 0
14942 },
14943};
14944
14945static struct hda_bind_ctls alc663_asus_two_bind_switch = {
14946 .ops = &snd_hda_bind_sw,
14947 .values = {
14948 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14949 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
14950 0
14951 },
14952};
14953
14954static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
14955 HDA_BIND_VOL("Master Playback Volume",
14956 &alc663_asus_two_bind_master_vol),
14957 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14958 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014959 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14960 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14961 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020014962 { } /* end */
14963};
14964
14965static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
14966 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
14967 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
14968 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14969 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14970 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14971 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014972 { } /* end */
14973};
14974
14975static struct snd_kcontrol_new alc663_g71v_mixer[] = {
14976 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14977 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14978 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14979 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14980 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14981
14982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14984 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14985 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14986 { } /* end */
14987};
14988
14989static struct snd_kcontrol_new alc663_g50v_mixer[] = {
14990 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14991 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14992 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14993
14994 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14995 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14996 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14997 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14999 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
15000 { } /* end */
15001};
15002
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015003static struct snd_kcontrol_new alc662_chmode_mixer[] = {
15004 {
15005 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15006 .name = "Channel Mode",
15007 .info = alc_ch_mode_info,
15008 .get = alc_ch_mode_get,
15009 .put = alc_ch_mode_put,
15010 },
15011 { } /* end */
15012};
15013
15014static struct hda_verb alc662_init_verbs[] = {
15015 /* ADC: mute amp left and right */
15016 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15017 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15018 /* Front mixer: unmute input/output amp left and right (volume = 0) */
15019
Takashi Iwaicb53c622007-08-10 17:21:45 +020015020 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15021 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15022 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15023 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15024 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015025
Kailang Yangb60dd392007-09-20 12:50:29 +020015026 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15027 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15028 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15029 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15030 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15031 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015032
15033 /* Front Pin: output 0 (0x0c) */
15034 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15035 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15036
15037 /* Rear Pin: output 1 (0x0d) */
15038 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15039 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15040
15041 /* CLFE Pin: output 2 (0x0e) */
15042 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15043 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15044
15045 /* Mic (rear) pin: input vref at 80% */
15046 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15047 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15048 /* Front Mic pin: input vref at 80% */
15049 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
15050 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15051 /* Line In pin: input */
15052 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15053 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15054 /* Line-2 In: Headphone output (output 0 - 0x0c) */
15055 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15056 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15057 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
15058 /* CD pin widget for input */
15059 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15060
15061 /* FIXME: use matrix-type input source selection */
15062 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15063 /* Input mixer */
15064 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15065 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15066 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020015068
15069 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15070 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15071 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15072 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015073
15074 /* always trun on EAPD */
15075 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
15076 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
15077
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015078 { }
15079};
15080
15081static struct hda_verb alc662_sue_init_verbs[] = {
15082 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15083 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020015084 {}
15085};
15086
15087static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
15088 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15089 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15090 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015091};
15092
Kailang Yang8c427222008-01-10 13:03:59 +010015093/* Set Unsolicited Event*/
15094static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
15095 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
15096 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15097 {}
15098};
15099
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015100/*
15101 * generic initialization of ADC, input mixers and output mixers
15102 */
15103static struct hda_verb alc662_auto_init_verbs[] = {
15104 /*
15105 * Unmute ADC and set the default input to mic-in
15106 */
15107 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
15108 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15109
15110 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
15111 * mixer widget
15112 * Note: PASD motherboards uses the Line In 2 as the input for front
15113 * panel mic (mic 2)
15114 */
15115 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020015116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
15120 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015121
15122 /*
15123 * Set up output mixers (0x0c - 0x0f)
15124 */
15125 /* set vol=0 to output mixers */
15126 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15127 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15128 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
15129
15130 /* set up input amps for analog loopback */
15131 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020015132 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15133 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15134 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15135 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15136 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15137 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015138
15139
15140 /* FIXME: use matrix-type input source selection */
15141 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
15142 /* Input mixer */
15143 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020015144 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015145 { }
15146};
15147
Takashi Iwai24fb9172008-09-02 14:48:20 +020015148/* additional verbs for ALC663 */
15149static struct hda_verb alc663_auto_init_verbs[] = {
15150 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15151 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15152 { }
15153};
15154
Kailang Yang6dda9f42008-05-27 12:05:31 +020015155static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020015156 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15157 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015158 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15159 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020015160 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15161 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15162 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020015163 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15164 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15165 {}
15166};
15167
Kailang Yangf1d4e282008-08-26 14:03:29 +020015168static struct hda_verb alc663_21jd_amic_init_verbs[] = {
15169 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15170 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15171 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15172 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15173 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15174 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15175 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15176 {}
15177};
15178
15179static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
15180 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15181 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15182 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15183 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15186 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15187 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15188 {}
15189};
15190
15191static struct hda_verb alc663_15jd_amic_init_verbs[] = {
15192 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15193 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15194 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15197 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15198 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15199 {}
15200};
15201
15202static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
15203 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15204 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15205 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15206 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15207 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15208 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15209 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
15210 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15211 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15212 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15213 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15214 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15215 {}
15216};
15217
15218static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
15219 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
15220 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15221 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15222 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15223 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15224 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15225 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
15226 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15227 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15228 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15229 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15230 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15231 {}
15232};
15233
Kailang Yang6dda9f42008-05-27 12:05:31 +020015234static struct hda_verb alc663_g71v_init_verbs[] = {
15235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15236 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
15237 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
15238
15239 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15240 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15241 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15242
15243 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
15244 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
15245 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
15246 {}
15247};
15248
15249static struct hda_verb alc663_g50v_init_verbs[] = {
15250 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
15251 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15252 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
15253
15254 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15255 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15256 {}
15257};
15258
Kailang Yangf1d4e282008-08-26 14:03:29 +020015259static struct hda_verb alc662_ecs_init_verbs[] = {
15260 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
15261 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15262 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
15263 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
15264 {}
15265};
15266
Kailang Yangf1d4e282008-08-26 14:03:29 +020015267static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
15268 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
15269 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
15270 { } /* end */
15271};
15272
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015273static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
15274{
15275 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015276 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015277
15278 present = snd_hda_codec_read(codec, 0x14, 0,
15279 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015280 bits = present ? HDA_AMP_MUTE : 0;
15281 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15282 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015283}
15284
15285static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
15286{
15287 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015288 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015289
15290 present = snd_hda_codec_read(codec, 0x1b, 0,
15291 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020015292 bits = present ? HDA_AMP_MUTE : 0;
15293 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15294 HDA_AMP_MUTE, bits);
15295 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15296 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015297}
15298
15299static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
15300 unsigned int res)
15301{
15302 if ((res >> 26) == ALC880_HP_EVENT)
15303 alc662_lenovo_101e_all_automute(codec);
15304 if ((res >> 26) == ALC880_FRONT_EVENT)
15305 alc662_lenovo_101e_ispeaker_automute(codec);
15306}
15307
Kailang Yang291702f2007-10-16 14:28:03 +020015308static void alc662_eeepc_mic_automute(struct hda_codec *codec)
15309{
15310 unsigned int present;
15311
15312 present = snd_hda_codec_read(codec, 0x18, 0,
15313 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
15314 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15315 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15316 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15317 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
15318 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15319 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15320 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15321 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
15322}
15323
15324/* unsolicited event for HP jack sensing */
15325static void alc662_eeepc_unsol_event(struct hda_codec *codec,
15326 unsigned int res)
15327{
15328 if ((res >> 26) == ALC880_HP_EVENT)
15329 alc262_hippo1_automute( codec );
15330
15331 if ((res >> 26) == ALC880_MIC_EVENT)
15332 alc662_eeepc_mic_automute(codec);
15333}
15334
15335static void alc662_eeepc_inithook(struct hda_codec *codec)
15336{
15337 alc262_hippo1_automute( codec );
15338 alc662_eeepc_mic_automute(codec);
15339}
15340
Kailang Yang8c427222008-01-10 13:03:59 +010015341static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
15342{
15343 unsigned int mute;
15344 unsigned int present;
15345
15346 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
15347 present = snd_hda_codec_read(codec, 0x14, 0,
15348 AC_VERB_GET_PIN_SENSE, 0);
15349 present = (present & 0x80000000) != 0;
15350 if (present) {
15351 /* mute internal speaker */
15352 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015353 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010015354 } else {
15355 /* unmute internal speaker if necessary */
15356 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
15357 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015358 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010015359 }
15360}
15361
15362/* unsolicited event for HP jack sensing */
15363static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
15364 unsigned int res)
15365{
15366 if ((res >> 26) == ALC880_HP_EVENT)
15367 alc662_eeepc_ep20_automute(codec);
15368}
15369
15370static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
15371{
15372 alc662_eeepc_ep20_automute(codec);
15373}
15374
Kailang Yang6dda9f42008-05-27 12:05:31 +020015375static void alc663_m51va_speaker_automute(struct hda_codec *codec)
15376{
15377 unsigned int present;
15378 unsigned char bits;
15379
15380 present = snd_hda_codec_read(codec, 0x21, 0,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015381 AC_VERB_GET_PIN_SENSE, 0)
15382 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015383 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020015384 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15385 AMP_IN_MUTE(0), bits);
15386 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15387 AMP_IN_MUTE(0), bits);
15388}
15389
15390static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
15391{
15392 unsigned int present;
15393 unsigned char bits;
15394
15395 present = snd_hda_codec_read(codec, 0x21, 0,
15396 AC_VERB_GET_PIN_SENSE, 0)
15397 & AC_PINSENSE_PRESENCE;
15398 bits = present ? HDA_AMP_MUTE : 0;
15399 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15400 AMP_IN_MUTE(0), bits);
15401 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15402 AMP_IN_MUTE(0), bits);
15403 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15404 AMP_IN_MUTE(0), bits);
15405 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15406 AMP_IN_MUTE(0), bits);
15407}
15408
15409static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
15410{
15411 unsigned int present;
15412 unsigned char bits;
15413
15414 present = snd_hda_codec_read(codec, 0x15, 0,
15415 AC_VERB_GET_PIN_SENSE, 0)
15416 & AC_PINSENSE_PRESENCE;
15417 bits = present ? HDA_AMP_MUTE : 0;
15418 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15419 AMP_IN_MUTE(0), bits);
15420 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15421 AMP_IN_MUTE(0), bits);
15422 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
15423 AMP_IN_MUTE(0), bits);
15424 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
15425 AMP_IN_MUTE(0), bits);
15426}
15427
15428static void alc662_f5z_speaker_automute(struct hda_codec *codec)
15429{
15430 unsigned int present;
15431 unsigned char bits;
15432
15433 present = snd_hda_codec_read(codec, 0x1b, 0,
15434 AC_VERB_GET_PIN_SENSE, 0)
15435 & AC_PINSENSE_PRESENCE;
15436 bits = present ? 0 : PIN_OUT;
15437 snd_hda_codec_write(codec, 0x14, 0,
15438 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
15439}
15440
15441static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
15442{
15443 unsigned int present1, present2;
15444
15445 present1 = snd_hda_codec_read(codec, 0x21, 0,
15446 AC_VERB_GET_PIN_SENSE, 0)
15447 & AC_PINSENSE_PRESENCE;
15448 present2 = snd_hda_codec_read(codec, 0x15, 0,
15449 AC_VERB_GET_PIN_SENSE, 0)
15450 & AC_PINSENSE_PRESENCE;
15451
15452 if (present1 || present2) {
15453 snd_hda_codec_write_cache(codec, 0x14, 0,
15454 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
15455 } else {
15456 snd_hda_codec_write_cache(codec, 0x14, 0,
15457 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
15458 }
15459}
15460
15461static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
15462{
15463 unsigned int present1, present2;
15464
15465 present1 = snd_hda_codec_read(codec, 0x1b, 0,
15466 AC_VERB_GET_PIN_SENSE, 0)
15467 & AC_PINSENSE_PRESENCE;
15468 present2 = snd_hda_codec_read(codec, 0x15, 0,
15469 AC_VERB_GET_PIN_SENSE, 0)
15470 & AC_PINSENSE_PRESENCE;
15471
15472 if (present1 || present2) {
15473 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15474 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15475 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15476 AMP_IN_MUTE(0), AMP_IN_MUTE(0));
15477 } else {
15478 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
15479 AMP_IN_MUTE(0), 0);
15480 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
15481 AMP_IN_MUTE(0), 0);
15482 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020015483}
15484
15485static void alc663_m51va_mic_automute(struct hda_codec *codec)
15486{
15487 unsigned int present;
15488
15489 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020015490 AC_VERB_GET_PIN_SENSE, 0)
15491 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020015492 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015493 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015494 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015495 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015496 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015497 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015498 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020015499 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020015500}
15501
15502static void alc663_m51va_unsol_event(struct hda_codec *codec,
15503 unsigned int res)
15504{
15505 switch (res >> 26) {
15506 case ALC880_HP_EVENT:
15507 alc663_m51va_speaker_automute(codec);
15508 break;
15509 case ALC880_MIC_EVENT:
15510 alc663_m51va_mic_automute(codec);
15511 break;
15512 }
15513}
15514
15515static void alc663_m51va_inithook(struct hda_codec *codec)
15516{
15517 alc663_m51va_speaker_automute(codec);
15518 alc663_m51va_mic_automute(codec);
15519}
15520
Kailang Yangf1d4e282008-08-26 14:03:29 +020015521/* ***************** Mode1 ******************************/
15522static void alc663_mode1_unsol_event(struct hda_codec *codec,
15523 unsigned int res)
15524{
15525 switch (res >> 26) {
15526 case ALC880_HP_EVENT:
15527 alc663_m51va_speaker_automute(codec);
15528 break;
15529 case ALC880_MIC_EVENT:
15530 alc662_eeepc_mic_automute(codec);
15531 break;
15532 }
15533}
15534
15535static void alc663_mode1_inithook(struct hda_codec *codec)
15536{
15537 alc663_m51va_speaker_automute(codec);
15538 alc662_eeepc_mic_automute(codec);
15539}
15540/* ***************** Mode2 ******************************/
15541static void alc662_mode2_unsol_event(struct hda_codec *codec,
15542 unsigned int res)
15543{
15544 switch (res >> 26) {
15545 case ALC880_HP_EVENT:
15546 alc662_f5z_speaker_automute(codec);
15547 break;
15548 case ALC880_MIC_EVENT:
15549 alc662_eeepc_mic_automute(codec);
15550 break;
15551 }
15552}
15553
15554static void alc662_mode2_inithook(struct hda_codec *codec)
15555{
15556 alc662_f5z_speaker_automute(codec);
15557 alc662_eeepc_mic_automute(codec);
15558}
15559/* ***************** Mode3 ******************************/
15560static void alc663_mode3_unsol_event(struct hda_codec *codec,
15561 unsigned int res)
15562{
15563 switch (res >> 26) {
15564 case ALC880_HP_EVENT:
15565 alc663_two_hp_m1_speaker_automute(codec);
15566 break;
15567 case ALC880_MIC_EVENT:
15568 alc662_eeepc_mic_automute(codec);
15569 break;
15570 }
15571}
15572
15573static void alc663_mode3_inithook(struct hda_codec *codec)
15574{
15575 alc663_two_hp_m1_speaker_automute(codec);
15576 alc662_eeepc_mic_automute(codec);
15577}
15578/* ***************** Mode4 ******************************/
15579static void alc663_mode4_unsol_event(struct hda_codec *codec,
15580 unsigned int res)
15581{
15582 switch (res >> 26) {
15583 case ALC880_HP_EVENT:
15584 alc663_21jd_two_speaker_automute(codec);
15585 break;
15586 case ALC880_MIC_EVENT:
15587 alc662_eeepc_mic_automute(codec);
15588 break;
15589 }
15590}
15591
15592static void alc663_mode4_inithook(struct hda_codec *codec)
15593{
15594 alc663_21jd_two_speaker_automute(codec);
15595 alc662_eeepc_mic_automute(codec);
15596}
15597/* ***************** Mode5 ******************************/
15598static void alc663_mode5_unsol_event(struct hda_codec *codec,
15599 unsigned int res)
15600{
15601 switch (res >> 26) {
15602 case ALC880_HP_EVENT:
15603 alc663_15jd_two_speaker_automute(codec);
15604 break;
15605 case ALC880_MIC_EVENT:
15606 alc662_eeepc_mic_automute(codec);
15607 break;
15608 }
15609}
15610
15611static void alc663_mode5_inithook(struct hda_codec *codec)
15612{
15613 alc663_15jd_two_speaker_automute(codec);
15614 alc662_eeepc_mic_automute(codec);
15615}
15616/* ***************** Mode6 ******************************/
15617static void alc663_mode6_unsol_event(struct hda_codec *codec,
15618 unsigned int res)
15619{
15620 switch (res >> 26) {
15621 case ALC880_HP_EVENT:
15622 alc663_two_hp_m2_speaker_automute(codec);
15623 break;
15624 case ALC880_MIC_EVENT:
15625 alc662_eeepc_mic_automute(codec);
15626 break;
15627 }
15628}
15629
15630static void alc663_mode6_inithook(struct hda_codec *codec)
15631{
15632 alc663_two_hp_m2_speaker_automute(codec);
15633 alc662_eeepc_mic_automute(codec);
15634}
15635
Kailang Yang6dda9f42008-05-27 12:05:31 +020015636static void alc663_g71v_hp_automute(struct hda_codec *codec)
15637{
15638 unsigned int present;
15639 unsigned char bits;
15640
15641 present = snd_hda_codec_read(codec, 0x21, 0,
15642 AC_VERB_GET_PIN_SENSE, 0)
15643 & AC_PINSENSE_PRESENCE;
15644 bits = present ? HDA_AMP_MUTE : 0;
15645 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
15646 HDA_AMP_MUTE, bits);
15647 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15648 HDA_AMP_MUTE, bits);
15649}
15650
15651static void alc663_g71v_front_automute(struct hda_codec *codec)
15652{
15653 unsigned int present;
15654 unsigned char bits;
15655
15656 present = snd_hda_codec_read(codec, 0x15, 0,
15657 AC_VERB_GET_PIN_SENSE, 0)
15658 & AC_PINSENSE_PRESENCE;
15659 bits = present ? HDA_AMP_MUTE : 0;
15660 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
15661 HDA_AMP_MUTE, bits);
15662}
15663
15664static void alc663_g71v_unsol_event(struct hda_codec *codec,
15665 unsigned int res)
15666{
15667 switch (res >> 26) {
15668 case ALC880_HP_EVENT:
15669 alc663_g71v_hp_automute(codec);
15670 break;
15671 case ALC880_FRONT_EVENT:
15672 alc663_g71v_front_automute(codec);
15673 break;
15674 case ALC880_MIC_EVENT:
15675 alc662_eeepc_mic_automute(codec);
15676 break;
15677 }
15678}
15679
15680static void alc663_g71v_inithook(struct hda_codec *codec)
15681{
15682 alc663_g71v_front_automute(codec);
15683 alc663_g71v_hp_automute(codec);
15684 alc662_eeepc_mic_automute(codec);
15685}
15686
15687static void alc663_g50v_unsol_event(struct hda_codec *codec,
15688 unsigned int res)
15689{
15690 switch (res >> 26) {
15691 case ALC880_HP_EVENT:
15692 alc663_m51va_speaker_automute(codec);
15693 break;
15694 case ALC880_MIC_EVENT:
15695 alc662_eeepc_mic_automute(codec);
15696 break;
15697 }
15698}
15699
15700static void alc663_g50v_inithook(struct hda_codec *codec)
15701{
15702 alc663_m51va_speaker_automute(codec);
15703 alc662_eeepc_mic_automute(codec);
15704}
15705
Kailang Yangf1d4e282008-08-26 14:03:29 +020015706/* bind hp and internal speaker mute (with plug check) */
15707static int alc662_ecs_master_sw_put(struct snd_kcontrol *kcontrol,
15708 struct snd_ctl_elem_value *ucontrol)
15709{
15710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
15711 long *valp = ucontrol->value.integer.value;
15712 int change;
15713
15714 change = snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
15715 HDA_AMP_MUTE,
15716 valp[0] ? 0 : HDA_AMP_MUTE);
15717 change |= snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
15718 HDA_AMP_MUTE,
15719 valp[1] ? 0 : HDA_AMP_MUTE);
15720 if (change)
15721 alc262_hippo1_automute(codec);
15722 return change;
15723}
15724
15725static struct snd_kcontrol_new alc662_ecs_mixer[] = {
15726 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
15727 {
15728 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15729 .name = "Master Playback Switch",
15730 .info = snd_hda_mixer_amp_switch_info,
15731 .get = snd_hda_mixer_amp_switch_get,
15732 .put = alc662_ecs_master_sw_put,
15733 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
15734 },
15735
15736 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
15737 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
15738 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
15739
15740 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
15741 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
15742 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
15743 { } /* end */
15744};
15745
Takashi Iwaicb53c622007-08-10 17:21:45 +020015746#ifdef CONFIG_SND_HDA_POWER_SAVE
15747#define alc662_loopbacks alc880_loopbacks
15748#endif
15749
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015750
15751/* pcm configuration: identiacal with ALC880 */
15752#define alc662_pcm_analog_playback alc880_pcm_analog_playback
15753#define alc662_pcm_analog_capture alc880_pcm_analog_capture
15754#define alc662_pcm_digital_playback alc880_pcm_digital_playback
15755#define alc662_pcm_digital_capture alc880_pcm_digital_capture
15756
15757/*
15758 * configuration and preset
15759 */
15760static const char *alc662_models[ALC662_MODEL_LAST] = {
15761 [ALC662_3ST_2ch_DIG] = "3stack-dig",
15762 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
15763 [ALC662_3ST_6ch] = "3stack-6ch",
15764 [ALC662_5ST_DIG] = "6stack-dig",
15765 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020015766 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010015767 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015768 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020015769 [ALC663_ASUS_M51VA] = "m51va",
15770 [ALC663_ASUS_G71V] = "g71v",
15771 [ALC663_ASUS_H13] = "h13",
15772 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020015773 [ALC663_ASUS_MODE1] = "asus-mode1",
15774 [ALC662_ASUS_MODE2] = "asus-mode2",
15775 [ALC663_ASUS_MODE3] = "asus-mode3",
15776 [ALC663_ASUS_MODE4] = "asus-mode4",
15777 [ALC663_ASUS_MODE5] = "asus-mode5",
15778 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015779 [ALC662_AUTO] = "auto",
15780};
15781
15782static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020015783 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Kailang Yang80ffe862008-10-15 11:23:27 +020015784 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010015785 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020015786 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010015787 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015788 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
15789 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),
15790 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
15791 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
15792 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
15793 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),
15794 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
15795 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
15796 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020015797 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015798 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
15799 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
15800 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
15801 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
15802 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
15803 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
15804 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
15805 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
15806 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
15807 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
15808 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
15809 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
15810 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
15811 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
15812 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
15813 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
15814 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
15815 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
15816 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
15817 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
15818 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
15819 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030015820 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
15821 ALC662_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015822 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yangf1d4e282008-08-26 14:03:29 +020015823 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
15824 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030015825 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
15826 ALC662_3ST_6ch_DIG),
Vedran Miletic19c009a2008-09-29 20:29:25 +020015827 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai238713d2008-10-05 10:57:39 +020015828 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020015829 ALC662_3ST_6ch_DIG),
Kailang Yang6dda9f42008-05-27 12:05:31 +020015830 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
15831 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
15832 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015833 {}
15834};
15835
15836static struct alc_config_preset alc662_presets[] = {
15837 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015838 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015839 .init_verbs = { alc662_init_verbs },
15840 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15841 .dac_nids = alc662_dac_nids,
15842 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015843 .dig_in_nid = ALC662_DIGIN_NID,
15844 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15845 .channel_mode = alc662_3ST_2ch_modes,
15846 .input_mux = &alc662_capture_source,
15847 },
15848 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015849 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015850 .init_verbs = { alc662_init_verbs },
15851 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15852 .dac_nids = alc662_dac_nids,
15853 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015854 .dig_in_nid = ALC662_DIGIN_NID,
15855 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15856 .channel_mode = alc662_3ST_6ch_modes,
15857 .need_dac_fix = 1,
15858 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015859 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015860 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015861 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015862 .init_verbs = { alc662_init_verbs },
15863 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15864 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015865 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15866 .channel_mode = alc662_3ST_6ch_modes,
15867 .need_dac_fix = 1,
15868 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015869 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015870 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015871 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015872 .init_verbs = { alc662_init_verbs },
15873 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15874 .dac_nids = alc662_dac_nids,
15875 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015876 .dig_in_nid = ALC662_DIGIN_NID,
15877 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
15878 .channel_mode = alc662_5stack_modes,
15879 .input_mux = &alc662_capture_source,
15880 },
15881 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015882 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015883 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
15884 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15885 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015886 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15887 .channel_mode = alc662_3ST_2ch_modes,
15888 .input_mux = &alc662_lenovo_101e_capture_source,
15889 .unsol_event = alc662_lenovo_101e_unsol_event,
15890 .init_hook = alc662_lenovo_101e_all_automute,
15891 },
Kailang Yang291702f2007-10-16 14:28:03 +020015892 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015893 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020015894 .init_verbs = { alc662_init_verbs,
15895 alc662_eeepc_sue_init_verbs },
15896 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15897 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020015898 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15899 .channel_mode = alc662_3ST_2ch_modes,
15900 .input_mux = &alc662_eeepc_capture_source,
15901 .unsol_event = alc662_eeepc_unsol_event,
15902 .init_hook = alc662_eeepc_inithook,
15903 },
Kailang Yang8c427222008-01-10 13:03:59 +010015904 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015905 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010015906 alc662_chmode_mixer },
15907 .init_verbs = { alc662_init_verbs,
15908 alc662_eeepc_ep20_sue_init_verbs },
15909 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15910 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010015911 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15912 .channel_mode = alc662_3ST_6ch_modes,
15913 .input_mux = &alc662_lenovo_101e_capture_source,
15914 .unsol_event = alc662_eeepc_ep20_unsol_event,
15915 .init_hook = alc662_eeepc_ep20_inithook,
15916 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015917 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015918 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015919 .init_verbs = { alc662_init_verbs,
15920 alc662_ecs_init_verbs },
15921 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15922 .dac_nids = alc662_dac_nids,
15923 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15924 .channel_mode = alc662_3ST_2ch_modes,
15925 .input_mux = &alc662_eeepc_capture_source,
15926 .unsol_event = alc662_eeepc_unsol_event,
15927 .init_hook = alc662_eeepc_inithook,
15928 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015929 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015930 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015931 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15932 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15933 .dac_nids = alc662_dac_nids,
15934 .dig_out_nid = ALC662_DIGOUT_NID,
15935 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15936 .channel_mode = alc662_3ST_2ch_modes,
15937 .input_mux = &alc663_m51va_capture_source,
15938 .unsol_event = alc663_m51va_unsol_event,
15939 .init_hook = alc663_m51va_inithook,
15940 },
15941 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015942 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015943 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
15944 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15945 .dac_nids = alc662_dac_nids,
15946 .dig_out_nid = ALC662_DIGOUT_NID,
15947 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15948 .channel_mode = alc662_3ST_2ch_modes,
15949 .input_mux = &alc662_eeepc_capture_source,
15950 .unsol_event = alc663_g71v_unsol_event,
15951 .init_hook = alc663_g71v_inithook,
15952 },
15953 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015954 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015955 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
15956 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15957 .dac_nids = alc662_dac_nids,
15958 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15959 .channel_mode = alc662_3ST_2ch_modes,
15960 .input_mux = &alc663_m51va_capture_source,
15961 .unsol_event = alc663_m51va_unsol_event,
15962 .init_hook = alc663_m51va_inithook,
15963 },
15964 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015965 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015966 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
15967 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15968 .dac_nids = alc662_dac_nids,
15969 .dig_out_nid = ALC662_DIGOUT_NID,
15970 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
15971 .channel_mode = alc662_3ST_6ch_modes,
15972 .input_mux = &alc663_capture_source,
15973 .unsol_event = alc663_g50v_unsol_event,
15974 .init_hook = alc663_g50v_inithook,
15975 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020015976 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015977 .mixers = { alc663_m51va_mixer },
15978 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015979 .init_verbs = { alc662_init_verbs,
15980 alc663_21jd_amic_init_verbs },
15981 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15982 .hp_nid = 0x03,
15983 .dac_nids = alc662_dac_nids,
15984 .dig_out_nid = ALC662_DIGOUT_NID,
15985 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
15986 .channel_mode = alc662_3ST_2ch_modes,
15987 .input_mux = &alc662_eeepc_capture_source,
15988 .unsol_event = alc663_mode1_unsol_event,
15989 .init_hook = alc663_mode1_inithook,
15990 },
15991 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015992 .mixers = { alc662_1bjd_mixer },
15993 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020015994 .init_verbs = { alc662_init_verbs,
15995 alc662_1bjd_amic_init_verbs },
15996 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
15997 .dac_nids = alc662_dac_nids,
15998 .dig_out_nid = ALC662_DIGOUT_NID,
15999 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16000 .channel_mode = alc662_3ST_2ch_modes,
16001 .input_mux = &alc662_eeepc_capture_source,
16002 .unsol_event = alc662_mode2_unsol_event,
16003 .init_hook = alc662_mode2_inithook,
16004 },
16005 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016006 .mixers = { alc663_two_hp_m1_mixer },
16007 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016008 .init_verbs = { alc662_init_verbs,
16009 alc663_two_hp_amic_m1_init_verbs },
16010 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16011 .hp_nid = 0x03,
16012 .dac_nids = alc662_dac_nids,
16013 .dig_out_nid = ALC662_DIGOUT_NID,
16014 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16015 .channel_mode = alc662_3ST_2ch_modes,
16016 .input_mux = &alc662_eeepc_capture_source,
16017 .unsol_event = alc663_mode3_unsol_event,
16018 .init_hook = alc663_mode3_inithook,
16019 },
16020 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016021 .mixers = { alc663_asus_21jd_clfe_mixer },
16022 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016023 .init_verbs = { alc662_init_verbs,
16024 alc663_21jd_amic_init_verbs},
16025 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16026 .hp_nid = 0x03,
16027 .dac_nids = alc662_dac_nids,
16028 .dig_out_nid = ALC662_DIGOUT_NID,
16029 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16030 .channel_mode = alc662_3ST_2ch_modes,
16031 .input_mux = &alc662_eeepc_capture_source,
16032 .unsol_event = alc663_mode4_unsol_event,
16033 .init_hook = alc663_mode4_inithook,
16034 },
16035 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016036 .mixers = { alc663_asus_15jd_clfe_mixer },
16037 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016038 .init_verbs = { alc662_init_verbs,
16039 alc663_15jd_amic_init_verbs },
16040 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16041 .hp_nid = 0x03,
16042 .dac_nids = alc662_dac_nids,
16043 .dig_out_nid = ALC662_DIGOUT_NID,
16044 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16045 .channel_mode = alc662_3ST_2ch_modes,
16046 .input_mux = &alc662_eeepc_capture_source,
16047 .unsol_event = alc663_mode5_unsol_event,
16048 .init_hook = alc663_mode5_inithook,
16049 },
16050 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016051 .mixers = { alc663_two_hp_m2_mixer },
16052 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020016053 .init_verbs = { alc662_init_verbs,
16054 alc663_two_hp_amic_m2_init_verbs },
16055 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
16056 .hp_nid = 0x03,
16057 .dac_nids = alc662_dac_nids,
16058 .dig_out_nid = ALC662_DIGOUT_NID,
16059 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
16060 .channel_mode = alc662_3ST_2ch_modes,
16061 .input_mux = &alc662_eeepc_capture_source,
16062 .unsol_event = alc663_mode6_unsol_event,
16063 .init_hook = alc663_mode6_inithook,
16064 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016065};
16066
16067
16068/*
16069 * BIOS auto configuration
16070 */
16071
16072/* add playback controls from the parsed DAC table */
16073static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
16074 const struct auto_pin_cfg *cfg)
16075{
16076 char name[32];
16077 static const char *chname[4] = {
16078 "Front", "Surround", NULL /*CLFE*/, "Side"
16079 };
16080 hda_nid_t nid;
16081 int i, err;
16082
16083 for (i = 0; i < cfg->line_outs; i++) {
16084 if (!spec->multiout.dac_nids[i])
16085 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020016086 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016087 if (i == 2) {
16088 /* Center/LFE */
16089 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16090 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016091 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
16092 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016093 if (err < 0)
16094 return err;
16095 err = add_control(spec, ALC_CTL_WIDGET_VOL,
16096 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016097 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
16098 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016099 if (err < 0)
16100 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016101 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016102 "Center Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016103 HDA_COMPOSE_AMP_VAL(0x0e, 1, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016104 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016105 if (err < 0)
16106 return err;
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016107 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016108 "LFE Playback Switch",
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016109 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016110 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016111 if (err < 0)
16112 return err;
16113 } else {
16114 sprintf(name, "%s Playback Volume", chname[i]);
16115 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016116 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
16117 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016118 if (err < 0)
16119 return err;
16120 sprintf(name, "%s Playback Switch", chname[i]);
Herton Ronaldo Krzesinskib69ce012008-09-18 16:41:49 -030016121 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16122 HDA_COMPOSE_AMP_VAL(alc880_idx_to_mixer(i),
16123 3, 0, HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016124 if (err < 0)
16125 return err;
16126 }
16127 }
16128 return 0;
16129}
16130
16131/* add playback controls for speaker and HP outputs */
16132static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
16133 const char *pfx)
16134{
16135 hda_nid_t nid;
16136 int err;
16137 char name[32];
16138
16139 if (!pin)
16140 return 0;
16141
Takashi Iwai24fb9172008-09-02 14:48:20 +020016142 if (pin == 0x17) {
16143 /* ALC663 has a mono output pin on 0x17 */
16144 sprintf(name, "%s Playback Switch", pfx);
16145 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16146 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
16147 return err;
16148 }
16149
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016150 if (alc880_is_fixed_pin(pin)) {
16151 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16152 /* printk("DAC nid=%x\n",nid); */
16153 /* specify the DAC as the extra output */
16154 if (!spec->multiout.hp_nid)
16155 spec->multiout.hp_nid = nid;
16156 else
16157 spec->multiout.extra_out_nid[0] = nid;
16158 /* control HP volume/switch on the output mixer amp */
16159 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16160 sprintf(name, "%s Playback Volume", pfx);
16161 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
16162 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
16163 if (err < 0)
16164 return err;
16165 sprintf(name, "%s Playback Switch", pfx);
16166 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
16167 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
16168 if (err < 0)
16169 return err;
16170 } else if (alc880_is_multi_pin(pin)) {
16171 /* set manual connection */
16172 /* we have only a switch on HP-out PIN */
16173 sprintf(name, "%s Playback Switch", pfx);
16174 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
16175 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16176 if (err < 0)
16177 return err;
16178 }
16179 return 0;
16180}
16181
16182/* create playback/capture controls for input pins */
16183static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
16184 const struct auto_pin_cfg *cfg)
16185{
16186 struct hda_input_mux *imux = &spec->private_imux;
16187 int i, err, idx;
16188
16189 for (i = 0; i < AUTO_PIN_LAST; i++) {
16190 if (alc880_is_input_pin(cfg->input_pins[i])) {
16191 idx = alc880_input_pin_idx(cfg->input_pins[i]);
16192 err = new_analog_input(spec, cfg->input_pins[i],
16193 auto_pin_cfg_labels[i],
16194 idx, 0x0b);
16195 if (err < 0)
16196 return err;
16197 imux->items[imux->num_items].label =
16198 auto_pin_cfg_labels[i];
16199 imux->items[imux->num_items].index =
16200 alc880_input_pin_idx(cfg->input_pins[i]);
16201 imux->num_items++;
16202 }
16203 }
16204 return 0;
16205}
16206
16207static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
16208 hda_nid_t nid, int pin_type,
16209 int dac_idx)
16210{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016211 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016212 /* need the manual connection? */
16213 if (alc880_is_multi_pin(nid)) {
16214 struct alc_spec *spec = codec->spec;
16215 int idx = alc880_multi_pin_idx(nid);
16216 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
16217 AC_VERB_SET_CONNECT_SEL,
16218 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
16219 }
16220}
16221
16222static void alc662_auto_init_multi_out(struct hda_codec *codec)
16223{
16224 struct alc_spec *spec = codec->spec;
16225 int i;
16226
Kailang Yang8c427222008-01-10 13:03:59 +010016227 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016228 for (i = 0; i <= HDA_SIDE; i++) {
16229 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016230 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016231 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016232 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016233 i);
16234 }
16235}
16236
16237static void alc662_auto_init_hp_out(struct hda_codec *codec)
16238{
16239 struct alc_spec *spec = codec->spec;
16240 hda_nid_t pin;
16241
16242 pin = spec->autocfg.hp_pins[0];
16243 if (pin) /* connect to front */
16244 /* use dac 0 */
16245 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016246 pin = spec->autocfg.speaker_pins[0];
16247 if (pin)
16248 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016249}
16250
16251#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
16252#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
16253
16254static void alc662_auto_init_analog_input(struct hda_codec *codec)
16255{
16256 struct alc_spec *spec = codec->spec;
16257 int i;
16258
16259 for (i = 0; i < AUTO_PIN_LAST; i++) {
16260 hda_nid_t nid = spec->autocfg.input_pins[i];
16261 if (alc662_is_input_pin(nid)) {
16262 snd_hda_codec_write(codec, nid, 0,
16263 AC_VERB_SET_PIN_WIDGET_CONTROL,
16264 (i <= AUTO_PIN_FRONT_MIC ?
16265 PIN_VREF80 : PIN_IN));
16266 if (nid != ALC662_PIN_CD_NID)
16267 snd_hda_codec_write(codec, nid, 0,
16268 AC_VERB_SET_AMP_GAIN_MUTE,
16269 AMP_OUT_MUTE);
16270 }
16271 }
16272}
16273
Takashi Iwaif511b012008-08-15 16:46:42 +020016274#define alc662_auto_init_input_src alc882_auto_init_input_src
16275
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016276static int alc662_parse_auto_config(struct hda_codec *codec)
16277{
16278 struct alc_spec *spec = codec->spec;
16279 int err;
16280 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
16281
16282 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16283 alc662_ignore);
16284 if (err < 0)
16285 return err;
16286 if (!spec->autocfg.line_outs)
16287 return 0; /* can't find valid BIOS pin config */
16288
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016289 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16290 if (err < 0)
16291 return err;
16292 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
16293 if (err < 0)
16294 return err;
16295 err = alc662_auto_create_extra_out(spec,
16296 spec->autocfg.speaker_pins[0],
16297 "Speaker");
16298 if (err < 0)
16299 return err;
16300 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
16301 "Headphone");
16302 if (err < 0)
16303 return err;
16304 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
16305 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016306 return err;
16307
16308 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16309
16310 if (spec->autocfg.dig_out_pin)
16311 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
16312
Takashi Iwai603c4012008-07-30 15:01:44 +020016313 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016314 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016315
16316 spec->num_mux_defs = 1;
16317 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020016318
Takashi Iwaid88897e2008-10-31 15:01:37 +010016319 add_verb(spec, alc662_auto_init_verbs);
Takashi Iwai24fb9172008-09-02 14:48:20 +020016320 if (codec->vendor_id == 0x10ec0663)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016321 add_verb(spec, alc663_auto_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020016322
16323 err = alc_auto_add_mic_boost(codec);
16324 if (err < 0)
16325 return err;
16326
Takashi Iwaie044c392008-10-27 16:56:24 +010016327 store_pin_configs(codec);
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016328 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016329}
16330
16331/* additional initialization for auto-configuration model */
16332static void alc662_auto_init(struct hda_codec *codec)
16333{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016334 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016335 alc662_auto_init_multi_out(codec);
16336 alc662_auto_init_hp_out(codec);
16337 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020016338 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016339 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016340 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016341}
16342
16343static int patch_alc662(struct hda_codec *codec)
16344{
16345 struct alc_spec *spec;
16346 int err, board_config;
16347
16348 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
16349 if (!spec)
16350 return -ENOMEM;
16351
16352 codec->spec = spec;
16353
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020016354 alc_fix_pll_init(codec, 0x20, 0x04, 15);
16355
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016356 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
16357 alc662_models,
16358 alc662_cfg_tbl);
16359 if (board_config < 0) {
16360 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
16361 "trying auto-probe from BIOS...\n");
16362 board_config = ALC662_AUTO;
16363 }
16364
16365 if (board_config == ALC662_AUTO) {
16366 /* automatic parse from the BIOS config */
16367 err = alc662_parse_auto_config(codec);
16368 if (err < 0) {
16369 alc_free(codec);
16370 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020016371 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016372 printk(KERN_INFO
16373 "hda_codec: Cannot set up configuration "
16374 "from BIOS. Using base mode...\n");
16375 board_config = ALC662_3ST_2ch_DIG;
16376 }
16377 }
16378
16379 if (board_config != ALC662_AUTO)
16380 setup_preset(spec, &alc662_presets[board_config]);
16381
Kailang Yang6dda9f42008-05-27 12:05:31 +020016382 if (codec->vendor_id == 0x10ec0663) {
16383 spec->stream_name_analog = "ALC663 Analog";
16384 spec->stream_name_digital = "ALC663 Digital";
Kailang Yang01afd412008-10-15 11:22:09 +020016385 } else if (codec->vendor_id == 0x10ec0272) {
16386 spec->stream_name_analog = "ALC272 Analog";
16387 spec->stream_name_digital = "ALC272 Digital";
Kailang Yang6dda9f42008-05-27 12:05:31 +020016388 } else {
16389 spec->stream_name_analog = "ALC662 Analog";
16390 spec->stream_name_digital = "ALC662 Digital";
16391 }
16392
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016393 spec->stream_analog_playback = &alc662_pcm_analog_playback;
16394 spec->stream_analog_capture = &alc662_pcm_analog_capture;
16395
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016396 spec->stream_digital_playback = &alc662_pcm_digital_playback;
16397 spec->stream_digital_capture = &alc662_pcm_digital_capture;
16398
Takashi Iwaie1406342008-02-11 18:32:32 +010016399 spec->adc_nids = alc662_adc_nids;
16400 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
16401 spec->capsrc_nids = alc662_capsrc_nids;
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010016402 spec->is_mix_capture = 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016403
Takashi Iwaif9e336f2008-10-31 16:37:07 +010016404 if (!spec->cap_mixer)
16405 set_capture_mixer(spec);
16406
Takashi Iwai2134ea42008-01-10 16:53:55 +010016407 spec->vmaster_nid = 0x02;
16408
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016409 codec->patch_ops = alc_patch_ops;
16410 if (board_config == ALC662_AUTO)
16411 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016412#ifdef CONFIG_SND_HDA_POWER_SAVE
16413 if (!spec->loopback.amplist)
16414 spec->loopback.amplist = alc662_loopbacks;
16415#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016416
16417 return 0;
16418}
16419
16420/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070016421 * patch entries
16422 */
16423struct hda_codec_preset snd_hda_preset_realtek[] = {
16424 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010016425 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016426 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020016427 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016428 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020016429 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016430 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016431 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016432 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
16433 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
16434 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020016435 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
16436 .patch = patch_alc883 },
16437 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
16438 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020016439 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016440 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016441 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016442 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Clive Messer669faba2008-09-30 15:49:13 +020016443 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
16444 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Takashi Iwaicb308f92008-04-16 14:13:29 +020016445 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020016446 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010016447 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yanga385a522008-10-15 11:20:21 +020016448 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016449 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yang44426082008-10-15 11:18:05 +020016450 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
16451 .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010016452 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070016453 {} /* terminator */
16454};