blob: 538d85440a306038aae25e47e0fa808aa0f2a5ec [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,
Kailang Yangdf694da2005-12-05 19:42:22 +0100106 ALC262_AUTO,
107 ALC262_MODEL_LAST /* last tag */
108};
109
Kailang Yanga361d842007-06-05 12:30:55 +0200110/* ALC268 models */
111enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200112 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200113 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200114 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200115 ALC268_ACER,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200116 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100117 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100118 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100119#ifdef CONFIG_SND_DEBUG
120 ALC268_TEST,
121#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200122 ALC268_AUTO,
123 ALC268_MODEL_LAST /* last tag */
124};
125
Kailang Yangf6a92242007-12-13 16:52:54 +0100126/* ALC269 models */
127enum {
128 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200129 ALC269_QUANTA_FL1,
Kailang Yangf53281e2008-07-18 12:36:43 +0200130 ALC269_ASUS_EEEPC_P703,
131 ALC269_ASUS_EEEPC_P901,
Kailang Yangf6a92242007-12-13 16:52:54 +0100132 ALC269_AUTO,
133 ALC269_MODEL_LAST /* last tag */
134};
135
Kailang Yangdf694da2005-12-05 19:42:22 +0100136/* ALC861 models */
137enum {
138 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200139 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100140 ALC861_3ST_DIG,
141 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200142 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200143 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200144 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100145 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100146 ALC861_AUTO,
147 ALC861_MODEL_LAST,
148};
149
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100150/* ALC861-VD models */
151enum {
152 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200153 ALC660VD_3ST_DIG,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100154 ALC861VD_3ST,
155 ALC861VD_3ST_DIG,
156 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200157 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200158 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200159 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160 ALC861VD_AUTO,
161 ALC861VD_MODEL_LAST,
162};
163
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200164/* ALC662 models */
165enum {
166 ALC662_3ST_2ch_DIG,
167 ALC662_3ST_6ch_DIG,
168 ALC662_3ST_6ch,
169 ALC662_5ST_DIG,
170 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200171 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100172 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200173 ALC663_ASUS_M51VA,
174 ALC663_ASUS_G71V,
175 ALC663_ASUS_H13,
176 ALC663_ASUS_G50V,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200177 ALC662_AUTO,
178 ALC662_MODEL_LAST,
179};
180
Kailang Yangdf694da2005-12-05 19:42:22 +0100181/* ALC882 models */
182enum {
183 ALC882_3ST_DIG,
184 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200185 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200186 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200187 ALC882_TARGA,
188 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200189 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100190 ALC885_MACPRO,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200191 ALC885_MBP3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200192 ALC885_IMAC24,
Kailang Yang272a5272007-05-14 11:00:38 +0200193 ALC882_AUTO,
Kailang Yangdf694da2005-12-05 19:42:22 +0100194 ALC882_MODEL_LAST,
195};
196
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200197/* ALC883 models */
198enum {
199 ALC883_3ST_2ch_DIG,
200 ALC883_3ST_6ch_DIG,
201 ALC883_3ST_6ch,
202 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200203 ALC883_TARGA_DIG,
204 ALC883_TARGA_2ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200205 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200206 ALC883_ACER_ASPIRE,
Tobin Davisc07584c2006-10-13 12:32:16 +0200207 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200208 ALC883_MEDION_MD2,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100209 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200210 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200211 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200212 ALC888_LENOVO_MS7195_DIG,
Kailang Yangea1fb292008-08-26 12:58:38 +0200213 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200214 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100215 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100216 ALC883_MITAC,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100217 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100218 ALC883_FUJITSU_PI2515,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200219 ALC883_3ST_6ch_INTEL,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220 ALC883_AUTO,
221 ALC883_MODEL_LAST,
222};
223
Kailang Yangdf694da2005-12-05 19:42:22 +0100224/* for GPIO Poll */
225#define GPIO_MASK 0x03
226
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227struct alc_spec {
228 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100229 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 unsigned int num_mixers;
231
Kailang Yangdf694da2005-12-05 19:42:22 +0100232 const struct hda_verb *init_verbs[5]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200233 * don't forget NULL
234 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200235 */
236 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
Takashi Iwai16ded522005-06-10 19:58:24 +0200238 char *stream_name_analog; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 struct hda_pcm_stream *stream_analog_playback;
240 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100241 struct hda_pcm_stream *stream_analog_alt_playback;
242 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200244 char *stream_name_digital; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 struct hda_pcm_stream *stream_digital_playback;
246 struct hda_pcm_stream *stream_digital_capture;
247
248 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200249 struct hda_multi_out multiout; /* playback set-up
250 * max_channels, dacs must be set
251 * dig_out_nid and hp_nid are optional
252 */
Takashi Iwai63300792008-01-24 15:31:36 +0100253 hda_nid_t alt_dac_nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
255 /* capture */
256 unsigned int num_adc_nids;
257 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100258 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200259 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
261 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200262 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 const struct hda_input_mux *input_mux;
264 unsigned int cur_mux[3];
265
266 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100267 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200269 int need_dac_fix;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
271 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100272 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200273
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200274 /* dynamic controls, init_verbs and input_mux */
275 struct auto_pin_cfg autocfg;
276 unsigned int num_kctl_alloc, num_kctl_used;
Takashi Iwaic8b6bf92005-11-17 14:57:47 +0100277 struct snd_kcontrol_new *kctl_alloc;
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200278 struct hda_input_mux private_imux;
Takashi Iwai41923e42007-10-22 17:20:10 +0200279 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100280
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100281 /* hooks */
282 void (*init_hook)(struct hda_codec *codec);
283 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
284
Takashi Iwai834be882006-03-01 14:16:17 +0100285 /* for pin sensing */
286 unsigned int sense_updated: 1;
287 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100288 unsigned int master_sw: 1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200289
Takashi Iwai2134ea42008-01-10 16:53:55 +0100290 /* for virtual master */
291 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200292#ifdef CONFIG_SND_HDA_POWER_SAVE
293 struct hda_loopback_check loopback;
294#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200295
296 /* for PLL fix */
297 hda_nid_t pll_nid;
298 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100299};
300
301/*
302 * configuration template - to be copied to the spec instance
303 */
304struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200305 struct snd_kcontrol_new *mixers[5]; /* should be identical size
306 * with spec
307 */
Kailang Yangdf694da2005-12-05 19:42:22 +0100308 const struct hda_verb *init_verbs[5];
309 unsigned int num_dacs;
310 hda_nid_t *dac_nids;
311 hda_nid_t dig_out_nid; /* optional */
312 hda_nid_t hp_nid; /* optional */
313 unsigned int num_adc_nids;
314 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100315 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100316 hda_nid_t dig_in_nid;
317 unsigned int num_channel_mode;
318 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200319 int need_dac_fix;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200320 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100321 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100322 void (*unsol_event)(struct hda_codec *, unsigned int);
323 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200324#ifdef CONFIG_SND_HDA_POWER_SAVE
325 struct hda_amp_list *loopbacks;
326#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327};
328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
330/*
331 * input MUX handling
332 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200333static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
334 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335{
336 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
337 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200338 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
339 if (mux_idx >= spec->num_mux_defs)
340 mux_idx = 0;
341 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342}
343
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200344static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
345 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346{
347 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
348 struct alc_spec *spec = codec->spec;
349 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
350
351 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
352 return 0;
353}
354
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200355static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
356 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357{
358 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
359 struct alc_spec *spec = codec->spec;
360 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200361 unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100362 hda_nid_t nid = spec->capsrc_nids ?
363 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200364 return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
Takashi Iwaie1406342008-02-11 18:32:32 +0100365 nid, &spec->cur_mux[adc_idx]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366}
367
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200368
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369/*
370 * channel mode setting
371 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200372static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
373 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374{
375 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
376 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100377 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
378 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379}
380
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200381static int alc_ch_mode_get(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 Iwaid2a6d7d2005-11-17 11:06:29 +0100386 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200387 spec->num_channel_mode,
388 spec->multiout.max_channels);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389}
390
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200391static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
392 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393{
394 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
395 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200396 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
397 spec->num_channel_mode,
398 &spec->multiout.max_channels);
Takashi Iwaibd2033f2006-10-10 19:49:31 +0200399 if (err >= 0 && spec->need_dac_fix)
Takashi Iwai4e195a72006-07-28 14:47:34 +0200400 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
401 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402}
403
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100405 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200406 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100407 * being part of a format specifier. Maximum allowed length of a value is
408 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100409 *
410 * Note: some retasking pin complexes seem to ignore requests for input
411 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
412 * are requested. Therefore order this list so that this behaviour will not
413 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200414 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
415 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200416 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100417static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100418 "Mic 50pc bias", "Mic 80pc bias",
419 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100420};
421static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100422 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100423};
424/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200425 * in the pin being assumed to be exclusively an input or an output pin. In
426 * addition, "input" pins may or may not process the mic bias option
427 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
428 * accept requests for bias as of chip versions up to March 2006) and/or
429 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100430 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200431#define ALC_PIN_DIR_IN 0x00
432#define ALC_PIN_DIR_OUT 0x01
433#define ALC_PIN_DIR_INOUT 0x02
434#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
435#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100436
Kailang Yangea1fb292008-08-26 12:58:38 +0200437/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100438 * For each direction the minimum and maximum values are given.
439 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200440static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100441 { 0, 2 }, /* ALC_PIN_DIR_IN */
442 { 3, 4 }, /* ALC_PIN_DIR_OUT */
443 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200444 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
445 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100446};
447#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
448#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
449#define alc_pin_mode_n_items(_dir) \
450 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
451
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200452static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
453 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200454{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100455 unsigned int item_num = uinfo->value.enumerated.item;
456 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
457
458 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200459 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100460 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
461
462 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
463 item_num = alc_pin_mode_min(dir);
464 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200465 return 0;
466}
467
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200470{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100471 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100474 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200475 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200476 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
477 AC_VERB_GET_PIN_WIDGET_CONTROL,
478 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200479
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100480 /* Find enumerated value for current pinctl setting */
481 i = alc_pin_mode_min(dir);
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200482 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100483 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200484 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100485 return 0;
486}
487
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200488static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
489 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100490{
491 signed int change;
492 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
493 hda_nid_t nid = kcontrol->private_value & 0xffff;
494 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
495 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200496 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
497 AC_VERB_GET_PIN_WIDGET_CONTROL,
498 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100499
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200500 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100501 val = alc_pin_mode_min(dir);
502
503 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100504 if (change) {
505 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200506 snd_hda_codec_write_cache(codec, nid, 0,
507 AC_VERB_SET_PIN_WIDGET_CONTROL,
508 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100509
Kailang Yangea1fb292008-08-26 12:58:38 +0200510 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100511 * for the requested pin mode. Enum values of 2 or less are
512 * input modes.
513 *
514 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200515 * reduces noise slightly (particularly on input) so we'll
516 * do it. However, having both input and output buffers
517 * enabled simultaneously doesn't seem to be problematic if
518 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100519 */
520 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200521 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
522 HDA_AMP_MUTE, HDA_AMP_MUTE);
523 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
524 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100525 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200526 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
527 HDA_AMP_MUTE, HDA_AMP_MUTE);
528 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
529 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100530 }
531 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200532 return change;
533}
534
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100535#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200536 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100537 .info = alc_pin_mode_info, \
538 .get = alc_pin_mode_get, \
539 .put = alc_pin_mode_put, \
540 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100541
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100542/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
543 * together using a mask with more than one bit set. This control is
544 * currently used only by the ALC260 test model. At this stage they are not
545 * needed for any "production" models.
546 */
547#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200548#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200549
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200550static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
551 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100552{
553 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
554 hda_nid_t nid = kcontrol->private_value & 0xffff;
555 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
556 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200557 unsigned int val = snd_hda_codec_read(codec, nid, 0,
558 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100559
560 *valp = (val & mask) != 0;
561 return 0;
562}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200563static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
564 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100565{
566 signed int change;
567 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
568 hda_nid_t nid = kcontrol->private_value & 0xffff;
569 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
570 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200571 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
572 AC_VERB_GET_GPIO_DATA,
573 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100574
575 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200576 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
577 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100578 gpio_data &= ~mask;
579 else
580 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200581 snd_hda_codec_write_cache(codec, nid, 0,
582 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100583
584 return change;
585}
586#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
587 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
588 .info = alc_gpio_data_info, \
589 .get = alc_gpio_data_get, \
590 .put = alc_gpio_data_put, \
591 .private_value = nid | (mask<<16) }
592#endif /* CONFIG_SND_DEBUG */
593
Jonathan Woithe92621f12006-02-28 11:47:47 +0100594/* A switch control to allow the enabling of the digital IO pins on the
595 * ALC260. This is incredibly simplistic; the intention of this control is
596 * to provide something in the test model allowing digital outputs to be
597 * identified if present. If models are found which can utilise these
598 * outputs a more complete mixer control can be devised for those models if
599 * necessary.
600 */
601#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200602#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200603
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200604static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
605 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100606{
607 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
608 hda_nid_t nid = kcontrol->private_value & 0xffff;
609 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
610 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200611 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100612 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100613
614 *valp = (val & mask) != 0;
615 return 0;
616}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200617static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
618 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100619{
620 signed int change;
621 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
622 hda_nid_t nid = kcontrol->private_value & 0xffff;
623 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
624 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200625 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100626 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200627 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100628
629 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200630 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100631 if (val==0)
632 ctrl_data &= ~mask;
633 else
634 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200635 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
636 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100637
638 return change;
639}
640#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
641 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
642 .info = alc_spdif_ctrl_info, \
643 .get = alc_spdif_ctrl_get, \
644 .put = alc_spdif_ctrl_put, \
645 .private_value = nid | (mask<<16) }
646#endif /* CONFIG_SND_DEBUG */
647
Jonathan Woithef8225f62008-01-08 12:16:54 +0100648/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
649 * Again, this is only used in the ALC26x test models to help identify when
650 * the EAPD line must be asserted for features to work.
651 */
652#ifdef CONFIG_SND_DEBUG
653#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
654
655static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
656 struct snd_ctl_elem_value *ucontrol)
657{
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;
662 unsigned int val = snd_hda_codec_read(codec, nid, 0,
663 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
664
665 *valp = (val & mask) != 0;
666 return 0;
667}
668
669static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
670 struct snd_ctl_elem_value *ucontrol)
671{
672 int change;
673 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
674 hda_nid_t nid = kcontrol->private_value & 0xffff;
675 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
676 long val = *ucontrol->value.integer.value;
677 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
678 AC_VERB_GET_EAPD_BTLENABLE,
679 0x00);
680
681 /* Set/unset the masked control bit(s) as needed */
682 change = (!val ? 0 : mask) != (ctrl_data & mask);
683 if (!val)
684 ctrl_data &= ~mask;
685 else
686 ctrl_data |= mask;
687 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
688 ctrl_data);
689
690 return change;
691}
692
693#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
694 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
695 .info = alc_eapd_ctrl_info, \
696 .get = alc_eapd_ctrl_get, \
697 .put = alc_eapd_ctrl_put, \
698 .private_value = nid | (mask<<16) }
699#endif /* CONFIG_SND_DEBUG */
700
Kailang Yangdf694da2005-12-05 19:42:22 +0100701/*
702 * set up from the preset table
703 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200704static void setup_preset(struct alc_spec *spec,
705 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100706{
707 int i;
708
709 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
710 spec->mixers[spec->num_mixers++] = preset->mixers[i];
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200711 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
712 i++)
713 spec->init_verbs[spec->num_init_verbs++] =
714 preset->init_verbs[i];
Kailang Yangea1fb292008-08-26 12:58:38 +0200715
Kailang Yangdf694da2005-12-05 19:42:22 +0100716 spec->channel_mode = preset->channel_mode;
717 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200718 spec->need_dac_fix = preset->need_dac_fix;
Kailang Yangdf694da2005-12-05 19:42:22 +0100719
720 spec->multiout.max_channels = spec->channel_mode[0].channels;
721
722 spec->multiout.num_dacs = preset->num_dacs;
723 spec->multiout.dac_nids = preset->dac_nids;
724 spec->multiout.dig_out_nid = preset->dig_out_nid;
725 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200726
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200727 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200728 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200729 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100730 spec->input_mux = preset->input_mux;
731
732 spec->num_adc_nids = preset->num_adc_nids;
733 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100734 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100735 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100736
737 spec->unsol_event = preset->unsol_event;
738 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200739#ifdef CONFIG_SND_HDA_POWER_SAVE
740 spec->loopback.amplist = preset->loopbacks;
741#endif
Kailang Yangdf694da2005-12-05 19:42:22 +0100742}
743
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200744/* Enable GPIO mask and set output */
745static struct hda_verb alc_gpio1_init_verbs[] = {
746 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
747 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
748 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
749 { }
750};
751
752static struct hda_verb alc_gpio2_init_verbs[] = {
753 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
754 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
755 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
756 { }
757};
758
Kailang Yangbdd148a2007-05-08 15:19:08 +0200759static struct hda_verb alc_gpio3_init_verbs[] = {
760 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
761 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
762 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
763 { }
764};
765
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200766/*
767 * Fix hardware PLL issue
768 * On some codecs, the analog PLL gating control must be off while
769 * the default value is 1.
770 */
771static void alc_fix_pll(struct hda_codec *codec)
772{
773 struct alc_spec *spec = codec->spec;
774 unsigned int val;
775
776 if (!spec->pll_nid)
777 return;
778 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
779 spec->pll_coef_idx);
780 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
781 AC_VERB_GET_PROC_COEF, 0);
782 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
783 spec->pll_coef_idx);
784 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
785 val & ~(1 << spec->pll_coef_bit));
786}
787
788static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
789 unsigned int coef_idx, unsigned int coef_bit)
790{
791 struct alc_spec *spec = codec->spec;
792 spec->pll_nid = nid;
793 spec->pll_coef_idx = coef_idx;
794 spec->pll_coef_bit = coef_bit;
795 alc_fix_pll(codec);
796}
797
Kailang Yangc9b58002007-10-16 14:30:01 +0200798static void alc_sku_automute(struct hda_codec *codec)
799{
800 struct alc_spec *spec = codec->spec;
Kailang Yangc9b58002007-10-16 14:30:01 +0200801 unsigned int present;
802 unsigned int hp_nid = spec->autocfg.hp_pins[0];
803 unsigned int sp_nid = spec->autocfg.speaker_pins[0];
804
805 /* need to execute and sync at first */
806 snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
807 present = snd_hda_codec_read(codec, hp_nid, 0,
808 AC_VERB_GET_PIN_SENSE, 0);
809 spec->jack_present = (present & 0x80000000) != 0;
Takashi Iwaif6c7e542008-02-12 18:32:23 +0100810 snd_hda_codec_write(codec, sp_nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
811 spec->jack_present ? 0 : PIN_OUT);
Kailang Yangc9b58002007-10-16 14:30:01 +0200812}
813
814/* unsolicited event for HP jack sensing */
815static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
816{
817 if (codec->vendor_id == 0x10ec0880)
818 res >>= 28;
819 else
820 res >>= 26;
821 if (res != ALC880_HP_EVENT)
822 return;
823
824 alc_sku_automute(codec);
825}
826
Kailang Yangf9423e72008-05-27 12:32:25 +0200827/* additional initialization for ALC888 variants */
828static void alc888_coef_init(struct hda_codec *codec)
829{
830 unsigned int tmp;
831
832 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
833 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
834 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
835 if ((tmp & 0xf0) == 2)
836 /* alc888S-VC */
837 snd_hda_codec_read(codec, 0x20, 0,
838 AC_VERB_SET_PROC_COEF, 0x830);
839 else
840 /* alc888-VB */
841 snd_hda_codec_read(codec, 0x20, 0,
842 AC_VERB_SET_PROC_COEF, 0x3030);
843}
844
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200845/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
846 * 31 ~ 16 : Manufacture ID
847 * 15 ~ 8 : SKU ID
848 * 7 ~ 0 : Assembly ID
849 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
850 */
851static void alc_subsystem_id(struct hda_codec *codec,
852 unsigned int porta, unsigned int porte,
853 unsigned int portd)
854{
Kailang Yangc9b58002007-10-16 14:30:01 +0200855 unsigned int ass, tmp, i;
856 unsigned nid;
857 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200858
Kailang Yangc9b58002007-10-16 14:30:01 +0200859 ass = codec->subsystem_id & 0xffff;
860 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
861 goto do_sku;
862
Kailang Yangea1fb292008-08-26 12:58:38 +0200863 /*
Kailang Yangc9b58002007-10-16 14:30:01 +0200864 * 31~30 : port conetcivity
865 * 29~21 : reserve
866 * 20 : PCBEEP input
867 * 19~16 : Check sum (15:1)
868 * 15~1 : Custom
869 * 0 : override
870 */
871 nid = 0x1d;
872 if (codec->vendor_id == 0x10ec0260)
873 nid = 0x17;
874 ass = snd_hda_codec_read(codec, nid, 0,
875 AC_VERB_GET_CONFIG_DEFAULT, 0);
876 if (!(ass & 1) && !(ass & 0x100000))
877 return;
878 if ((ass >> 30) != 1) /* no physical connection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200879 return;
880
Kailang Yangc9b58002007-10-16 14:30:01 +0200881 /* check sum */
882 tmp = 0;
883 for (i = 1; i < 16; i++) {
Kailang Yang8c427222008-01-10 13:03:59 +0100884 if ((ass >> i) & 1)
Kailang Yangc9b58002007-10-16 14:30:01 +0200885 tmp++;
886 }
887 if (((ass >> 16) & 0xf) != tmp)
888 return;
889do_sku:
890 /*
891 * 0 : override
892 * 1 : Swap Jack
893 * 2 : 0 --> Desktop, 1 --> Laptop
894 * 3~5 : External Amplifier control
895 * 7~6 : Reserved
896 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200897 tmp = (ass & 0x38) >> 3; /* external Amp control */
898 switch (tmp) {
899 case 1:
900 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
901 break;
902 case 3:
903 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
904 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200905 case 7:
906 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
907 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200908 case 5: /* set EAPD output high */
Kailang Yangbdd148a2007-05-08 15:19:08 +0200909 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +0200910 case 0x10ec0260:
911 snd_hda_codec_write(codec, 0x0f, 0,
912 AC_VERB_SET_EAPD_BTLENABLE, 2);
913 snd_hda_codec_write(codec, 0x10, 0,
914 AC_VERB_SET_EAPD_BTLENABLE, 2);
915 break;
916 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200917 case 0x10ec0267:
918 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +0200919 case 0x10ec0269:
Kailang Yangf9423e72008-05-27 12:32:25 +0200920 case 0x10ec0660:
921 case 0x10ec0662:
922 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +0200923 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200924 case 0x10ec0889:
Kailang Yangbdd148a2007-05-08 15:19:08 +0200925 snd_hda_codec_write(codec, 0x14, 0,
926 AC_VERB_SET_EAPD_BTLENABLE, 2);
927 snd_hda_codec_write(codec, 0x15, 0,
928 AC_VERB_SET_EAPD_BTLENABLE, 2);
Kailang Yangc9b58002007-10-16 14:30:01 +0200929 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +0200930 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200931 switch (codec->vendor_id) {
932 case 0x10ec0260:
933 snd_hda_codec_write(codec, 0x1a, 0,
934 AC_VERB_SET_COEF_INDEX, 7);
935 tmp = snd_hda_codec_read(codec, 0x1a, 0,
936 AC_VERB_GET_PROC_COEF, 0);
937 snd_hda_codec_write(codec, 0x1a, 0,
938 AC_VERB_SET_COEF_INDEX, 7);
939 snd_hda_codec_write(codec, 0x1a, 0,
940 AC_VERB_SET_PROC_COEF,
941 tmp | 0x2010);
942 break;
943 case 0x10ec0262:
944 case 0x10ec0880:
945 case 0x10ec0882:
946 case 0x10ec0883:
947 case 0x10ec0885:
Takashi Iwai20a3a052008-05-23 17:52:53 +0200948 case 0x10ec0889:
Kailang Yangc9b58002007-10-16 14:30:01 +0200949 snd_hda_codec_write(codec, 0x20, 0,
950 AC_VERB_SET_COEF_INDEX, 7);
951 tmp = snd_hda_codec_read(codec, 0x20, 0,
952 AC_VERB_GET_PROC_COEF, 0);
953 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200954 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200955 snd_hda_codec_write(codec, 0x20, 0,
956 AC_VERB_SET_PROC_COEF,
957 tmp | 0x2010);
958 break;
Kailang Yangf9423e72008-05-27 12:32:25 +0200959 case 0x10ec0888:
Takashi Iwai1082c742008-08-22 15:24:22 +0200960 /*alc888_coef_init(codec);*/ /* called in alc_init() */
Kailang Yangf9423e72008-05-27 12:32:25 +0200961 break;
Kailang Yangc9b58002007-10-16 14:30:01 +0200962 case 0x10ec0267:
963 case 0x10ec0268:
964 snd_hda_codec_write(codec, 0x20, 0,
965 AC_VERB_SET_COEF_INDEX, 7);
966 tmp = snd_hda_codec_read(codec, 0x20, 0,
967 AC_VERB_GET_PROC_COEF, 0);
968 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +0200969 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +0200970 snd_hda_codec_write(codec, 0x20, 0,
971 AC_VERB_SET_PROC_COEF,
972 tmp | 0x3000);
973 break;
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200974 }
Kailang Yangc9b58002007-10-16 14:30:01 +0200975 default:
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200976 break;
977 }
Kailang Yangea1fb292008-08-26 12:58:38 +0200978
Kailang Yang8c427222008-01-10 13:03:59 +0100979 /* is laptop or Desktop and enable the function "Mute internal speaker
Kailang Yangc9b58002007-10-16 14:30:01 +0200980 * when the external headphone out jack is plugged"
981 */
Kailang Yang8c427222008-01-10 13:03:59 +0100982 if (!(ass & 0x8000))
Kailang Yangc9b58002007-10-16 14:30:01 +0200983 return;
984 /*
985 * 10~8 : Jack location
986 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
987 * 14~13: Resvered
988 * 15 : 1 --> enable the function "Mute internal speaker
989 * when the external headphone out jack is plugged"
990 */
991 if (!spec->autocfg.speaker_pins[0]) {
Kailang Yang8c427222008-01-10 13:03:59 +0100992 if (spec->autocfg.line_out_pins[0])
Kailang Yangc9b58002007-10-16 14:30:01 +0200993 spec->autocfg.speaker_pins[0] =
Kailang Yang8c427222008-01-10 13:03:59 +0100994 spec->autocfg.line_out_pins[0];
Kailang Yangc9b58002007-10-16 14:30:01 +0200995 else
996 return;
997 }
998
999 if (!spec->autocfg.hp_pins[0]) {
1000 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1001 if (tmp == 0)
1002 spec->autocfg.hp_pins[0] = porta;
1003 else if (tmp == 1)
1004 spec->autocfg.hp_pins[0] = porte;
1005 else if (tmp == 2)
1006 spec->autocfg.hp_pins[0] = portd;
1007 else
1008 return;
1009 }
1010
1011 snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
1012 AC_VERB_SET_UNSOLICITED_ENABLE,
1013 AC_USRSP_EN | ALC880_HP_EVENT);
Kailang Yangea1fb292008-08-26 12:58:38 +02001014
Kailang Yangc9b58002007-10-16 14:30:01 +02001015 spec->unsol_event = alc_sku_unsol_event;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001016}
1017
Takashi Iwai41e41f12005-06-08 14:48:49 +02001018/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02001019 * Fix-up pin default configurations
1020 */
1021
1022struct alc_pincfg {
1023 hda_nid_t nid;
1024 u32 val;
1025};
1026
1027static void alc_fix_pincfg(struct hda_codec *codec,
1028 const struct snd_pci_quirk *quirk,
1029 const struct alc_pincfg **pinfix)
1030{
1031 const struct alc_pincfg *cfg;
1032
1033 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1034 if (!quirk)
1035 return;
1036
1037 cfg = pinfix[quirk->value];
1038 for (; cfg->nid; cfg++) {
1039 int i;
1040 u32 val = cfg->val;
1041 for (i = 0; i < 4; i++) {
1042 snd_hda_codec_write(codec, cfg->nid, 0,
1043 AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
1044 val & 0xff);
1045 val >>= 8;
1046 }
1047 }
1048}
1049
1050/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001051 * ALC880 3-stack model
1052 *
1053 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001054 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
1055 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 */
1057
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001058static hda_nid_t alc880_dac_nids[4] = {
1059 /* front, rear, clfe, rear_surr */
1060 0x02, 0x05, 0x04, 0x03
1061};
1062
1063static hda_nid_t alc880_adc_nids[3] = {
1064 /* ADC0-2 */
1065 0x07, 0x08, 0x09,
1066};
1067
1068/* The datasheet says the node 0x07 is connected from inputs,
1069 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01001070 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001072static hda_nid_t alc880_adc_nids_alt[2] = {
1073 /* ADC1-2 */
1074 0x08, 0x09,
1075};
1076
1077#define ALC880_DIGOUT_NID 0x06
1078#define ALC880_DIGIN_NID 0x0a
1079
1080static struct hda_input_mux alc880_capture_source = {
1081 .num_items = 4,
1082 .items = {
1083 { "Mic", 0x0 },
1084 { "Front Mic", 0x3 },
1085 { "Line", 0x2 },
1086 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001088};
1089
1090/* channel source setting (2/6 channel selection for 3-stack) */
1091/* 2ch mode */
1092static struct hda_verb alc880_threestack_ch2_init[] = {
1093 /* set line-in to input, mute it */
1094 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1095 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1096 /* set mic-in to input vref 80%, mute it */
1097 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1098 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099 { } /* end */
1100};
1101
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001102/* 6ch mode */
1103static struct hda_verb alc880_threestack_ch6_init[] = {
1104 /* set line-in to output, unmute it */
1105 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1106 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1107 /* set mic-in to output, unmute it */
1108 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1109 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1110 { } /* end */
1111};
1112
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001113static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001114 { 2, alc880_threestack_ch2_init },
1115 { 6, alc880_threestack_ch6_init },
1116};
1117
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001118static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001119 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001120 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001121 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001122 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02001123 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1124 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001125 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1126 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1128 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1129 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1130 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1131 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1132 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1133 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
1134 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
1135 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1136 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001137 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001138 {
1139 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1140 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001141 .info = alc_ch_mode_info,
1142 .get = alc_ch_mode_get,
1143 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001144 },
1145 { } /* end */
1146};
1147
1148/* capture mixer elements */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001149static struct snd_kcontrol_new alc880_capture_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001150 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
1151 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
1152 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
1153 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
1154 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
1155 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
1156 {
1157 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1158 /* The multiple "Capture Source" controls confuse alsamixer
1159 * So call somewhat different..
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001160 */
1161 /* .name = "Capture Source", */
1162 .name = "Input Source",
1163 .count = 3,
1164 .info = alc_mux_enum_info,
1165 .get = alc_mux_enum_get,
1166 .put = alc_mux_enum_put,
1167 },
1168 { } /* end */
1169};
1170
1171/* capture mixer elements (in case NID 0x07 not available) */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001172static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001173 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1174 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1175 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
1176 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 {
1178 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1179 /* The multiple "Capture Source" controls confuse alsamixer
1180 * So call somewhat different..
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 */
1182 /* .name = "Capture Source", */
1183 .name = "Input Source",
1184 .count = 2,
1185 .info = alc_mux_enum_info,
1186 .get = alc_mux_enum_get,
1187 .put = alc_mux_enum_put,
1188 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001189 { } /* end */
1190};
1191
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001192
1193
1194/*
1195 * ALC880 5-stack model
1196 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001197 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
1198 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001199 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
1200 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
1201 */
1202
1203/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001204static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001205 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001206 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207 { } /* end */
1208};
1209
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001210/* channel source setting (6/8 channel selection for 5-stack) */
1211/* 6ch mode */
1212static struct hda_verb alc880_fivestack_ch6_init[] = {
1213 /* set line-in to input, mute it */
1214 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1215 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001216 { } /* end */
1217};
1218
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001219/* 8ch mode */
1220static struct hda_verb alc880_fivestack_ch8_init[] = {
1221 /* set line-in to output, unmute it */
1222 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1223 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1224 { } /* end */
1225};
1226
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001227static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001228 { 6, alc880_fivestack_ch6_init },
1229 { 8, alc880_fivestack_ch8_init },
1230};
1231
1232
1233/*
1234 * ALC880 6-stack model
1235 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001236 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
1237 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001238 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
1239 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
1240 */
1241
1242static hda_nid_t alc880_6st_dac_nids[4] = {
1243 /* front, rear, clfe, rear_surr */
1244 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001245};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001246
1247static struct hda_input_mux alc880_6stack_capture_source = {
1248 .num_items = 4,
1249 .items = {
1250 { "Mic", 0x0 },
1251 { "Front Mic", 0x1 },
1252 { "Line", 0x2 },
1253 { "CD", 0x4 },
1254 },
1255};
1256
1257/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001258static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001259 { 8, NULL },
1260};
1261
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001262static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001263 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001264 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001265 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001266 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001267 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1268 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001269 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1270 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001271 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001272 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001273 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1274 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1275 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1276 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1277 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1278 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1279 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1280 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1281 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1282 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001283 {
1284 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1285 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001286 .info = alc_ch_mode_info,
1287 .get = alc_ch_mode_get,
1288 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001289 },
1290 { } /* end */
1291};
1292
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001293
1294/*
1295 * ALC880 W810 model
1296 *
1297 * W810 has rear IO for:
1298 * Front (DAC 02)
1299 * Surround (DAC 03)
1300 * Center/LFE (DAC 04)
1301 * Digital out (06)
1302 *
1303 * The system also has a pair of internal speakers, and a headphone jack.
1304 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02001305 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001306 * There is a variable resistor to control the speaker or headphone
1307 * volume. This is a hardware-only device without a software API.
1308 *
1309 * Plugging headphones in will disable the internal speakers. This is
1310 * implemented in hardware, not via the driver using jack sense. In
1311 * a similar fashion, plugging into the rear socket marked "front" will
1312 * disable both the speakers and headphones.
1313 *
1314 * For input, there's a microphone jack, and an "audio in" jack.
1315 * These may not do anything useful with this driver yet, because I
1316 * haven't setup any initialization verbs for these yet...
1317 */
1318
1319static hda_nid_t alc880_w810_dac_nids[3] = {
1320 /* front, rear/surround, clfe */
1321 0x02, 0x03, 0x04
1322};
1323
1324/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001325static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001326 { 6, NULL }
1327};
1328
1329/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001330static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001331 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001332 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001333 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001334 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001335 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1336 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001337 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1338 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001339 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1340 { } /* end */
1341};
1342
1343
1344/*
1345 * Z710V model
1346 *
1347 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001348 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
1349 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001350 */
1351
1352static hda_nid_t alc880_z71v_dac_nids[1] = {
1353 0x02
1354};
1355#define ALC880_Z71V_HP_DAC 0x03
1356
1357/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01001358static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001359 { 2, NULL }
1360};
1361
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001362static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001363 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001364 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001365 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001366 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001367 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1368 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1370 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1371 { } /* end */
1372};
1373
1374
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001375/*
1376 * ALC880 F1734 model
1377 *
1378 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
1379 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
1380 */
1381
1382static hda_nid_t alc880_f1734_dac_nids[1] = {
1383 0x03
1384};
1385#define ALC880_F1734_HP_DAC 0x02
1386
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001387static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001388 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001389 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01001390 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1391 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001392 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1393 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01001394 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1395 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001396 { } /* end */
1397};
1398
Takashi Iwai937b4162008-02-11 14:52:36 +01001399static struct hda_input_mux alc880_f1734_capture_source = {
1400 .num_items = 2,
1401 .items = {
1402 { "Mic", 0x1 },
1403 { "CD", 0x4 },
1404 },
1405};
1406
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001407
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001408/*
1409 * ALC880 ASUS model
1410 *
1411 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1412 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1413 * Mic = 0x18, Line = 0x1a
1414 */
1415
1416#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
1417#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
1418
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001419static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001420 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001421 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001422 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001423 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001424 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1425 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01001426 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1427 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001428 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1429 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1430 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1431 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1432 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1433 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001434 {
1435 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1436 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01001437 .info = alc_ch_mode_info,
1438 .get = alc_ch_mode_get,
1439 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02001440 },
1441 { } /* end */
1442};
1443
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001444/*
1445 * ALC880 ASUS W1V model
1446 *
1447 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
1448 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
1449 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
1450 */
1451
1452/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001453static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02001454 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
1455 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02001456 { } /* end */
1457};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001458
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001459/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01001460static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02001461 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1462 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1463 { } /* end */
1464};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001465
Kailang Yangdf694da2005-12-05 19:42:22 +01001466/* TCL S700 */
1467static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
1468 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1469 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
1470 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
1471 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
1472 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
1473 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
1474 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
1475 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
1476 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
1477 {
1478 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1479 /* The multiple "Capture Source" controls confuse alsamixer
1480 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01001481 */
1482 /* .name = "Capture Source", */
1483 .name = "Input Source",
1484 .count = 1,
1485 .info = alc_mux_enum_info,
1486 .get = alc_mux_enum_get,
1487 .put = alc_mux_enum_put,
1488 },
1489 { } /* end */
1490};
1491
Kailang Yangccc656c2006-10-17 12:32:26 +02001492/* Uniwill */
1493static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001494 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1495 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1496 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1497 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001498 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
1499 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
1500 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
1501 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
1502 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1503 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
1505 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
1506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1507 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1508 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1509 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1510 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
1511 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
1512 {
1513 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1514 .name = "Channel Mode",
1515 .info = alc_ch_mode_info,
1516 .get = alc_ch_mode_get,
1517 .put = alc_ch_mode_put,
1518 },
1519 { } /* end */
1520};
1521
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001522static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
1523 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1524 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1525 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1526 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
1527 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
1528 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
1529 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1530 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1531 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
1532 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
1533 { } /* end */
1534};
1535
Kailang Yangccc656c2006-10-17 12:32:26 +02001536static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01001537 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
1538 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
1539 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
1540 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02001541 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
1542 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
1543 { } /* end */
1544};
1545
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01001547 * virtual master controls
1548 */
1549
1550/*
1551 * slave controls for virtual master
1552 */
1553static const char *alc_slave_vols[] = {
1554 "Front Playback Volume",
1555 "Surround Playback Volume",
1556 "Center Playback Volume",
1557 "LFE Playback Volume",
1558 "Side Playback Volume",
1559 "Headphone Playback Volume",
1560 "Speaker Playback Volume",
1561 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001562 "Line-Out Playback Volume",
1563 NULL,
1564};
1565
1566static const char *alc_slave_sws[] = {
1567 "Front Playback Switch",
1568 "Surround Playback Switch",
1569 "Center Playback Switch",
1570 "LFE Playback Switch",
1571 "Side Playback Switch",
1572 "Headphone Playback Switch",
1573 "Speaker Playback Switch",
1574 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01001575 "IEC958 Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01001576 NULL,
1577};
1578
1579/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001580 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07001581 */
1582static int alc_build_controls(struct hda_codec *codec)
1583{
1584 struct alc_spec *spec = codec->spec;
1585 int err;
1586 int i;
1587
1588 for (i = 0; i < spec->num_mixers; i++) {
1589 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
1590 if (err < 0)
1591 return err;
1592 }
1593
1594 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001595 err = snd_hda_create_spdif_out_ctls(codec,
1596 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001597 if (err < 0)
1598 return err;
Takashi Iwai9a081602008-02-12 18:37:26 +01001599 err = snd_hda_create_spdif_share_sw(codec,
1600 &spec->multiout);
1601 if (err < 0)
1602 return err;
1603 spec->multiout.share_spdif = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001604 }
1605 if (spec->dig_in_nid) {
1606 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
1607 if (err < 0)
1608 return err;
1609 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01001610
1611 /* if we have no master control, let's create it */
1612 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001613 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01001614 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001615 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001616 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01001617 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01001618 if (err < 0)
1619 return err;
1620 }
1621 if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
1622 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
1623 NULL, alc_slave_sws);
1624 if (err < 0)
1625 return err;
1626 }
1627
Linus Torvalds1da177e2005-04-16 15:20:36 -07001628 return 0;
1629}
1630
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001631
Linus Torvalds1da177e2005-04-16 15:20:36 -07001632/*
1633 * initialize the codec volumes, etc
1634 */
1635
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001636/*
1637 * generic initialization of ADC, input mixers and output mixers
1638 */
1639static struct hda_verb alc880_volume_init_verbs[] = {
1640 /*
1641 * Unmute ADC0-2 and set the default input to mic-in
1642 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001643 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001644 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001645 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001646 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02001647 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001648 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001649
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001650 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
1651 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001652 * Note: PASD motherboards uses the Line In 2 as the input for front
1653 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001654 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001655 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02001656 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1657 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
1658 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
1659 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
1660 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
1661 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
1662 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001663
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001664 /*
1665 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001667 /* set vol=0 to output mixers */
1668 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1669 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1670 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1671 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
1672 /* set up input amps for analog loopback */
1673 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02001674 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1675 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001676 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1677 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001678 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1679 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02001680 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
1681 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682
1683 { }
1684};
1685
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001686/*
1687 * 3-stack pin configuration:
1688 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
1689 */
1690static struct hda_verb alc880_pin_3stack_init_verbs[] = {
1691 /*
1692 * preset connection lists of input pins
1693 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1694 */
1695 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
1696 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1697 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
1698
1699 /*
1700 * Set pin mode and muting
1701 */
1702 /* set front pin widgets 0x14 for output */
1703 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1704 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1705 /* Mic1 (rear panel) pin widget for input and vref at 80% */
1706 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1707 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1708 /* Mic2 (as headphone out) for HP output */
1709 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1710 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1711 /* Line In pin widget for input */
1712 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1713 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1714 /* Line2 (as front mic) pin widget for input and vref at 80% */
1715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1716 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1717 /* CD pin widget for input */
1718 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1719
1720 { }
1721};
1722
1723/*
1724 * 5-stack pin configuration:
1725 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
1726 * line-in/side = 0x1a, f-mic = 0x1b
1727 */
1728static struct hda_verb alc880_pin_5stack_init_verbs[] = {
1729 /*
1730 * preset connection lists of input pins
1731 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
1732 */
1733 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1734 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
1735
1736 /*
1737 * Set pin mode and muting
1738 */
1739 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02001740 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1741 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1742 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1743 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001744 /* unmute pins for output (no gain on this amp) */
1745 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1746 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1747 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1748 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1749
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02001751 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001752 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1753 /* Mic2 (as headphone out) for HP output */
1754 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001755 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001756 /* Line In pin widget for input */
1757 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1758 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1759 /* Line2 (as front mic) pin widget for input and vref at 80% */
1760 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1761 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1762 /* CD pin widget for input */
1763 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001764
1765 { }
1766};
1767
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001768/*
1769 * W810 pin configuration:
1770 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
1771 */
1772static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001773 /* hphone/speaker input selector: front DAC */
1774 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
1775
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001776 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1777 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1778 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1779 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1780 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1781 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1782
1783 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02001784 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07001785
Linus Torvalds1da177e2005-04-16 15:20:36 -07001786 { }
1787};
1788
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001789/*
1790 * Z71V pin configuration:
1791 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
1792 */
1793static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02001794 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001795 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02001796 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001797 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001798
Takashi Iwai16ded522005-06-10 19:58:24 +02001799 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001800 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02001801 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001802 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02001803
1804 { }
1805};
1806
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001807/*
1808 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02001809 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
1810 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001811 */
1812static struct hda_verb alc880_pin_6stack_init_verbs[] = {
1813 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1814
Takashi Iwai16ded522005-06-10 19:58:24 +02001815 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001816 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001817 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001818 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001819 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001820 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001821 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001822 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1823
Takashi Iwai16ded522005-06-10 19:58:24 +02001824 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001825 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001826 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001827 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001828 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001829 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001830 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02001831 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02001832 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02001833
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001834 { }
1835};
Takashi Iwai16ded522005-06-10 19:58:24 +02001836
Kailang Yangccc656c2006-10-17 12:32:26 +02001837/*
1838 * Uniwill pin configuration:
1839 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
1840 * line = 0x1a
1841 */
1842static struct hda_verb alc880_uniwill_init_verbs[] = {
1843 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1844
1845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1846 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1848 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1849 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1850 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1851 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1852 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1853 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1854 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1855 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1856 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1857 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1858 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1859
1860 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1861 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1862 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1863 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1864 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1865 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1866 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
1867 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
1868 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1869
1870 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1871 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
1872
1873 { }
1874};
1875
1876/*
1877* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02001878* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02001879 */
1880static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
1881 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
1882
1883 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1884 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1885 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1886 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1887 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
1888 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1889 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1890 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1891 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1892 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1893 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
1894 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
1895
1896 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1897 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1898 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
1899 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1900 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1901 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
1902
1903 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
1904 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
1905
1906 { }
1907};
1908
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01001909static struct hda_verb alc880_beep_init_verbs[] = {
1910 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
1911 { }
1912};
1913
Kailang Yangccc656c2006-10-17 12:32:26 +02001914/* toggle speaker-output according to the hp-jack state */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001915static void alc880_uniwill_hp_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02001916{
1917 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001918 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001919
1920 present = snd_hda_codec_read(codec, 0x14, 0,
1921 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001922 bits = present ? HDA_AMP_MUTE : 0;
1923 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
1924 HDA_AMP_MUTE, bits);
1925 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
1926 HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001927}
1928
1929/* auto-toggle front mic */
1930static void alc880_uniwill_mic_automute(struct hda_codec *codec)
1931{
1932 unsigned int present;
1933 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001934
1935 present = snd_hda_codec_read(codec, 0x18, 0,
1936 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001937 bits = present ? HDA_AMP_MUTE : 0;
1938 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001939}
1940
1941static void alc880_uniwill_automute(struct hda_codec *codec)
1942{
1943 alc880_uniwill_hp_automute(codec);
1944 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02001945}
1946
1947static void alc880_uniwill_unsol_event(struct hda_codec *codec,
1948 unsigned int res)
1949{
1950 /* Looks like the unsol event is incompatible with the standard
1951 * definition. 4bit tag is placed at 28 bit!
1952 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02001953 switch (res >> 28) {
1954 case ALC880_HP_EVENT:
1955 alc880_uniwill_hp_automute(codec);
1956 break;
1957 case ALC880_MIC_EVENT:
1958 alc880_uniwill_mic_automute(codec);
1959 break;
1960 }
Kailang Yangccc656c2006-10-17 12:32:26 +02001961}
1962
1963static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
1964{
1965 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001966 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02001967
1968 present = snd_hda_codec_read(codec, 0x14, 0,
1969 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02001970 bits = present ? HDA_AMP_MUTE : 0;
Jiang zhe64654c22008-04-14 13:26:21 +02001971 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0, HDA_AMP_MUTE, bits);
Kailang Yangccc656c2006-10-17 12:32:26 +02001972}
1973
1974static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
1975{
1976 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02001977
Kailang Yangccc656c2006-10-17 12:32:26 +02001978 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02001979 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
1980 present &= HDA_AMP_VOLMASK;
1981 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
1982 HDA_AMP_VOLMASK, present);
1983 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
1984 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02001985}
Takashi Iwai47fd8302007-08-10 17:11:07 +02001986
Kailang Yangccc656c2006-10-17 12:32:26 +02001987static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
1988 unsigned int res)
1989{
1990 /* Looks like the unsol event is incompatible with the standard
1991 * definition. 4bit tag is placed at 28 bit!
1992 */
1993 if ((res >> 28) == ALC880_HP_EVENT)
1994 alc880_uniwill_p53_hp_automute(codec);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02001995 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02001996 alc880_uniwill_p53_dcvol_automute(codec);
1997}
1998
Takashi Iwaie9edcee2005-06-13 14:16:38 +02001999/*
2000 * F1734 pin configuration:
2001 * HP = 0x14, speaker-out = 0x15, mic = 0x18
2002 */
2003static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01002004 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002005 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2006 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2007 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2008 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2009
2010 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2011 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2012 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2013 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2014
2015 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2016 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01002017 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002018 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2019 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2020 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2021 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2022 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2023 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02002024
Takashi Iwai937b4162008-02-11 14:52:36 +01002025 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
2026 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
2027
Takashi Iwai16ded522005-06-10 19:58:24 +02002028 { }
2029};
2030
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002031/*
2032 * ASUS pin configuration:
2033 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
2034 */
2035static struct hda_verb alc880_pin_asus_init_verbs[] = {
2036 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
2037 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
2038 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
2039 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
2040
2041 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2042 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2043 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2044 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2045 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2046 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2047 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2048 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2049
2050 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2051 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2052 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2053 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2054 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2055 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2056 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2057 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2058 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02002059
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002060 { }
2061};
2062
2063/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02002064#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
2065#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002066
Kailang Yangdf694da2005-12-05 19:42:22 +01002067/* Clevo m520g init */
2068static struct hda_verb alc880_pin_clevo_init_verbs[] = {
2069 /* headphone output */
2070 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2071 /* line-out */
2072 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2073 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2074 /* Line-in */
2075 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2076 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2077 /* CD */
2078 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2079 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2080 /* Mic1 (rear panel) */
2081 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2082 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2083 /* Mic2 (front panel) */
2084 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2085 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2086 /* headphone */
2087 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2088 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2089 /* change to EAPD mode */
2090 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2091 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2092
2093 { }
2094};
2095
2096static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02002097 /* change to EAPD mode */
2098 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2099 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2100
Kailang Yangdf694da2005-12-05 19:42:22 +01002101 /* Headphone output */
2102 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2103 /* Front output*/
2104 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2105 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
2106
2107 /* Line In pin widget for input */
2108 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2109 /* CD pin widget for input */
2110 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2111 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2112 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2113
2114 /* change to EAPD mode */
2115 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2116 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
2117
2118 { }
2119};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002120
2121/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002122 * LG m1 express dual
2123 *
2124 * Pin assignment:
2125 * Rear Line-In/Out (blue): 0x14
2126 * Build-in Mic-In: 0x15
2127 * Speaker-out: 0x17
2128 * HP-Out (green): 0x1b
2129 * Mic-In/Out (red): 0x19
2130 * SPDIF-Out: 0x1e
2131 */
2132
2133/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
2134static hda_nid_t alc880_lg_dac_nids[3] = {
2135 0x05, 0x02, 0x03
2136};
2137
2138/* seems analog CD is not working */
2139static struct hda_input_mux alc880_lg_capture_source = {
2140 .num_items = 3,
2141 .items = {
2142 { "Mic", 0x1 },
2143 { "Line", 0x5 },
2144 { "Internal Mic", 0x6 },
2145 },
2146};
2147
2148/* 2,4,6 channel modes */
2149static struct hda_verb alc880_lg_ch2_init[] = {
2150 /* set line-in and mic-in to input */
2151 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2152 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2153 { }
2154};
2155
2156static struct hda_verb alc880_lg_ch4_init[] = {
2157 /* set line-in to out and mic-in to input */
2158 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2159 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2160 { }
2161};
2162
2163static struct hda_verb alc880_lg_ch6_init[] = {
2164 /* set line-in and mic-in to output */
2165 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2166 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
2167 { }
2168};
2169
2170static struct hda_channel_mode alc880_lg_ch_modes[3] = {
2171 { 2, alc880_lg_ch2_init },
2172 { 4, alc880_lg_ch4_init },
2173 { 6, alc880_lg_ch6_init },
2174};
2175
2176static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002177 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2178 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002179 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2180 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
2181 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
2182 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
2183 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
2184 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
2185 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2186 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2187 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
2188 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
2189 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
2190 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
2191 {
2192 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2193 .name = "Channel Mode",
2194 .info = alc_ch_mode_info,
2195 .get = alc_ch_mode_get,
2196 .put = alc_ch_mode_put,
2197 },
2198 { } /* end */
2199};
2200
2201static struct hda_verb alc880_lg_init_verbs[] = {
2202 /* set capture source to mic-in */
2203 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2204 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2205 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2206 /* mute all amp mixer inputs */
2207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002208 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2209 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002210 /* line-in to input */
2211 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2212 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2213 /* built-in mic */
2214 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2215 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2216 /* speaker-out */
2217 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2218 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2219 /* mic-in to input */
2220 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
2221 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2222 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2223 /* HP-out */
2224 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
2225 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2226 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2227 /* jack sense */
2228 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2229 { }
2230};
2231
2232/* toggle speaker-output according to the hp-jack state */
2233static void alc880_lg_automute(struct hda_codec *codec)
2234{
2235 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002236 unsigned char bits;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002237
2238 present = snd_hda_codec_read(codec, 0x1b, 0,
2239 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002240 bits = present ? HDA_AMP_MUTE : 0;
2241 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
2242 HDA_AMP_MUTE, bits);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002243}
2244
2245static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
2246{
2247 /* Looks like the unsol event is incompatible with the standard
2248 * definition. 4bit tag is placed at 28 bit!
2249 */
2250 if ((res >> 28) == 0x01)
2251 alc880_lg_automute(codec);
2252}
2253
2254/*
Takashi Iwaid6815182006-03-23 16:06:23 +01002255 * LG LW20
2256 *
2257 * Pin assignment:
2258 * Speaker-out: 0x14
2259 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002260 * Built-in Mic-In: 0x19
2261 * Line-In: 0x1b
2262 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01002263 * SPDIF-Out: 0x1e
2264 */
2265
Takashi Iwaid6815182006-03-23 16:06:23 +01002266static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002267 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01002268 .items = {
2269 { "Mic", 0x0 },
2270 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02002271 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002272 },
2273};
2274
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002275#define alc880_lg_lw_modes alc880_threestack_modes
2276
Takashi Iwaid6815182006-03-23 16:06:23 +01002277static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002278 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2279 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2280 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2281 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
2282 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2283 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2284 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2285 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2286 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2287 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01002288 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2289 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2290 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
2291 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002292 {
2293 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2294 .name = "Channel Mode",
2295 .info = alc_ch_mode_info,
2296 .get = alc_ch_mode_get,
2297 .put = alc_ch_mode_put,
2298 },
Takashi Iwaid6815182006-03-23 16:06:23 +01002299 { } /* end */
2300};
2301
2302static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02002303 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2304 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2305 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2306
Takashi Iwaid6815182006-03-23 16:06:23 +01002307 /* set capture source to mic-in */
2308 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2309 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2310 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02002311 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01002312 /* speaker-out */
2313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2314 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2315 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01002316 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2317 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2318 /* mic-in to input */
2319 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2320 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2321 /* built-in mic */
2322 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2323 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2324 /* jack sense */
2325 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
2326 { }
2327};
2328
2329/* toggle speaker-output according to the hp-jack state */
2330static void alc880_lg_lw_automute(struct hda_codec *codec)
2331{
2332 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002333 unsigned char bits;
Takashi Iwaid6815182006-03-23 16:06:23 +01002334
2335 present = snd_hda_codec_read(codec, 0x1b, 0,
2336 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02002337 bits = present ? HDA_AMP_MUTE : 0;
2338 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
2339 HDA_AMP_MUTE, bits);
Takashi Iwaid6815182006-03-23 16:06:23 +01002340}
2341
2342static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
2343{
2344 /* Looks like the unsol event is incompatible with the standard
2345 * definition. 4bit tag is placed at 28 bit!
2346 */
2347 if ((res >> 28) == 0x01)
2348 alc880_lg_lw_automute(codec);
2349}
2350
Takashi Iwaidf99cd32008-04-25 15:25:04 +02002351static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
2352 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2353 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
2354 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2355 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2356 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2357 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
2358 { } /* end */
2359};
2360
2361static struct hda_input_mux alc880_medion_rim_capture_source = {
2362 .num_items = 2,
2363 .items = {
2364 { "Mic", 0x0 },
2365 { "Internal Mic", 0x1 },
2366 },
2367};
2368
2369static struct hda_verb alc880_medion_rim_init_verbs[] = {
2370 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2371
2372 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2373 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2374
2375 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2376 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2377 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2378 /* Mic2 (as headphone out) for HP output */
2379 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2380 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2381 /* Internal Speaker */
2382 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2383 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2384
2385 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
2386 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
2387
2388 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
2389 { }
2390};
2391
2392/* toggle speaker-output according to the hp-jack state */
2393static void alc880_medion_rim_automute(struct hda_codec *codec)
2394{
2395 unsigned int present;
2396 unsigned char bits;
2397
2398 present = snd_hda_codec_read(codec, 0x14, 0,
2399 AC_VERB_GET_PIN_SENSE, 0)
2400 & AC_PINSENSE_PRESENCE;
2401 bits = present ? HDA_AMP_MUTE : 0;
2402 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
2403 HDA_AMP_MUTE, bits);
2404 if (present)
2405 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
2406 else
2407 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
2408}
2409
2410static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
2411 unsigned int res)
2412{
2413 /* Looks like the unsol event is incompatible with the standard
2414 * definition. 4bit tag is placed at 28 bit!
2415 */
2416 if ((res >> 28) == ALC880_HP_EVENT)
2417 alc880_medion_rim_automute(codec);
2418}
2419
Takashi Iwaicb53c622007-08-10 17:21:45 +02002420#ifdef CONFIG_SND_HDA_POWER_SAVE
2421static struct hda_amp_list alc880_loopbacks[] = {
2422 { 0x0b, HDA_INPUT, 0 },
2423 { 0x0b, HDA_INPUT, 1 },
2424 { 0x0b, HDA_INPUT, 2 },
2425 { 0x0b, HDA_INPUT, 3 },
2426 { 0x0b, HDA_INPUT, 4 },
2427 { } /* end */
2428};
2429
2430static struct hda_amp_list alc880_lg_loopbacks[] = {
2431 { 0x0b, HDA_INPUT, 1 },
2432 { 0x0b, HDA_INPUT, 6 },
2433 { 0x0b, HDA_INPUT, 7 },
2434 { } /* end */
2435};
2436#endif
2437
Takashi Iwaid6815182006-03-23 16:06:23 +01002438/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002439 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002440 */
Takashi Iwai16ded522005-06-10 19:58:24 +02002441
Linus Torvalds1da177e2005-04-16 15:20:36 -07002442static int alc_init(struct hda_codec *codec)
2443{
2444 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002445 unsigned int i;
2446
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002447 alc_fix_pll(codec);
Takashi Iwai1082c742008-08-22 15:24:22 +02002448 if (codec->vendor_id == 0x10ec0888)
2449 alc888_coef_init(codec);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02002450
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002451 for (i = 0; i < spec->num_init_verbs; i++)
2452 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002453
2454 if (spec->init_hook)
2455 spec->init_hook(codec);
2456
Linus Torvalds1da177e2005-04-16 15:20:36 -07002457 return 0;
2458}
2459
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002460static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
2461{
2462 struct alc_spec *spec = codec->spec;
2463
2464 if (spec->unsol_event)
2465 spec->unsol_event(codec, res);
2466}
2467
Takashi Iwaicb53c622007-08-10 17:21:45 +02002468#ifdef CONFIG_SND_HDA_POWER_SAVE
2469static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
2470{
2471 struct alc_spec *spec = codec->spec;
2472 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
2473}
2474#endif
2475
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476/*
2477 * Analog playback callbacks
2478 */
2479static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
2480 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002481 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002482{
2483 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01002484 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
2485 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002486}
2487
2488static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2489 struct hda_codec *codec,
2490 unsigned int stream_tag,
2491 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002492 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002493{
2494 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002495 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
2496 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497}
2498
2499static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
2500 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002501 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002502{
2503 struct alc_spec *spec = codec->spec;
2504 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
2505}
2506
2507/*
2508 * Digital out
2509 */
2510static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
2511 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002512 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002513{
2514 struct alc_spec *spec = codec->spec;
2515 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2516}
2517
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002518static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2519 struct hda_codec *codec,
2520 unsigned int stream_tag,
2521 unsigned int format,
2522 struct snd_pcm_substream *substream)
2523{
2524 struct alc_spec *spec = codec->spec;
2525 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2526 stream_tag, format, substream);
2527}
2528
Linus Torvalds1da177e2005-04-16 15:20:36 -07002529static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
2530 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002531 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002532{
2533 struct alc_spec *spec = codec->spec;
2534 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2535}
2536
2537/*
2538 * Analog capture
2539 */
Takashi Iwai63300792008-01-24 15:31:36 +01002540static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002541 struct hda_codec *codec,
2542 unsigned int stream_tag,
2543 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002544 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002545{
2546 struct alc_spec *spec = codec->spec;
2547
Takashi Iwai63300792008-01-24 15:31:36 +01002548 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07002549 stream_tag, 0, format);
2550 return 0;
2551}
2552
Takashi Iwai63300792008-01-24 15:31:36 +01002553static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002554 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002555 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556{
2557 struct alc_spec *spec = codec->spec;
2558
Takashi Iwai888afa12008-03-18 09:57:50 +01002559 snd_hda_codec_cleanup_stream(codec,
2560 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561 return 0;
2562}
2563
2564
2565/*
2566 */
2567static struct hda_pcm_stream alc880_pcm_analog_playback = {
2568 .substreams = 1,
2569 .channels_min = 2,
2570 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002571 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002572 .ops = {
2573 .open = alc880_playback_pcm_open,
2574 .prepare = alc880_playback_pcm_prepare,
2575 .cleanup = alc880_playback_pcm_cleanup
2576 },
2577};
2578
2579static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01002580 .substreams = 1,
2581 .channels_min = 2,
2582 .channels_max = 2,
2583 /* NID is set in alc_build_pcms */
2584};
2585
2586static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
2587 .substreams = 1,
2588 .channels_min = 2,
2589 .channels_max = 2,
2590 /* NID is set in alc_build_pcms */
2591};
2592
2593static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
2594 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002595 .channels_min = 2,
2596 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002597 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002598 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01002599 .prepare = alc880_alt_capture_pcm_prepare,
2600 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07002601 },
2602};
2603
2604static struct hda_pcm_stream alc880_pcm_digital_playback = {
2605 .substreams = 1,
2606 .channels_min = 2,
2607 .channels_max = 2,
2608 /* NID is set in alc_build_pcms */
2609 .ops = {
2610 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02002611 .close = alc880_dig_playback_pcm_close,
2612 .prepare = alc880_dig_playback_pcm_prepare
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613 },
2614};
2615
2616static struct hda_pcm_stream alc880_pcm_digital_capture = {
2617 .substreams = 1,
2618 .channels_min = 2,
2619 .channels_max = 2,
2620 /* NID is set in alc_build_pcms */
2621};
2622
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002623/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01002624static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01002625 .substreams = 0,
2626 .channels_min = 0,
2627 .channels_max = 0,
2628};
2629
Linus Torvalds1da177e2005-04-16 15:20:36 -07002630static int alc_build_pcms(struct hda_codec *codec)
2631{
2632 struct alc_spec *spec = codec->spec;
2633 struct hda_pcm *info = spec->pcm_rec;
2634 int i;
2635
2636 codec->num_pcms = 1;
2637 codec->pcm_info = info;
2638
2639 info->name = spec->stream_name_analog;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002640 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002641 if (snd_BUG_ON(!spec->multiout.dac_nids))
2642 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002643 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
2644 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
2645 }
2646 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02002647 if (snd_BUG_ON(!spec->adc_nids))
2648 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002649 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
2650 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
2651 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652
Takashi Iwai4a471b72005-12-07 13:56:29 +01002653 if (spec->channel_mode) {
2654 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
2655 for (i = 0; i < spec->num_channel_mode; i++) {
2656 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
2657 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
2658 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002659 }
2660 }
2661
Takashi Iwaie08a0072006-09-07 17:52:14 +02002662 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002663 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002664 codec->num_pcms = 2;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002665 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002666 info->name = spec->stream_name_digital;
Takashi Iwai7ba72ba2008-02-06 14:03:20 +01002667 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01002668 if (spec->multiout.dig_out_nid &&
2669 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
2671 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
2672 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01002673 if (spec->dig_in_nid &&
2674 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002675 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
2676 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
2677 }
Takashi Iwai963f8032008-08-11 10:04:40 +02002678 /* FIXME: do we need this for all Realtek codec models? */
2679 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002680 }
2681
Takashi Iwaie08a0072006-09-07 17:52:14 +02002682 /* If the use of more than one ADC is requested for the current
2683 * model, configure a second analog capture-only PCM.
2684 */
2685 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01002686 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
2687 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02002688 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02002689 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002690 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01002691 if (spec->alt_dac_nid) {
2692 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2693 *spec->stream_analog_alt_playback;
2694 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
2695 spec->alt_dac_nid;
2696 } else {
2697 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
2698 alc_pcm_null_stream;
2699 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
2700 }
2701 if (spec->num_adc_nids > 1) {
2702 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2703 *spec->stream_analog_alt_capture;
2704 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
2705 spec->adc_nids[1];
2706 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
2707 spec->num_adc_nids - 1;
2708 } else {
2709 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
2710 alc_pcm_null_stream;
2711 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02002712 }
2713 }
2714
Linus Torvalds1da177e2005-04-16 15:20:36 -07002715 return 0;
2716}
2717
2718static void alc_free(struct hda_codec *codec)
2719{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002720 struct alc_spec *spec = codec->spec;
2721 unsigned int i;
2722
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002723 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002724 return;
2725
2726 if (spec->kctl_alloc) {
2727 for (i = 0; i < spec->num_kctl_used; i++)
2728 kfree(spec->kctl_alloc[i].name);
2729 kfree(spec->kctl_alloc);
2730 }
2731 kfree(spec);
Takashi Iwai7943a8a2008-04-16 17:29:09 +02002732 codec->spec = NULL; /* to be sure */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002733}
2734
2735/*
2736 */
2737static struct hda_codec_ops alc_patch_ops = {
2738 .build_controls = alc_build_controls,
2739 .build_pcms = alc_build_pcms,
2740 .init = alc_init,
2741 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002742 .unsol_event = alc_unsol_event,
Takashi Iwaicb53c622007-08-10 17:21:45 +02002743#ifdef CONFIG_SND_HDA_POWER_SAVE
2744 .check_power_status = alc_check_power_status,
2745#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002746};
2747
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002748
2749/*
2750 * Test configuration for debugging
2751 *
2752 * Almost all inputs/outputs are enabled. I/O pins can be configured via
2753 * enum controls.
2754 */
2755#ifdef CONFIG_SND_DEBUG
2756static hda_nid_t alc880_test_dac_nids[4] = {
2757 0x02, 0x03, 0x04, 0x05
2758};
2759
2760static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002761 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002762 .items = {
2763 { "In-1", 0x0 },
2764 { "In-2", 0x1 },
2765 { "In-3", 0x2 },
2766 { "In-4", 0x3 },
2767 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01002768 { "Front", 0x5 },
2769 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002770 },
2771};
2772
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002773static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002774 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002775 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002776 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02002777 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002778};
2779
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002780static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
2781 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002782{
2783 static char *texts[] = {
2784 "N/A", "Line Out", "HP Out",
2785 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
2786 };
2787 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2788 uinfo->count = 1;
2789 uinfo->value.enumerated.items = 8;
2790 if (uinfo->value.enumerated.item >= 8)
2791 uinfo->value.enumerated.item = 7;
2792 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2793 return 0;
2794}
2795
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002796static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
2797 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002798{
2799 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2800 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2801 unsigned int pin_ctl, item = 0;
2802
2803 pin_ctl = snd_hda_codec_read(codec, nid, 0,
2804 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2805 if (pin_ctl & AC_PINCTL_OUT_EN) {
2806 if (pin_ctl & AC_PINCTL_HP_EN)
2807 item = 2;
2808 else
2809 item = 1;
2810 } else if (pin_ctl & AC_PINCTL_IN_EN) {
2811 switch (pin_ctl & AC_PINCTL_VREFEN) {
2812 case AC_PINCTL_VREF_HIZ: item = 3; break;
2813 case AC_PINCTL_VREF_50: item = 4; break;
2814 case AC_PINCTL_VREF_GRD: item = 5; break;
2815 case AC_PINCTL_VREF_80: item = 6; break;
2816 case AC_PINCTL_VREF_100: item = 7; break;
2817 }
2818 }
2819 ucontrol->value.enumerated.item[0] = item;
2820 return 0;
2821}
2822
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002823static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
2824 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002825{
2826 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2827 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2828 static unsigned int ctls[] = {
2829 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
2830 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
2831 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
2832 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
2833 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
2834 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
2835 };
2836 unsigned int old_ctl, new_ctl;
2837
2838 old_ctl = snd_hda_codec_read(codec, nid, 0,
2839 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
2840 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
2841 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002842 int val;
2843 snd_hda_codec_write_cache(codec, nid, 0,
2844 AC_VERB_SET_PIN_WIDGET_CONTROL,
2845 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02002846 val = ucontrol->value.enumerated.item[0] >= 3 ?
2847 HDA_AMP_MUTE : 0;
2848 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
2849 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002850 return 1;
2851 }
2852 return 0;
2853}
2854
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002855static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
2856 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002857{
2858 static char *texts[] = {
2859 "Front", "Surround", "CLFE", "Side"
2860 };
2861 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2862 uinfo->count = 1;
2863 uinfo->value.enumerated.items = 4;
2864 if (uinfo->value.enumerated.item >= 4)
2865 uinfo->value.enumerated.item = 3;
2866 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
2867 return 0;
2868}
2869
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002870static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
2871 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002872{
2873 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2874 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2875 unsigned int sel;
2876
2877 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
2878 ucontrol->value.enumerated.item[0] = sel & 3;
2879 return 0;
2880}
2881
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002882static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
2883 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002884{
2885 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2886 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
2887 unsigned int sel;
2888
2889 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
2890 if (ucontrol->value.enumerated.item[0] != sel) {
2891 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02002892 snd_hda_codec_write_cache(codec, nid, 0,
2893 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002894 return 1;
2895 }
2896 return 0;
2897}
2898
2899#define PIN_CTL_TEST(xname,nid) { \
2900 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2901 .name = xname, \
2902 .info = alc_test_pin_ctl_info, \
2903 .get = alc_test_pin_ctl_get, \
2904 .put = alc_test_pin_ctl_put, \
2905 .private_value = nid \
2906 }
2907
2908#define PIN_SRC_TEST(xname,nid) { \
2909 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2910 .name = xname, \
2911 .info = alc_test_pin_src_info, \
2912 .get = alc_test_pin_src_get, \
2913 .put = alc_test_pin_src_put, \
2914 .private_value = nid \
2915 }
2916
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002917static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002918 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2919 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2920 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
2921 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002922 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2923 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2924 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
2925 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002926 PIN_CTL_TEST("Front Pin Mode", 0x14),
2927 PIN_CTL_TEST("Surround Pin Mode", 0x15),
2928 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
2929 PIN_CTL_TEST("Side Pin Mode", 0x17),
2930 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
2931 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
2932 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
2933 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
2934 PIN_SRC_TEST("In-1 Pin Source", 0x18),
2935 PIN_SRC_TEST("In-2 Pin Source", 0x19),
2936 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
2937 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
2938 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
2939 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
2940 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
2941 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
2942 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
2943 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
2944 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
2945 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
2946 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
2947 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002948 {
2949 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2950 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002951 .info = alc_ch_mode_info,
2952 .get = alc_ch_mode_get,
2953 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002954 },
2955 { } /* end */
2956};
2957
2958static struct hda_verb alc880_test_init_verbs[] = {
2959 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002960 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2961 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2962 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2963 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2964 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2965 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2966 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2967 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002968 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02002969 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2970 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2971 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2972 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002973 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002974 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2975 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2976 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2977 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002978 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002979 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2980 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2981 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2982 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002983 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02002984 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2985 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02002986 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2987 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2988 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02002989 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02002990 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2991 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2992 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2993 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002994 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02002995 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002996 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002997 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002998 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02002999 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003000 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02003001 /* Analog input/passthru */
3002 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3003 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3004 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3005 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3006 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003007 { }
3008};
3009#endif
3010
Linus Torvalds1da177e2005-04-16 15:20:36 -07003011/*
3012 */
3013
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003014static const char *alc880_models[ALC880_MODEL_LAST] = {
3015 [ALC880_3ST] = "3stack",
3016 [ALC880_TCL_S700] = "tcl",
3017 [ALC880_3ST_DIG] = "3stack-digout",
3018 [ALC880_CLEVO] = "clevo",
3019 [ALC880_5ST] = "5stack",
3020 [ALC880_5ST_DIG] = "5stack-digout",
3021 [ALC880_W810] = "w810",
3022 [ALC880_Z71V] = "z71v",
3023 [ALC880_6ST] = "6stack",
3024 [ALC880_6ST_DIG] = "6stack-digout",
3025 [ALC880_ASUS] = "asus",
3026 [ALC880_ASUS_W1V] = "asus-w1v",
3027 [ALC880_ASUS_DIG] = "asus-dig",
3028 [ALC880_ASUS_DIG2] = "asus-dig2",
3029 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003030 [ALC880_UNIWILL_P53] = "uniwill-p53",
3031 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003032 [ALC880_F1734] = "F1734",
3033 [ALC880_LG] = "lg",
3034 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003035 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003036#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003037 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02003038#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003039 [ALC880_AUTO] = "auto",
3040};
3041
3042static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003043 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003044 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
3045 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
3046 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
3047 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
3048 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
3049 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
3050 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
3051 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003052 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
3053 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003054 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
3055 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
3056 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
3057 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
3058 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
3059 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
3060 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
3061 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
3062 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
3063 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02003064 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003065 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
3066 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
3067 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003068 SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003069 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003070 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
3071 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003072 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
3073 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003074 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
3075 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
3076 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
3077 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003078 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
3079 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003080 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003081 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003082 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003083 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003084 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
3085 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003086 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003087 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003088 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003089 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003090 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02003091 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003092 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003093 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003094 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003095 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
3096 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003097 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003098 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
3099 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
3100 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
3101 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003102 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
3103 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003104 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003105 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003106 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
3107 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003108 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
3109 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
3110 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01003111 SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST), /* default Intel */
3112 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
3113 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07003114 {}
3115};
3116
Takashi Iwai16ded522005-06-10 19:58:24 +02003117/*
Kailang Yangdf694da2005-12-05 19:42:22 +01003118 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02003119 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003120static struct alc_config_preset alc880_presets[] = {
3121 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003122 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003123 .init_verbs = { alc880_volume_init_verbs,
3124 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003125 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003126 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003127 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3128 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003129 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003130 .input_mux = &alc880_capture_source,
3131 },
3132 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003133 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003134 .init_verbs = { alc880_volume_init_verbs,
3135 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003136 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02003137 .dac_nids = alc880_dac_nids,
3138 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003139 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3140 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003141 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003142 .input_mux = &alc880_capture_source,
3143 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003144 [ALC880_TCL_S700] = {
3145 .mixers = { alc880_tcl_s700_mixer },
3146 .init_verbs = { alc880_volume_init_verbs,
3147 alc880_pin_tcl_S700_init_verbs,
3148 alc880_gpio2_init_verbs },
3149 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3150 .dac_nids = alc880_dac_nids,
3151 .hp_nid = 0x03,
3152 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3153 .channel_mode = alc880_2_jack_modes,
3154 .input_mux = &alc880_capture_source,
3155 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003156 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003157 .mixers = { alc880_three_stack_mixer,
3158 alc880_five_stack_mixer},
3159 .init_verbs = { alc880_volume_init_verbs,
3160 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003161 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3162 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003163 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3164 .channel_mode = alc880_fivestack_modes,
3165 .input_mux = &alc880_capture_source,
3166 },
3167 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003168 .mixers = { alc880_three_stack_mixer,
3169 alc880_five_stack_mixer },
3170 .init_verbs = { alc880_volume_init_verbs,
3171 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003172 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3173 .dac_nids = alc880_dac_nids,
3174 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003175 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
3176 .channel_mode = alc880_fivestack_modes,
3177 .input_mux = &alc880_capture_source,
3178 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003179 [ALC880_6ST] = {
3180 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003181 .init_verbs = { alc880_volume_init_verbs,
3182 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02003183 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3184 .dac_nids = alc880_6st_dac_nids,
3185 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3186 .channel_mode = alc880_sixstack_modes,
3187 .input_mux = &alc880_6stack_capture_source,
3188 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003189 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003190 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003191 .init_verbs = { alc880_volume_init_verbs,
3192 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003193 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
3194 .dac_nids = alc880_6st_dac_nids,
3195 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003196 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
3197 .channel_mode = alc880_sixstack_modes,
3198 .input_mux = &alc880_6stack_capture_source,
3199 },
3200 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003201 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003202 .init_verbs = { alc880_volume_init_verbs,
3203 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003204 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003205 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
3206 .dac_nids = alc880_w810_dac_nids,
3207 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003208 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
3209 .channel_mode = alc880_w810_modes,
3210 .input_mux = &alc880_capture_source,
3211 },
3212 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003213 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003214 .init_verbs = { alc880_volume_init_verbs,
3215 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003216 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
3217 .dac_nids = alc880_z71v_dac_nids,
3218 .dig_out_nid = ALC880_DIGOUT_NID,
3219 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003220 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3221 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02003222 .input_mux = &alc880_capture_source,
3223 },
3224 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003225 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003226 .init_verbs = { alc880_volume_init_verbs,
3227 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003228 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
3229 .dac_nids = alc880_f1734_dac_nids,
3230 .hp_nid = 0x02,
3231 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3232 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01003233 .input_mux = &alc880_f1734_capture_source,
3234 .unsol_event = alc880_uniwill_p53_unsol_event,
3235 .init_hook = alc880_uniwill_p53_hp_automute,
Takashi Iwai16ded522005-06-10 19:58:24 +02003236 },
3237 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003239 .init_verbs = { alc880_volume_init_verbs,
3240 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003241 alc880_gpio1_init_verbs },
3242 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3243 .dac_nids = alc880_asus_dac_nids,
3244 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3245 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003246 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003247 .input_mux = &alc880_capture_source,
3248 },
3249 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003250 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003251 .init_verbs = { alc880_volume_init_verbs,
3252 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003253 alc880_gpio1_init_verbs },
3254 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3255 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003256 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3258 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003259 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003260 .input_mux = &alc880_capture_source,
3261 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003262 [ALC880_ASUS_DIG2] = {
3263 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003264 .init_verbs = { alc880_volume_init_verbs,
3265 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01003266 alc880_gpio2_init_verbs }, /* use GPIO2 */
3267 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3268 .dac_nids = alc880_asus_dac_nids,
3269 .dig_out_nid = ALC880_DIGOUT_NID,
3270 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3271 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003272 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003273 .input_mux = &alc880_capture_source,
3274 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003275 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003276 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003277 .init_verbs = { alc880_volume_init_verbs,
3278 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003279 alc880_gpio1_init_verbs },
3280 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3281 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003282 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003283 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3284 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003285 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003286 .input_mux = &alc880_capture_source,
3287 },
3288 [ALC880_UNIWILL_DIG] = {
Takashi Iwai3c10a9d2005-08-23 20:02:27 +02003289 .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02003290 .init_verbs = { alc880_volume_init_verbs,
3291 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003292 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3293 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02003294 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003295 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
3296 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003297 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02003298 .input_mux = &alc880_capture_source,
3299 },
Kailang Yangccc656c2006-10-17 12:32:26 +02003300 [ALC880_UNIWILL] = {
3301 .mixers = { alc880_uniwill_mixer },
3302 .init_verbs = { alc880_volume_init_verbs,
3303 alc880_uniwill_init_verbs },
3304 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3305 .dac_nids = alc880_asus_dac_nids,
3306 .dig_out_nid = ALC880_DIGOUT_NID,
3307 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3308 .channel_mode = alc880_threestack_modes,
3309 .need_dac_fix = 1,
3310 .input_mux = &alc880_capture_source,
3311 .unsol_event = alc880_uniwill_unsol_event,
3312 .init_hook = alc880_uniwill_automute,
3313 },
3314 [ALC880_UNIWILL_P53] = {
3315 .mixers = { alc880_uniwill_p53_mixer },
3316 .init_verbs = { alc880_volume_init_verbs,
3317 alc880_uniwill_p53_init_verbs },
3318 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
3319 .dac_nids = alc880_asus_dac_nids,
3320 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003321 .channel_mode = alc880_threestack_modes,
3322 .input_mux = &alc880_capture_source,
3323 .unsol_event = alc880_uniwill_p53_unsol_event,
3324 .init_hook = alc880_uniwill_p53_hp_automute,
3325 },
3326 [ALC880_FUJITSU] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003327 .mixers = { alc880_fujitsu_mixer,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003328 alc880_pcbeep_mixer, },
3329 .init_verbs = { alc880_volume_init_verbs,
3330 alc880_uniwill_p53_init_verbs,
3331 alc880_beep_init_verbs },
3332 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3333 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02003334 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003335 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3336 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02003337 .input_mux = &alc880_capture_source,
3338 .unsol_event = alc880_uniwill_p53_unsol_event,
3339 .init_hook = alc880_uniwill_p53_hp_automute,
3340 },
Kailang Yangdf694da2005-12-05 19:42:22 +01003341 [ALC880_CLEVO] = {
3342 .mixers = { alc880_three_stack_mixer },
3343 .init_verbs = { alc880_volume_init_verbs,
3344 alc880_pin_clevo_init_verbs },
3345 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3346 .dac_nids = alc880_dac_nids,
3347 .hp_nid = 0x03,
3348 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
3349 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003350 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01003351 .input_mux = &alc880_capture_source,
3352 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003353 [ALC880_LG] = {
3354 .mixers = { alc880_lg_mixer },
3355 .init_verbs = { alc880_volume_init_verbs,
3356 alc880_lg_init_verbs },
3357 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
3358 .dac_nids = alc880_lg_dac_nids,
3359 .dig_out_nid = ALC880_DIGOUT_NID,
3360 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
3361 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02003362 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003363 .input_mux = &alc880_lg_capture_source,
3364 .unsol_event = alc880_lg_unsol_event,
3365 .init_hook = alc880_lg_automute,
Takashi Iwaicb53c622007-08-10 17:21:45 +02003366#ifdef CONFIG_SND_HDA_POWER_SAVE
3367 .loopbacks = alc880_lg_loopbacks,
3368#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003369 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003370 [ALC880_LG_LW] = {
3371 .mixers = { alc880_lg_lw_mixer },
3372 .init_verbs = { alc880_volume_init_verbs,
3373 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003374 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01003375 .dac_nids = alc880_dac_nids,
3376 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003377 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
3378 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01003379 .input_mux = &alc880_lg_lw_capture_source,
3380 .unsol_event = alc880_lg_lw_unsol_event,
3381 .init_hook = alc880_lg_lw_automute,
3382 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003383 [ALC880_MEDION_RIM] = {
3384 .mixers = { alc880_medion_rim_mixer },
3385 .init_verbs = { alc880_volume_init_verbs,
3386 alc880_medion_rim_init_verbs,
3387 alc_gpio2_init_verbs },
3388 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
3389 .dac_nids = alc880_dac_nids,
3390 .dig_out_nid = ALC880_DIGOUT_NID,
3391 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
3392 .channel_mode = alc880_2_jack_modes,
3393 .input_mux = &alc880_medion_rim_capture_source,
3394 .unsol_event = alc880_medion_rim_unsol_event,
3395 .init_hook = alc880_medion_rim_automute,
3396 },
Takashi Iwai16ded522005-06-10 19:58:24 +02003397#ifdef CONFIG_SND_DEBUG
3398 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003399 .mixers = { alc880_test_mixer },
3400 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02003401 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
3402 .dac_nids = alc880_test_dac_nids,
3403 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02003404 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
3405 .channel_mode = alc880_test_modes,
3406 .input_mux = &alc880_test_capture_source,
3407 },
3408#endif
3409};
3410
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003411/*
3412 * Automatic parse of I/O pins from the BIOS configuration
3413 */
3414
3415#define NUM_CONTROL_ALLOC 32
3416#define NUM_VERB_ALLOC 32
3417
3418enum {
3419 ALC_CTL_WIDGET_VOL,
3420 ALC_CTL_WIDGET_MUTE,
3421 ALC_CTL_BIND_MUTE,
3422};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003423static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003424 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
3425 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01003426 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003427};
3428
3429/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003430static int add_control(struct alc_spec *spec, int type, const char *name,
3431 unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003432{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003433 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003434
3435 if (spec->num_kctl_used >= spec->num_kctl_alloc) {
3436 int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
3437
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003438 /* array + terminator */
3439 knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
3440 if (!knew)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003441 return -ENOMEM;
3442 if (spec->kctl_alloc) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003443 memcpy(knew, spec->kctl_alloc,
3444 sizeof(*knew) * spec->num_kctl_alloc);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003445 kfree(spec->kctl_alloc);
3446 }
3447 spec->kctl_alloc = knew;
3448 spec->num_kctl_alloc = num;
3449 }
3450
3451 knew = &spec->kctl_alloc[spec->num_kctl_used];
3452 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07003453 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003454 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003455 return -ENOMEM;
3456 knew->private_value = val;
3457 spec->num_kctl_used++;
3458 return 0;
3459}
3460
3461#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
3462#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
3463#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
3464#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
3465#define alc880_is_input_pin(nid) ((nid) >= 0x18)
3466#define alc880_input_pin_idx(nid) ((nid) - 0x18)
3467#define alc880_idx_to_dac(nid) ((nid) + 0x02)
3468#define alc880_dac_to_idx(nid) ((nid) - 0x02)
3469#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
3470#define alc880_idx_to_selector(nid) ((nid) + 0x10)
3471#define ALC880_PIN_CD_NID 0x1c
3472
3473/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003474static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
3475 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003476{
3477 hda_nid_t nid;
3478 int assigned[4];
3479 int i, j;
3480
3481 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02003482 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003483
3484 /* check the pins hardwired to audio widget */
3485 for (i = 0; i < cfg->line_outs; i++) {
3486 nid = cfg->line_out_pins[i];
3487 if (alc880_is_fixed_pin(nid)) {
3488 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01003489 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003490 assigned[idx] = 1;
3491 }
3492 }
3493 /* left pins can be connect to any audio widget */
3494 for (i = 0; i < cfg->line_outs; i++) {
3495 nid = cfg->line_out_pins[i];
3496 if (alc880_is_fixed_pin(nid))
3497 continue;
3498 /* search for an empty channel */
3499 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003500 if (!assigned[j]) {
3501 spec->multiout.dac_nids[i] =
3502 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003503 assigned[j] = 1;
3504 break;
3505 }
3506 }
3507 }
3508 spec->multiout.num_dacs = cfg->line_outs;
3509 return 0;
3510}
3511
3512/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01003513static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
3514 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003515{
3516 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003517 static const char *chname[4] = {
3518 "Front", "Surround", NULL /*CLFE*/, "Side"
3519 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003520 hda_nid_t nid;
3521 int i, err;
3522
3523 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003524 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003525 continue;
3526 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
3527 if (i == 2) {
3528 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003529 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3530 "Center Playback Volume",
3531 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
3532 HDA_OUTPUT));
3533 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003534 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003535 err = add_control(spec, ALC_CTL_WIDGET_VOL,
3536 "LFE Playback Volume",
3537 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
3538 HDA_OUTPUT));
3539 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003540 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003541 err = add_control(spec, ALC_CTL_BIND_MUTE,
3542 "Center Playback Switch",
3543 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
3544 HDA_INPUT));
3545 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003546 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003547 err = add_control(spec, ALC_CTL_BIND_MUTE,
3548 "LFE Playback Switch",
3549 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
3550 HDA_INPUT));
3551 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003552 return err;
3553 } else {
3554 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003555 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3556 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
3557 HDA_OUTPUT));
3558 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003559 return err;
3560 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003561 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3562 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
3563 HDA_INPUT));
3564 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003565 return err;
3566 }
3567 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003568 return 0;
3569}
3570
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003571/* add playback controls for speaker and HP outputs */
3572static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
3573 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003574{
3575 hda_nid_t nid;
3576 int err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003577 char name[32];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003578
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003579 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003580 return 0;
3581
3582 if (alc880_is_fixed_pin(pin)) {
3583 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01003584 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003585 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003586 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01003587 else
3588 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003589 /* control HP volume/switch on the output mixer amp */
3590 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003591 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003592 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3593 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
3594 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003595 return err;
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003596 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003597 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
3598 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
3599 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003600 return err;
3601 } else if (alc880_is_multi_pin(pin)) {
3602 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003603 /* we have only a switch on HP-out PIN */
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003604 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003605 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3606 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
3607 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003608 return err;
3609 }
3610 return 0;
3611}
3612
3613/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003614static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
3615 const char *ctlname,
Kailang Yangdf694da2005-12-05 19:42:22 +01003616 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003617{
3618 char name[32];
Kailang Yangdf694da2005-12-05 19:42:22 +01003619 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003620
3621 sprintf(name, "%s Playback Volume", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003622 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
3623 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3624 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003625 return err;
3626 sprintf(name, "%s Playback Switch", ctlname);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003627 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
3628 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
3629 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003630 return err;
3631 return 0;
3632}
3633
3634/* create playback/capture controls for input pins */
Kailang Yangdf694da2005-12-05 19:42:22 +01003635static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
3636 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003637{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003638 struct hda_input_mux *imux = &spec->private_imux;
Kailang Yangdf694da2005-12-05 19:42:22 +01003639 int i, err, idx;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003640
3641 for (i = 0; i < AUTO_PIN_LAST; i++) {
3642 if (alc880_is_input_pin(cfg->input_pins[i])) {
Kailang Yangdf694da2005-12-05 19:42:22 +01003643 idx = alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwai4a471b72005-12-07 13:56:29 +01003644 err = new_analog_input(spec, cfg->input_pins[i],
3645 auto_pin_cfg_labels[i],
Kailang Yangdf694da2005-12-05 19:42:22 +01003646 idx, 0x0b);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003647 if (err < 0)
3648 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003649 imux->items[imux->num_items].label =
3650 auto_pin_cfg_labels[i];
3651 imux->items[imux->num_items].index =
3652 alc880_input_pin_idx(cfg->input_pins[i]);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003653 imux->num_items++;
3654 }
3655 }
3656 return 0;
3657}
3658
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003659static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
3660 unsigned int pin_type)
3661{
3662 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
3663 pin_type);
3664 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01003665 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
3666 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003667}
3668
Kailang Yangdf694da2005-12-05 19:42:22 +01003669static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
3670 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003671 int dac_idx)
3672{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003673 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003674 /* need the manual connection? */
3675 if (alc880_is_multi_pin(nid)) {
3676 struct alc_spec *spec = codec->spec;
3677 int idx = alc880_multi_pin_idx(nid);
3678 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
3679 AC_VERB_SET_CONNECT_SEL,
3680 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
3681 }
3682}
3683
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003684static int get_pin_type(int line_out_type)
3685{
3686 if (line_out_type == AUTO_PIN_HP_OUT)
3687 return PIN_HP;
3688 else
3689 return PIN_OUT;
3690}
3691
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003692static void alc880_auto_init_multi_out(struct hda_codec *codec)
3693{
3694 struct alc_spec *spec = codec->spec;
3695 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02003696
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003697 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003698 for (i = 0; i < spec->autocfg.line_outs; i++) {
3699 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02003700 int pin_type = get_pin_type(spec->autocfg.line_out_type);
3701 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003702 }
3703}
3704
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003705static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003706{
3707 struct alc_spec *spec = codec->spec;
3708 hda_nid_t pin;
3709
Takashi Iwai82bc9552006-03-21 11:24:42 +01003710 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003711 if (pin) /* connect to front */
3712 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02003713 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003714 if (pin) /* connect to front */
3715 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
3716}
3717
3718static void alc880_auto_init_analog_input(struct hda_codec *codec)
3719{
3720 struct alc_spec *spec = codec->spec;
3721 int i;
3722
3723 for (i = 0; i < AUTO_PIN_LAST; i++) {
3724 hda_nid_t nid = spec->autocfg.input_pins[i];
3725 if (alc880_is_input_pin(nid)) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003726 snd_hda_codec_write(codec, nid, 0,
3727 AC_VERB_SET_PIN_WIDGET_CONTROL,
3728 i <= AUTO_PIN_FRONT_MIC ?
3729 PIN_VREF80 : PIN_IN);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003730 if (nid != ALC880_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003731 snd_hda_codec_write(codec, nid, 0,
3732 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003733 AMP_OUT_MUTE);
3734 }
3735 }
3736}
3737
3738/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003739/* return 1 if successful, 0 if the proper config is not found,
3740 * or a negative error code
3741 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003742static int alc880_parse_auto_config(struct hda_codec *codec)
3743{
3744 struct alc_spec *spec = codec->spec;
3745 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01003746 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003747
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003748 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
3749 alc880_ignore);
3750 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003751 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003752 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003753 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01003754
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003755 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
3756 if (err < 0)
3757 return err;
3758 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
3759 if (err < 0)
3760 return err;
3761 err = alc880_auto_create_extra_out(spec,
3762 spec->autocfg.speaker_pins[0],
3763 "Speaker");
3764 if (err < 0)
3765 return err;
3766 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
3767 "Headphone");
3768 if (err < 0)
3769 return err;
3770 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
3771 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003772 return err;
3773
3774 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
3775
3776 if (spec->autocfg.dig_out_pin)
3777 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
3778 if (spec->autocfg.dig_in_pin)
3779 spec->dig_in_nid = ALC880_DIGIN_NID;
3780
3781 if (spec->kctl_alloc)
3782 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
3783
3784 spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
3785
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003786 spec->num_mux_defs = 1;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003787 spec->input_mux = &spec->private_imux;
3788
3789 return 1;
3790}
3791
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003792/* additional initialization for auto-configuration model */
3793static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003794{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003795 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003796 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01003797 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003798 alc880_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01003799 if (spec->unsol_event)
3800 alc_sku_automute(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003801}
3802
3803/*
3804 * OK, here we have finally the patch for ALC880
3805 */
3806
Linus Torvalds1da177e2005-04-16 15:20:36 -07003807static int patch_alc880(struct hda_codec *codec)
3808{
3809 struct alc_spec *spec;
3810 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01003811 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003812
Takashi Iwaie560d8d2005-09-09 14:21:46 +02003813 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003814 if (spec == NULL)
3815 return -ENOMEM;
3816
3817 codec->spec = spec;
3818
Takashi Iwaif5fcc132006-11-24 17:07:44 +01003819 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
3820 alc880_models,
3821 alc880_cfg_tbl);
3822 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003823 printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
3824 "trying auto-probe from BIOS...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003825 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003826 }
3827
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003828 if (board_config == ALC880_AUTO) {
3829 /* automatic parse from the BIOS config */
3830 err = alc880_parse_auto_config(codec);
3831 if (err < 0) {
3832 alc_free(codec);
3833 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003834 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003835 printk(KERN_INFO
3836 "hda_codec: Cannot set up configuration "
3837 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003838 board_config = ALC880_3ST;
3839 }
3840 }
3841
Kailang Yangdf694da2005-12-05 19:42:22 +01003842 if (board_config != ALC880_AUTO)
3843 setup_preset(spec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003844
3845 spec->stream_name_analog = "ALC880 Analog";
3846 spec->stream_analog_playback = &alc880_pcm_analog_playback;
3847 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01003848 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003849
3850 spec->stream_name_digital = "ALC880 Digital";
3851 spec->stream_digital_playback = &alc880_pcm_digital_playback;
3852 spec->stream_digital_capture = &alc880_pcm_digital_capture;
3853
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003854 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003855 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01003856 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003857 /* get type */
3858 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003859 if (wcap != AC_WID_AUD_IN) {
3860 spec->adc_nids = alc880_adc_nids_alt;
3861 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003862 spec->mixers[spec->num_mixers] =
3863 alc880_capture_alt_mixer;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003864 spec->num_mixers++;
3865 } else {
3866 spec->adc_nids = alc880_adc_nids;
3867 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
3868 spec->mixers[spec->num_mixers] = alc880_capture_mixer;
3869 spec->num_mixers++;
3870 }
3871 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003872
Takashi Iwai2134ea42008-01-10 16:53:55 +01003873 spec->vmaster_nid = 0x0c;
3874
Linus Torvalds1da177e2005-04-16 15:20:36 -07003875 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003876 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003877 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02003878#ifdef CONFIG_SND_HDA_POWER_SAVE
3879 if (!spec->loopback.amplist)
3880 spec->loopback.amplist = alc880_loopbacks;
3881#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003882
3883 return 0;
3884}
3885
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003886
Linus Torvalds1da177e2005-04-16 15:20:36 -07003887/*
3888 * ALC260 support
3889 */
3890
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003891static hda_nid_t alc260_dac_nids[1] = {
3892 /* front */
3893 0x02,
3894};
3895
3896static hda_nid_t alc260_adc_nids[1] = {
3897 /* ADC0 */
3898 0x04,
3899};
3900
Kailang Yangdf694da2005-12-05 19:42:22 +01003901static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003902 /* ADC1 */
3903 0x05,
3904};
3905
Kailang Yangdf694da2005-12-05 19:42:22 +01003906static hda_nid_t alc260_hp_adc_nids[2] = {
3907 /* ADC1, 0 */
3908 0x05, 0x04
3909};
3910
Jonathan Woithed57fdac2006-02-28 11:38:35 +01003911/* NIDs used when simultaneous access to both ADCs makes sense. Note that
3912 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
3913 */
3914static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003915 /* ADC0, ADC1 */
3916 0x04, 0x05
3917};
3918
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003919#define ALC260_DIGOUT_NID 0x03
3920#define ALC260_DIGIN_NID 0x06
3921
3922static struct hda_input_mux alc260_capture_source = {
3923 .num_items = 4,
3924 .items = {
3925 { "Mic", 0x0 },
3926 { "Front Mic", 0x1 },
3927 { "Line", 0x2 },
3928 { "CD", 0x4 },
3929 },
3930};
3931
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01003932/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003933 * headphone jack and the internal CD lines since these are the only pins at
3934 * which audio can appear. For flexibility, also allow the option of
3935 * recording the mixer output on the second ADC (ADC0 doesn't have a
3936 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003937 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003938static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
3939 {
3940 .num_items = 3,
3941 .items = {
3942 { "Mic/Line", 0x0 },
3943 { "CD", 0x4 },
3944 { "Headphone", 0x2 },
3945 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003946 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003947 {
3948 .num_items = 4,
3949 .items = {
3950 { "Mic/Line", 0x0 },
3951 { "CD", 0x4 },
3952 { "Headphone", 0x2 },
3953 { "Mixer", 0x5 },
3954 },
3955 },
3956
Jonathan Woithea9430dd2005-09-16 19:12:48 +02003957};
3958
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003959/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
3960 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003961 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02003962static struct hda_input_mux alc260_acer_capture_sources[2] = {
3963 {
3964 .num_items = 4,
3965 .items = {
3966 { "Mic", 0x0 },
3967 { "Line", 0x2 },
3968 { "CD", 0x4 },
3969 { "Headphone", 0x5 },
3970 },
3971 },
3972 {
3973 .num_items = 5,
3974 .items = {
3975 { "Mic", 0x0 },
3976 { "Line", 0x2 },
3977 { "CD", 0x4 },
3978 { "Headphone", 0x6 },
3979 { "Mixer", 0x5 },
3980 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01003981 },
3982};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003983/*
3984 * This is just place-holder, so there's something for alc_build_pcms to look
3985 * at when it calculates the maximum number of channels. ALC260 has no mixer
3986 * element which allows changing the channel mode, so the verb list is
3987 * never used.
3988 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01003989static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003990 { 2, NULL },
3991};
3992
Kailang Yangdf694da2005-12-05 19:42:22 +01003993
3994/* Mixer combinations
3995 *
3996 * basic: base_output + input + pc_beep + capture
3997 * HP: base_output + input + capture_alt
3998 * HP_3013: hp_3013 + input + capture
3999 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004000 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01004001 */
4002
4003static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004004 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004005 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004006 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4007 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4008 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4009 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4010 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004011};
Kailang Yangdf694da2005-12-05 19:42:22 +01004012
4013static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004014 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4015 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4016 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4017 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4019 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4020 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
4021 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004022 { } /* end */
4023};
4024
Kailang Yangdf694da2005-12-05 19:42:22 +01004025static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
4026 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
4027 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
4028 { } /* end */
4029};
4030
Takashi Iwaibec15c32008-01-28 18:16:30 +01004031/* update HP, line and mono out pins according to the master switch */
4032static void alc260_hp_master_update(struct hda_codec *codec,
4033 hda_nid_t hp, hda_nid_t line,
4034 hda_nid_t mono)
4035{
4036 struct alc_spec *spec = codec->spec;
4037 unsigned int val = spec->master_sw ? PIN_HP : 0;
4038 /* change HP and line-out pins */
4039 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4040 val);
4041 snd_hda_codec_write(codec, 0x10, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4042 val);
4043 /* mono (speaker) depending on the HP jack sense */
4044 val = (val && !spec->jack_present) ? PIN_OUT : 0;
4045 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4046 val);
4047}
4048
4049static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
4050 struct snd_ctl_elem_value *ucontrol)
4051{
4052 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4053 struct alc_spec *spec = codec->spec;
4054 *ucontrol->value.integer.value = spec->master_sw;
4055 return 0;
4056}
4057
4058static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
4059 struct snd_ctl_elem_value *ucontrol)
4060{
4061 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4062 struct alc_spec *spec = codec->spec;
4063 int val = !!*ucontrol->value.integer.value;
4064 hda_nid_t hp, line, mono;
4065
4066 if (val == spec->master_sw)
4067 return 0;
4068 spec->master_sw = val;
4069 hp = (kcontrol->private_value >> 16) & 0xff;
4070 line = (kcontrol->private_value >> 8) & 0xff;
4071 mono = kcontrol->private_value & 0xff;
4072 alc260_hp_master_update(codec, hp, line, mono);
4073 return 1;
4074}
4075
4076static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
4077 {
4078 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4079 .name = "Master Playback Switch",
4080 .info = snd_ctl_boolean_mono_info,
4081 .get = alc260_hp_master_sw_get,
4082 .put = alc260_hp_master_sw_put,
4083 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
4084 },
4085 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4086 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
4087 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4088 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
4089 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
4090 HDA_OUTPUT),
4091 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4092 { } /* end */
4093};
4094
4095static struct hda_verb alc260_hp_unsol_verbs[] = {
4096 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4097 {},
4098};
4099
4100static void alc260_hp_automute(struct hda_codec *codec)
4101{
4102 struct alc_spec *spec = codec->spec;
4103 unsigned int present;
4104
4105 present = snd_hda_codec_read(codec, 0x10, 0,
4106 AC_VERB_GET_PIN_SENSE, 0);
4107 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4108 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
4109}
4110
4111static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
4112{
4113 if ((res >> 26) == ALC880_HP_EVENT)
4114 alc260_hp_automute(codec);
4115}
4116
Kailang Yangdf694da2005-12-05 19:42:22 +01004117static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01004118 {
4119 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4120 .name = "Master Playback Switch",
4121 .info = snd_ctl_boolean_mono_info,
4122 .get = alc260_hp_master_sw_get,
4123 .put = alc260_hp_master_sw_put,
4124 .private_value = (0x10 << 16) | (0x15 << 8) | 0x11
4125 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004126 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4127 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4128 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
4129 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
4130 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4131 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01004132 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4133 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02004134 { } /* end */
4135};
4136
Kailang Yang3f878302008-08-26 13:02:23 +02004137static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
4138 .ops = &snd_hda_bind_vol,
4139 .values = {
4140 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
4141 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
4142 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
4143 0
4144 },
4145};
4146
4147static struct hda_bind_ctls alc260_dc7600_bind_switch = {
4148 .ops = &snd_hda_bind_sw,
4149 .values = {
4150 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
4151 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
4152 0
4153 },
4154};
4155
4156static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
4157 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
4158 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
4159 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
4160 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
4161 { } /* end */
4162};
4163
Takashi Iwaibec15c32008-01-28 18:16:30 +01004164static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
4165 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4166 {},
4167};
4168
4169static void alc260_hp_3013_automute(struct hda_codec *codec)
4170{
4171 struct alc_spec *spec = codec->spec;
4172 unsigned int present;
4173
4174 present = snd_hda_codec_read(codec, 0x15, 0,
4175 AC_VERB_GET_PIN_SENSE, 0);
4176 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
4177 alc260_hp_master_update(codec, 0x10, 0x15, 0x11);
4178}
4179
4180static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
4181 unsigned int res)
4182{
4183 if ((res >> 26) == ALC880_HP_EVENT)
4184 alc260_hp_3013_automute(codec);
4185}
4186
Kailang Yang3f878302008-08-26 13:02:23 +02004187static void alc260_hp_3012_automute(struct hda_codec *codec)
4188{
4189 unsigned int present, bits;
4190
4191 present = snd_hda_codec_read(codec, 0x10, 0,
4192 AC_VERB_GET_PIN_SENSE, 0) & AC_PINSENSE_PRESENCE;
4193
4194 bits = present ? 0 : PIN_OUT;
4195 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4196 bits);
4197 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4198 bits);
4199 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
4200 bits);
4201}
4202
4203static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
4204 unsigned int res)
4205{
4206 if ((res >> 26) == ALC880_HP_EVENT)
4207 alc260_hp_3012_automute(codec);
4208}
4209
4210/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004211 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
4212 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004213static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004214 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004215 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004216 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004217 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4218 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4219 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
4220 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004221 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004222 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4223 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004224 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4225 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004226 { } /* end */
4227};
4228
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004229/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
4230 * versions of the ALC260 don't act on requests to enable mic bias from NID
4231 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
4232 * datasheet doesn't mention this restriction. At this stage it's not clear
4233 * whether this behaviour is intentional or is a hardware bug in chip
4234 * revisions available in early 2006. Therefore for now allow the
4235 * "Headphone Jack Mode" control to span all choices, but if it turns out
4236 * that the lack of mic bias for this NID is intentional we could change the
4237 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4238 *
4239 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
4240 * don't appear to make the mic bias available from the "line" jack, even
4241 * though the NID used for this jack (0x14) can supply it. The theory is
4242 * that perhaps Acer have included blocking capacitors between the ALC260
4243 * and the output jack. If this turns out to be the case for all such
4244 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
4245 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01004246 *
4247 * The C20x Tablet series have a mono internal speaker which is controlled
4248 * via the chip's Mono sum widget and pin complex, so include the necessary
4249 * controls for such models. On models without a "mono speaker" the control
4250 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004251 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004252static struct snd_kcontrol_new alc260_acer_mixer[] = {
4253 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4254 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004255 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004256 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01004257 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01004258 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01004259 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004260 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4261 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4262 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4263 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4264 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4265 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4266 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4267 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4268 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4269 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4270 { } /* end */
4271};
4272
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004273/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
4274 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
4275 */
4276static struct snd_kcontrol_new alc260_will_mixer[] = {
4277 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4278 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4280 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4281 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4282 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4283 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4284 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4285 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4286 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4287 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4288 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4289 { } /* end */
4290};
4291
4292/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
4293 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
4294 */
4295static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
4296 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4297 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
4298 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
4299 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
4300 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
4301 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
4302 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
4303 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
4304 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
4305 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
4306 { } /* end */
4307};
4308
Kailang Yangdf694da2005-12-05 19:42:22 +01004309/* capture mixer elements */
4310static struct snd_kcontrol_new alc260_capture_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004311 HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
4312 HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01004313 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
4314 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004315 {
4316 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
Kailang Yangdf694da2005-12-05 19:42:22 +01004317 /* The multiple "Capture Source" controls confuse alsamixer
4318 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004319 */
4320 /* .name = "Capture Source", */
4321 .name = "Input Source",
4322 .count = 2,
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004323 .info = alc_mux_enum_info,
4324 .get = alc_mux_enum_get,
4325 .put = alc_mux_enum_put,
4326 },
4327 { } /* end */
4328};
4329
Kailang Yangdf694da2005-12-05 19:42:22 +01004330static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
4331 HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
4332 HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
4333 {
4334 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4335 /* The multiple "Capture Source" controls confuse alsamixer
4336 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01004337 */
4338 /* .name = "Capture Source", */
4339 .name = "Input Source",
4340 .count = 1,
4341 .info = alc_mux_enum_info,
4342 .get = alc_mux_enum_get,
4343 .put = alc_mux_enum_put,
4344 },
4345 { } /* end */
4346};
4347
4348/*
4349 * initialization verbs
4350 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004351static struct hda_verb alc260_init_verbs[] = {
4352 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004353 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004354 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02004355 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004356 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004357 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004358 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02004359 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004360 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02004361 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004362 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01004363 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004364 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02004365 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004366 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02004367 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004368 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02004369 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4370 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02004371 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004372 /* set connection select to line in (default select for this ADC) */
4373 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02004374 /* mute capture amp left and right */
4375 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4376 /* set connection select to line in (default select for this ADC) */
4377 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02004378 /* set vol=0 Line-Out mixer amp left and right */
4379 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4380 /* unmute pin widget amp left and right (no gain on this amp) */
4381 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4382 /* set vol=0 HP mixer amp left and right */
4383 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4384 /* unmute pin widget amp left and right (no gain on this amp) */
4385 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4386 /* set vol=0 Mono mixer amp left and right */
4387 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4388 /* unmute pin widget amp left and right (no gain on this amp) */
4389 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4390 /* unmute LINE-2 out pin */
4391 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004392 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4393 * Line In 2 = 0x03
4394 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004395 /* mute analog inputs */
4396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4400 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004401 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004402 /* mute Front out path */
4403 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4404 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4405 /* mute Headphone out path */
4406 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4407 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4408 /* mute Mono out path */
4409 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4410 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07004411 { }
4412};
4413
Takashi Iwai474167d2006-05-17 17:17:43 +02004414#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01004415static struct hda_verb alc260_hp_init_verbs[] = {
4416 /* Headphone and output */
4417 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4418 /* mono output */
4419 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4420 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4421 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4422 /* Mic2 (front panel) pin widget for input and vref at 80% */
4423 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4424 /* Line In pin widget for input */
4425 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4426 /* Line-2 pin widget for output */
4427 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4428 /* CD pin widget for input */
4429 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4430 /* unmute amp left and right */
4431 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4432 /* set connection select to line in (default select for this ADC) */
4433 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4434 /* unmute Line-Out mixer amp left and right (volume = 0) */
4435 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4436 /* mute pin widget amp left and right (no gain on this amp) */
4437 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4438 /* unmute HP mixer amp left and right (volume = 0) */
4439 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4440 /* mute pin widget amp left and right (no gain on this amp) */
4441 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004442 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4443 * Line In 2 = 0x03
4444 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004445 /* mute analog inputs */
4446 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4447 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4448 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4449 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004451 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4452 /* Unmute Front out path */
4453 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4454 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4455 /* Unmute Headphone out path */
4456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4457 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4458 /* Unmute Mono out path */
4459 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4460 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4461 { }
4462};
Takashi Iwai474167d2006-05-17 17:17:43 +02004463#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01004464
4465static struct hda_verb alc260_hp_3013_init_verbs[] = {
4466 /* Line out and output */
4467 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4468 /* mono output */
4469 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
4470 /* Mic1 (rear panel) pin widget for input and vref at 80% */
4471 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4472 /* Mic2 (front panel) pin widget for input and vref at 80% */
4473 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
4474 /* Line In pin widget for input */
4475 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4476 /* Headphone pin widget for output */
4477 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
4478 /* CD pin widget for input */
4479 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
4480 /* unmute amp left and right */
4481 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
4482 /* set connection select to line in (default select for this ADC) */
4483 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
4484 /* unmute Line-Out mixer amp left and right (volume = 0) */
4485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4486 /* mute pin widget amp left and right (no gain on this amp) */
4487 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
4488 /* unmute HP mixer amp left and right (volume = 0) */
4489 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
4490 /* mute pin widget amp left and right (no gain on this amp) */
4491 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004492 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
4493 * Line In 2 = 0x03
4494 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02004495 /* mute analog inputs */
4496 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4498 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4499 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4500 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01004501 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
4502 /* Unmute Front out path */
4503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4504 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4505 /* Unmute Headphone out path */
4506 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4507 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4508 /* Unmute Mono out path */
4509 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
4510 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
4511 { }
4512};
4513
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004514/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004515 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
4516 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004517 */
4518static struct hda_verb alc260_fujitsu_init_verbs[] = {
4519 /* Disable all GPIOs */
4520 {0x01, AC_VERB_SET_GPIO_MASK, 0},
4521 /* Internal speaker is connected to headphone pin */
4522 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4523 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
4524 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004525 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
4526 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4527 /* Ensure all other unused pins are disabled and muted. */
4528 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4529 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004530 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004531 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004532 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004533 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4534 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4535 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004536
Jonathan Woithef7ace402006-02-28 11:46:14 +01004537 /* Disable digital (SPDIF) pins */
4538 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4539 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004540
Kailang Yangea1fb292008-08-26 12:58:38 +02004541 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01004542 * when acting as an output.
4543 */
4544 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4545
4546 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01004547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4548 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4549 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4550 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4551 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4552 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4553 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4554 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4555 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004556
Jonathan Woithef7ace402006-02-28 11:46:14 +01004557 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
4558 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4559 /* Unmute Line1 pin widget output buffer since it starts as an output.
4560 * If the pin mode is changed by the user the pin mode control will
4561 * take care of enabling the pin's input/output buffers as needed.
4562 * Therefore there's no need to enable the input buffer at this
4563 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004564 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004565 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02004566 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004567 * mixer ctrl)
4568 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01004569 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004570
Jonathan Woithef7ace402006-02-28 11:46:14 +01004571 /* Mute capture amp left and right */
4572 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02004573 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01004574 * in (on mic1 pin)
4575 */
4576 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004577
Jonathan Woithef7ace402006-02-28 11:46:14 +01004578 /* Do the same for the second ADC: mute capture input amp and
4579 * set ADC connection to line in (on mic1 pin)
4580 */
4581 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4582 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004583
Jonathan Woithef7ace402006-02-28 11:46:14 +01004584 /* Mute all inputs to mixer widget (even unconnected ones) */
4585 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4586 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4587 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4588 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4589 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4590 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4591 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4592 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01004593
4594 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02004595};
4596
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004597/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
4598 * similar laptops (adapted from Fujitsu init verbs).
4599 */
4600static struct hda_verb alc260_acer_init_verbs[] = {
4601 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
4602 * the headphone jack. Turn this on and rely on the standard mute
4603 * methods whenever the user wants to turn these outputs off.
4604 */
4605 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4606 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4607 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
4608 /* Internal speaker/Headphone jack is connected to Line-out pin */
4609 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4610 /* Internal microphone/Mic jack is connected to Mic1 pin */
4611 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
4612 /* Line In jack is connected to Line1 pin */
4613 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01004614 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
4615 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004616 /* Ensure all other unused pins are disabled and muted. */
4617 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4618 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004619 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4620 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4621 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
4622 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4623 /* Disable digital (SPDIF) pins */
4624 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4625 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4626
Kailang Yangea1fb292008-08-26 12:58:38 +02004627 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004628 * bus when acting as outputs.
4629 */
4630 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4631 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4632
4633 /* Start with output sum widgets muted and their output gains at min */
4634 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4635 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4637 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4638 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4639 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4640 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4641 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4642 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4643
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004644 /* Unmute Line-out pin widget amp left and right
4645 * (no equiv mixer ctrl)
4646 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004647 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01004648 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
4649 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004650 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
4651 * inputs. If the pin mode is changed by the user the pin mode control
4652 * will take care of enabling the pin's input/output buffers as needed.
4653 * Therefore there's no need to enable the input buffer at this
4654 * stage.
4655 */
4656 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4657 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4658
4659 /* Mute capture amp left and right */
4660 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4661 /* Set ADC connection select to match default mixer setting - mic
4662 * (on mic1 pin)
4663 */
4664 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4665
4666 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004667 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004668 */
4669 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004670 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01004671
4672 /* Mute all inputs to mixer widget (even unconnected ones) */
4673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4677 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4678 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4679 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4680 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4681
4682 { }
4683};
4684
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004685static struct hda_verb alc260_will_verbs[] = {
4686 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4687 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
4688 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
4689 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4690 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4691 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
4692 {}
4693};
4694
4695static struct hda_verb alc260_replacer_672v_verbs[] = {
4696 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
4697 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
4698 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
4699
4700 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
4701 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
4702 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4703
4704 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4705 {}
4706};
4707
4708/* toggle speaker-output according to the hp-jack state */
4709static void alc260_replacer_672v_automute(struct hda_codec *codec)
4710{
4711 unsigned int present;
4712
4713 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
4714 present = snd_hda_codec_read(codec, 0x0f, 0,
4715 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
4716 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004717 snd_hda_codec_write_cache(codec, 0x01, 0,
4718 AC_VERB_SET_GPIO_DATA, 1);
4719 snd_hda_codec_write_cache(codec, 0x0f, 0,
4720 AC_VERB_SET_PIN_WIDGET_CONTROL,
4721 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004722 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004723 snd_hda_codec_write_cache(codec, 0x01, 0,
4724 AC_VERB_SET_GPIO_DATA, 0);
4725 snd_hda_codec_write_cache(codec, 0x0f, 0,
4726 AC_VERB_SET_PIN_WIDGET_CONTROL,
4727 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02004728 }
4729}
4730
4731static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
4732 unsigned int res)
4733{
4734 if ((res >> 26) == ALC880_HP_EVENT)
4735 alc260_replacer_672v_automute(codec);
4736}
4737
Kailang Yang3f878302008-08-26 13:02:23 +02004738static struct hda_verb alc260_hp_dc7600_verbs[] = {
4739 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
4740 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
4741 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4742 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
4743 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4744 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4745 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4746 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4747 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4748 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
4749 {}
4750};
4751
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004752/* Test configuration for debugging, modelled after the ALC880 test
4753 * configuration.
4754 */
4755#ifdef CONFIG_SND_DEBUG
4756static hda_nid_t alc260_test_dac_nids[1] = {
4757 0x02,
4758};
4759static hda_nid_t alc260_test_adc_nids[2] = {
4760 0x04, 0x05,
4761};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004762/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02004763 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004764 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01004765 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004766static struct hda_input_mux alc260_test_capture_sources[2] = {
4767 {
4768 .num_items = 7,
4769 .items = {
4770 { "MIC1 pin", 0x0 },
4771 { "MIC2 pin", 0x1 },
4772 { "LINE1 pin", 0x2 },
4773 { "LINE2 pin", 0x3 },
4774 { "CD pin", 0x4 },
4775 { "LINE-OUT pin", 0x5 },
4776 { "HP-OUT pin", 0x6 },
4777 },
4778 },
4779 {
4780 .num_items = 8,
4781 .items = {
4782 { "MIC1 pin", 0x0 },
4783 { "MIC2 pin", 0x1 },
4784 { "LINE1 pin", 0x2 },
4785 { "LINE2 pin", 0x3 },
4786 { "CD pin", 0x4 },
4787 { "Mixer", 0x5 },
4788 { "LINE-OUT pin", 0x6 },
4789 { "HP-OUT pin", 0x7 },
4790 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004791 },
4792};
4793static struct snd_kcontrol_new alc260_test_mixer[] = {
4794 /* Output driver widgets */
4795 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
4796 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
4797 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
4798 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
4799 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
4800 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
4801
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02004802 /* Modes for retasking pin widgets
4803 * Note: the ALC260 doesn't seem to act on requests to enable mic
4804 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
4805 * mention this restriction. At this stage it's not clear whether
4806 * this behaviour is intentional or is a hardware bug in chip
4807 * revisions available at least up until early 2006. Therefore for
4808 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
4809 * choices, but if it turns out that the lack of mic bias for these
4810 * NIDs is intentional we could change their modes from
4811 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
4812 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004813 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
4814 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
4815 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
4816 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
4817 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
4818 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
4819
4820 /* Loopback mixer controls */
4821 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
4822 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
4823 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
4824 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
4825 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
4826 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
4827 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
4828 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
4829 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
4830 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
4831 HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
4832 HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
4833 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
4834 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
4835 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
4836 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004837
4838 /* Controls for GPIO pins, assuming they are configured as outputs */
4839 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
4840 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
4841 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
4842 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
4843
Jonathan Woithe92621f12006-02-28 11:47:47 +01004844 /* Switches to allow the digital IO pins to be enabled. The datasheet
4845 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02004846 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01004847 */
4848 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
4849 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
4850
Jonathan Woithef8225f62008-01-08 12:16:54 +01004851 /* A switch allowing EAPD to be enabled. Some laptops seem to use
4852 * this output to turn on an external amplifier.
4853 */
4854 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
4855 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
4856
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004857 { } /* end */
4858};
4859static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01004860 /* Enable all GPIOs as outputs with an initial value of 0 */
4861 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
4862 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
4863 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
4864
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004865 /* Enable retasking pins as output, initially without power amp */
4866 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4867 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4869 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4870 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4871 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4872
Jonathan Woithe92621f12006-02-28 11:47:47 +01004873 /* Disable digital (SPDIF) pins initially, but users can enable
4874 * them via a mixer switch. In the case of SPDIF-out, this initverb
4875 * payload also sets the generation to 0, output to be in "consumer"
4876 * PCM format, copyright asserted, no pre-emphasis and no validity
4877 * control.
4878 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004879 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
4880 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
4881
Kailang Yangea1fb292008-08-26 12:58:38 +02004882 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004883 * OUT1 sum bus when acting as an output.
4884 */
4885 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
4886 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
4887 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
4888 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
4889
4890 /* Start with output sum widgets muted and their output gains at min */
4891 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4892 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4893 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4894 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4895 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4896 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4897 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4898 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4899 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4900
Jonathan Woithecdcd9262006-02-28 11:36:42 +01004901 /* Unmute retasking pin widget output buffers since the default
4902 * state appears to be output. As the pin mode is changed by the
4903 * user the pin mode control will take care of enabling the pin's
4904 * input/output buffers as needed.
4905 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004906 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4908 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4909 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4910 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4911 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4912 /* Also unmute the mono-out pin widget */
4913 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4914
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004915 /* Mute capture amp left and right */
4916 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01004917 /* Set ADC connection select to match default mixer setting (mic1
4918 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004919 */
4920 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
4921
4922 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01004923 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01004924 */
4925 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4926 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
4927
4928 /* Mute all inputs to mixer widget (even unconnected ones) */
4929 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
4930 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
4931 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
4932 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
4933 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
4934 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
4935 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
4936 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
4937
4938 { }
4939};
4940#endif
4941
Takashi Iwai63300792008-01-24 15:31:36 +01004942#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
4943#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07004944
Takashi Iwaia3bcba32005-12-06 19:05:29 +01004945#define alc260_pcm_digital_playback alc880_pcm_digital_playback
4946#define alc260_pcm_digital_capture alc880_pcm_digital_capture
4947
Kailang Yangdf694da2005-12-05 19:42:22 +01004948/*
4949 * for BIOS auto-configuration
4950 */
4951
4952static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
4953 const char *pfx)
4954{
4955 hda_nid_t nid_vol;
4956 unsigned long vol_val, sw_val;
4957 char name[32];
4958 int err;
4959
4960 if (nid >= 0x0f && nid < 0x11) {
4961 nid_vol = nid - 0x7;
4962 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4963 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4964 } else if (nid == 0x11) {
4965 nid_vol = nid - 0x7;
4966 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
4967 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
4968 } else if (nid >= 0x12 && nid <= 0x15) {
4969 nid_vol = 0x08;
4970 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
4971 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
4972 } else
4973 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02004974
Kailang Yangdf694da2005-12-05 19:42:22 +01004975 snprintf(name, sizeof(name), "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004976 err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
4977 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004978 return err;
4979 snprintf(name, sizeof(name), "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004980 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
4981 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01004982 return err;
4983 return 1;
4984}
4985
4986/* add playback controls from the parsed DAC table */
4987static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
4988 const struct auto_pin_cfg *cfg)
4989{
4990 hda_nid_t nid;
4991 int err;
4992
4993 spec->multiout.num_dacs = 1;
4994 spec->multiout.dac_nids = spec->private_dac_nids;
4995 spec->multiout.dac_nids[0] = 0x02;
4996
4997 nid = cfg->line_out_pins[0];
4998 if (nid) {
4999 err = alc260_add_playback_controls(spec, nid, "Front");
5000 if (err < 0)
5001 return err;
5002 }
5003
Takashi Iwai82bc9552006-03-21 11:24:42 +01005004 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005005 if (nid) {
5006 err = alc260_add_playback_controls(spec, nid, "Speaker");
5007 if (err < 0)
5008 return err;
5009 }
5010
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005011 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005012 if (nid) {
5013 err = alc260_add_playback_controls(spec, nid, "Headphone");
5014 if (err < 0)
5015 return err;
5016 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005017 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01005018}
5019
5020/* create playback/capture controls for input pins */
5021static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
5022 const struct auto_pin_cfg *cfg)
5023{
Kailang Yangdf694da2005-12-05 19:42:22 +01005024 struct hda_input_mux *imux = &spec->private_imux;
5025 int i, err, idx;
5026
5027 for (i = 0; i < AUTO_PIN_LAST; i++) {
5028 if (cfg->input_pins[i] >= 0x12) {
5029 idx = cfg->input_pins[i] - 0x12;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005030 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005031 auto_pin_cfg_labels[i], idx,
5032 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005033 if (err < 0)
5034 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005035 imux->items[imux->num_items].label =
5036 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005037 imux->items[imux->num_items].index = idx;
5038 imux->num_items++;
5039 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005040 if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
Kailang Yangdf694da2005-12-05 19:42:22 +01005041 idx = cfg->input_pins[i] - 0x09;
Takashi Iwai4a471b72005-12-07 13:56:29 +01005042 err = new_analog_input(spec, cfg->input_pins[i],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005043 auto_pin_cfg_labels[i], idx,
5044 0x07);
Kailang Yangdf694da2005-12-05 19:42:22 +01005045 if (err < 0)
5046 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005047 imux->items[imux->num_items].label =
5048 auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +01005049 imux->items[imux->num_items].index = idx;
5050 imux->num_items++;
5051 }
5052 }
5053 return 0;
5054}
5055
5056static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
5057 hda_nid_t nid, int pin_type,
5058 int sel_idx)
5059{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005060 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01005061 /* need the manual connection? */
5062 if (nid >= 0x12) {
5063 int idx = nid - 0x12;
5064 snd_hda_codec_write(codec, idx + 0x0b, 0,
5065 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01005066 }
5067}
5068
5069static void alc260_auto_init_multi_out(struct hda_codec *codec)
5070{
5071 struct alc_spec *spec = codec->spec;
5072 hda_nid_t nid;
5073
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005074 alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005075 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005076 if (nid) {
5077 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5078 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
5079 }
Kailang Yangea1fb292008-08-26 12:58:38 +02005080
Takashi Iwai82bc9552006-03-21 11:24:42 +01005081 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005082 if (nid)
5083 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
5084
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005085 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01005086 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005087 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005088}
Kailang Yangdf694da2005-12-05 19:42:22 +01005089
5090#define ALC260_PIN_CD_NID 0x16
5091static void alc260_auto_init_analog_input(struct hda_codec *codec)
5092{
5093 struct alc_spec *spec = codec->spec;
5094 int i;
5095
5096 for (i = 0; i < AUTO_PIN_LAST; i++) {
5097 hda_nid_t nid = spec->autocfg.input_pins[i];
5098 if (nid >= 0x12) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005099 snd_hda_codec_write(codec, nid, 0,
5100 AC_VERB_SET_PIN_WIDGET_CONTROL,
5101 i <= AUTO_PIN_FRONT_MIC ?
5102 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +01005103 if (nid != ALC260_PIN_CD_NID)
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005104 snd_hda_codec_write(codec, nid, 0,
5105 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01005106 AMP_OUT_MUTE);
5107 }
5108 }
5109}
5110
5111/*
5112 * generic initialization of ADC, input mixers and output mixers
5113 */
5114static struct hda_verb alc260_volume_init_verbs[] = {
5115 /*
5116 * Unmute ADC0-1 and set the default input to mic-in
5117 */
5118 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
5119 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5120 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
5121 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005122
Kailang Yangdf694da2005-12-05 19:42:22 +01005123 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
5124 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005125 * Note: PASD motherboards uses the Line In 2 as the input for
5126 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01005127 */
5128 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02005129 /* mute analog inputs */
5130 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5131 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5134 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01005135
5136 /*
5137 * Set up output mixers (0x08 - 0x0a)
5138 */
5139 /* set vol=0 to output mixers */
5140 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5141 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5142 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5143 /* set up input amps for analog loopback */
5144 /* Amp Indices: DAC = 0, mixer = 1 */
5145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5146 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5147 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5149 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5150 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02005151
Kailang Yangdf694da2005-12-05 19:42:22 +01005152 { }
5153};
5154
5155static int alc260_parse_auto_config(struct hda_codec *codec)
5156{
5157 struct alc_spec *spec = codec->spec;
5158 unsigned int wcap;
5159 int err;
5160 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
5161
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005162 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5163 alc260_ignore);
5164 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005165 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005166 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
5167 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01005168 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005169 if (!spec->kctl_alloc)
Kailang Yangdf694da2005-12-05 19:42:22 +01005170 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005171 err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
5172 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01005173 return err;
5174
5175 spec->multiout.max_channels = 2;
5176
5177 if (spec->autocfg.dig_out_pin)
5178 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
5179 if (spec->kctl_alloc)
5180 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
5181
5182 spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
5183
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005184 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01005185 spec->input_mux = &spec->private_imux;
5186
5187 /* check whether NID 0x04 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01005188 wcap = get_wcaps(codec, 0x04);
Kailang Yangdf694da2005-12-05 19:42:22 +01005189 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
Takashi Iwai67ebcb02008-02-19 15:03:57 +01005190 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Kailang Yangdf694da2005-12-05 19:42:22 +01005191 spec->adc_nids = alc260_adc_nids_alt;
5192 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
5193 spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005194 } else {
5195 spec->adc_nids = alc260_adc_nids;
5196 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
5197 spec->mixers[spec->num_mixers] = alc260_capture_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01005198 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01005199 spec->num_mixers++;
Kailang Yangdf694da2005-12-05 19:42:22 +01005200
5201 return 1;
5202}
5203
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005204/* additional initialization for auto-configuration model */
5205static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01005206{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005207 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005208 alc260_auto_init_multi_out(codec);
5209 alc260_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005210 if (spec->unsol_event)
5211 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01005212}
5213
Takashi Iwaicb53c622007-08-10 17:21:45 +02005214#ifdef CONFIG_SND_HDA_POWER_SAVE
5215static struct hda_amp_list alc260_loopbacks[] = {
5216 { 0x07, HDA_INPUT, 0 },
5217 { 0x07, HDA_INPUT, 1 },
5218 { 0x07, HDA_INPUT, 2 },
5219 { 0x07, HDA_INPUT, 3 },
5220 { 0x07, HDA_INPUT, 4 },
5221 { } /* end */
5222};
5223#endif
5224
Kailang Yangdf694da2005-12-05 19:42:22 +01005225/*
5226 * ALC260 configurations
5227 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005228static const char *alc260_models[ALC260_MODEL_LAST] = {
5229 [ALC260_BASIC] = "basic",
5230 [ALC260_HP] = "hp",
5231 [ALC260_HP_3013] = "hp-3013",
5232 [ALC260_FUJITSU_S702X] = "fujitsu",
5233 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005234 [ALC260_WILL] = "will",
5235 [ALC260_REPLACER_672V] = "replacer",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005236#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005237 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005238#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005239 [ALC260_AUTO] = "auto",
5240};
5241
5242static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01005243 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005244 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Takashi Iwai9720b712007-03-13 21:46:23 +01005245 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwaia8a5d062007-03-15 15:10:28 +01005246 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005247 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02005248 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02005249 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005250 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
5251 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
5252 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
5253 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
5254 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
5255 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
5256 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
5257 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
5258 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005259 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01005260 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02005261 {}
5262};
5263
Kailang Yangdf694da2005-12-05 19:42:22 +01005264static struct alc_config_preset alc260_presets[] = {
5265 [ALC260_BASIC] = {
5266 .mixers = { alc260_base_output_mixer,
5267 alc260_input_mixer,
5268 alc260_pc_beep_mixer,
5269 alc260_capture_mixer },
5270 .init_verbs = { alc260_init_verbs },
5271 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5272 .dac_nids = alc260_dac_nids,
5273 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5274 .adc_nids = alc260_adc_nids,
5275 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5276 .channel_mode = alc260_modes,
5277 .input_mux = &alc260_capture_source,
5278 },
5279 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005280 .mixers = { alc260_hp_output_mixer,
Kailang Yangdf694da2005-12-05 19:42:22 +01005281 alc260_input_mixer,
5282 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005283 .init_verbs = { alc260_init_verbs,
5284 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005285 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5286 .dac_nids = alc260_dac_nids,
5287 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5288 .adc_nids = alc260_hp_adc_nids,
5289 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5290 .channel_mode = alc260_modes,
5291 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005292 .unsol_event = alc260_hp_unsol_event,
5293 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005294 },
Kailang Yang3f878302008-08-26 13:02:23 +02005295 [ALC260_HP_DC7600] = {
5296 .mixers = { alc260_hp_dc7600_mixer,
5297 alc260_input_mixer,
5298 alc260_capture_alt_mixer },
5299 .init_verbs = { alc260_init_verbs,
5300 alc260_hp_dc7600_verbs },
5301 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5302 .dac_nids = alc260_dac_nids,
5303 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5304 .adc_nids = alc260_hp_adc_nids,
5305 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5306 .channel_mode = alc260_modes,
5307 .input_mux = &alc260_capture_source,
5308 .unsol_event = alc260_hp_3012_unsol_event,
5309 .init_hook = alc260_hp_3012_automute,
5310 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005311 [ALC260_HP_3013] = {
5312 .mixers = { alc260_hp_3013_mixer,
5313 alc260_input_mixer,
5314 alc260_capture_alt_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01005315 .init_verbs = { alc260_hp_3013_init_verbs,
5316 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01005317 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5318 .dac_nids = alc260_dac_nids,
5319 .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
5320 .adc_nids = alc260_hp_adc_nids,
5321 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5322 .channel_mode = alc260_modes,
5323 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005324 .unsol_event = alc260_hp_3013_unsol_event,
5325 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01005326 },
5327 [ALC260_FUJITSU_S702X] = {
5328 .mixers = { alc260_fujitsu_mixer,
5329 alc260_capture_mixer },
5330 .init_verbs = { alc260_fujitsu_init_verbs },
5331 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5332 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005333 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5334 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01005335 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5336 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005337 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
5338 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01005339 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005340 [ALC260_ACER] = {
5341 .mixers = { alc260_acer_mixer,
5342 alc260_capture_mixer },
5343 .init_verbs = { alc260_acer_init_verbs },
5344 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5345 .dac_nids = alc260_dac_nids,
5346 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
5347 .adc_nids = alc260_dual_adc_nids,
5348 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5349 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005350 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
5351 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005352 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005353 [ALC260_WILL] = {
5354 .mixers = { alc260_will_mixer,
5355 alc260_capture_mixer },
5356 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
5357 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5358 .dac_nids = alc260_dac_nids,
5359 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5360 .adc_nids = alc260_adc_nids,
5361 .dig_out_nid = ALC260_DIGOUT_NID,
5362 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5363 .channel_mode = alc260_modes,
5364 .input_mux = &alc260_capture_source,
5365 },
5366 [ALC260_REPLACER_672V] = {
5367 .mixers = { alc260_replacer_672v_mixer,
5368 alc260_capture_mixer },
5369 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
5370 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
5371 .dac_nids = alc260_dac_nids,
5372 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
5373 .adc_nids = alc260_adc_nids,
5374 .dig_out_nid = ALC260_DIGOUT_NID,
5375 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5376 .channel_mode = alc260_modes,
5377 .input_mux = &alc260_capture_source,
5378 .unsol_event = alc260_replacer_672v_unsol_event,
5379 .init_hook = alc260_replacer_672v_automute,
5380 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005381#ifdef CONFIG_SND_DEBUG
5382 [ALC260_TEST] = {
5383 .mixers = { alc260_test_mixer,
5384 alc260_capture_mixer },
5385 .init_verbs = { alc260_test_init_verbs },
5386 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
5387 .dac_nids = alc260_test_dac_nids,
5388 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
5389 .adc_nids = alc260_test_adc_nids,
5390 .num_channel_mode = ARRAY_SIZE(alc260_modes),
5391 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005392 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
5393 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01005394 },
5395#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01005396};
5397
Linus Torvalds1da177e2005-04-16 15:20:36 -07005398static int patch_alc260(struct hda_codec *codec)
5399{
5400 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01005401 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005402
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005403 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005404 if (spec == NULL)
5405 return -ENOMEM;
5406
5407 codec->spec = spec;
5408
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005409 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
5410 alc260_models,
5411 alc260_cfg_tbl);
5412 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005413 snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
5414 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005415 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02005416 }
5417
Kailang Yangdf694da2005-12-05 19:42:22 +01005418 if (board_config == ALC260_AUTO) {
5419 /* automatic parse from the BIOS config */
5420 err = alc260_parse_auto_config(codec);
5421 if (err < 0) {
5422 alc_free(codec);
5423 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005424 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005425 printk(KERN_INFO
5426 "hda_codec: Cannot set up configuration "
5427 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01005428 board_config = ALC260_BASIC;
5429 }
Takashi Iwai16ded522005-06-10 19:58:24 +02005430 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07005431
Kailang Yangdf694da2005-12-05 19:42:22 +01005432 if (board_config != ALC260_AUTO)
5433 setup_preset(spec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005434
5435 spec->stream_name_analog = "ALC260 Analog";
5436 spec->stream_analog_playback = &alc260_pcm_analog_playback;
5437 spec->stream_analog_capture = &alc260_pcm_analog_capture;
5438
Takashi Iwaia3bcba32005-12-06 19:05:29 +01005439 spec->stream_name_digital = "ALC260 Digital";
5440 spec->stream_digital_playback = &alc260_pcm_digital_playback;
5441 spec->stream_digital_capture = &alc260_pcm_digital_capture;
5442
Takashi Iwai2134ea42008-01-10 16:53:55 +01005443 spec->vmaster_nid = 0x08;
5444
Linus Torvalds1da177e2005-04-16 15:20:36 -07005445 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01005446 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005447 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005448#ifdef CONFIG_SND_HDA_POWER_SAVE
5449 if (!spec->loopback.amplist)
5450 spec->loopback.amplist = alc260_loopbacks;
5451#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005452
5453 return 0;
5454}
5455
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005456
Linus Torvalds1da177e2005-04-16 15:20:36 -07005457/*
5458 * ALC882 support
5459 *
5460 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
5461 * configuration. Each pin widget can choose any input DACs and a mixer.
5462 * Each ADC is connected from a mixer of all inputs. This makes possible
5463 * 6-channel independent captures.
5464 *
5465 * In addition, an independent DAC for the multi-playback (not used in this
5466 * driver yet).
5467 */
Kailang Yangdf694da2005-12-05 19:42:22 +01005468#define ALC882_DIGOUT_NID 0x06
5469#define ALC882_DIGIN_NID 0x0a
Linus Torvalds1da177e2005-04-16 15:20:36 -07005470
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005471static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005472 { 8, NULL }
5473};
5474
5475static hda_nid_t alc882_dac_nids[4] = {
5476 /* front, rear, clfe, rear_surr */
5477 0x02, 0x03, 0x04, 0x05
5478};
5479
Kailang Yangdf694da2005-12-05 19:42:22 +01005480/* identical with ALC880 */
5481#define alc882_adc_nids alc880_adc_nids
5482#define alc882_adc_nids_alt alc880_adc_nids_alt
Linus Torvalds1da177e2005-04-16 15:20:36 -07005483
Takashi Iwaie1406342008-02-11 18:32:32 +01005484static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
5485static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
5486
Linus Torvalds1da177e2005-04-16 15:20:36 -07005487/* input MUX */
5488/* FIXME: should be a matrix-type input source selection */
5489
5490static struct hda_input_mux alc882_capture_source = {
5491 .num_items = 4,
5492 .items = {
5493 { "Mic", 0x0 },
5494 { "Front Mic", 0x1 },
5495 { "Line", 0x2 },
5496 { "CD", 0x4 },
5497 },
5498};
Linus Torvalds1da177e2005-04-16 15:20:36 -07005499#define alc882_mux_enum_info alc_mux_enum_info
5500#define alc882_mux_enum_get alc_mux_enum_get
5501
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005502static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
5503 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005504{
5505 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5506 struct alc_spec *spec = codec->spec;
5507 const struct hda_input_mux *imux = spec->input_mux;
5508 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwai88c71a92008-02-14 17:27:17 +01005509 hda_nid_t nid = spec->capsrc_nids ?
5510 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Linus Torvalds1da177e2005-04-16 15:20:36 -07005511 unsigned int *cur_val = &spec->cur_mux[adc_idx];
5512 unsigned int i, idx;
5513
5514 idx = ucontrol->value.enumerated.item[0];
5515 if (idx >= imux->num_items)
5516 idx = imux->num_items - 1;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005517 if (*cur_val == idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005518 return 0;
5519 for (i = 0; i < imux->num_items; i++) {
Takashi Iwai47fd8302007-08-10 17:11:07 +02005520 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
5521 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
Takashi Iwai82beb8f2007-08-10 17:09:26 +02005522 imux->items[i].index,
Takashi Iwai47fd8302007-08-10 17:11:07 +02005523 HDA_AMP_MUTE, v);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005524 }
5525 *cur_val = idx;
5526 return 1;
5527}
5528
Kailang Yangdf694da2005-12-05 19:42:22 +01005529/*
Kailang Yang272a5272007-05-14 11:00:38 +02005530 * 2ch mode
5531 */
5532static struct hda_verb alc882_3ST_ch2_init[] = {
5533 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
5534 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5535 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5536 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
5537 { } /* end */
5538};
5539
5540/*
5541 * 6ch mode
5542 */
5543static struct hda_verb alc882_3ST_ch6_init[] = {
5544 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5545 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5546 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
5547 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5548 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
5549 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5550 { } /* end */
5551};
5552
5553static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
5554 { 2, alc882_3ST_ch2_init },
5555 { 6, alc882_3ST_ch6_init },
5556};
5557
5558/*
Kailang Yangdf694da2005-12-05 19:42:22 +01005559 * 6ch mode
5560 */
5561static struct hda_verb alc882_sixstack_ch6_init[] = {
5562 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
5563 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5564 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5565 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5566 { } /* end */
5567};
5568
5569/*
5570 * 8ch mode
5571 */
5572static struct hda_verb alc882_sixstack_ch8_init[] = {
5573 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5574 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5575 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5576 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5577 { } /* end */
5578};
5579
5580static struct hda_channel_mode alc882_sixstack_modes[2] = {
5581 { 6, alc882_sixstack_ch6_init },
5582 { 8, alc882_sixstack_ch8_init },
5583};
5584
Takashi Iwai87350ad2007-08-16 18:19:38 +02005585/*
5586 * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
5587 */
5588
5589/*
5590 * 2ch mode
5591 */
5592static struct hda_verb alc885_mbp_ch2_init[] = {
5593 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
5594 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5595 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5596 { } /* end */
5597};
5598
5599/*
5600 * 6ch mode
5601 */
5602static struct hda_verb alc885_mbp_ch6_init[] = {
5603 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
5604 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5605 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
5606 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5607 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
5608 { } /* end */
5609};
5610
5611static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
5612 { 2, alc885_mbp_ch2_init },
5613 { 6, alc885_mbp_ch6_init },
5614};
5615
5616
Linus Torvalds1da177e2005-04-16 15:20:36 -07005617/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
5618 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
5619 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005620static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005621 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005622 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005623 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005624 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005625 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
5626 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005627 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
5628 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02005629 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005630 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005631 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5633 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5634 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5635 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005637 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005638 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5639 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01005640 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005641 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
5642 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5643 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005644 { } /* end */
5645};
5646
Takashi Iwai87350ad2007-08-16 18:19:38 +02005647static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01005648 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5649 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
5650 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT),
5651 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
5652 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5653 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005654 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
5655 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01005656 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02005657 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
5658 { } /* end */
5659};
Kailang Yangbdd148a2007-05-08 15:19:08 +02005660static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
5661 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5662 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5663 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5664 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5665 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5666 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5668 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5669 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5670 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5671 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5672 { } /* end */
5673};
5674
Kailang Yang272a5272007-05-14 11:00:38 +02005675static struct snd_kcontrol_new alc882_targa_mixer[] = {
5676 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5677 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5678 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
5679 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5680 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5681 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5682 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5683 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5684 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005685 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005686 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
5687 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005688 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005689 { } /* end */
5690};
5691
5692/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
5693 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
5694 */
5695static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
5696 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5697 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
5698 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5699 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
5700 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5701 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5702 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5703 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5704 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
5705 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
5706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02005708 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02005709 { } /* end */
5710};
5711
Takashi Iwai914759b2007-09-06 14:52:04 +02005712static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
5713 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5714 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5715 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
5716 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
5717 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
5718 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
5719 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
5720 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
5721 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
5722 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
5723 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
5724 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
5725 { } /* end */
5726};
5727
Kailang Yangdf694da2005-12-05 19:42:22 +01005728static struct snd_kcontrol_new alc882_chmode_mixer[] = {
5729 {
5730 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5731 .name = "Channel Mode",
5732 .info = alc_ch_mode_info,
5733 .get = alc_ch_mode_get,
5734 .put = alc_ch_mode_put,
5735 },
5736 { } /* end */
5737};
5738
Linus Torvalds1da177e2005-04-16 15:20:36 -07005739static struct hda_verb alc882_init_verbs[] = {
5740 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005741 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5742 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5743 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005744 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005745 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5746 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5747 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005748 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005749 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5750 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5751 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005752 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02005753 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5754 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5755 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005756
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005757 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005758 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005759 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005760 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005761 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005762 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005763 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005764 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005765 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005766 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005767 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005768 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005769 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02005770 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02005771 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005772 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005773 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005774 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005775 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5776 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005777 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005778 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5779 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005780 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005781 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5782 /* Line-2 In: Headphone output (output 0 - 0x0c) */
5783 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5784 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5785 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005786 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005787 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005788
5789 /* FIXME: use matrix-type input source selection */
5790 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5791 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Takashi Iwai05acb862005-06-10 19:50:25 +02005792 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5793 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5794 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5795 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005796 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005797 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5798 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5799 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5800 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005801 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02005802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5804 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5805 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5806 /* ADC1: mute amp left and right */
5807 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005808 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005809 /* ADC2: mute amp left and right */
5810 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005811 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02005812 /* ADC3: mute amp left and right */
5813 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02005814 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005815
5816 { }
5817};
5818
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005819static struct hda_verb alc882_eapd_verbs[] = {
5820 /* change to EAPD mode */
5821 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01005822 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005823 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02005824};
5825
Tobin Davis9102cd12006-12-15 10:02:12 +01005826/* Mac Pro test */
5827static struct snd_kcontrol_new alc882_macpro_mixer[] = {
5828 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
5829 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
5830 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
5831 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
5832 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
5833 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
5834 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
5835 { } /* end */
5836};
5837
5838static struct hda_verb alc882_macpro_init_verbs[] = {
5839 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5842 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5843 /* Front Pin: output 0 (0x0c) */
5844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5845 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5846 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5847 /* Front Mic pin: input vref at 80% */
5848 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5849 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5850 /* Speaker: output */
5851 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5852 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5853 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
5854 /* Headphone output (output 0 - 0x0c) */
5855 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5856 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5857 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5858
5859 /* FIXME: use matrix-type input source selection */
5860 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5861 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5866 /* Input mixer2 */
5867 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5868 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5869 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5870 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5871 /* Input mixer3 */
5872 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5873 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5874 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5876 /* ADC1: mute amp left and right */
5877 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5878 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5879 /* ADC2: mute amp left and right */
5880 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5881 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5882 /* ADC3: mute amp left and right */
5883 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5884 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5885
5886 { }
5887};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005888
Takashi Iwai87350ad2007-08-16 18:19:38 +02005889/* Macbook Pro rev3 */
5890static struct hda_verb alc885_mbp3_init_verbs[] = {
5891 /* Front mixer: unmute input/output amp left and right (volume = 0) */
5892 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5893 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5894 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5895 /* Rear mixer */
5896 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
5897 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5898 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
5899 /* Front Pin: output 0 (0x0c) */
5900 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5901 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5902 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5903 /* HP Pin: output 0 (0x0d) */
5904 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
5905 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5906 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
5907 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5908 /* Mic (rear) pin: input vref at 80% */
5909 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5910 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5911 /* Front Mic pin: input vref at 80% */
5912 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5913 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5914 /* Line In pin: use output 1 when in LineOut mode */
5915 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
5916 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5917 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
5918
5919 /* FIXME: use matrix-type input source selection */
5920 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
5921 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
5922 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5923 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5924 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5925 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5926 /* Input mixer2 */
5927 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5928 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5929 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5930 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5931 /* Input mixer3 */
5932 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
5933 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
5934 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
5935 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
5936 /* ADC1: mute amp left and right */
5937 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5938 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
5939 /* ADC2: mute amp left and right */
5940 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5941 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
5942 /* ADC3: mute amp left and right */
5943 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
5944 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
5945
5946 { }
5947};
5948
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005949/* iMac 24 mixer. */
5950static struct snd_kcontrol_new alc885_imac24_mixer[] = {
5951 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
5952 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
5953 { } /* end */
5954};
5955
5956/* iMac 24 init verbs. */
5957static struct hda_verb alc885_imac24_init_verbs[] = {
5958 /* Internal speakers: output 0 (0x0c) */
5959 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5960 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5961 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
5962 /* Internal speakers: output 0 (0x0c) */
5963 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
5964 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5965 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
5966 /* Headphone: output 0 (0x0c) */
5967 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
5968 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
5969 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
5970 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
5971 /* Front Mic: input vref at 80% */
5972 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
5973 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
5974 { }
5975};
5976
5977/* Toggle speaker-output according to the hp-jack state */
5978static void alc885_imac24_automute(struct hda_codec *codec)
5979{
5980 unsigned int present;
5981
5982 present = snd_hda_codec_read(codec, 0x14, 0,
5983 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02005984 snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
5985 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
5986 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
5987 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Nicola Fagnanic54728d2007-07-19 23:28:52 +02005988}
5989
5990/* Processes unsolicited events. */
5991static void alc885_imac24_unsol_event(struct hda_codec *codec,
5992 unsigned int res)
5993{
5994 /* Headphone insertion or removal. */
5995 if ((res >> 26) == ALC880_HP_EVENT)
5996 alc885_imac24_automute(codec);
5997}
5998
Takashi Iwai87350ad2007-08-16 18:19:38 +02005999static void alc885_mbp3_automute(struct hda_codec *codec)
6000{
6001 unsigned int present;
6002
6003 present = snd_hda_codec_read(codec, 0x15, 0,
6004 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
6005 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
6006 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
6007 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
6008 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
6009
6010}
6011static void alc885_mbp3_unsol_event(struct hda_codec *codec,
6012 unsigned int res)
6013{
6014 /* Headphone insertion or removal. */
6015 if ((res >> 26) == ALC880_HP_EVENT)
6016 alc885_mbp3_automute(codec);
6017}
6018
6019
Kailang Yang272a5272007-05-14 11:00:38 +02006020static struct hda_verb alc882_targa_verbs[] = {
6021 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6022 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6023
6024 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6025 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006026
Kailang Yang272a5272007-05-14 11:00:38 +02006027 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6028 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6029 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6030
6031 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6032 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
6033 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
6034 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
6035 { } /* end */
6036};
6037
6038/* toggle speaker-output according to the hp-jack state */
6039static void alc882_targa_automute(struct hda_codec *codec)
6040{
6041 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02006042
Kailang Yang272a5272007-05-14 11:00:38 +02006043 present = snd_hda_codec_read(codec, 0x14, 0,
6044 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02006045 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
6046 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006047 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
6048 present ? 1 : 3);
Kailang Yang272a5272007-05-14 11:00:38 +02006049}
6050
6051static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
6052{
6053 /* Looks like the unsol event is incompatible with the standard
6054 * definition. 4bit tag is placed at 26 bit!
6055 */
6056 if (((res >> 26) == ALC880_HP_EVENT)) {
6057 alc882_targa_automute(codec);
6058 }
6059}
6060
6061static struct hda_verb alc882_asus_a7j_verbs[] = {
6062 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6063 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6064
6065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6066 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6067 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006068
Kailang Yang272a5272007-05-14 11:00:38 +02006069 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6070 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6071 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6072
6073 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6074 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6075 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6076 { } /* end */
6077};
6078
Takashi Iwai914759b2007-09-06 14:52:04 +02006079static struct hda_verb alc882_asus_a7m_verbs[] = {
6080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6082
6083 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6085 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02006086
Takashi Iwai914759b2007-09-06 14:52:04 +02006087 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6088 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6089 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
6090
6091 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
6092 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
6093 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
6094 { } /* end */
6095};
6096
Tobin Davis9102cd12006-12-15 10:02:12 +01006097static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
6098{
6099 unsigned int gpiostate, gpiomask, gpiodir;
6100
6101 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
6102 AC_VERB_GET_GPIO_DATA, 0);
6103
6104 if (!muted)
6105 gpiostate |= (1 << pin);
6106 else
6107 gpiostate &= ~(1 << pin);
6108
6109 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
6110 AC_VERB_GET_GPIO_MASK, 0);
6111 gpiomask |= (1 << pin);
6112
6113 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
6114 AC_VERB_GET_GPIO_DIRECTION, 0);
6115 gpiodir |= (1 << pin);
6116
6117
6118 snd_hda_codec_write(codec, codec->afg, 0,
6119 AC_VERB_SET_GPIO_MASK, gpiomask);
6120 snd_hda_codec_write(codec, codec->afg, 0,
6121 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
6122
6123 msleep(1);
6124
6125 snd_hda_codec_write(codec, codec->afg, 0,
6126 AC_VERB_SET_GPIO_DATA, gpiostate);
6127}
6128
Takashi Iwai7debbe52007-08-16 15:01:03 +02006129/* set up GPIO at initialization */
6130static void alc885_macpro_init_hook(struct hda_codec *codec)
6131{
6132 alc882_gpio_mute(codec, 0, 0);
6133 alc882_gpio_mute(codec, 1, 0);
6134}
6135
6136/* set up GPIO and update auto-muting at initialization */
6137static void alc885_imac24_init_hook(struct hda_codec *codec)
6138{
6139 alc885_macpro_init_hook(codec);
6140 alc885_imac24_automute(codec);
6141}
6142
Kailang Yangdf694da2005-12-05 19:42:22 +01006143/*
6144 * generic initialization of ADC, input mixers and output mixers
6145 */
6146static struct hda_verb alc882_auto_init_verbs[] = {
6147 /*
6148 * Unmute ADC0-2 and set the default input to mic-in
6149 */
6150 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
6151 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6152 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
6153 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6154 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
6155 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6156
Takashi Iwaicb53c622007-08-10 17:21:45 +02006157 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01006158 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006159 * Note: PASD motherboards uses the Line In 2 as the input for
6160 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006161 */
6162 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006163 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6164 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6165 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6166 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6167 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006168
6169 /*
6170 * Set up output mixers (0x0c - 0x0f)
6171 */
6172 /* set vol=0 to output mixers */
6173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6174 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6175 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6176 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6177 /* set up input amps for analog loopback */
6178 /* Amp Indices: DAC = 0, mixer = 1 */
6179 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6180 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6181 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6182 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6183 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6184 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6185 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6186 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6187 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6188 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6189
6190 /* FIXME: use matrix-type input source selection */
6191 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
6192 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
6193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6197 /* Input mixer2 */
6198 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6199 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6200 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6201 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6202 /* Input mixer3 */
6203 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6204 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
6205 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
6206 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
6207
6208 { }
6209};
6210
6211/* capture mixer elements */
6212static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
6213 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6214 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6215 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6216 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6217 {
6218 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6219 /* The multiple "Capture Source" controls confuse alsamixer
6220 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006221 */
6222 /* .name = "Capture Source", */
6223 .name = "Input Source",
6224 .count = 2,
6225 .info = alc882_mux_enum_info,
6226 .get = alc882_mux_enum_get,
6227 .put = alc882_mux_enum_put,
6228 },
6229 { } /* end */
6230};
6231
6232static struct snd_kcontrol_new alc882_capture_mixer[] = {
6233 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
6234 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
6235 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
6236 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
6237 HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
6238 HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
6239 {
6240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6241 /* The multiple "Capture Source" controls confuse alsamixer
6242 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +01006243 */
6244 /* .name = "Capture Source", */
6245 .name = "Input Source",
6246 .count = 3,
6247 .info = alc882_mux_enum_info,
6248 .get = alc882_mux_enum_get,
6249 .put = alc882_mux_enum_put,
6250 },
6251 { } /* end */
6252};
6253
Takashi Iwaicb53c622007-08-10 17:21:45 +02006254#ifdef CONFIG_SND_HDA_POWER_SAVE
6255#define alc882_loopbacks alc880_loopbacks
6256#endif
6257
Kailang Yangdf694da2005-12-05 19:42:22 +01006258/* pcm configuration: identiacal with ALC880 */
6259#define alc882_pcm_analog_playback alc880_pcm_analog_playback
6260#define alc882_pcm_analog_capture alc880_pcm_analog_capture
6261#define alc882_pcm_digital_playback alc880_pcm_digital_playback
6262#define alc882_pcm_digital_capture alc880_pcm_digital_capture
6263
6264/*
6265 * configuration and preset
6266 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006267static const char *alc882_models[ALC882_MODEL_LAST] = {
6268 [ALC882_3ST_DIG] = "3stack-dig",
6269 [ALC882_6ST_DIG] = "6stack-dig",
6270 [ALC882_ARIMA] = "arima",
Kailang Yangbdd148a2007-05-08 15:19:08 +02006271 [ALC882_W2JC] = "w2jc",
Takashi Iwai0438a002007-09-06 14:54:11 +02006272 [ALC882_TARGA] = "targa",
6273 [ALC882_ASUS_A7J] = "asus-a7j",
6274 [ALC882_ASUS_A7M] = "asus-a7m",
Tobin Davis9102cd12006-12-15 10:02:12 +01006275 [ALC885_MACPRO] = "macpro",
Takashi Iwai87350ad2007-08-16 18:19:38 +02006276 [ALC885_MBP3] = "mbp3",
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006277 [ALC885_IMAC24] = "imac24",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006278 [ALC882_AUTO] = "auto",
6279};
6280
6281static struct snd_pci_quirk alc882_cfg_tbl[] = {
6282 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
Kailang Yang272a5272007-05-14 11:00:38 +02006283 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
Kailang Yangac8842a2007-09-20 12:51:39 +02006284 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
Takashi Iwai914759b2007-09-06 14:52:04 +02006285 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006286 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
Claudio Matsuokac5d9f1c2007-07-19 23:18:32 +02006287 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
Tobin Davis7b9470d2006-12-28 13:56:48 +01006288 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006289 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Jiang zhe44447042008-01-28 12:28:24 +01006290 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006291 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
6292 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
6293 SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
Kailang Yangdf694da2005-12-05 19:42:22 +01006294 {}
6295};
6296
6297static struct alc_config_preset alc882_presets[] = {
6298 [ALC882_3ST_DIG] = {
6299 .mixers = { alc882_base_mixer },
6300 .init_verbs = { alc882_init_verbs },
6301 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6302 .dac_nids = alc882_dac_nids,
6303 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006304 .dig_in_nid = ALC882_DIGIN_NID,
6305 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6306 .channel_mode = alc882_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02006307 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01006308 .input_mux = &alc882_capture_source,
6309 },
6310 [ALC882_6ST_DIG] = {
6311 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6312 .init_verbs = { alc882_init_verbs },
6313 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6314 .dac_nids = alc882_dac_nids,
6315 .dig_out_nid = ALC882_DIGOUT_NID,
Kailang Yangdf694da2005-12-05 19:42:22 +01006316 .dig_in_nid = ALC882_DIGIN_NID,
6317 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6318 .channel_mode = alc882_sixstack_modes,
6319 .input_mux = &alc882_capture_source,
6320 },
Takashi Iwai4b146cb2006-07-28 14:42:36 +02006321 [ALC882_ARIMA] = {
6322 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
6323 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
6324 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6325 .dac_nids = alc882_dac_nids,
6326 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
6327 .channel_mode = alc882_sixstack_modes,
6328 .input_mux = &alc882_capture_source,
6329 },
Kailang Yangbdd148a2007-05-08 15:19:08 +02006330 [ALC882_W2JC] = {
6331 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
6332 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6333 alc880_gpio1_init_verbs },
6334 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6335 .dac_nids = alc882_dac_nids,
6336 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6337 .channel_mode = alc880_threestack_modes,
6338 .need_dac_fix = 1,
6339 .input_mux = &alc882_capture_source,
6340 .dig_out_nid = ALC882_DIGOUT_NID,
6341 },
Takashi Iwai87350ad2007-08-16 18:19:38 +02006342 [ALC885_MBP3] = {
6343 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
6344 .init_verbs = { alc885_mbp3_init_verbs,
6345 alc880_gpio1_init_verbs },
6346 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6347 .dac_nids = alc882_dac_nids,
6348 .channel_mode = alc885_mbp_6ch_modes,
6349 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
6350 .input_mux = &alc882_capture_source,
6351 .dig_out_nid = ALC882_DIGOUT_NID,
6352 .dig_in_nid = ALC882_DIGIN_NID,
6353 .unsol_event = alc885_mbp3_unsol_event,
6354 .init_hook = alc885_mbp3_automute,
6355 },
Tobin Davis9102cd12006-12-15 10:02:12 +01006356 [ALC885_MACPRO] = {
6357 .mixers = { alc882_macpro_mixer },
6358 .init_verbs = { alc882_macpro_init_verbs },
6359 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6360 .dac_nids = alc882_dac_nids,
6361 .dig_out_nid = ALC882_DIGOUT_NID,
6362 .dig_in_nid = ALC882_DIGIN_NID,
6363 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6364 .channel_mode = alc882_ch_modes,
6365 .input_mux = &alc882_capture_source,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006366 .init_hook = alc885_macpro_init_hook,
Tobin Davis9102cd12006-12-15 10:02:12 +01006367 },
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006368 [ALC885_IMAC24] = {
6369 .mixers = { alc885_imac24_mixer },
6370 .init_verbs = { alc885_imac24_init_verbs },
6371 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6372 .dac_nids = alc882_dac_nids,
6373 .dig_out_nid = ALC882_DIGOUT_NID,
6374 .dig_in_nid = ALC882_DIGIN_NID,
6375 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
6376 .channel_mode = alc882_ch_modes,
6377 .input_mux = &alc882_capture_source,
6378 .unsol_event = alc885_imac24_unsol_event,
Takashi Iwai7debbe52007-08-16 15:01:03 +02006379 .init_hook = alc885_imac24_init_hook,
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006380 },
Kailang Yang272a5272007-05-14 11:00:38 +02006381 [ALC882_TARGA] = {
6382 .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
6383 alc882_capture_mixer },
6384 .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
6385 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6386 .dac_nids = alc882_dac_nids,
6387 .dig_out_nid = ALC882_DIGOUT_NID,
6388 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6389 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006390 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006391 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6392 .channel_mode = alc882_3ST_6ch_modes,
6393 .need_dac_fix = 1,
6394 .input_mux = &alc882_capture_source,
6395 .unsol_event = alc882_targa_unsol_event,
6396 .init_hook = alc882_targa_automute,
6397 },
6398 [ALC882_ASUS_A7J] = {
6399 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
6400 alc882_capture_mixer },
6401 .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
6402 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6403 .dac_nids = alc882_dac_nids,
6404 .dig_out_nid = ALC882_DIGOUT_NID,
6405 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
6406 .adc_nids = alc882_adc_nids,
Takashi Iwaie1406342008-02-11 18:32:32 +01006407 .capsrc_nids = alc882_capsrc_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02006408 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
6409 .channel_mode = alc882_3ST_6ch_modes,
6410 .need_dac_fix = 1,
6411 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006412 },
Takashi Iwai914759b2007-09-06 14:52:04 +02006413 [ALC882_ASUS_A7M] = {
6414 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
6415 .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
6416 alc880_gpio1_init_verbs,
6417 alc882_asus_a7m_verbs },
6418 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
6419 .dac_nids = alc882_dac_nids,
6420 .dig_out_nid = ALC882_DIGOUT_NID,
6421 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
6422 .channel_mode = alc880_threestack_modes,
6423 .need_dac_fix = 1,
6424 .input_mux = &alc882_capture_source,
Kailang Yangea1fb292008-08-26 12:58:38 +02006425 },
Kailang Yangdf694da2005-12-05 19:42:22 +01006426};
6427
6428
6429/*
Takashi Iwaif95474e2007-07-10 00:47:43 +02006430 * Pin config fixes
6431 */
Kailang Yangea1fb292008-08-26 12:58:38 +02006432enum {
Takashi Iwaif95474e2007-07-10 00:47:43 +02006433 PINFIX_ABIT_AW9D_MAX
6434};
6435
6436static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
6437 { 0x15, 0x01080104 }, /* side */
6438 { 0x16, 0x01011012 }, /* rear */
6439 { 0x17, 0x01016011 }, /* clfe */
6440 { }
6441};
6442
6443static const struct alc_pincfg *alc882_pin_fixes[] = {
6444 [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
6445};
6446
6447static struct snd_pci_quirk alc882_pinfix_tbl[] = {
6448 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
6449 {}
6450};
6451
6452/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006453 * BIOS auto configuration
6454 */
6455static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
6456 hda_nid_t nid, int pin_type,
6457 int dac_idx)
6458{
6459 /* set as output */
6460 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006461 int idx;
6462
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006463 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006464 if (spec->multiout.dac_nids[dac_idx] == 0x25)
6465 idx = 4;
6466 else
6467 idx = spec->multiout.dac_nids[dac_idx] - 2;
Kailang Yangdf694da2005-12-05 19:42:22 +01006468 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
6469
6470}
6471
6472static void alc882_auto_init_multi_out(struct hda_codec *codec)
6473{
6474 struct alc_spec *spec = codec->spec;
6475 int i;
6476
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006477 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangdf694da2005-12-05 19:42:22 +01006478 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006479 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006480 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006481 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006482 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006483 i);
Kailang Yangdf694da2005-12-05 19:42:22 +01006484 }
6485}
6486
6487static void alc882_auto_init_hp_out(struct hda_codec *codec)
6488{
6489 struct alc_spec *spec = codec->spec;
6490 hda_nid_t pin;
6491
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006492 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006493 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006494 /* use dac 0 */
6495 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006496 pin = spec->autocfg.speaker_pins[0];
6497 if (pin)
6498 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +01006499}
6500
6501#define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
6502#define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
6503
6504static void alc882_auto_init_analog_input(struct hda_codec *codec)
6505{
6506 struct alc_spec *spec = codec->spec;
6507 int i;
6508
6509 for (i = 0; i < AUTO_PIN_LAST; i++) {
6510 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwai7194cae2008-03-06 16:58:17 +01006511 unsigned int vref;
6512 if (!nid)
6513 continue;
6514 vref = PIN_IN;
6515 if (1 /*i <= AUTO_PIN_FRONT_MIC*/) {
Kailang Yang531240f2008-05-27 12:10:25 +02006516 unsigned int pincap;
6517 pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
6518 if ((pincap >> AC_PINCAP_VREF_SHIFT) &
Takashi Iwai7194cae2008-03-06 16:58:17 +01006519 AC_PINCAP_VREF_80)
6520 vref = PIN_VREF80;
Kailang Yangdf694da2005-12-05 19:42:22 +01006521 }
Takashi Iwai7194cae2008-03-06 16:58:17 +01006522 snd_hda_codec_write(codec, nid, 0,
6523 AC_VERB_SET_PIN_WIDGET_CONTROL, vref);
6524 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
6525 snd_hda_codec_write(codec, nid, 0,
6526 AC_VERB_SET_AMP_GAIN_MUTE,
6527 AMP_OUT_MUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +01006528 }
6529}
6530
Takashi Iwaif511b012008-08-15 16:46:42 +02006531static void alc882_auto_init_input_src(struct hda_codec *codec)
6532{
6533 struct alc_spec *spec = codec->spec;
6534 const struct hda_input_mux *imux = spec->input_mux;
6535 int c;
6536
6537 for (c = 0; c < spec->num_adc_nids; c++) {
6538 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
6539 hda_nid_t nid = spec->capsrc_nids[c];
6540 int conns, mute, idx, item;
6541
6542 conns = snd_hda_get_connections(codec, nid, conn_list,
6543 ARRAY_SIZE(conn_list));
6544 if (conns < 0)
6545 continue;
6546 for (idx = 0; idx < conns; idx++) {
6547 /* if the current connection is the selected one,
6548 * unmute it as default - otherwise mute it
6549 */
6550 mute = AMP_IN_MUTE(idx);
6551 for (item = 0; item < imux->num_items; item++) {
6552 if (imux->items[item].index == idx) {
6553 if (spec->cur_mux[c] == item)
6554 mute = AMP_IN_UNMUTE(idx);
6555 break;
6556 }
6557 }
6558 snd_hda_codec_write(codec, nid, 0,
6559 AC_VERB_SET_AMP_GAIN_MUTE, mute);
6560 }
6561 }
6562}
6563
Takashi Iwai776e1842007-08-29 15:07:11 +02006564/* add mic boosts if needed */
6565static int alc_auto_add_mic_boost(struct hda_codec *codec)
6566{
6567 struct alc_spec *spec = codec->spec;
6568 int err;
6569 hda_nid_t nid;
6570
6571 nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006572 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006573 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6574 "Mic Boost",
6575 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6576 if (err < 0)
6577 return err;
6578 }
6579 nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
Takashi Iwaice22e032008-01-11 17:38:35 +01006580 if (nid && (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) {
Takashi Iwai776e1842007-08-29 15:07:11 +02006581 err = add_control(spec, ALC_CTL_WIDGET_VOL,
6582 "Front Mic Boost",
6583 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
6584 if (err < 0)
6585 return err;
6586 }
6587 return 0;
6588}
6589
Kailang Yangdf694da2005-12-05 19:42:22 +01006590/* almost identical with ALC880 parser... */
6591static int alc882_parse_auto_config(struct hda_codec *codec)
6592{
6593 struct alc_spec *spec = codec->spec;
6594 int err = alc880_parse_auto_config(codec);
6595
6596 if (err < 0)
6597 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02006598 else if (!err)
6599 return 0; /* no config found */
6600
6601 err = alc_auto_add_mic_boost(codec);
6602 if (err < 0)
6603 return err;
6604
6605 /* hack - override the init verbs */
6606 spec->init_verbs[0] = alc882_auto_init_verbs;
6607
6608 return 1; /* config found */
Kailang Yangdf694da2005-12-05 19:42:22 +01006609}
6610
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006611/* additional initialization for auto-configuration model */
6612static void alc882_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006613{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006614 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006615 alc882_auto_init_multi_out(codec);
6616 alc882_auto_init_hp_out(codec);
6617 alc882_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02006618 alc882_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006619 if (spec->unsol_event)
6620 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006621}
6622
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006623static int patch_alc883(struct hda_codec *codec); /* called in patch_alc882() */
6624
Linus Torvalds1da177e2005-04-16 15:20:36 -07006625static int patch_alc882(struct hda_codec *codec)
6626{
6627 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006628 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006629
Takashi Iwaie560d8d2005-09-09 14:21:46 +02006630 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006631 if (spec == NULL)
6632 return -ENOMEM;
6633
Linus Torvalds1da177e2005-04-16 15:20:36 -07006634 codec->spec = spec;
6635
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006636 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
6637 alc882_models,
6638 alc882_cfg_tbl);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006639
Kailang Yangdf694da2005-12-05 19:42:22 +01006640 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Tobin Davis081d17c2007-02-15 17:46:18 +01006641 /* Pick up systems that don't supply PCI SSID */
6642 switch (codec->subsystem_id) {
6643 case 0x106b0c00: /* Mac Pro */
6644 board_config = ALC885_MACPRO;
6645 break;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02006646 case 0x106b1000: /* iMac 24 */
6647 board_config = ALC885_IMAC24;
6648 break;
Takashi Iwaic7e07572008-06-26 14:42:51 +02006649 case 0x106b00a1: /* Macbook (might be wrong - PCI SSID?) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006650 case 0x106b2c00: /* Macbook Pro rev3 */
Takashi Iwaic7e07572008-06-26 14:42:51 +02006651 case 0x106b3600: /* Macbook 3.1 */
Takashi Iwai87350ad2007-08-16 18:19:38 +02006652 board_config = ALC885_MBP3;
6653 break;
Tobin Davis081d17c2007-02-15 17:46:18 +01006654 default:
Takashi Iwai7943a8a2008-04-16 17:29:09 +02006655 /* ALC889A is handled better as ALC888-compatible */
6656 if (codec->revision_id == 0x100103) {
6657 alc_free(codec);
6658 return patch_alc883(codec);
6659 }
Tobin Davis081d17c2007-02-15 17:46:18 +01006660 printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
6661 "trying auto-probe from BIOS...\n");
6662 board_config = ALC882_AUTO;
6663 }
Kailang Yangdf694da2005-12-05 19:42:22 +01006664 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02006665
Takashi Iwaif95474e2007-07-10 00:47:43 +02006666 alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
6667
Kailang Yangdf694da2005-12-05 19:42:22 +01006668 if (board_config == ALC882_AUTO) {
6669 /* automatic parse from the BIOS config */
6670 err = alc882_parse_auto_config(codec);
6671 if (err < 0) {
6672 alc_free(codec);
6673 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006674 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006675 printk(KERN_INFO
6676 "hda_codec: Cannot set up configuration "
6677 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01006678 board_config = ALC882_3ST_DIG;
6679 }
6680 }
6681
6682 if (board_config != ALC882_AUTO)
6683 setup_preset(spec, &alc882_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07006684
Kailang Yang2f893282008-05-27 12:14:47 +02006685 if (codec->vendor_id == 0x10ec0885) {
6686 spec->stream_name_analog = "ALC885 Analog";
6687 spec->stream_name_digital = "ALC885 Digital";
6688 } else {
6689 spec->stream_name_analog = "ALC882 Analog";
6690 spec->stream_name_digital = "ALC882 Digital";
6691 }
6692
Kailang Yangdf694da2005-12-05 19:42:22 +01006693 spec->stream_analog_playback = &alc882_pcm_analog_playback;
6694 spec->stream_analog_capture = &alc882_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01006695 /* FIXME: setup DAC5 */
6696 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
6697 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006698
Kailang Yangdf694da2005-12-05 19:42:22 +01006699 spec->stream_digital_playback = &alc882_pcm_digital_playback;
6700 spec->stream_digital_capture = &alc882_pcm_digital_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07006701
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006702 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +01006703 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006704 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006705 /* get type */
6706 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +01006707 if (wcap != AC_WID_AUD_IN) {
6708 spec->adc_nids = alc882_adc_nids_alt;
6709 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
Takashi Iwaie1406342008-02-11 18:32:32 +01006710 spec->capsrc_nids = alc882_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006711 spec->mixers[spec->num_mixers] =
6712 alc882_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +01006713 spec->num_mixers++;
6714 } else {
6715 spec->adc_nids = alc882_adc_nids;
6716 spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +01006717 spec->capsrc_nids = alc882_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +01006718 spec->mixers[spec->num_mixers] = alc882_capture_mixer;
6719 spec->num_mixers++;
6720 }
6721 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07006722
Takashi Iwai2134ea42008-01-10 16:53:55 +01006723 spec->vmaster_nid = 0x0c;
6724
Linus Torvalds1da177e2005-04-16 15:20:36 -07006725 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01006726 if (board_config == ALC882_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006727 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02006728#ifdef CONFIG_SND_HDA_POWER_SAVE
6729 if (!spec->loopback.amplist)
6730 spec->loopback.amplist = alc882_loopbacks;
6731#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07006732
6733 return 0;
6734}
6735
6736/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006737 * ALC883 support
6738 *
6739 * ALC883 is almost identical with ALC880 but has cleaner and more flexible
6740 * configuration. Each pin widget can choose any input DACs and a mixer.
6741 * Each ADC is connected from a mixer of all inputs. This makes possible
6742 * 6-channel independent captures.
6743 *
6744 * In addition, an independent DAC for the multi-playback (not used in this
6745 * driver yet).
6746 */
6747#define ALC883_DIGOUT_NID 0x06
6748#define ALC883_DIGIN_NID 0x0a
6749
6750static hda_nid_t alc883_dac_nids[4] = {
6751 /* front, rear, clfe, rear_surr */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01006752 0x02, 0x03, 0x04, 0x05
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006753};
6754
6755static hda_nid_t alc883_adc_nids[2] = {
6756 /* ADC1-2 */
6757 0x08, 0x09,
6758};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006759
Takashi Iwaie1406342008-02-11 18:32:32 +01006760static hda_nid_t alc883_capsrc_nids[2] = { 0x23, 0x22 };
6761
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006762/* input MUX */
6763/* FIXME: should be a matrix-type input source selection */
6764
6765static struct hda_input_mux alc883_capture_source = {
6766 .num_items = 4,
6767 .items = {
6768 { "Mic", 0x0 },
6769 { "Front Mic", 0x1 },
6770 { "Line", 0x2 },
6771 { "CD", 0x4 },
6772 },
6773};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006774
Jiang zhe17bba1b2008-06-04 12:11:07 +02006775static struct hda_input_mux alc883_3stack_6ch_intel = {
6776 .num_items = 4,
6777 .items = {
6778 { "Mic", 0x1 },
6779 { "Front Mic", 0x0 },
6780 { "Line", 0x2 },
6781 { "CD", 0x4 },
6782 },
6783};
6784
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006785static struct hda_input_mux alc883_lenovo_101e_capture_source = {
6786 .num_items = 2,
6787 .items = {
6788 { "Mic", 0x1 },
6789 { "Line", 0x2 },
6790 },
6791};
6792
Kailang Yang272a5272007-05-14 11:00:38 +02006793static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
6794 .num_items = 4,
6795 .items = {
6796 { "Mic", 0x0 },
6797 { "iMic", 0x1 },
6798 { "Line", 0x2 },
6799 { "CD", 0x4 },
6800 },
6801};
6802
Jiang zhefb97dc62008-03-06 11:07:11 +01006803static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
6804 .num_items = 2,
6805 .items = {
6806 { "Mic", 0x0 },
6807 { "Int Mic", 0x1 },
6808 },
6809};
6810
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006811#define alc883_mux_enum_info alc_mux_enum_info
6812#define alc883_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +01006813/* ALC883 has the ALC882-type input selection */
6814#define alc883_mux_enum_put alc882_mux_enum_put
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006815
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006816/*
6817 * 2ch mode
6818 */
6819static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
6820 { 2, NULL }
6821};
6822
6823/*
6824 * 2ch mode
6825 */
6826static struct hda_verb alc883_3ST_ch2_init[] = {
6827 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6828 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6829 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6830 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6831 { } /* end */
6832};
6833
6834/*
Tobin Davisb2011312007-09-17 12:45:11 +02006835 * 4ch mode
6836 */
6837static struct hda_verb alc883_3ST_ch4_init[] = {
6838 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6839 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6842 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6843 { } /* end */
6844};
6845
6846/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006847 * 6ch mode
6848 */
6849static struct hda_verb alc883_3ST_ch6_init[] = {
6850 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6851 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6852 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
6853 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6854 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6855 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6856 { } /* end */
6857};
6858
Tobin Davisb2011312007-09-17 12:45:11 +02006859static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006860 { 2, alc883_3ST_ch2_init },
Tobin Davisb2011312007-09-17 12:45:11 +02006861 { 4, alc883_3ST_ch4_init },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006862 { 6, alc883_3ST_ch6_init },
6863};
6864
6865/*
Jiang zhe17bba1b2008-06-04 12:11:07 +02006866 * 2ch mode
6867 */
6868static struct hda_verb alc883_3ST_ch2_intel_init[] = {
6869 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6870 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6871 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
6872 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6873 { } /* end */
6874};
6875
6876/*
6877 * 4ch mode
6878 */
6879static struct hda_verb alc883_3ST_ch4_intel_init[] = {
6880 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
6881 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
6882 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6883 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6884 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6885 { } /* end */
6886};
6887
6888/*
6889 * 6ch mode
6890 */
6891static struct hda_verb alc883_3ST_ch6_intel_init[] = {
6892 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6893 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6894 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
6895 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6896 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
6897 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
6898 { } /* end */
6899};
6900
6901static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
6902 { 2, alc883_3ST_ch2_intel_init },
6903 { 4, alc883_3ST_ch4_intel_init },
6904 { 6, alc883_3ST_ch6_intel_init },
6905};
6906
6907/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006908 * 6ch mode
6909 */
6910static struct hda_verb alc883_sixstack_ch6_init[] = {
6911 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
6912 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6913 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6914 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6915 { } /* end */
6916};
6917
6918/*
6919 * 8ch mode
6920 */
6921static struct hda_verb alc883_sixstack_ch8_init[] = {
6922 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6923 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6924 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6925 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6926 { } /* end */
6927};
6928
6929static struct hda_channel_mode alc883_sixstack_modes[2] = {
6930 { 6, alc883_sixstack_ch6_init },
6931 { 8, alc883_sixstack_ch8_init },
6932};
6933
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01006934static struct hda_verb alc883_medion_eapd_verbs[] = {
6935 /* eanable EAPD on medion laptop */
6936 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
6937 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
6938 { }
6939};
6940
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006941/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
6942 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
6943 */
6944
6945static struct snd_kcontrol_new alc883_base_mixer[] = {
6946 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6947 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6948 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
6949 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
6950 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6951 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6952 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6953 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6954 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
6955 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
6956 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
6957 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
6958 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
6959 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6960 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6961 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006962 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006963 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6964 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01006965 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02006966 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6967 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
6968 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
6969 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
6970 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
6971 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
6972 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
6973 {
6974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
6975 /* .name = "Capture Source", */
6976 .name = "Input Source",
6977 .count = 2,
6978 .info = alc883_mux_enum_info,
6979 .get = alc883_mux_enum_get,
6980 .put = alc883_mux_enum_put,
6981 },
6982 { } /* end */
6983};
6984
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01006985static struct snd_kcontrol_new alc883_mitac_mixer[] = {
6986 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
6987 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
6988 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
6989 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
6990 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
6991 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
6992 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
6993 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
6994 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
6995 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
6996 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
6997 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
6998 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
6999 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7000 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7001 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7002 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7003 {
7004 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7005 /* .name = "Capture Source", */
7006 .name = "Input Source",
7007 .count = 2,
7008 .info = alc883_mux_enum_info,
7009 .get = alc883_mux_enum_get,
7010 .put = alc883_mux_enum_put,
7011 },
7012 { } /* end */
7013};
7014
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007015static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007016 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7017 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7018 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7019 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7021 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7022 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7023 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7024 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7025 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7026 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7027 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7028 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7029 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7030 {
7031 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7032 /* .name = "Capture Source", */
7033 .name = "Input Source",
7034 .count = 2,
7035 .info = alc883_mux_enum_info,
7036 .get = alc883_mux_enum_get,
7037 .put = alc883_mux_enum_put,
7038 },
7039 { } /* end */
7040};
7041
Jiang zhefb97dc62008-03-06 11:07:11 +01007042static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
7043 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7044 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
7045 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7046 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
7047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7048 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7049 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7050 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7051 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7052 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7053 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7054 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7055 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7056 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7057 {
7058 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7059 /* .name = "Capture Source", */
7060 .name = "Input Source",
7061 .count = 2,
7062 .info = alc883_mux_enum_info,
7063 .get = alc883_mux_enum_get,
7064 .put = alc883_mux_enum_put,
7065 },
7066 { } /* end */
7067};
7068
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007069static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
7070 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7071 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7072 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7073 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7074 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7075 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7076 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7077 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007078 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007079 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7080 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007081 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007082 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7083 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7084 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7085 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7086 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7087 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7088 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7089 {
7090 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7091 /* .name = "Capture Source", */
7092 .name = "Input Source",
7093 .count = 2,
7094 .info = alc883_mux_enum_info,
7095 .get = alc883_mux_enum_get,
7096 .put = alc883_mux_enum_put,
7097 },
7098 { } /* end */
7099};
7100
7101static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
7102 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7103 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7104 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7105 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7106 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7107 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7108 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7109 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7110 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7111 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7112 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7113 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7114 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7115 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007116 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007117 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7118 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007119 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007120 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7121 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7122 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7123 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7124 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7125 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7126 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7127 {
7128 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7129 /* .name = "Capture Source", */
7130 .name = "Input Source",
7131 .count = 2,
7132 .info = alc883_mux_enum_info,
7133 .get = alc883_mux_enum_get,
7134 .put = alc883_mux_enum_put,
7135 },
7136 { } /* end */
7137};
7138
Jiang zhe17bba1b2008-06-04 12:11:07 +02007139static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
7140 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7141 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7142 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7143 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7144 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
7145 HDA_OUTPUT),
7146 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7147 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7148 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7149 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7150 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7151 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7152 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7153 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7155 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
7156 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7157 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7158 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
7159 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7160 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7161 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7162 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7163 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7164 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7165 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7166 {
7167 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7168 /* .name = "Capture Source", */
7169 .name = "Input Source",
7170 .count = 2,
7171 .info = alc883_mux_enum_info,
7172 .get = alc883_mux_enum_get,
7173 .put = alc883_mux_enum_put,
7174 },
7175 { } /* end */
7176};
7177
Takashi Iwaid1d985f2006-11-23 19:27:12 +01007178static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02007179 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007180 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007181 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007182 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007183 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7184 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02007185 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7186 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007187 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7188 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7189 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7190 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7191 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007193 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007194 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7195 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007196 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02007197 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7198 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
7199 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
7200 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7201 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7202
7203 {
7204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7205 /* .name = "Capture Source", */
7206 .name = "Input Source",
7207 .count = 1,
7208 .info = alc883_mux_enum_info,
7209 .get = alc883_mux_enum_get,
7210 .put = alc883_mux_enum_put,
7211 },
7212 { } /* end */
7213};
7214
Kailang Yangccc656c2006-10-17 12:32:26 +02007215static struct snd_kcontrol_new alc883_tagra_mixer[] = {
7216 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7217 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7218 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7219 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7220 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
7221 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7222 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
7223 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7224 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
7225 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7226 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7227 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7228 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7229 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007230 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007231 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7232 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7233 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7234 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7235 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7236 {
7237 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7238 /* .name = "Capture Source", */
7239 .name = "Input Source",
7240 .count = 2,
7241 .info = alc883_mux_enum_info,
7242 .get = alc883_mux_enum_get,
7243 .put = alc883_mux_enum_put,
7244 },
7245 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007246};
Kailang Yangccc656c2006-10-17 12:32:26 +02007247
7248static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
7249 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7250 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7251 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7252 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7253 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7254 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007255 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007256 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02007257 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7258 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
7259 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02007260 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7261 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7262 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7263 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7264 {
7265 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7266 /* .name = "Capture Source", */
7267 .name = "Input Source",
7268 .count = 2,
7269 .info = alc883_mux_enum_info,
7270 .get = alc883_mux_enum_get,
7271 .put = alc883_mux_enum_put,
7272 },
7273 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007274};
Kailang Yangccc656c2006-10-17 12:32:26 +02007275
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007276static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
7277 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7278 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01007279 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
7280 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007281 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7282 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7283 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7284 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7285 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7286 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7287 {
7288 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7289 /* .name = "Capture Source", */
7290 .name = "Input Source",
7291 .count = 1,
7292 .info = alc883_mux_enum_info,
7293 .get = alc883_mux_enum_get,
7294 .put = alc883_mux_enum_put,
7295 },
7296 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007297};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007298
Kailang Yang272a5272007-05-14 11:00:38 +02007299static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
7300 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7301 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
7302 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7303 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7304 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7305 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7306 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7307 HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7308 HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
7309 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7310 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7311 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7312 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7313 {
7314 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7315 /* .name = "Capture Source", */
7316 .name = "Input Source",
7317 .count = 2,
7318 .info = alc883_mux_enum_info,
7319 .get = alc883_mux_enum_get,
7320 .put = alc883_mux_enum_put,
7321 },
7322 { } /* end */
7323};
7324
7325static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
7326 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7327 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7328 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7329 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7330 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7331 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7332 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, 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("Capture Volume", 0x08, 0x0, HDA_INPUT),
7336 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7337 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7338 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7339 {
7340 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7341 /* .name = "Capture Source", */
7342 .name = "Input Source",
7343 .count = 2,
7344 .info = alc883_mux_enum_info,
7345 .get = alc883_mux_enum_get,
7346 .put = alc883_mux_enum_put,
7347 },
7348 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02007349};
Kailang Yang272a5272007-05-14 11:00:38 +02007350
Tobin Davis2880a862007-08-07 11:50:26 +02007351static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02007352 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7353 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007354 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007355 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7356 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02007357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7358 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02007360 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7361 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7362 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7363 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7364 {
7365 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7366 /* .name = "Capture Source", */
7367 .name = "Input Source",
7368 .count = 2,
7369 .info = alc883_mux_enum_info,
7370 .get = alc883_mux_enum_get,
7371 .put = alc883_mux_enum_put,
7372 },
7373 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02007374};
Tobin Davis2880a862007-08-07 11:50:26 +02007375
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007376static struct snd_kcontrol_new alc883_chmode_mixer[] = {
7377 {
7378 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7379 .name = "Channel Mode",
7380 .info = alc_ch_mode_info,
7381 .get = alc_ch_mode_get,
7382 .put = alc_ch_mode_put,
7383 },
7384 { } /* end */
7385};
7386
7387static struct hda_verb alc883_init_verbs[] = {
7388 /* ADC1: mute amp left and right */
7389 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7390 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7391 /* ADC2: mute amp left and right */
7392 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7393 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7394 /* Front mixer: unmute input/output amp left and right (volume = 0) */
7395 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7398 /* Rear mixer */
7399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7401 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7402 /* CLFE mixer */
7403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7404 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7405 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7406 /* Side mixer */
7407 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7408 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7409 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7410
Takashi Iwaicb53c622007-08-10 17:21:45 +02007411 /* mute analog input loopbacks */
7412 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7413 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7414 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7415 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7416 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007417
7418 /* Front Pin: output 0 (0x0c) */
7419 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7420 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7421 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7422 /* Rear Pin: output 1 (0x0d) */
7423 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7424 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7425 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7426 /* CLFE Pin: output 2 (0x0e) */
7427 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7428 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7429 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
7430 /* Side Pin: output 3 (0x0f) */
7431 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7432 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7433 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
7434 /* Mic (rear) pin: input vref at 80% */
7435 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7436 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7437 /* Front Mic pin: input vref at 80% */
7438 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
7439 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7440 /* Line In pin: input */
7441 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7442 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7443 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7444 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7445 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7446 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7447 /* CD pin widget for input */
7448 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7449
7450 /* FIXME: use matrix-type input source selection */
7451 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7452 /* Input mixer2 */
7453 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7454 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7455 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7456 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7457 /* Input mixer3 */
7458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
7461 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7462 { }
7463};
7464
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01007465/* toggle speaker-output according to the hp-jack state */
7466static void alc883_mitac_hp_automute(struct hda_codec *codec)
7467{
7468 unsigned int present;
7469
7470 present = snd_hda_codec_read(codec, 0x15, 0,
7471 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7472 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7473 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7474 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7475 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7476}
7477
7478/* auto-toggle front mic */
7479/*
7480static void alc883_mitac_mic_automute(struct hda_codec *codec)
7481{
7482 unsigned int present;
7483 unsigned char bits;
7484
7485 present = snd_hda_codec_read(codec, 0x18, 0,
7486 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7487 bits = present ? HDA_AMP_MUTE : 0;
7488 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
7489}
7490*/
7491
7492static void alc883_mitac_automute(struct hda_codec *codec)
7493{
7494 alc883_mitac_hp_automute(codec);
7495 /* alc883_mitac_mic_automute(codec); */
7496}
7497
7498static void alc883_mitac_unsol_event(struct hda_codec *codec,
7499 unsigned int res)
7500{
7501 switch (res >> 26) {
7502 case ALC880_HP_EVENT:
7503 alc883_mitac_hp_automute(codec);
7504 break;
7505 case ALC880_MIC_EVENT:
7506 /* alc883_mitac_mic_automute(codec); */
7507 break;
7508 }
7509}
7510
7511static struct hda_verb alc883_mitac_verbs[] = {
7512 /* HP */
7513 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7514 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7515 /* Subwoofer */
7516 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
7517 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7518
7519 /* enable unsolicited event */
7520 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7521 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
7522
7523 { } /* end */
7524};
7525
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007526static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01007527 /* HP */
7528 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7529 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7530 /* Int speaker */
7531 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
7532 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7533
7534 /* enable unsolicited event */
7535 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007536 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01007537
7538 { } /* end */
7539};
7540
Jiang zhefb97dc62008-03-06 11:07:11 +01007541static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
7542 /* HP */
7543 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7544 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7545 /* Subwoofer */
7546 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7547 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7548
7549 /* enable unsolicited event */
7550 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7551
7552 { } /* end */
7553};
7554
Kailang Yangccc656c2006-10-17 12:32:26 +02007555static struct hda_verb alc883_tagra_verbs[] = {
7556 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7557 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7558
7559 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7560 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02007561
Kailang Yangccc656c2006-10-17 12:32:26 +02007562 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
7563 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
7564 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
7565
7566 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007567 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
7568 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
7569 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
Kailang Yangccc656c2006-10-17 12:32:26 +02007570
7571 { } /* end */
7572};
7573
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007574static struct hda_verb alc883_lenovo_101e_verbs[] = {
7575 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7576 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
7577 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
7578 { } /* end */
7579};
7580
Kailang Yang272a5272007-05-14 11:00:38 +02007581static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
7582 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7583 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7584 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7586 { } /* end */
7587};
7588
7589static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
7590 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7591 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7592 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
7593 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
7594 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7595 { } /* end */
7596};
7597
Kailang Yang189609a2007-08-20 11:31:23 +02007598static struct hda_verb alc883_haier_w66_verbs[] = {
7599 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7600 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7601
7602 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7603
7604 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
7605 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7606 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7607 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7608 { } /* end */
7609};
7610
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007611static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007612 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01007613 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
7614 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007615 { }
7616};
7617
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007618static struct hda_verb alc888_6st_dell_verbs[] = {
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007619 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7620 { }
7621};
7622
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007623static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007624 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7625 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7626 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7627 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7628 { }
7629};
7630
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007631static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007632 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7633 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7634 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7635 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7636 { }
7637};
7638
Claudio Matsuoka4723c022007-07-13 14:36:19 +02007639static struct hda_channel_mode alc888_3st_hp_modes[2] = {
7640 { 2, alc888_3st_hp_2ch_init },
7641 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02007642};
7643
Kailang Yang272a5272007-05-14 11:00:38 +02007644/* toggle front-jack and RCA according to the hp-jack state */
7645static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
7646{
7647 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007648
Kailang Yang272a5272007-05-14 11:00:38 +02007649 present = snd_hda_codec_read(codec, 0x1b, 0,
7650 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007651 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7652 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7653 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7654 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007655}
7656
7657/* toggle RCA according to the front-jack state */
7658static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
7659{
7660 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007661
Kailang Yang272a5272007-05-14 11:00:38 +02007662 present = snd_hda_codec_read(codec, 0x14, 0,
7663 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007664 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7665 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007666}
Takashi Iwai47fd8302007-08-10 17:11:07 +02007667
Kailang Yang272a5272007-05-14 11:00:38 +02007668static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
7669 unsigned int res)
7670{
7671 if ((res >> 26) == ALC880_HP_EVENT)
7672 alc888_lenovo_ms7195_front_automute(codec);
7673 if ((res >> 26) == ALC880_FRONT_EVENT)
7674 alc888_lenovo_ms7195_rca_automute(codec);
7675}
7676
7677static struct hda_verb alc883_medion_md2_verbs[] = {
7678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7679 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7680
7681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7682
7683 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
7684 { } /* end */
7685};
7686
7687/* toggle speaker-output according to the hp-jack state */
7688static void alc883_medion_md2_automute(struct hda_codec *codec)
7689{
7690 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007691
Kailang Yang272a5272007-05-14 11:00:38 +02007692 present = snd_hda_codec_read(codec, 0x14, 0,
7693 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007694 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7695 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02007696}
7697
7698static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
7699 unsigned int res)
7700{
7701 if ((res >> 26) == ALC880_HP_EVENT)
7702 alc883_medion_md2_automute(codec);
7703}
7704
Kailang Yangccc656c2006-10-17 12:32:26 +02007705/* toggle speaker-output according to the hp-jack state */
7706static void alc883_tagra_automute(struct hda_codec *codec)
7707{
7708 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007709 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02007710
7711 present = snd_hda_codec_read(codec, 0x14, 0,
7712 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007713 bits = present ? HDA_AMP_MUTE : 0;
7714 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
7715 HDA_AMP_MUTE, bits);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02007716 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
7717 present ? 1 : 3);
Kailang Yangccc656c2006-10-17 12:32:26 +02007718}
7719
7720static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
7721{
7722 if ((res >> 26) == ALC880_HP_EVENT)
7723 alc883_tagra_automute(codec);
7724}
7725
Jiang zhe368c7a92008-03-04 11:20:33 +01007726/* toggle speaker-output according to the hp-jack state */
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007727static void alc883_clevo_m720_hp_automute(struct hda_codec *codec)
Jiang zhe368c7a92008-03-04 11:20:33 +01007728{
7729 unsigned int present;
7730 unsigned char bits;
7731
7732 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
7733 & AC_PINSENSE_PRESENCE;
7734 bits = present ? HDA_AMP_MUTE : 0;
7735 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7736 HDA_AMP_MUTE, bits);
7737}
7738
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007739static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
7740{
7741 unsigned int present;
7742
7743 present = snd_hda_codec_read(codec, 0x18, 0,
7744 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7745 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
7746 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7747}
7748
7749static void alc883_clevo_m720_automute(struct hda_codec *codec)
7750{
7751 alc883_clevo_m720_hp_automute(codec);
7752 alc883_clevo_m720_mic_automute(codec);
7753}
7754
7755static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01007756 unsigned int res)
7757{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01007758 switch (res >> 26) {
7759 case ALC880_HP_EVENT:
7760 alc883_clevo_m720_hp_automute(codec);
7761 break;
7762 case ALC880_MIC_EVENT:
7763 alc883_clevo_m720_mic_automute(codec);
7764 break;
7765 }
Jiang zhe368c7a92008-03-04 11:20:33 +01007766}
7767
Jiang zhefb97dc62008-03-06 11:07:11 +01007768/* toggle speaker-output according to the hp-jack state */
7769static void alc883_2ch_fujitsu_pi2515_automute(struct hda_codec *codec)
7770{
7771 unsigned int present;
7772 unsigned char bits;
7773
7774 present = snd_hda_codec_read(codec, 0x14, 0, AC_VERB_GET_PIN_SENSE, 0)
7775 & AC_PINSENSE_PRESENCE;
7776 bits = present ? HDA_AMP_MUTE : 0;
7777 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7778 HDA_AMP_MUTE, bits);
7779}
7780
7781static void alc883_2ch_fujitsu_pi2515_unsol_event(struct hda_codec *codec,
7782 unsigned int res)
7783{
7784 if ((res >> 26) == ALC880_HP_EVENT)
7785 alc883_2ch_fujitsu_pi2515_automute(codec);
7786}
7787
Kailang Yang189609a2007-08-20 11:31:23 +02007788static void alc883_haier_w66_automute(struct hda_codec *codec)
7789{
7790 unsigned int present;
7791 unsigned char bits;
7792
7793 present = snd_hda_codec_read(codec, 0x1b, 0,
7794 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7795 bits = present ? 0x80 : 0;
7796 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7797 0x80, bits);
7798}
7799
7800static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
7801 unsigned int res)
7802{
7803 if ((res >> 26) == ALC880_HP_EVENT)
7804 alc883_haier_w66_automute(codec);
7805}
7806
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007807static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
7808{
7809 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007810 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007811
7812 present = snd_hda_codec_read(codec, 0x14, 0,
7813 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007814 bits = present ? HDA_AMP_MUTE : 0;
7815 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7816 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007817}
7818
7819static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
7820{
7821 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007822 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007823
7824 present = snd_hda_codec_read(codec, 0x1b, 0,
7825 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +02007826 bits = present ? HDA_AMP_MUTE : 0;
7827 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7828 HDA_AMP_MUTE, bits);
7829 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7830 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007831}
7832
7833static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
7834 unsigned int res)
7835{
7836 if ((res >> 26) == ALC880_HP_EVENT)
7837 alc883_lenovo_101e_all_automute(codec);
7838 if ((res >> 26) == ALC880_FRONT_EVENT)
7839 alc883_lenovo_101e_ispeaker_automute(codec);
7840}
7841
Takashi Iwai676a9b52007-08-16 15:23:35 +02007842/* toggle speaker-output according to the hp-jack state */
7843static void alc883_acer_aspire_automute(struct hda_codec *codec)
7844{
7845 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007846
Takashi Iwai676a9b52007-08-16 15:23:35 +02007847 present = snd_hda_codec_read(codec, 0x14, 0,
7848 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7849 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7850 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7851 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7852 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7853}
7854
7855static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
7856 unsigned int res)
7857{
7858 if ((res >> 26) == ALC880_HP_EVENT)
7859 alc883_acer_aspire_automute(codec);
7860}
7861
Kailang Yangd1a991a2007-08-15 16:21:59 +02007862static struct hda_verb alc883_acer_eapd_verbs[] = {
7863 /* HP Pin: output 0 (0x0c) */
7864 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7865 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7866 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
7867 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02007868 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7869 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007870 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007871 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
7872 /* eanable EAPD on medion laptop */
7873 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
7874 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02007875 /* enable unsolicited event */
7876 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02007877 { }
7878};
7879
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007880static void alc888_6st_dell_front_automute(struct hda_codec *codec)
7881{
7882 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02007883
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01007884 present = snd_hda_codec_read(codec, 0x1b, 0,
7885 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
7886 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
7887 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7888 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
7889 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7890 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
7891 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7892 snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
7893 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
7894}
7895
7896static void alc888_6st_dell_unsol_event(struct hda_codec *codec,
7897 unsigned int res)
7898{
7899 switch (res >> 26) {
7900 case ALC880_HP_EVENT:
7901 printk("hp_event\n");
7902 alc888_6st_dell_front_automute(codec);
7903 break;
7904 }
7905}
7906
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007907/*
7908 * generic initialization of ADC, input mixers and output mixers
7909 */
7910static struct hda_verb alc883_auto_init_verbs[] = {
7911 /*
7912 * Unmute ADC0-2 and set the default input to mic-in
7913 */
7914 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
7915 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7916 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
7917 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7918
Takashi Iwaicb53c622007-08-10 17:21:45 +02007919 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007920 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007921 * Note: PASD motherboards uses the Line In 2 as the input for
7922 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007923 */
7924 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007925 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7926 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7927 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7928 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7929 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007930
7931 /*
7932 * Set up output mixers (0x0c - 0x0f)
7933 */
7934 /* set vol=0 to output mixers */
7935 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7936 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7937 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7938 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7939 /* set up input amps for analog loopback */
7940 /* Amp Indices: DAC = 0, mixer = 1 */
7941 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7942 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7943 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7944 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7945 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7946 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7947 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7948 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7949 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7950 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7951
7952 /* FIXME: use matrix-type input source selection */
7953 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
7954 /* Input mixer1 */
7955 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7956 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7957 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007958 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007959 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
7960 /* Input mixer2 */
7961 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7962 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7963 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007964 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
Andy Shevchenkoe3cde642007-12-03 16:50:58 +01007965 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007966
7967 { }
7968};
7969
7970/* capture mixer elements */
7971static struct snd_kcontrol_new alc883_capture_mixer[] = {
7972 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
7973 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
7974 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
7975 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
7976 {
7977 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7978 /* The multiple "Capture Source" controls confuse alsamixer
7979 * So call somewhat different..
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007980 */
7981 /* .name = "Capture Source", */
7982 .name = "Input Source",
7983 .count = 2,
7984 .info = alc882_mux_enum_info,
7985 .get = alc882_mux_enum_get,
7986 .put = alc882_mux_enum_put,
7987 },
7988 { } /* end */
7989};
7990
Takashi Iwaicb53c622007-08-10 17:21:45 +02007991#ifdef CONFIG_SND_HDA_POWER_SAVE
7992#define alc883_loopbacks alc880_loopbacks
7993#endif
7994
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007995/* pcm configuration: identiacal with ALC880 */
7996#define alc883_pcm_analog_playback alc880_pcm_analog_playback
7997#define alc883_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +01007998#define alc883_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007999#define alc883_pcm_digital_playback alc880_pcm_digital_playback
8000#define alc883_pcm_digital_capture alc880_pcm_digital_capture
8001
8002/*
8003 * configuration and preset
8004 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008005static const char *alc883_models[ALC883_MODEL_LAST] = {
8006 [ALC883_3ST_2ch_DIG] = "3stack-dig",
8007 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
8008 [ALC883_3ST_6ch] = "3stack-6ch",
8009 [ALC883_6ST_DIG] = "6stack-dig",
8010 [ALC883_TARGA_DIG] = "targa-dig",
8011 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008012 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02008013 [ALC883_ACER_ASPIRE] = "acer-aspire",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008014 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02008015 [ALC883_MEDION_MD2] = "medion-md2",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008016 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008017 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02008018 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
8019 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yang189609a2007-08-20 11:31:23 +02008020 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008021 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008022 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008023 [ALC883_MITAC] = "mitac",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008024 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01008025 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Jiang zhe17bba1b2008-06-04 12:11:07 +02008026 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008027 [ALC883_AUTO] = "auto",
8028};
8029
8030static struct snd_pci_quirk alc883_cfg_tbl[] = {
8031 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008032 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
8033 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
8034 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02008035 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008036 SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008037 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Tobin Davisfebe3372007-06-12 11:27:46 +02008038 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008039 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
8040 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01008041 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008042 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Travis Place97ec7102008-05-23 18:31:46 +02008043 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008044 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008045 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
8046 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
8047 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Tobin Davis57b14f22007-04-18 23:05:36 +02008048 SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008049 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
8050 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
8051 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Jiang zhe4383fae2008-04-14 12:58:57 +02008052 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008053 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01008054 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008055 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
8056 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
8057 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
8058 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
8059 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
8060 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
8061 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
8062 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
8063 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008064 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
8065 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02008066 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01008067 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01008068 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02008069 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008070 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008071 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008072 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
8073 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008074 SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04008075 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008076 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Jiang zhefb97dc62008-03-06 11:07:11 +01008077 SND_PCI_QUIRK(0x1734, 0x1108, "Fujitsu AMILO Pi2515", ALC883_FUJITSU_PI2515),
Kailang Yang272a5272007-05-14 11:00:38 +02008078 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02008079 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008080 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
8081 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yang272a5272007-05-14 11:00:38 +02008082 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01008083 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02008084 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008085 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
8086 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01008087 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008088 {}
8089};
8090
8091static struct alc_config_preset alc883_presets[] = {
8092 [ALC883_3ST_2ch_DIG] = {
8093 .mixers = { alc883_3ST_2ch_mixer },
8094 .init_verbs = { alc883_init_verbs },
8095 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8096 .dac_nids = alc883_dac_nids,
8097 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008098 .dig_in_nid = ALC883_DIGIN_NID,
8099 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8100 .channel_mode = alc883_3ST_2ch_modes,
8101 .input_mux = &alc883_capture_source,
8102 },
8103 [ALC883_3ST_6ch_DIG] = {
8104 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8105 .init_verbs = { alc883_init_verbs },
8106 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8107 .dac_nids = alc883_dac_nids,
8108 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008109 .dig_in_nid = ALC883_DIGIN_NID,
8110 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8111 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008112 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008113 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008114 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008115 [ALC883_3ST_6ch] = {
8116 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8117 .init_verbs = { alc883_init_verbs },
8118 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8119 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008120 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8121 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02008122 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008123 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008124 },
Jiang zhe17bba1b2008-06-04 12:11:07 +02008125 [ALC883_3ST_6ch_INTEL] = {
8126 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
8127 .init_verbs = { alc883_init_verbs },
8128 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8129 .dac_nids = alc883_dac_nids,
8130 .dig_out_nid = ALC883_DIGOUT_NID,
8131 .dig_in_nid = ALC883_DIGIN_NID,
8132 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
8133 .channel_mode = alc883_3ST_6ch_intel_modes,
8134 .need_dac_fix = 1,
8135 .input_mux = &alc883_3stack_6ch_intel,
8136 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008137 [ALC883_6ST_DIG] = {
8138 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
8139 .init_verbs = { alc883_init_verbs },
8140 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8141 .dac_nids = alc883_dac_nids,
8142 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008143 .dig_in_nid = ALC883_DIGIN_NID,
8144 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8145 .channel_mode = alc883_sixstack_modes,
8146 .input_mux = &alc883_capture_source,
8147 },
Kailang Yangccc656c2006-10-17 12:32:26 +02008148 [ALC883_TARGA_DIG] = {
8149 .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
8150 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8151 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8152 .dac_nids = alc883_dac_nids,
8153 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008154 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8155 .channel_mode = alc883_3ST_6ch_modes,
8156 .need_dac_fix = 1,
8157 .input_mux = &alc883_capture_source,
8158 .unsol_event = alc883_tagra_unsol_event,
8159 .init_hook = alc883_tagra_automute,
8160 },
8161 [ALC883_TARGA_2ch_DIG] = {
8162 .mixers = { alc883_tagra_2ch_mixer},
8163 .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
8164 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8165 .dac_nids = alc883_dac_nids,
8166 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +02008167 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8168 .channel_mode = alc883_3ST_2ch_modes,
8169 .input_mux = &alc883_capture_source,
8170 .unsol_event = alc883_tagra_unsol_event,
8171 .init_hook = alc883_tagra_automute,
8172 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008173 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008174 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008175 /* On TravelMate laptops, GPIO 0 enables the internal speaker
8176 * and the headphone jack. Turn this on and rely on the
8177 * standard mute methods whenever the user wants to turn
8178 * these outputs off.
8179 */
8180 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
8181 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8182 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +02008183 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8184 .channel_mode = alc883_3ST_2ch_modes,
8185 .input_mux = &alc883_capture_source,
8186 },
Tobin Davis2880a862007-08-07 11:50:26 +02008187 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008188 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +02008189 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +02008190 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8191 .dac_nids = alc883_dac_nids,
8192 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +02008193 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8194 .channel_mode = alc883_3ST_2ch_modes,
8195 .input_mux = &alc883_capture_source,
Takashi Iwai676a9b52007-08-16 15:23:35 +02008196 .unsol_event = alc883_acer_aspire_unsol_event,
8197 .init_hook = alc883_acer_aspire_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +02008198 },
Tobin Davisc07584c2006-10-13 12:32:16 +02008199 [ALC883_MEDION] = {
8200 .mixers = { alc883_fivestack_mixer,
8201 alc883_chmode_mixer },
8202 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008203 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +02008204 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8205 .dac_nids = alc883_dac_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +02008206 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8207 .channel_mode = alc883_sixstack_modes,
8208 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008209 },
Kailang Yang272a5272007-05-14 11:00:38 +02008210 [ALC883_MEDION_MD2] = {
8211 .mixers = { alc883_medion_md2_mixer},
8212 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
8213 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8214 .dac_nids = alc883_dac_nids,
8215 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008216 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8217 .channel_mode = alc883_3ST_2ch_modes,
8218 .input_mux = &alc883_capture_source,
8219 .unsol_event = alc883_medion_md2_unsol_event,
8220 .init_hook = alc883_medion_md2_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +02008221 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008222 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +02008223 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008224 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
8225 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8226 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008227 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8228 .channel_mode = alc883_3ST_2ch_modes,
8229 .input_mux = &alc883_capture_source,
8230 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008231 [ALC883_CLEVO_M720] = {
8232 .mixers = { alc883_clevo_m720_mixer },
8233 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +01008234 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8235 .dac_nids = alc883_dac_nids,
8236 .dig_out_nid = ALC883_DIGOUT_NID,
8237 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8238 .channel_mode = alc883_3ST_2ch_modes,
8239 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008240 .unsol_event = alc883_clevo_m720_unsol_event,
8241 .init_hook = alc883_clevo_m720_automute,
Jiang zhe368c7a92008-03-04 11:20:33 +01008242 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008243 [ALC883_LENOVO_101E_2ch] = {
8244 .mixers = { alc883_lenovo_101e_2ch_mixer},
8245 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
8246 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8247 .dac_nids = alc883_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008248 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8249 .channel_mode = alc883_3ST_2ch_modes,
8250 .input_mux = &alc883_lenovo_101e_capture_source,
8251 .unsol_event = alc883_lenovo_101e_unsol_event,
8252 .init_hook = alc883_lenovo_101e_all_automute,
8253 },
Kailang Yang272a5272007-05-14 11:00:38 +02008254 [ALC883_LENOVO_NB0763] = {
8255 .mixers = { alc883_lenovo_nb0763_mixer },
8256 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
8257 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8258 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +02008259 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8260 .channel_mode = alc883_3ST_2ch_modes,
8261 .need_dac_fix = 1,
8262 .input_mux = &alc883_lenovo_nb0763_capture_source,
8263 .unsol_event = alc883_medion_md2_unsol_event,
8264 .init_hook = alc883_medion_md2_automute,
8265 },
8266 [ALC888_LENOVO_MS7195_DIG] = {
8267 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
8268 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
8269 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8270 .dac_nids = alc883_dac_nids,
8271 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +02008272 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
8273 .channel_mode = alc883_3ST_6ch_modes,
8274 .need_dac_fix = 1,
8275 .input_mux = &alc883_capture_source,
8276 .unsol_event = alc883_lenovo_ms7195_unsol_event,
8277 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +02008278 },
8279 [ALC883_HAIER_W66] = {
8280 .mixers = { alc883_tagra_2ch_mixer},
8281 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
8282 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8283 .dac_nids = alc883_dac_nids,
8284 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +02008285 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8286 .channel_mode = alc883_3ST_2ch_modes,
8287 .input_mux = &alc883_capture_source,
8288 .unsol_event = alc883_haier_w66_unsol_event,
8289 .init_hook = alc883_haier_w66_automute,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008290 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008291 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +01008292 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008293 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008294 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8295 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +02008296 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
8297 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +02008298 .need_dac_fix = 1,
8299 .input_mux = &alc883_capture_source,
8300 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008301 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +01008302 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008303 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
8304 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8305 .dac_nids = alc883_dac_nids,
8306 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01008307 .dig_in_nid = ALC883_DIGIN_NID,
8308 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
8309 .channel_mode = alc883_sixstack_modes,
8310 .input_mux = &alc883_capture_source,
8311 .unsol_event = alc888_6st_dell_unsol_event,
8312 .init_hook = alc888_6st_dell_front_automute,
8313 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008314 [ALC883_MITAC] = {
8315 .mixers = { alc883_mitac_mixer },
8316 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
8317 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8318 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008319 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8320 .channel_mode = alc883_3ST_2ch_modes,
8321 .input_mux = &alc883_capture_source,
8322 .unsol_event = alc883_mitac_unsol_event,
8323 .init_hook = alc883_mitac_automute,
8324 },
Jiang zhefb97dc62008-03-06 11:07:11 +01008325 [ALC883_FUJITSU_PI2515] = {
8326 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
8327 .init_verbs = { alc883_init_verbs,
8328 alc883_2ch_fujitsu_pi2515_verbs},
8329 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
8330 .dac_nids = alc883_dac_nids,
8331 .dig_out_nid = ALC883_DIGOUT_NID,
8332 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
8333 .channel_mode = alc883_3ST_2ch_modes,
8334 .input_mux = &alc883_fujitsu_pi2515_capture_source,
8335 .unsol_event = alc883_2ch_fujitsu_pi2515_unsol_event,
8336 .init_hook = alc883_2ch_fujitsu_pi2515_automute,
8337 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008338};
8339
8340
8341/*
8342 * BIOS auto configuration
8343 */
8344static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
8345 hda_nid_t nid, int pin_type,
8346 int dac_idx)
8347{
8348 /* set as output */
8349 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008350 int idx;
8351
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008352 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008353 if (spec->multiout.dac_nids[dac_idx] == 0x25)
8354 idx = 4;
8355 else
8356 idx = spec->multiout.dac_nids[dac_idx] - 2;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008357 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
8358
8359}
8360
8361static void alc883_auto_init_multi_out(struct hda_codec *codec)
8362{
8363 struct alc_spec *spec = codec->spec;
8364 int i;
8365
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008366 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008367 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008368 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008369 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008370 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02008371 alc883_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008372 i);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008373 }
8374}
8375
8376static void alc883_auto_init_hp_out(struct hda_codec *codec)
8377{
8378 struct alc_spec *spec = codec->spec;
8379 hda_nid_t pin;
8380
Takashi Iwaieb06ed82006-09-20 17:10:27 +02008381 pin = spec->autocfg.hp_pins[0];
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008382 if (pin) /* connect to front */
8383 /* use dac 0 */
8384 alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008385 pin = spec->autocfg.speaker_pins[0];
8386 if (pin)
8387 alc883_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008388}
8389
8390#define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
8391#define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
8392
8393static void alc883_auto_init_analog_input(struct hda_codec *codec)
8394{
8395 struct alc_spec *spec = codec->spec;
8396 int i;
8397
8398 for (i = 0; i < AUTO_PIN_LAST; i++) {
8399 hda_nid_t nid = spec->autocfg.input_pins[i];
8400 if (alc883_is_input_pin(nid)) {
8401 snd_hda_codec_write(codec, nid, 0,
8402 AC_VERB_SET_PIN_WIDGET_CONTROL,
8403 (i <= AUTO_PIN_FRONT_MIC ?
8404 PIN_VREF80 : PIN_IN));
8405 if (nid != ALC883_PIN_CD_NID)
8406 snd_hda_codec_write(codec, nid, 0,
8407 AC_VERB_SET_AMP_GAIN_MUTE,
8408 AMP_OUT_MUTE);
8409 }
8410 }
8411}
8412
Takashi Iwaif511b012008-08-15 16:46:42 +02008413#define alc883_auto_init_input_src alc882_auto_init_input_src
8414
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008415/* almost identical with ALC880 parser... */
8416static int alc883_parse_auto_config(struct hda_codec *codec)
8417{
8418 struct alc_spec *spec = codec->spec;
8419 int err = alc880_parse_auto_config(codec);
8420
8421 if (err < 0)
8422 return err;
Takashi Iwai776e1842007-08-29 15:07:11 +02008423 else if (!err)
8424 return 0; /* no config found */
8425
8426 err = alc_auto_add_mic_boost(codec);
8427 if (err < 0)
8428 return err;
8429
8430 /* hack - override the init verbs */
8431 spec->init_verbs[0] = alc883_auto_init_verbs;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008432 spec->mixers[spec->num_mixers] = alc883_capture_mixer;
8433 spec->num_mixers++;
Takashi Iwai776e1842007-08-29 15:07:11 +02008434
8435 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008436}
8437
8438/* additional initialization for auto-configuration model */
8439static void alc883_auto_init(struct hda_codec *codec)
8440{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008441 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008442 alc883_auto_init_multi_out(codec);
8443 alc883_auto_init_hp_out(codec);
8444 alc883_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02008445 alc883_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01008446 if (spec->unsol_event)
8447 alc_sku_automute(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008448}
8449
8450static int patch_alc883(struct hda_codec *codec)
8451{
8452 struct alc_spec *spec;
8453 int err, board_config;
8454
8455 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
8456 if (spec == NULL)
8457 return -ENOMEM;
8458
8459 codec->spec = spec;
8460
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02008461 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
8462
Takashi Iwaif5fcc132006-11-24 17:07:44 +01008463 board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
8464 alc883_models,
8465 alc883_cfg_tbl);
8466 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008467 printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
8468 "trying auto-probe from BIOS...\n");
8469 board_config = ALC883_AUTO;
8470 }
8471
8472 if (board_config == ALC883_AUTO) {
8473 /* automatic parse from the BIOS config */
8474 err = alc883_parse_auto_config(codec);
8475 if (err < 0) {
8476 alc_free(codec);
8477 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008478 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008479 printk(KERN_INFO
8480 "hda_codec: Cannot set up configuration "
8481 "from BIOS. Using base mode...\n");
8482 board_config = ALC883_3ST_2ch_DIG;
8483 }
8484 }
8485
8486 if (board_config != ALC883_AUTO)
8487 setup_preset(spec, &alc883_presets[board_config]);
8488
Kailang Yang2f893282008-05-27 12:14:47 +02008489 switch (codec->vendor_id) {
8490 case 0x10ec0888:
8491 spec->stream_name_analog = "ALC888 Analog";
8492 spec->stream_name_digital = "ALC888 Digital";
8493 break;
8494 case 0x10ec0889:
8495 spec->stream_name_analog = "ALC889 Analog";
8496 spec->stream_name_digital = "ALC889 Digital";
8497 break;
8498 default:
8499 spec->stream_name_analog = "ALC883 Analog";
8500 spec->stream_name_digital = "ALC883 Digital";
8501 break;
8502 }
8503
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008504 spec->stream_analog_playback = &alc883_pcm_analog_playback;
8505 spec->stream_analog_capture = &alc883_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01008506 spec->stream_analog_alt_capture = &alc883_pcm_analog_alt_capture;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008507
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008508 spec->stream_digital_playback = &alc883_pcm_digital_playback;
8509 spec->stream_digital_capture = &alc883_pcm_digital_capture;
8510
Takashi Iwaie1406342008-02-11 18:32:32 +01008511 spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
8512 spec->adc_nids = alc883_adc_nids;
8513 spec->capsrc_nids = alc883_capsrc_nids;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008514
Takashi Iwai2134ea42008-01-10 16:53:55 +01008515 spec->vmaster_nid = 0x0c;
8516
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008517 codec->patch_ops = alc_patch_ops;
8518 if (board_config == ALC883_AUTO)
8519 spec->init_hook = alc883_auto_init;
Kailang Yangf9423e72008-05-27 12:32:25 +02008520
Takashi Iwaicb53c622007-08-10 17:21:45 +02008521#ifdef CONFIG_SND_HDA_POWER_SAVE
8522 if (!spec->loopback.amplist)
8523 spec->loopback.amplist = alc883_loopbacks;
8524#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008525
8526 return 0;
8527}
8528
8529/*
Kailang Yangdf694da2005-12-05 19:42:22 +01008530 * ALC262 support
8531 */
8532
8533#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
8534#define ALC262_DIGIN_NID ALC880_DIGIN_NID
8535
8536#define alc262_dac_nids alc260_dac_nids
8537#define alc262_adc_nids alc882_adc_nids
8538#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +01008539#define alc262_capsrc_nids alc882_capsrc_nids
8540#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +01008541
8542#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +01008543#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +01008544
Kailang Yang4e555fe2008-08-26 13:05:55 +02008545static hda_nid_t alc262_dmic_adc_nids[1] = {
8546 /* ADC0 */
8547 0x09
8548};
8549
8550static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
8551
Kailang Yangdf694da2005-12-05 19:42:22 +01008552static struct snd_kcontrol_new alc262_base_mixer[] = {
8553 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8554 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8555 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8556 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8557 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8558 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8559 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8560 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008561 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008562 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8563 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008564 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008565 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008566 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangdf694da2005-12-05 19:42:22 +01008567 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
8568 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8569 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8570 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01008571 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +01008572};
8573
Kailang Yangccc656c2006-10-17 12:32:26 +02008574static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
8575 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8576 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8577 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8578 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8579 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8580 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8581 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8582 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008583 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008584 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8585 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008586 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008587 /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01008588 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT), */
Kailang Yangccc656c2006-10-17 12:32:26 +02008589 /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
8590 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8591 { } /* end */
8592};
8593
Takashi Iwaice875f02008-01-28 18:17:43 +01008594/* update HP, line and mono-out pins according to the master switch */
8595static void alc262_hp_master_update(struct hda_codec *codec)
8596{
8597 struct alc_spec *spec = codec->spec;
8598 int val = spec->master_sw;
8599
8600 /* HP & line-out */
8601 snd_hda_codec_write_cache(codec, 0x1b, 0,
8602 AC_VERB_SET_PIN_WIDGET_CONTROL,
8603 val ? PIN_HP : 0);
8604 snd_hda_codec_write_cache(codec, 0x15, 0,
8605 AC_VERB_SET_PIN_WIDGET_CONTROL,
8606 val ? PIN_HP : 0);
8607 /* mono (speaker) depending on the HP jack sense */
8608 val = val && !spec->jack_present;
8609 snd_hda_codec_write_cache(codec, 0x16, 0,
8610 AC_VERB_SET_PIN_WIDGET_CONTROL,
8611 val ? PIN_OUT : 0);
8612}
8613
8614static void alc262_hp_bpc_automute(struct hda_codec *codec)
8615{
8616 struct alc_spec *spec = codec->spec;
8617 unsigned int presence;
8618 presence = snd_hda_codec_read(codec, 0x1b, 0,
8619 AC_VERB_GET_PIN_SENSE, 0);
8620 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8621 alc262_hp_master_update(codec);
8622}
8623
8624static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
8625{
8626 if ((res >> 26) != ALC880_HP_EVENT)
8627 return;
8628 alc262_hp_bpc_automute(codec);
8629}
8630
8631static void alc262_hp_wildwest_automute(struct hda_codec *codec)
8632{
8633 struct alc_spec *spec = codec->spec;
8634 unsigned int presence;
8635 presence = snd_hda_codec_read(codec, 0x15, 0,
8636 AC_VERB_GET_PIN_SENSE, 0);
8637 spec->jack_present = !!(presence & AC_PINSENSE_PRESENCE);
8638 alc262_hp_master_update(codec);
8639}
8640
8641static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
8642 unsigned int res)
8643{
8644 if ((res >> 26) != ALC880_HP_EVENT)
8645 return;
8646 alc262_hp_wildwest_automute(codec);
8647}
8648
8649static int alc262_hp_master_sw_get(struct snd_kcontrol *kcontrol,
8650 struct snd_ctl_elem_value *ucontrol)
8651{
8652 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8653 struct alc_spec *spec = codec->spec;
8654 *ucontrol->value.integer.value = spec->master_sw;
8655 return 0;
8656}
8657
8658static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
8659 struct snd_ctl_elem_value *ucontrol)
8660{
8661 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8662 struct alc_spec *spec = codec->spec;
8663 int val = !!*ucontrol->value.integer.value;
8664
8665 if (val == spec->master_sw)
8666 return 0;
8667 spec->master_sw = val;
8668 alc262_hp_master_update(codec);
8669 return 1;
8670}
8671
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008672static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008673 {
8674 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8675 .name = "Master Playback Switch",
8676 .info = snd_ctl_boolean_mono_info,
8677 .get = alc262_hp_master_sw_get,
8678 .put = alc262_hp_master_sw_put,
8679 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008680 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8681 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008683 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8684 HDA_OUTPUT),
8685 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8686 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8688 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008689 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008690 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8691 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008692 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008693 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8694 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8695 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8696 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8697 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8698 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8699 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
8700 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
8701 { } /* end */
8702};
8703
Kailang Yangcd7509a2007-01-26 18:33:17 +01008704static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaice875f02008-01-28 18:17:43 +01008705 {
8706 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8707 .name = "Master Playback Switch",
8708 .info = snd_ctl_boolean_mono_info,
8709 .get = alc262_hp_master_sw_get,
8710 .put = alc262_hp_master_sw_put,
8711 },
Kailang Yangcd7509a2007-01-26 18:33:17 +01008712 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8713 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8714 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8715 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +01008716 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
8717 HDA_OUTPUT),
8718 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
8719 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008720 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
8721 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008722 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008723 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8724 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8725 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8726 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8727 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
8728 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
8729 { } /* end */
8730};
8731
8732static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
8733 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8734 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +01008735 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +01008736 { } /* end */
8737};
8738
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008739/* mute/unmute internal speaker according to the hp jack and mute state */
8740static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
8741{
8742 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008743
8744 if (force || !spec->sense_updated) {
8745 unsigned int present;
8746 present = snd_hda_codec_read(codec, 0x15, 0,
8747 AC_VERB_GET_PIN_SENSE, 0);
Takashi Iwai4bb26132008-01-28 18:12:42 +01008748 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008749 spec->sense_updated = 1;
8750 }
Takashi Iwai4bb26132008-01-28 18:12:42 +01008751 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0, HDA_AMP_MUTE,
8752 spec->jack_present ? HDA_AMP_MUTE : 0);
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008753}
8754
8755static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
8756 unsigned int res)
8757{
8758 if ((res >> 26) != ALC880_HP_EVENT)
8759 return;
8760 alc262_hp_t5735_automute(codec, 1);
8761}
8762
8763static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
8764{
8765 alc262_hp_t5735_automute(codec, 1);
8766}
8767
8768static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +01008769 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8770 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01008771 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8772 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8774 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8775 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8776 { } /* end */
8777};
8778
8779static struct hda_verb alc262_hp_t5735_verbs[] = {
8780 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8781 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8782
8783 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8784 { }
8785};
8786
Kailang Yang8c427222008-01-10 13:03:59 +01008787static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +01008788 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8789 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008790 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8791 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +01008792 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8793 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
8794 { } /* end */
8795};
8796
8797static struct hda_verb alc262_hp_rp5700_verbs[] = {
8798 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8799 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8800 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8801 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8802 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8803 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8804 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8805 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
8806 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8807 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
8808 {}
8809};
8810
8811static struct hda_input_mux alc262_hp_rp5700_capture_source = {
8812 .num_items = 1,
8813 .items = {
8814 { "Line", 0x1 },
8815 },
8816};
8817
Takashi Iwai0724ea22007-08-23 00:31:43 +02008818/* bind hp and internal speaker mute (with plug check) */
8819static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
8820 struct snd_ctl_elem_value *ucontrol)
8821{
8822 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
8823 long *valp = ucontrol->value.integer.value;
8824 int change;
8825
8826 /* change hp mute */
8827 change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
8828 HDA_AMP_MUTE,
8829 valp[0] ? 0 : HDA_AMP_MUTE);
8830 change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
8831 HDA_AMP_MUTE,
8832 valp[1] ? 0 : HDA_AMP_MUTE);
8833 if (change) {
8834 /* change speaker according to HP jack state */
8835 struct alc_spec *spec = codec->spec;
8836 unsigned int mute;
8837 if (spec->jack_present)
8838 mute = HDA_AMP_MUTE;
8839 else
8840 mute = snd_hda_codec_amp_read(codec, 0x15, 0,
8841 HDA_OUTPUT, 0);
8842 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
8843 HDA_AMP_MUTE, mute);
8844 }
8845 return change;
8846}
Takashi Iwai5b319542007-07-26 11:49:22 +02008847
Kailang Yang272a5272007-05-14 11:00:38 +02008848static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +02008849 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8850 {
8851 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8852 .name = "Master Playback Switch",
8853 .info = snd_hda_mixer_amp_switch_info,
8854 .get = snd_hda_mixer_amp_switch_get,
8855 .put = alc262_sony_master_sw_put,
8856 .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
8857 },
Kailang Yang272a5272007-05-14 11:00:38 +02008858 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8859 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8860 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8861 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8862 { } /* end */
8863};
8864
Kailang Yang83c34212007-07-05 11:43:05 +02008865static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
8866 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8867 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8868 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8869 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8870 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8871 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
8872 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
8873 { } /* end */
8874};
Kailang Yang272a5272007-05-14 11:00:38 +02008875
Kailang Yangdf694da2005-12-05 19:42:22 +01008876#define alc262_capture_mixer alc882_capture_mixer
8877#define alc262_capture_alt_mixer alc882_capture_alt_mixer
8878
8879/*
8880 * generic initialization of ADC, input mixers and output mixers
8881 */
8882static struct hda_verb alc262_init_verbs[] = {
8883 /*
8884 * Unmute ADC0-2 and set the default input to mic-in
8885 */
8886 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8887 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8888 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8889 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8890 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8891 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8892
Takashi Iwaicb53c622007-08-10 17:21:45 +02008893 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01008894 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008895 * Note: PASD motherboards uses the Line In 2 as the input for
8896 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01008897 */
8898 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02008899 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8900 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8901 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8902 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8903 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008904
8905 /*
8906 * Set up output mixers (0x0c - 0x0e)
8907 */
8908 /* set vol=0 to output mixers */
8909 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8910 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8911 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8912 /* set up input amps for analog loopback */
8913 /* Amp Indices: DAC = 0, mixer = 1 */
8914 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8915 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8916 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8917 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8918 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8919 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8920
8921 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8922 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8923 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
8924 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
8925 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8926 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
8927
8928 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8929 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8930 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8931 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8932 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +02008933
Kailang Yangdf694da2005-12-05 19:42:22 +01008934 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8935 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +02008936
Kailang Yangdf694da2005-12-05 19:42:22 +01008937 /* FIXME: use matrix-type input source selection */
8938 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8939 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8940 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8941 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8942 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8943 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8944 /* Input mixer2 */
8945 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8946 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8947 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
8948 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
8949 /* Input mixer3 */
8950 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
8951 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
8952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +01008954
8955 { }
8956};
8957
Kailang Yang4e555fe2008-08-26 13:05:55 +02008958static struct hda_verb alc262_eapd_verbs[] = {
8959 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8960 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8961 { }
8962};
8963
Kailang Yangccc656c2006-10-17 12:32:26 +02008964static struct hda_verb alc262_hippo_unsol_verbs[] = {
8965 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8966 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8967 {}
8968};
8969
8970static struct hda_verb alc262_hippo1_unsol_verbs[] = {
8971 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8972 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
8973 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
8974
8975 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8976 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8977 {}
8978};
8979
Kailang Yang272a5272007-05-14 11:00:38 +02008980static struct hda_verb alc262_sony_unsol_verbs[] = {
8981 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
8982 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8983 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
8984
8985 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8986 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +09008987 {}
Kailang Yang272a5272007-05-14 11:00:38 +02008988};
8989
Kailang Yang4e555fe2008-08-26 13:05:55 +02008990static struct hda_input_mux alc262_dmic_capture_source = {
8991 .num_items = 2,
8992 .items = {
8993 { "Int DMic", 0x9 },
8994 { "Mic", 0x0 },
8995 },
8996};
8997
8998static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
8999 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9000 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9001 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9002 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9003 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9004 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
9005 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
9006 {
9007 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9008 /* The multiple "Capture Source" controls confuse alsamixer
9009 * So call somewhat different..
9010 */
9011 /* .name = "Capture Source", */
9012 .name = "Input Source",
9013 .count = 1,
9014 .info = alc_mux_enum_info,
9015 .get = alc_mux_enum_get,
9016 .put = alc_mux_enum_put,
9017 },
9018 { } /* end */
9019};
9020
9021static struct hda_verb alc262_toshiba_s06_verbs[] = {
9022 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
9023 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9024 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9025 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9026 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
9027 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9028 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
9029 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9030 {}
9031};
9032
9033static void alc262_dmic_automute(struct hda_codec *codec)
9034{
9035 unsigned int present;
9036
9037 present = snd_hda_codec_read(codec, 0x18, 0,
9038 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9039 snd_hda_codec_write(codec, 0x22, 0,
9040 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x09);
9041}
9042
9043/* toggle speaker-output according to the hp-jack state */
9044static void alc262_toshiba_s06_speaker_automute(struct hda_codec *codec)
9045{
9046 unsigned int present;
9047 unsigned char bits;
9048
9049 present = snd_hda_codec_read(codec, 0x15, 0,
9050 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
9051 bits = present ? 0 : PIN_OUT;
9052 snd_hda_codec_write(codec, 0x14, 0,
9053 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
9054}
9055
9056
9057
9058/* unsolicited event for HP jack sensing */
9059static void alc262_toshiba_s06_unsol_event(struct hda_codec *codec,
9060 unsigned int res)
9061{
9062 if ((res >> 26) == ALC880_HP_EVENT)
9063 alc262_toshiba_s06_speaker_automute(codec);
9064 if ((res >> 26) == ALC880_MIC_EVENT)
9065 alc262_dmic_automute(codec);
9066
9067}
9068
9069static void alc262_toshiba_s06_init_hook(struct hda_codec *codec)
9070{
9071 alc262_toshiba_s06_speaker_automute(codec);
9072 alc262_dmic_automute(codec);
9073}
9074
Kailang Yangccc656c2006-10-17 12:32:26 +02009075/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai5b319542007-07-26 11:49:22 +02009076static void alc262_hippo_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009077{
9078 struct alc_spec *spec = codec->spec;
9079 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009080 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009081
Takashi Iwai5b319542007-07-26 11:49:22 +02009082 /* need to execute and sync at first */
9083 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9084 present = snd_hda_codec_read(codec, 0x15, 0,
9085 AC_VERB_GET_PIN_SENSE, 0);
9086 spec->jack_present = (present & 0x80000000) != 0;
Kailang Yangccc656c2006-10-17 12:32:26 +02009087 if (spec->jack_present) {
9088 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009089 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9090 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009091 } else {
9092 /* unmute internal speaker if necessary */
9093 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009094 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9095 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009096 }
9097}
9098
9099/* unsolicited event for HP jack sensing */
9100static void alc262_hippo_unsol_event(struct hda_codec *codec,
9101 unsigned int res)
9102{
9103 if ((res >> 26) != ALC880_HP_EVENT)
9104 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009105 alc262_hippo_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009106}
9107
Takashi Iwai5b319542007-07-26 11:49:22 +02009108static void alc262_hippo1_automute(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02009109{
Kailang Yangccc656c2006-10-17 12:32:26 +02009110 unsigned int mute;
Takashi Iwai5b319542007-07-26 11:49:22 +02009111 unsigned int present;
Kailang Yangccc656c2006-10-17 12:32:26 +02009112
Takashi Iwai5b319542007-07-26 11:49:22 +02009113 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9114 present = snd_hda_codec_read(codec, 0x1b, 0,
9115 AC_VERB_GET_PIN_SENSE, 0);
9116 present = (present & 0x80000000) != 0;
9117 if (present) {
Kailang Yangccc656c2006-10-17 12:32:26 +02009118 /* mute internal speaker */
Takashi Iwai47fd8302007-08-10 17:11:07 +02009119 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9120 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangccc656c2006-10-17 12:32:26 +02009121 } else {
9122 /* unmute internal speaker if necessary */
9123 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
Takashi Iwai47fd8302007-08-10 17:11:07 +02009124 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9125 HDA_AMP_MUTE, mute);
Kailang Yangccc656c2006-10-17 12:32:26 +02009126 }
9127}
9128
9129/* unsolicited event for HP jack sensing */
9130static void alc262_hippo1_unsol_event(struct hda_codec *codec,
9131 unsigned int res)
9132{
9133 if ((res >> 26) != ALC880_HP_EVENT)
9134 return;
Takashi Iwai5b319542007-07-26 11:49:22 +02009135 alc262_hippo1_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02009136}
9137
Takashi Iwai834be882006-03-01 14:16:17 +01009138/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009139 * nec model
9140 * 0x15 = headphone
9141 * 0x16 = internal speaker
9142 * 0x18 = external mic
9143 */
9144
9145static struct snd_kcontrol_new alc262_nec_mixer[] = {
9146 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
9147 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
9148
9149 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9150 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9151 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9152
9153 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9154 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9155 { } /* end */
9156};
9157
9158static struct hda_verb alc262_nec_verbs[] = {
9159 /* Unmute Speaker */
9160 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9161
9162 /* Headphone */
9163 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9164 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9165
9166 /* External mic to headphone */
9167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9168 /* External mic to speaker */
9169 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9170 {}
9171};
9172
9173/*
Takashi Iwai834be882006-03-01 14:16:17 +01009174 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +01009175 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
9176 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +01009177 */
9178
9179#define ALC_HP_EVENT 0x37
9180
9181static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
9182 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +01009184 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9185 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +01009186 {}
9187};
9188
Jiang zhe0e31daf2008-03-20 12:12:39 +01009189static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
9190 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
9191 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9192 {}
9193};
9194
Takashi Iwai834be882006-03-01 14:16:17 +01009195static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009196 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +01009197 .items = {
9198 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009199 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +01009200 { "CD", 0x4 },
9201 },
9202};
9203
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009204static struct hda_input_mux alc262_HP_capture_source = {
9205 .num_items = 5,
9206 .items = {
9207 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +02009208 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009209 { "Line", 0x2 },
9210 { "CD", 0x4 },
9211 { "AUX IN", 0x6 },
9212 },
9213};
9214
zhejiangaccbe492007-08-31 12:36:05 +02009215static struct hda_input_mux alc262_HP_D7000_capture_source = {
9216 .num_items = 4,
9217 .items = {
9218 { "Mic", 0x0 },
9219 { "Front Mic", 0x2 },
9220 { "Line", 0x1 },
9221 { "CD", 0x4 },
9222 },
9223};
9224
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009225/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +01009226static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
9227{
9228 struct alc_spec *spec = codec->spec;
9229 unsigned int mute;
9230
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009231 if (force || !spec->sense_updated) {
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009232 unsigned int present;
Takashi Iwai834be882006-03-01 14:16:17 +01009233 /* need to execute and sync at first */
9234 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009235 /* check laptop HP jack */
9236 present = snd_hda_codec_read(codec, 0x14, 0,
9237 AC_VERB_GET_PIN_SENSE, 0);
9238 /* need to execute and sync at first */
9239 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9240 /* check docking HP jack */
9241 present |= snd_hda_codec_read(codec, 0x1b, 0,
9242 AC_VERB_GET_PIN_SENSE, 0);
9243 if (present & AC_PINSENSE_PRESENCE)
9244 spec->jack_present = 1;
9245 else
9246 spec->jack_present = 0;
Takashi Iwai834be882006-03-01 14:16:17 +01009247 spec->sense_updated = 1;
9248 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009249 /* unmute internal speaker only if both HPs are unplugged and
9250 * master switch is on
9251 */
9252 if (spec->jack_present)
9253 mute = HDA_AMP_MUTE;
9254 else
Takashi Iwai834be882006-03-01 14:16:17 +01009255 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009256 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9257 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +01009258}
9259
9260/* unsolicited event for HP jack sensing */
9261static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
9262 unsigned int res)
9263{
9264 if ((res >> 26) != ALC_HP_EVENT)
9265 return;
9266 alc262_fujitsu_automute(codec, 1);
9267}
9268
Takashi Iwaiebc7a402008-05-20 09:23:05 +02009269static void alc262_fujitsu_init_hook(struct hda_codec *codec)
9270{
9271 alc262_fujitsu_automute(codec, 1);
9272}
9273
Takashi Iwai834be882006-03-01 14:16:17 +01009274/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +02009275static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
9276 .ops = &snd_hda_bind_vol,
9277 .values = {
9278 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
9279 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
9280 0
9281 },
9282};
Takashi Iwai834be882006-03-01 14:16:17 +01009283
Jiang zhe0e31daf2008-03-20 12:12:39 +01009284/* mute/unmute internal speaker according to the hp jack and mute state */
9285static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
9286{
9287 struct alc_spec *spec = codec->spec;
9288 unsigned int mute;
9289
9290 if (force || !spec->sense_updated) {
9291 unsigned int present_int_hp;
9292 /* need to execute and sync at first */
9293 snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
9294 present_int_hp = snd_hda_codec_read(codec, 0x1b, 0,
9295 AC_VERB_GET_PIN_SENSE, 0);
9296 spec->jack_present = (present_int_hp & 0x80000000) != 0;
9297 spec->sense_updated = 1;
9298 }
9299 if (spec->jack_present) {
9300 /* mute internal speaker */
9301 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9302 HDA_AMP_MUTE, HDA_AMP_MUTE);
9303 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9304 HDA_AMP_MUTE, HDA_AMP_MUTE);
9305 } else {
9306 /* unmute internal speaker if necessary */
9307 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
9308 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9309 HDA_AMP_MUTE, mute);
9310 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9311 HDA_AMP_MUTE, mute);
9312 }
9313}
9314
9315/* unsolicited event for HP jack sensing */
9316static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
9317 unsigned int res)
9318{
9319 if ((res >> 26) != ALC_HP_EVENT)
9320 return;
9321 alc262_lenovo_3000_automute(codec, 1);
9322}
9323
Takashi Iwai834be882006-03-01 14:16:17 +01009324/* bind hp and internal speaker mute (with plug check) */
9325static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
9326 struct snd_ctl_elem_value *ucontrol)
9327{
9328 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9329 long *valp = ucontrol->value.integer.value;
9330 int change;
9331
Tony Vroon5d9fab22008-03-14 17:09:18 +01009332 change = snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9333 HDA_AMP_MUTE,
9334 valp ? 0 : HDA_AMP_MUTE);
9335 change |= snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9336 HDA_AMP_MUTE,
9337 valp ? 0 : HDA_AMP_MUTE);
9338
Takashi Iwai82beb8f2007-08-10 17:09:26 +02009339 if (change)
9340 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +01009341 return change;
9342}
9343
9344static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +02009345 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +01009346 {
9347 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9348 .name = "Master Playback Switch",
9349 .info = snd_hda_mixer_amp_switch_info,
9350 .get = snd_hda_mixer_amp_switch_get,
9351 .put = alc262_fujitsu_master_sw_put,
9352 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
9353 },
9354 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9355 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Tony Vroon06a9c302008-04-14 13:31:45 +02009356 HDA_CODEC_VOLUME("PC Speaker Volume", 0x0b, 0x05, HDA_INPUT),
9357 HDA_CODEC_MUTE("PC Speaker Switch", 0x0b, 0x05, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009358 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9359 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9360 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +02009361 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9362 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9363 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +01009364 { } /* end */
9365};
9366
Jiang zhe0e31daf2008-03-20 12:12:39 +01009367/* bind hp and internal speaker mute (with plug check) */
9368static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
9369 struct snd_ctl_elem_value *ucontrol)
9370{
9371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9372 long *valp = ucontrol->value.integer.value;
9373 int change;
9374
9375 change = snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
9376 HDA_AMP_MUTE,
9377 valp ? 0 : HDA_AMP_MUTE);
9378
9379 if (change)
9380 alc262_lenovo_3000_automute(codec, 0);
9381 return change;
9382}
9383
9384static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
9385 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
9386 {
9387 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9388 .name = "Master Playback Switch",
9389 .info = snd_hda_mixer_amp_switch_info,
9390 .get = snd_hda_mixer_amp_switch_get,
9391 .put = alc262_lenovo_3000_master_sw_put,
9392 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
9393 },
9394 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9395 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9396 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9397 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9398 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9399 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9400 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9401 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9402 { } /* end */
9403};
9404
Takashi Iwai304dcaa2006-07-25 14:51:16 +02009405/* additional init verbs for Benq laptops */
9406static struct hda_verb alc262_EAPD_verbs[] = {
9407 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9408 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
9409 {}
9410};
9411
Kailang Yang83c34212007-07-05 11:43:05 +02009412static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
9413 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9414 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9415
9416 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9417 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
9418 {}
9419};
9420
Tobin Davisf651b502007-10-26 12:40:47 +02009421/* Samsung Q1 Ultra Vista model setup */
9422static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009423 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9424 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009425 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
9426 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
9427 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009428 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +02009429 { } /* end */
9430};
9431
9432static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009433 /* output mixer */
9434 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9437 /* speaker */
9438 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9439 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9440 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9441 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9442 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +02009443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
9445 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9446 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9447 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
9448 /* internal mic */
9449 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
9450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9451 /* ADC, choose mic */
9452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9453 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9454 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9455 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9460 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
9461 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +02009462 {}
9463};
9464
Tobin Davisf651b502007-10-26 12:40:47 +02009465/* mute/unmute internal speaker according to the hp jack and mute state */
9466static void alc262_ultra_automute(struct hda_codec *codec)
9467{
9468 struct alc_spec *spec = codec->spec;
9469 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +02009470
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009471 mute = 0;
9472 /* auto-mute only when HP is used as HP */
9473 if (!spec->cur_mux[0]) {
9474 unsigned int present;
9475 /* need to execute and sync at first */
9476 snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
9477 present = snd_hda_codec_read(codec, 0x15, 0,
9478 AC_VERB_GET_PIN_SENSE, 0);
9479 spec->jack_present = (present & AC_PINSENSE_PRESENCE) != 0;
9480 if (spec->jack_present)
9481 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +02009482 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009483 /* mute/unmute internal speaker */
9484 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9485 HDA_AMP_MUTE, mute);
9486 /* mute/unmute HP */
9487 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9488 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +02009489}
9490
9491/* unsolicited event for HP jack sensing */
9492static void alc262_ultra_unsol_event(struct hda_codec *codec,
9493 unsigned int res)
9494{
9495 if ((res >> 26) != ALC880_HP_EVENT)
9496 return;
9497 alc262_ultra_automute(codec);
9498}
9499
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009500static struct hda_input_mux alc262_ultra_capture_source = {
9501 .num_items = 2,
9502 .items = {
9503 { "Mic", 0x1 },
9504 { "Headphone", 0x7 },
9505 },
9506};
9507
9508static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
9509 struct snd_ctl_elem_value *ucontrol)
9510{
9511 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
9512 struct alc_spec *spec = codec->spec;
9513 int ret;
9514
9515 ret = alc882_mux_enum_put(kcontrol, ucontrol);
9516 if (!ret)
9517 return 0;
9518 /* reprogram the HP pin as mic or HP according to the input source */
9519 snd_hda_codec_write_cache(codec, 0x15, 0,
9520 AC_VERB_SET_PIN_WIDGET_CONTROL,
9521 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
9522 alc262_ultra_automute(codec); /* mute/unmute HP */
9523 return ret;
9524}
9525
9526static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
9527 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
9528 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
9529 {
9530 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9531 .name = "Capture Source",
9532 .info = alc882_mux_enum_info,
9533 .get = alc882_mux_enum_get,
9534 .put = alc262_ultra_mux_enum_put,
9535 },
9536 { } /* end */
9537};
9538
Kailang Yangdf694da2005-12-05 19:42:22 +01009539/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009540static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
9541 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +01009542{
9543 hda_nid_t nid;
9544 int err;
9545
9546 spec->multiout.num_dacs = 1; /* only use one dac */
9547 spec->multiout.dac_nids = spec->private_dac_nids;
9548 spec->multiout.dac_nids[0] = 2;
9549
9550 nid = cfg->line_out_pins[0];
9551 if (nid) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009552 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9553 "Front Playback Volume",
9554 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
9555 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009556 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009557 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9558 "Front Playback Switch",
9559 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
9560 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009561 return err;
9562 }
9563
Takashi Iwai82bc9552006-03-21 11:24:42 +01009564 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009565 if (nid) {
9566 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009567 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9568 "Speaker Playback Volume",
9569 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9570 HDA_OUTPUT));
9571 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009572 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009573 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9574 "Speaker Playback Switch",
9575 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9576 HDA_OUTPUT));
9577 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009578 return err;
9579 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009580 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9581 "Speaker Playback Switch",
9582 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9583 HDA_OUTPUT));
9584 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009585 return err;
9586 }
9587 }
Takashi Iwaieb06ed82006-09-20 17:10:27 +02009588 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01009589 if (nid) {
9590 /* spec->multiout.hp_nid = 2; */
9591 if (nid == 0x16) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009592 err = add_control(spec, ALC_CTL_WIDGET_VOL,
9593 "Headphone Playback Volume",
9594 HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
9595 HDA_OUTPUT));
9596 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009597 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009598 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9599 "Headphone Playback Switch",
9600 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
9601 HDA_OUTPUT));
9602 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009603 return err;
9604 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009605 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
9606 "Headphone Playback Switch",
9607 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
9608 HDA_OUTPUT));
9609 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009610 return err;
9611 }
9612 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009613 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01009614}
9615
9616/* identical with ALC880 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009617#define alc262_auto_create_analog_input_ctls \
9618 alc880_auto_create_analog_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +01009619
9620/*
9621 * generic initialization of ADC, input mixers and output mixers
9622 */
9623static struct hda_verb alc262_volume_init_verbs[] = {
9624 /*
9625 * Unmute ADC0-2 and set the default input to mic-in
9626 */
9627 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9628 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9629 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9630 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9631 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9632 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9633
Takashi Iwaicb53c622007-08-10 17:21:45 +02009634 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +01009635 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009636 * Note: PASD motherboards uses the Line In 2 as the input for
9637 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01009638 */
9639 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9642 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9643 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9644 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01009645
9646 /*
9647 * Set up output mixers (0x0c - 0x0f)
9648 */
9649 /* set vol=0 to output mixers */
9650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9651 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9652 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +02009653
Kailang Yangdf694da2005-12-05 19:42:22 +01009654 /* set up input amps for analog loopback */
9655 /* Amp Indices: DAC = 0, mixer = 1 */
9656 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9657 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9658 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9659 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9660 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9661 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9662
9663 /* FIXME: use matrix-type input source selection */
9664 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9665 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9667 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9668 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9669 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9670 /* Input mixer2 */
9671 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9672 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9673 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9674 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9675 /* Input mixer3 */
9676 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9677 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
9678 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
9679 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
9680
9681 { }
9682};
9683
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009684static struct hda_verb alc262_HP_BPC_init_verbs[] = {
9685 /*
9686 * Unmute ADC0-2 and set the default input to mic-in
9687 */
9688 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9689 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9690 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9691 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9692 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9693 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9694
Takashi Iwaicb53c622007-08-10 17:21:45 +02009695 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009696 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009697 * Note: PASD motherboards uses the Line In 2 as the input for
9698 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009699 */
9700 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009701 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9702 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9703 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9704 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9705 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9706 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9707 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +02009708
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009709 /*
9710 * Set up output mixers (0x0c - 0x0e)
9711 */
9712 /* set vol=0 to output mixers */
9713 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9714 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9715 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9716
9717 /* set up input amps for analog loopback */
9718 /* Amp Indices: DAC = 0, mixer = 1 */
9719 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9720 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9721 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9722 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9723 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9724 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9725
Takashi Iwaice875f02008-01-28 18:17:43 +01009726 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009727 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9728 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9729
9730 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9731 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9732
9733 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9734 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9735
9736 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9737 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9738 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
9739 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9740 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
9741
9742 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9743 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9744 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9745 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9746 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9747 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9748
9749
9750 /* FIXME: use matrix-type input source selection */
9751 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9752 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9753 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9754 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9755 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9756 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9757 /* Input mixer2 */
9758 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9759 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9760 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9761 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9762 /* Input mixer3 */
9763 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9764 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9765 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9766 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9767
Takashi Iwaice875f02008-01-28 18:17:43 +01009768 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9769
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009770 { }
9771};
9772
Kailang Yangcd7509a2007-01-26 18:33:17 +01009773static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
9774 /*
9775 * Unmute ADC0-2 and set the default input to mic-in
9776 */
9777 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
9778 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9779 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
9780 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9781 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
9782 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9783
Takashi Iwaicb53c622007-08-10 17:21:45 +02009784 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +01009785 * mixer widget
9786 * Note: PASD motherboards uses the Line In 2 as the input for front
9787 * panel mic (mic 2)
9788 */
9789 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02009790 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9791 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9792 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
9793 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
9794 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
9795 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
9796 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
9797 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +01009798 /*
9799 * Set up output mixers (0x0c - 0x0e)
9800 */
9801 /* set vol=0 to output mixers */
9802 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9803 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9804 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
9805
9806 /* set up input amps for analog loopback */
9807 /* Amp Indices: DAC = 0, mixer = 1 */
9808 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9809 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9810 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9811 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9812 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9813 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9814
9815
9816 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
9817 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
9818 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
9819 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
9820 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
9821 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
9822 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
9823
9824 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9825 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9826
9827 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9828 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9829
9830 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
9831 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9832 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9833 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
9834 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9835 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
9836
9837 /* FIXME: use matrix-type input source selection */
9838 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
9839 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
9840 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
9841 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
9842 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
9843 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
9844 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
9845 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9846 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
9847 /* Input mixer2 */
9848 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9849 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9850 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9851 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9852 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9853 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9854 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9855 /* Input mixer3 */
9856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
9857 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
9858 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
9859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
9860 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
9861 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
9862 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
9863
Takashi Iwaice875f02008-01-28 18:17:43 +01009864 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9865
Kailang Yangcd7509a2007-01-26 18:33:17 +01009866 { }
9867};
9868
Takashi Iwaicb53c622007-08-10 17:21:45 +02009869#ifdef CONFIG_SND_HDA_POWER_SAVE
9870#define alc262_loopbacks alc880_loopbacks
9871#endif
9872
Kailang Yangdf694da2005-12-05 19:42:22 +01009873/* pcm configuration: identiacal with ALC880 */
9874#define alc262_pcm_analog_playback alc880_pcm_analog_playback
9875#define alc262_pcm_analog_capture alc880_pcm_analog_capture
9876#define alc262_pcm_digital_playback alc880_pcm_digital_playback
9877#define alc262_pcm_digital_capture alc880_pcm_digital_capture
9878
9879/*
9880 * BIOS auto configuration
9881 */
9882static int alc262_parse_auto_config(struct hda_codec *codec)
9883{
9884 struct alc_spec *spec = codec->spec;
9885 int err;
9886 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
9887
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009888 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
9889 alc262_ignore);
9890 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009891 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009892 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01009893 return 0; /* can't find valid BIOS pin config */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009894 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
9895 if (err < 0)
9896 return err;
9897 err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
9898 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01009899 return err;
9900
9901 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
9902
9903 if (spec->autocfg.dig_out_pin)
9904 spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
9905 if (spec->autocfg.dig_in_pin)
9906 spec->dig_in_nid = ALC262_DIGIN_NID;
9907
9908 if (spec->kctl_alloc)
9909 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
9910
9911 spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02009912 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +01009913 spec->input_mux = &spec->private_imux;
9914
Takashi Iwai776e1842007-08-29 15:07:11 +02009915 err = alc_auto_add_mic_boost(codec);
9916 if (err < 0)
9917 return err;
9918
Kailang Yangdf694da2005-12-05 19:42:22 +01009919 return 1;
9920}
9921
9922#define alc262_auto_init_multi_out alc882_auto_init_multi_out
9923#define alc262_auto_init_hp_out alc882_auto_init_hp_out
9924#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +02009925#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +01009926
9927
9928/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +01009929static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01009930{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009931 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01009932 alc262_auto_init_multi_out(codec);
9933 alc262_auto_init_hp_out(codec);
9934 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +02009935 alc262_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01009936 if (spec->unsol_event)
9937 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01009938}
9939
9940/*
9941 * configuration and preset
9942 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009943static const char *alc262_models[ALC262_MODEL_LAST] = {
9944 [ALC262_BASIC] = "basic",
9945 [ALC262_HIPPO] = "hippo",
9946 [ALC262_HIPPO_1] = "hippo_1",
9947 [ALC262_FUJITSU] = "fujitsu",
9948 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +01009949 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +01009950 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +01009951 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009952 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +02009953 [ALC262_BENQ_T31] = "benq-t31",
9954 [ALC262_SONY_ASSAMD] = "sony-assamd",
Tobin Davisf651b502007-10-26 12:40:47 +02009955 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +01009956 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009957 [ALC262_NEC] = "nec",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009958 [ALC262_AUTO] = "auto",
9959};
9960
9961static struct snd_pci_quirk alc262_cfg_tbl[] = {
9962 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +02009963 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009964 SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009965 SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009966 SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
9967 SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
Kailang Yang7d87de22007-06-05 12:17:21 +02009968 SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009969 SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009970 SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
Takashi Iwaib98f9332007-11-07 14:18:01 +01009971 SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009972 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009973 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009974 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009975 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009976 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009977 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009978 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +01009979 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009980 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
9981 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
9982 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +01009983 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
9984 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +01009985 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009986 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009987 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009988 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9989 SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
9990 SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
Akio Idehara36ca6e12008-06-09 22:57:40 +09009991 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
9992 ALC262_SONY_ASSAMD),
Kailang Yang4e555fe2008-08-26 13:05:55 +02009993 SND_PCI_QUIRK(0x1179, 0x0268, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009994 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +01009995 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009996 SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +01009997 SND_PCI_QUIRK(0x144d, 0xc039, "Samsung Q1U EL", ALC262_ULTRA),
Jiang zhe0e31daf2008-03-20 12:12:39 +01009998 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009999 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020010000 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010010001 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010010002 {}
10003};
10004
10005static struct alc_config_preset alc262_presets[] = {
10006 [ALC262_BASIC] = {
10007 .mixers = { alc262_base_mixer },
10008 .init_verbs = { alc262_init_verbs },
10009 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10010 .dac_nids = alc262_dac_nids,
10011 .hp_nid = 0x03,
10012 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10013 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010010014 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010010015 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010016 [ALC262_HIPPO] = {
10017 .mixers = { alc262_base_mixer },
10018 .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
10019 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10020 .dac_nids = alc262_dac_nids,
10021 .hp_nid = 0x03,
10022 .dig_out_nid = ALC262_DIGOUT_NID,
10023 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10024 .channel_mode = alc262_modes,
10025 .input_mux = &alc262_capture_source,
10026 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010027 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010028 },
10029 [ALC262_HIPPO_1] = {
10030 .mixers = { alc262_hippo1_mixer },
10031 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
10032 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10033 .dac_nids = alc262_dac_nids,
10034 .hp_nid = 0x02,
10035 .dig_out_nid = ALC262_DIGOUT_NID,
10036 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10037 .channel_mode = alc262_modes,
10038 .input_mux = &alc262_capture_source,
10039 .unsol_event = alc262_hippo1_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010040 .init_hook = alc262_hippo1_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010041 },
Takashi Iwai834be882006-03-01 14:16:17 +010010042 [ALC262_FUJITSU] = {
10043 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020010044 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10045 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010010046 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10047 .dac_nids = alc262_dac_nids,
10048 .hp_nid = 0x03,
10049 .dig_out_nid = ALC262_DIGOUT_NID,
10050 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10051 .channel_mode = alc262_modes,
10052 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010053 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020010054 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010010055 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010056 [ALC262_HP_BPC] = {
10057 .mixers = { alc262_HP_BPC_mixer },
10058 .init_verbs = { alc262_HP_BPC_init_verbs },
10059 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10060 .dac_nids = alc262_dac_nids,
10061 .hp_nid = 0x03,
10062 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10063 .channel_mode = alc262_modes,
10064 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010065 .unsol_event = alc262_hp_bpc_unsol_event,
10066 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010067 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010068 [ALC262_HP_BPC_D7000_WF] = {
10069 .mixers = { alc262_HP_BPC_WildWest_mixer },
10070 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10071 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10072 .dac_nids = alc262_dac_nids,
10073 .hp_nid = 0x03,
10074 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10075 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010076 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010077 .unsol_event = alc262_hp_wildwest_unsol_event,
10078 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010079 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010010080 [ALC262_HP_BPC_D7000_WL] = {
10081 .mixers = { alc262_HP_BPC_WildWest_mixer,
10082 alc262_HP_BPC_WildWest_option_mixer },
10083 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
10084 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10085 .dac_nids = alc262_dac_nids,
10086 .hp_nid = 0x03,
10087 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10088 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020010089 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010010090 .unsol_event = alc262_hp_wildwest_unsol_event,
10091 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010092 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010093 [ALC262_HP_TC_T5735] = {
10094 .mixers = { alc262_hp_t5735_mixer },
10095 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
10096 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10097 .dac_nids = alc262_dac_nids,
10098 .hp_nid = 0x03,
10099 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10100 .channel_mode = alc262_modes,
10101 .input_mux = &alc262_capture_source,
10102 .unsol_event = alc262_hp_t5735_unsol_event,
10103 .init_hook = alc262_hp_t5735_init_hook,
Kailang Yang8c427222008-01-10 13:03:59 +010010104 },
10105 [ALC262_HP_RP5700] = {
10106 .mixers = { alc262_hp_rp5700_mixer },
10107 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
10108 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10109 .dac_nids = alc262_dac_nids,
10110 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10111 .channel_mode = alc262_modes,
10112 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010010113 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020010114 [ALC262_BENQ_ED8] = {
10115 .mixers = { alc262_base_mixer },
10116 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
10117 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10118 .dac_nids = alc262_dac_nids,
10119 .hp_nid = 0x03,
10120 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10121 .channel_mode = alc262_modes,
10122 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010123 },
Kailang Yang272a5272007-05-14 11:00:38 +020010124 [ALC262_SONY_ASSAMD] = {
10125 .mixers = { alc262_sony_mixer },
10126 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
10127 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10128 .dac_nids = alc262_dac_nids,
10129 .hp_nid = 0x02,
10130 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10131 .channel_mode = alc262_modes,
10132 .input_mux = &alc262_capture_source,
10133 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010134 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020010135 },
10136 [ALC262_BENQ_T31] = {
10137 .mixers = { alc262_benq_t31_mixer },
10138 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
10139 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10140 .dac_nids = alc262_dac_nids,
10141 .hp_nid = 0x03,
10142 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10143 .channel_mode = alc262_modes,
10144 .input_mux = &alc262_capture_source,
10145 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai5b319542007-07-26 11:49:22 +020010146 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020010147 },
Tobin Davisf651b502007-10-26 12:40:47 +020010148 [ALC262_ULTRA] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010149 .mixers = { alc262_ultra_mixer, alc262_ultra_capture_mixer },
10150 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020010151 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10152 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020010153 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10154 .channel_mode = alc262_modes,
10155 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010010156 .adc_nids = alc262_adc_nids, /* ADC0 */
10157 .capsrc_nids = alc262_capsrc_nids,
10158 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020010159 .unsol_event = alc262_ultra_unsol_event,
10160 .init_hook = alc262_ultra_automute,
10161 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010010162 [ALC262_LENOVO_3000] = {
10163 .mixers = { alc262_lenovo_3000_mixer },
10164 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
10165 alc262_lenovo_3000_unsol_verbs },
10166 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10167 .dac_nids = alc262_dac_nids,
10168 .hp_nid = 0x03,
10169 .dig_out_nid = ALC262_DIGOUT_NID,
10170 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10171 .channel_mode = alc262_modes,
10172 .input_mux = &alc262_fujitsu_capture_source,
10173 .unsol_event = alc262_lenovo_3000_unsol_event,
10174 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020010175 [ALC262_NEC] = {
10176 .mixers = { alc262_nec_mixer },
10177 .init_verbs = { alc262_nec_verbs },
10178 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10179 .dac_nids = alc262_dac_nids,
10180 .hp_nid = 0x03,
10181 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10182 .channel_mode = alc262_modes,
10183 .input_mux = &alc262_capture_source,
10184 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020010185 [ALC262_TOSHIBA_S06] = {
10186 .mixers = { alc262_toshiba_s06_mixer },
10187 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
10188 alc262_eapd_verbs },
10189 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
10190 .capsrc_nids = alc262_dmic_capsrc_nids,
10191 .dac_nids = alc262_dac_nids,
10192 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
10193 .dig_out_nid = ALC262_DIGOUT_NID,
10194 .num_channel_mode = ARRAY_SIZE(alc262_modes),
10195 .channel_mode = alc262_modes,
10196 .input_mux = &alc262_dmic_capture_source,
10197 .unsol_event = alc262_toshiba_s06_unsol_event,
10198 .init_hook = alc262_toshiba_s06_init_hook,
10199 },
Kailang Yangdf694da2005-12-05 19:42:22 +010010200};
10201
10202static int patch_alc262(struct hda_codec *codec)
10203{
10204 struct alc_spec *spec;
10205 int board_config;
10206 int err;
10207
Robert P. J. Daydc041e02006-12-19 14:44:15 +010010208 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010010209 if (spec == NULL)
10210 return -ENOMEM;
10211
10212 codec->spec = spec;
10213#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010214 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
10215 * under-run
10216 */
Kailang Yangdf694da2005-12-05 19:42:22 +010010217 {
10218 int tmp;
10219 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10220 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
10221 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
10222 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
10223 }
10224#endif
10225
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020010226 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10227
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010228 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
10229 alc262_models,
10230 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010010231
Takashi Iwaif5fcc132006-11-24 17:07:44 +010010232 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010233 printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
10234 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010235 board_config = ALC262_AUTO;
10236 }
10237
10238 if (board_config == ALC262_AUTO) {
10239 /* automatic parse from the BIOS config */
10240 err = alc262_parse_auto_config(codec);
10241 if (err < 0) {
10242 alc_free(codec);
10243 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010244 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010245 printk(KERN_INFO
10246 "hda_codec: Cannot set up configuration "
10247 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010010248 board_config = ALC262_BASIC;
10249 }
10250 }
10251
10252 if (board_config != ALC262_AUTO)
10253 setup_preset(spec, &alc262_presets[board_config]);
10254
10255 spec->stream_name_analog = "ALC262 Analog";
10256 spec->stream_analog_playback = &alc262_pcm_analog_playback;
10257 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020010258
Kailang Yangdf694da2005-12-05 19:42:22 +010010259 spec->stream_name_digital = "ALC262 Digital";
10260 spec->stream_digital_playback = &alc262_pcm_digital_playback;
10261 spec->stream_digital_capture = &alc262_pcm_digital_capture;
10262
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010263 if (!spec->adc_nids && spec->input_mux) {
Kailang Yangdf694da2005-12-05 19:42:22 +010010264 /* check whether NID 0x07 is valid */
Takashi Iwai4a471b72005-12-07 13:56:29 +010010265 unsigned int wcap = get_wcaps(codec, 0x07);
10266
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010267 /* get type */
10268 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Kailang Yangdf694da2005-12-05 19:42:22 +010010269 if (wcap != AC_WID_AUD_IN) {
10270 spec->adc_nids = alc262_adc_nids_alt;
10271 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010272 spec->capsrc_nids = alc262_capsrc_nids_alt;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010273 spec->mixers[spec->num_mixers] =
10274 alc262_capture_alt_mixer;
Kailang Yangdf694da2005-12-05 19:42:22 +010010275 spec->num_mixers++;
10276 } else {
10277 spec->adc_nids = alc262_adc_nids;
10278 spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
Takashi Iwai88c71a92008-02-14 17:27:17 +010010279 spec->capsrc_nids = alc262_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010010280 spec->mixers[spec->num_mixers] = alc262_capture_mixer;
10281 spec->num_mixers++;
10282 }
10283 }
10284
Takashi Iwai2134ea42008-01-10 16:53:55 +010010285 spec->vmaster_nid = 0x0c;
10286
Kailang Yangdf694da2005-12-05 19:42:22 +010010287 codec->patch_ops = alc_patch_ops;
10288 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010010289 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010290#ifdef CONFIG_SND_HDA_POWER_SAVE
10291 if (!spec->loopback.amplist)
10292 spec->loopback.amplist = alc262_loopbacks;
10293#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020010294
Kailang Yangdf694da2005-12-05 19:42:22 +010010295 return 0;
10296}
10297
Kailang Yangdf694da2005-12-05 19:42:22 +010010298/*
Kailang Yanga361d842007-06-05 12:30:55 +020010299 * ALC268 channel source setting (2 channel)
10300 */
10301#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
10302#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020010303
Kailang Yanga361d842007-06-05 12:30:55 +020010304static hda_nid_t alc268_dac_nids[2] = {
10305 /* front, hp */
10306 0x02, 0x03
10307};
10308
10309static hda_nid_t alc268_adc_nids[2] = {
10310 /* ADC0-1 */
10311 0x08, 0x07
10312};
10313
10314static hda_nid_t alc268_adc_nids_alt[1] = {
10315 /* ADC0 */
10316 0x08
10317};
10318
Takashi Iwaie1406342008-02-11 18:32:32 +010010319static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
10320
Kailang Yanga361d842007-06-05 12:30:55 +020010321static struct snd_kcontrol_new alc268_base_mixer[] = {
10322 /* output mixer control */
10323 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10324 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10325 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10326 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010327 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10328 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
10329 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020010330 { }
10331};
10332
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010333/* bind Beep switches of both NID 0x0f and 0x10 */
10334static struct hda_bind_ctls alc268_bind_beep_sw = {
10335 .ops = &snd_hda_bind_sw,
10336 .values = {
10337 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
10338 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
10339 0
10340 },
10341};
10342
10343static struct snd_kcontrol_new alc268_beep_mixer[] = {
10344 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
10345 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
10346 { }
10347};
10348
Kailang Yangd1a991a2007-08-15 16:21:59 +020010349static struct hda_verb alc268_eapd_verbs[] = {
10350 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
10351 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
10352 { }
10353};
10354
Takashi Iwaid2738092007-08-16 14:59:45 +020010355/* Toshiba specific */
10356#define alc268_toshiba_automute alc262_hippo_automute
10357
10358static struct hda_verb alc268_toshiba_verbs[] = {
10359 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10360 { } /* end */
10361};
10362
Kailang Yang8ef355d2008-08-26 13:10:22 +020010363static struct hda_input_mux alc268_acer_lc_capture_source = {
10364 .num_items = 2,
10365 .items = {
10366 { "i-Mic", 0x6 },
10367 { "E-Mic", 0x0 },
10368 },
10369};
10370
Takashi Iwaid2738092007-08-16 14:59:45 +020010371/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020010372/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020010373static struct hda_bind_ctls alc268_acer_bind_master_vol = {
10374 .ops = &snd_hda_bind_vol,
10375 .values = {
10376 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
10377 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
10378 0
10379 },
10380};
10381
Takashi Iwai889c4392007-08-23 18:56:52 +020010382/* mute/unmute internal speaker according to the hp jack and mute state */
10383static void alc268_acer_automute(struct hda_codec *codec, int force)
10384{
10385 struct alc_spec *spec = codec->spec;
10386 unsigned int mute;
10387
10388 if (force || !spec->sense_updated) {
10389 unsigned int present;
10390 present = snd_hda_codec_read(codec, 0x14, 0,
10391 AC_VERB_GET_PIN_SENSE, 0);
10392 spec->jack_present = (present & 0x80000000) != 0;
10393 spec->sense_updated = 1;
10394 }
10395 if (spec->jack_present)
10396 mute = HDA_AMP_MUTE; /* mute internal speaker */
10397 else /* unmute internal speaker if necessary */
10398 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
10399 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
10400 HDA_AMP_MUTE, mute);
10401}
10402
10403
10404/* bind hp and internal speaker mute (with plug check) */
10405static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
10406 struct snd_ctl_elem_value *ucontrol)
10407{
10408 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
10409 long *valp = ucontrol->value.integer.value;
10410 int change;
10411
10412 change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
10413 HDA_AMP_MUTE,
10414 valp[0] ? 0 : HDA_AMP_MUTE);
10415 change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
10416 HDA_AMP_MUTE,
10417 valp[1] ? 0 : HDA_AMP_MUTE);
10418 if (change)
10419 alc268_acer_automute(codec, 0);
10420 return change;
10421}
Takashi Iwaid2738092007-08-16 14:59:45 +020010422
Kailang Yang8ef355d2008-08-26 13:10:22 +020010423static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
10424 /* output mixer control */
10425 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10426 {
10427 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10428 .name = "Master Playback Switch",
10429 .info = snd_hda_mixer_amp_switch_info,
10430 .get = snd_hda_mixer_amp_switch_get,
10431 .put = alc268_acer_master_sw_put,
10432 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10433 },
10434 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
10435 { }
10436};
10437
Takashi Iwaid2738092007-08-16 14:59:45 +020010438static struct snd_kcontrol_new alc268_acer_mixer[] = {
10439 /* output mixer control */
10440 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
10441 {
10442 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10443 .name = "Master Playback Switch",
10444 .info = snd_hda_mixer_amp_switch_info,
10445 .get = snd_hda_mixer_amp_switch_get,
10446 .put = alc268_acer_master_sw_put,
10447 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
10448 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020010449 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10450 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10451 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020010452 { }
10453};
10454
Kailang Yang8ef355d2008-08-26 13:10:22 +020010455static struct hda_verb alc268_acer_aspire_one_verbs[] = {
10456 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
10457 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10458 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10459 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
10460 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
10461 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
10462 { }
10463};
10464
Takashi Iwaid2738092007-08-16 14:59:45 +020010465static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010466 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
10467 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020010468 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10469 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010470 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
10471 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020010472 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10473 { }
10474};
10475
10476/* unsolicited event for HP jack sensing */
10477static void alc268_toshiba_unsol_event(struct hda_codec *codec,
10478 unsigned int res)
10479{
Takashi Iwai889c4392007-08-23 18:56:52 +020010480 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010481 return;
10482 alc268_toshiba_automute(codec);
10483}
10484
10485static void alc268_acer_unsol_event(struct hda_codec *codec,
10486 unsigned int res)
10487{
Takashi Iwai889c4392007-08-23 18:56:52 +020010488 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020010489 return;
10490 alc268_acer_automute(codec, 1);
10491}
10492
Takashi Iwai889c4392007-08-23 18:56:52 +020010493static void alc268_acer_init_hook(struct hda_codec *codec)
10494{
10495 alc268_acer_automute(codec, 1);
10496}
10497
Kailang Yang8ef355d2008-08-26 13:10:22 +020010498/* toggle speaker-output according to the hp-jack state */
10499static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
10500{
10501 unsigned int present;
10502 unsigned char bits;
10503
10504 present = snd_hda_codec_read(codec, 0x15, 0,
10505 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10506 bits = present ? AMP_IN_MUTE(0) : 0;
10507 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
10508 AMP_IN_MUTE(0), bits);
10509 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
10510 AMP_IN_MUTE(0), bits);
10511}
10512
10513
10514static void alc268_acer_mic_automute(struct hda_codec *codec)
10515{
10516 unsigned int present;
10517
10518 present = snd_hda_codec_read(codec, 0x18, 0,
10519 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10520 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_CONNECT_SEL,
10521 present ? 0x0 : 0x6);
10522}
10523
10524static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
10525 unsigned int res)
10526{
10527 if ((res >> 26) == ALC880_HP_EVENT)
10528 alc268_aspire_one_speaker_automute(codec);
10529 if ((res >> 26) == ALC880_MIC_EVENT)
10530 alc268_acer_mic_automute(codec);
10531}
10532
10533static void alc268_acer_lc_init_hook(struct hda_codec *codec)
10534{
10535 alc268_aspire_one_speaker_automute(codec);
10536 alc268_acer_mic_automute(codec);
10537}
10538
Takashi Iwai3866f0b2008-01-15 12:37:42 +010010539static struct snd_kcontrol_new alc268_dell_mixer[] = {
10540 /* output mixer control */
10541 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10542 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10543 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10545 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
10546 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
10547 { }
10548};
10549
10550static struct hda_verb alc268_dell_verbs[] = {
10551 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10552 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
10553 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10554 { }
10555};
10556
10557/* mute/unmute internal speaker according to the hp jack and mute state */
10558static void alc268_dell_automute(struct hda_codec *codec)
10559{
10560 unsigned int present;
10561 unsigned int mute;
10562
10563 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0);
10564 if (present & 0x80000000)
10565 mute = HDA_AMP_MUTE;
10566 else
10567 mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
10568 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
10569 HDA_AMP_MUTE, mute);
10570}
10571
10572static void alc268_dell_unsol_event(struct hda_codec *codec,
10573 unsigned int res)
10574{
10575 if ((res >> 26) != ALC880_HP_EVENT)
10576 return;
10577 alc268_dell_automute(codec);
10578}
10579
10580#define alc268_dell_init_hook alc268_dell_automute
10581
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020010582static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
10583 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
10584 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10585 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
10586 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10587 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10588 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
10589 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
10590 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
10591 { }
10592};
10593
10594static struct hda_verb alc267_quanta_il1_verbs[] = {
10595 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
10596 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
10597 { }
10598};
10599
10600static void alc267_quanta_il1_hp_automute(struct hda_codec *codec)
10601{
10602 unsigned int present;
10603
10604 present = snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_PIN_SENSE, 0)
10605 & AC_PINSENSE_PRESENCE;
10606 snd_hda_codec_write(codec, 0x14, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
10607 present ? 0 : PIN_OUT);
10608}
10609
10610static void alc267_quanta_il1_mic_automute(struct hda_codec *codec)
10611{
10612 unsigned int present;
10613
10614 present = snd_hda_codec_read(codec, 0x18, 0,
10615 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
10616 snd_hda_codec_write(codec, 0x23, 0,
10617 AC_VERB_SET_CONNECT_SEL,
10618 present ? 0x00 : 0x01);
10619}
10620
10621static void alc267_quanta_il1_automute(struct hda_codec *codec)
10622{
10623 alc267_quanta_il1_hp_automute(codec);
10624 alc267_quanta_il1_mic_automute(codec);
10625}
10626
10627static void alc267_quanta_il1_unsol_event(struct hda_codec *codec,
10628 unsigned int res)
10629{
10630 switch (res >> 26) {
10631 case ALC880_HP_EVENT:
10632 alc267_quanta_il1_hp_automute(codec);
10633 break;
10634 case ALC880_MIC_EVENT:
10635 alc267_quanta_il1_mic_automute(codec);
10636 break;
10637 }
10638}
10639
Kailang Yanga361d842007-06-05 12:30:55 +020010640/*
10641 * generic initialization of ADC, input mixers and output mixers
10642 */
10643static struct hda_verb alc268_base_init_verbs[] = {
10644 /* Unmute DAC0-1 and set vol = 0 */
10645 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10646 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10647 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10648 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10649 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10650 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10651
10652 /*
10653 * Set up output mixers (0x0c - 0x0e)
10654 */
10655 /* set vol=0 to output mixers */
10656 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10657 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10658 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10659 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
10660
10661 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10662 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10663
10664 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10665 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
10666 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
10667 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10668 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10669 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10670 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10671 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10672
10673 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10675 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10676 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10677 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10678 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10679 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010680
10681 /* set PCBEEP vol = 0, mute connections */
10682 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10683 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10684 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010685
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010686 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020010687
Jiang Zhea9b3aa82007-12-20 13:13:13 +010010688 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
10689 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
10690 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
10691 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020010692
Kailang Yanga361d842007-06-05 12:30:55 +020010693 { }
10694};
10695
10696/*
10697 * generic initialization of ADC, input mixers and output mixers
10698 */
10699static struct hda_verb alc268_volume_init_verbs[] = {
10700 /* set output DAC */
10701 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10702 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10703 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10704 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10705
10706 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10707 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
10708 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10709 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10710 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
10711
10712 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
10713 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10714 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
10715 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10716 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10717
10718 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10719 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10720 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10721 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
10722
Takashi Iwaiaef9d312008-02-19 13:16:41 +010010723 /* set PCBEEP vol = 0, mute connections */
10724 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
10725 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
10726 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020010727
10728 { }
10729};
10730
10731#define alc268_mux_enum_info alc_mux_enum_info
10732#define alc268_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010010733#define alc268_mux_enum_put alc_mux_enum_put
Kailang Yanga361d842007-06-05 12:30:55 +020010734
10735static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
10736 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10737 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10738 {
10739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10740 /* The multiple "Capture Source" controls confuse alsamixer
10741 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010742 */
10743 /* .name = "Capture Source", */
10744 .name = "Input Source",
10745 .count = 1,
10746 .info = alc268_mux_enum_info,
10747 .get = alc268_mux_enum_get,
10748 .put = alc268_mux_enum_put,
10749 },
10750 { } /* end */
10751};
10752
10753static struct snd_kcontrol_new alc268_capture_mixer[] = {
10754 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10755 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
10756 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
10757 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
10758 {
10759 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
10760 /* The multiple "Capture Source" controls confuse alsamixer
10761 * So call somewhat different..
Kailang Yanga361d842007-06-05 12:30:55 +020010762 */
10763 /* .name = "Capture Source", */
10764 .name = "Input Source",
10765 .count = 2,
10766 .info = alc268_mux_enum_info,
10767 .get = alc268_mux_enum_get,
10768 .put = alc268_mux_enum_put,
10769 },
10770 { } /* end */
10771};
10772
10773static struct hda_input_mux alc268_capture_source = {
10774 .num_items = 4,
10775 .items = {
10776 { "Mic", 0x0 },
10777 { "Front Mic", 0x1 },
10778 { "Line", 0x2 },
10779 { "CD", 0x3 },
10780 },
10781};
10782
Takashi Iwai0ccb5412008-03-06 16:58:35 +010010783static struct hda_input_mux alc268_acer_capture_source = {
10784 .num_items = 3,
10785 .items = {
10786 { "Mic", 0x0 },
10787 { "Internal Mic", 0x6 },
10788 { "Line", 0x2 },
10789 },
10790};
10791
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010792#ifdef CONFIG_SND_DEBUG
10793static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010794 /* Volume widgets */
10795 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
10796 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
10797 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
10798 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
10799 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
10800 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
10801 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
10802 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
10803 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
10804 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
10805 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
10806 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
10807 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010010808 /* The below appears problematic on some hardwares */
10809 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010010810 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
10811 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
10812 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
10813 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
10814
10815 /* Modes for retasking pin widgets */
10816 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
10817 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
10818 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
10819 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
10820
10821 /* Controls for GPIO pins, assuming they are configured as outputs */
10822 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
10823 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
10824 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
10825 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
10826
10827 /* Switches to allow the digital SPDIF output pin to be enabled.
10828 * The ALC268 does not have an SPDIF input.
10829 */
10830 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
10831
10832 /* A switch allowing EAPD to be enabled. Some laptops seem to use
10833 * this output to turn on an external amplifier.
10834 */
10835 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
10836 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
10837
10838 { } /* end */
10839};
10840#endif
10841
Kailang Yanga361d842007-06-05 12:30:55 +020010842/* create input playback/capture controls for the given pin */
10843static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
10844 const char *ctlname, int idx)
10845{
10846 char name[32];
10847 int err;
10848
10849 sprintf(name, "%s Playback Volume", ctlname);
10850 if (nid == 0x14) {
10851 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10852 HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
10853 HDA_OUTPUT));
10854 if (err < 0)
10855 return err;
10856 } else if (nid == 0x15) {
10857 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
10858 HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
10859 HDA_OUTPUT));
10860 if (err < 0)
10861 return err;
10862 } else
10863 return -1;
10864 sprintf(name, "%s Playback Switch", ctlname);
10865 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
10866 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
10867 if (err < 0)
10868 return err;
10869 return 0;
10870}
10871
10872/* add playback controls from the parsed DAC table */
10873static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
10874 const struct auto_pin_cfg *cfg)
10875{
10876 hda_nid_t nid;
10877 int err;
10878
10879 spec->multiout.num_dacs = 2; /* only use one dac */
10880 spec->multiout.dac_nids = spec->private_dac_nids;
10881 spec->multiout.dac_nids[0] = 2;
10882 spec->multiout.dac_nids[1] = 3;
10883
10884 nid = cfg->line_out_pins[0];
10885 if (nid)
Kailang Yangea1fb292008-08-26 12:58:38 +020010886 alc268_new_analog_output(spec, nid, "Front", 0);
Kailang Yanga361d842007-06-05 12:30:55 +020010887
10888 nid = cfg->speaker_pins[0];
10889 if (nid == 0x1d) {
10890 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10891 "Speaker Playback Volume",
10892 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
10893 if (err < 0)
10894 return err;
10895 }
10896 nid = cfg->hp_pins[0];
10897 if (nid)
10898 alc268_new_analog_output(spec, nid, "Headphone", 0);
10899
10900 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
10901 if (nid == 0x16) {
10902 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
10903 "Mono Playback Switch",
10904 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
10905 if (err < 0)
10906 return err;
10907 }
Kailang Yangea1fb292008-08-26 12:58:38 +020010908 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020010909}
10910
10911/* create playback/capture controls for input pins */
10912static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
10913 const struct auto_pin_cfg *cfg)
10914{
10915 struct hda_input_mux *imux = &spec->private_imux;
10916 int i, idx1;
10917
10918 for (i = 0; i < AUTO_PIN_LAST; i++) {
10919 switch(cfg->input_pins[i]) {
10920 case 0x18:
10921 idx1 = 0; /* Mic 1 */
10922 break;
10923 case 0x19:
10924 idx1 = 1; /* Mic 2 */
10925 break;
10926 case 0x1a:
10927 idx1 = 2; /* Line In */
10928 break;
Kailang Yangea1fb292008-08-26 12:58:38 +020010929 case 0x1c:
Kailang Yanga361d842007-06-05 12:30:55 +020010930 idx1 = 3; /* CD */
10931 break;
Takashi Iwai7194cae2008-03-06 16:58:17 +010010932 case 0x12:
10933 case 0x13:
10934 idx1 = 6; /* digital mics */
10935 break;
Kailang Yanga361d842007-06-05 12:30:55 +020010936 default:
10937 continue;
10938 }
10939 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
10940 imux->items[imux->num_items].index = idx1;
Kailang Yangea1fb292008-08-26 12:58:38 +020010941 imux->num_items++;
Kailang Yanga361d842007-06-05 12:30:55 +020010942 }
10943 return 0;
10944}
10945
10946static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
10947{
10948 struct alc_spec *spec = codec->spec;
10949 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
10950 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
10951 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
10952 unsigned int dac_vol1, dac_vol2;
10953
10954 if (speaker_nid) {
10955 snd_hda_codec_write(codec, speaker_nid, 0,
10956 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
10957 snd_hda_codec_write(codec, 0x0f, 0,
10958 AC_VERB_SET_AMP_GAIN_MUTE,
10959 AMP_IN_UNMUTE(1));
10960 snd_hda_codec_write(codec, 0x10, 0,
10961 AC_VERB_SET_AMP_GAIN_MUTE,
10962 AMP_IN_UNMUTE(1));
10963 } else {
10964 snd_hda_codec_write(codec, 0x0f, 0,
10965 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10966 snd_hda_codec_write(codec, 0x10, 0,
10967 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
10968 }
10969
10970 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020010971 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020010972 dac_vol2 = AMP_OUT_ZERO;
10973 else if (line_nid == 0x15)
10974 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020010975 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020010976 dac_vol2 = AMP_OUT_ZERO;
10977 else if (hp_nid == 0x15)
10978 dac_vol1 = AMP_OUT_ZERO;
10979 if (line_nid != 0x16 || hp_nid != 0x16 ||
10980 spec->autocfg.line_out_pins[1] != 0x16 ||
10981 spec->autocfg.line_out_pins[2] != 0x16)
10982 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
10983
10984 snd_hda_codec_write(codec, 0x02, 0,
10985 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
10986 snd_hda_codec_write(codec, 0x03, 0,
10987 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
10988}
10989
10990/* pcm configuration: identiacal with ALC880 */
10991#define alc268_pcm_analog_playback alc880_pcm_analog_playback
10992#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010010993#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020010994#define alc268_pcm_digital_playback alc880_pcm_digital_playback
10995
10996/*
10997 * BIOS auto configuration
10998 */
10999static int alc268_parse_auto_config(struct hda_codec *codec)
11000{
11001 struct alc_spec *spec = codec->spec;
11002 int err;
11003 static hda_nid_t alc268_ignore[] = { 0 };
11004
11005 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11006 alc268_ignore);
11007 if (err < 0)
11008 return err;
11009 if (!spec->autocfg.line_outs)
11010 return 0; /* can't find valid BIOS pin config */
11011
11012 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
11013 if (err < 0)
11014 return err;
11015 err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
11016 if (err < 0)
11017 return err;
11018
11019 spec->multiout.max_channels = 2;
11020
11021 /* digital only support output */
11022 if (spec->autocfg.dig_out_pin)
11023 spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
11024
11025 if (spec->kctl_alloc)
11026 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11027
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011028 if (spec->autocfg.speaker_pins[0] != 0x1d)
11029 spec->mixers[spec->num_mixers++] = alc268_beep_mixer;
11030
Kailang Yanga361d842007-06-05 12:30:55 +020011031 spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
11032 spec->num_mux_defs = 1;
11033 spec->input_mux = &spec->private_imux;
11034
Takashi Iwai776e1842007-08-29 15:07:11 +020011035 err = alc_auto_add_mic_boost(codec);
11036 if (err < 0)
11037 return err;
11038
Kailang Yanga361d842007-06-05 12:30:55 +020011039 return 1;
11040}
11041
11042#define alc268_auto_init_multi_out alc882_auto_init_multi_out
11043#define alc268_auto_init_hp_out alc882_auto_init_hp_out
11044#define alc268_auto_init_analog_input alc882_auto_init_analog_input
11045
11046/* init callback for auto-configuration model -- overriding the default init */
11047static void alc268_auto_init(struct hda_codec *codec)
11048{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011049 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020011050 alc268_auto_init_multi_out(codec);
11051 alc268_auto_init_hp_out(codec);
11052 alc268_auto_init_mono_speaker_out(codec);
11053 alc268_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011054 if (spec->unsol_event)
11055 alc_sku_automute(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020011056}
11057
11058/*
11059 * configuration and preset
11060 */
11061static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011062 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020011063 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020011064 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020011065 [ALC268_ACER] = "acer",
Kailang Yang8ef355d2008-08-26 13:10:22 +020011066 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011067 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011068 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011069#ifdef CONFIG_SND_DEBUG
11070 [ALC268_TEST] = "test",
11071#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011072 [ALC268_AUTO] = "auto",
11073};
11074
11075static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020011076 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011077 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010011078 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011079 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010011080 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020011081 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
11082 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011083 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010011084 SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
Kailang Yanga361d842007-06-05 12:30:55 +020011085 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Kailang Yangd1a991a2007-08-15 16:21:59 +020011086 SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
Takashi Iwai8e7f00f2007-09-07 10:58:58 +020011087 SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
Tony Vroon378bd6a2008-06-04 12:08:30 +020011088 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020011089 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011090 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011091 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Kailang Yanga361d842007-06-05 12:30:55 +020011092 {}
11093};
11094
11095static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020011096 [ALC267_QUANTA_IL1] = {
11097 .mixers = { alc267_quanta_il1_mixer },
11098 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11099 alc267_quanta_il1_verbs },
11100 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11101 .dac_nids = alc268_dac_nids,
11102 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11103 .adc_nids = alc268_adc_nids_alt,
11104 .hp_nid = 0x03,
11105 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11106 .channel_mode = alc268_modes,
11107 .input_mux = &alc268_capture_source,
11108 .unsol_event = alc267_quanta_il1_unsol_event,
11109 .init_hook = alc267_quanta_il1_automute,
11110 },
Kailang Yanga361d842007-06-05 12:30:55 +020011111 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011112 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11113 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020011114 .init_verbs = { alc268_base_init_verbs },
11115 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11116 .dac_nids = alc268_dac_nids,
11117 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11118 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011119 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020011120 .hp_nid = 0x03,
11121 .dig_out_nid = ALC268_DIGOUT_NID,
11122 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11123 .channel_mode = alc268_modes,
11124 .input_mux = &alc268_capture_source,
11125 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011126 [ALC268_TOSHIBA] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011127 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11128 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011129 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11130 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020011131 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11132 .dac_nids = alc268_dac_nids,
11133 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11134 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011135 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011136 .hp_nid = 0x03,
11137 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11138 .channel_mode = alc268_modes,
11139 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011140 .unsol_event = alc268_toshiba_unsol_event,
11141 .init_hook = alc268_toshiba_automute,
11142 },
11143 [ALC268_ACER] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011144 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
11145 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020011146 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11147 alc268_acer_verbs },
11148 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11149 .dac_nids = alc268_dac_nids,
11150 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11151 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011152 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020011153 .hp_nid = 0x02,
11154 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11155 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010011156 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020011157 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020011158 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020011159 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020011160 [ALC268_ACER_ASPIRE_ONE] = {
11161 .mixers = { alc268_acer_aspire_one_mixer,
11162 alc268_capture_alt_mixer },
11163 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11164 alc268_acer_aspire_one_verbs },
11165 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11166 .dac_nids = alc268_dac_nids,
11167 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11168 .adc_nids = alc268_adc_nids_alt,
11169 .capsrc_nids = alc268_capsrc_nids,
11170 .hp_nid = 0x03,
11171 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11172 .channel_mode = alc268_modes,
11173 .input_mux = &alc268_acer_lc_capture_source,
11174 .unsol_event = alc268_acer_lc_unsol_event,
11175 .init_hook = alc268_acer_lc_init_hook,
11176 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011177 [ALC268_DELL] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011178 .mixers = { alc268_dell_mixer, alc268_beep_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011179 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11180 alc268_dell_verbs },
11181 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11182 .dac_nids = alc268_dac_nids,
11183 .hp_nid = 0x02,
11184 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11185 .channel_mode = alc268_modes,
11186 .unsol_event = alc268_dell_unsol_event,
11187 .init_hook = alc268_dell_init_hook,
11188 .input_mux = &alc268_capture_source,
11189 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011190 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011191 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
11192 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011193 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11194 alc268_toshiba_verbs },
11195 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11196 .dac_nids = alc268_dac_nids,
11197 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11198 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011199 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010011200 .hp_nid = 0x03,
11201 .dig_out_nid = ALC268_DIGOUT_NID,
11202 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11203 .channel_mode = alc268_modes,
11204 .input_mux = &alc268_capture_source,
11205 .unsol_event = alc268_toshiba_unsol_event,
11206 .init_hook = alc268_toshiba_automute
11207 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011208#ifdef CONFIG_SND_DEBUG
11209 [ALC268_TEST] = {
11210 .mixers = { alc268_test_mixer, alc268_capture_mixer },
11211 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
11212 alc268_volume_init_verbs },
11213 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
11214 .dac_nids = alc268_dac_nids,
11215 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
11216 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010011217 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010011218 .hp_nid = 0x03,
11219 .dig_out_nid = ALC268_DIGOUT_NID,
11220 .num_channel_mode = ARRAY_SIZE(alc268_modes),
11221 .channel_mode = alc268_modes,
11222 .input_mux = &alc268_capture_source,
11223 },
11224#endif
Kailang Yanga361d842007-06-05 12:30:55 +020011225};
11226
11227static int patch_alc268(struct hda_codec *codec)
11228{
11229 struct alc_spec *spec;
11230 int board_config;
11231 int err;
11232
11233 spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
11234 if (spec == NULL)
11235 return -ENOMEM;
11236
11237 codec->spec = spec;
11238
11239 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
11240 alc268_models,
11241 alc268_cfg_tbl);
11242
11243 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
11244 printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
11245 "trying auto-probe from BIOS...\n");
11246 board_config = ALC268_AUTO;
11247 }
11248
11249 if (board_config == ALC268_AUTO) {
11250 /* automatic parse from the BIOS config */
11251 err = alc268_parse_auto_config(codec);
11252 if (err < 0) {
11253 alc_free(codec);
11254 return err;
11255 } else if (!err) {
11256 printk(KERN_INFO
11257 "hda_codec: Cannot set up configuration "
11258 "from BIOS. Using base mode...\n");
11259 board_config = ALC268_3ST;
11260 }
11261 }
11262
11263 if (board_config != ALC268_AUTO)
11264 setup_preset(spec, &alc268_presets[board_config]);
11265
Kailang Yang2f893282008-05-27 12:14:47 +020011266 if (codec->vendor_id == 0x10ec0267) {
11267 spec->stream_name_analog = "ALC267 Analog";
11268 spec->stream_name_digital = "ALC267 Digital";
11269 } else {
11270 spec->stream_name_analog = "ALC268 Analog";
11271 spec->stream_name_digital = "ALC268 Digital";
11272 }
11273
Kailang Yanga361d842007-06-05 12:30:55 +020011274 spec->stream_analog_playback = &alc268_pcm_analog_playback;
11275 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010011276 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020011277
Kailang Yanga361d842007-06-05 12:30:55 +020011278 spec->stream_digital_playback = &alc268_pcm_digital_playback;
11279
Takashi Iwaiaef9d312008-02-19 13:16:41 +010011280 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
11281 /* override the amp caps for beep generator */
11282 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
11283 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
11284 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
11285 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
11286 (0 << AC_AMPCAP_MUTE_SHIFT));
11287
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011288 if (!spec->adc_nids && spec->input_mux) {
11289 /* check whether NID 0x07 is valid */
11290 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010011291 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020011292
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011293 /* get type */
11294 wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
Takashi Iwai67ebcb02008-02-19 15:03:57 +010011295 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011296 spec->adc_nids = alc268_adc_nids_alt;
11297 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
11298 spec->mixers[spec->num_mixers] =
Kailang Yanga361d842007-06-05 12:30:55 +020011299 alc268_capture_alt_mixer;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010011300 spec->num_mixers++;
11301 } else {
11302 spec->adc_nids = alc268_adc_nids;
11303 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
11304 spec->mixers[spec->num_mixers] =
11305 alc268_capture_mixer;
11306 spec->num_mixers++;
Kailang Yanga361d842007-06-05 12:30:55 +020011307 }
Takashi Iwaie1406342008-02-11 18:32:32 +010011308 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai85860c02008-02-19 15:00:15 +010011309 /* set default input source */
11310 for (i = 0; i < spec->num_adc_nids; i++)
11311 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
11312 0, AC_VERB_SET_CONNECT_SEL,
11313 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020011314 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010011315
11316 spec->vmaster_nid = 0x02;
11317
Kailang Yanga361d842007-06-05 12:30:55 +020011318 codec->patch_ops = alc_patch_ops;
11319 if (board_config == ALC268_AUTO)
11320 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020011321
Kailang Yanga361d842007-06-05 12:30:55 +020011322 return 0;
11323}
11324
11325/*
Kailang Yangf6a92242007-12-13 16:52:54 +010011326 * ALC269 channel source setting (2 channel)
11327 */
11328#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
11329
11330#define alc269_dac_nids alc260_dac_nids
11331
11332static hda_nid_t alc269_adc_nids[1] = {
11333 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020011334 0x08,
11335};
11336
Takashi Iwaie01bf502008-08-21 16:25:07 +020011337static hda_nid_t alc269_capsrc_nids[1] = {
11338 0x23,
11339};
11340
11341/* NOTE: ADC2 (0x07) is connected from a recording *MIXER* (0x24),
11342 * not a mux!
11343 */
11344
Kailang Yangf53281e2008-07-18 12:36:43 +020011345static struct hda_input_mux alc269_eeepc_dmic_capture_source = {
11346 .num_items = 2,
11347 .items = {
11348 { "i-Mic", 0x5 },
11349 { "e-Mic", 0x0 },
11350 },
11351};
11352
11353static struct hda_input_mux alc269_eeepc_amic_capture_source = {
11354 .num_items = 2,
11355 .items = {
11356 { "i-Mic", 0x1 },
11357 { "e-Mic", 0x0 },
11358 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011359};
11360
11361#define alc269_modes alc260_modes
11362#define alc269_capture_source alc880_lg_lw_capture_source
11363
11364static struct snd_kcontrol_new alc269_base_mixer[] = {
11365 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
11366 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11367 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11368 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11369 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11370 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai2005af22008-08-20 18:38:26 +020011371 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11372 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011373 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11374 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11375 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11376 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11377 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11378 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
11379 { } /* end */
11380};
11381
Kailang Yang60db6b52008-08-26 13:13:00 +020011382static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
11383 /* output mixer control */
11384 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
11385 {
11386 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11387 .name = "Master Playback Switch",
11388 .info = snd_hda_mixer_amp_switch_info,
11389 .get = snd_hda_mixer_amp_switch_get,
11390 .put = alc268_acer_master_sw_put,
11391 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11392 },
11393 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11394 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11395 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11396 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11397 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11398 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
11399 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x04, HDA_INPUT),
11400 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x04, HDA_INPUT),
11401 { }
11402};
11403
Kailang Yangf53281e2008-07-18 12:36:43 +020011404/* bind volumes of both NID 0x0c and 0x0d */
11405static struct hda_bind_ctls alc269_epc_bind_vol = {
11406 .ops = &snd_hda_bind_vol,
11407 .values = {
11408 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
11409 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
11410 0
11411 },
11412};
11413
11414static struct snd_kcontrol_new alc269_eeepc_mixer[] = {
11415 HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11416 HDA_BIND_VOL("LineOut Playback Volume", &alc269_epc_bind_vol),
11417 HDA_CODEC_MUTE("LineOut Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11418 { } /* end */
11419};
11420
Kailang Yangf6a92242007-12-13 16:52:54 +010011421/* capture mixer elements */
11422static struct snd_kcontrol_new alc269_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011423 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11424 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010011425 {
11426 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11427 /* The multiple "Capture Source" controls confuse alsamixer
11428 * So call somewhat different..
Kailang Yangf6a92242007-12-13 16:52:54 +010011429 */
11430 /* .name = "Capture Source", */
11431 .name = "Input Source",
11432 .count = 1,
11433 .info = alc_mux_enum_info,
11434 .get = alc_mux_enum_get,
11435 .put = alc_mux_enum_put,
11436 },
11437 { } /* end */
11438};
11439
Kailang Yangf53281e2008-07-18 12:36:43 +020011440/* capture mixer elements */
11441static struct snd_kcontrol_new alc269_epc_capture_mixer[] = {
11442 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
11443 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
11444 { } /* end */
11445};
11446
Takashi Iwai2005af22008-08-20 18:38:26 +020011447/* beep control */
11448static struct snd_kcontrol_new alc269_beep_mixer[] = {
11449 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x4, HDA_INPUT),
11450 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x4, HDA_INPUT),
11451 { } /* end */
11452};
11453
Kailang Yang60db6b52008-08-26 13:13:00 +020011454static struct hda_verb alc269_quanta_fl1_verbs[] = {
11455 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11456 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11457 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11458 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11459 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11460 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11461 { }
11462};
11463
11464/* toggle speaker-output according to the hp-jack state */
11465static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
11466{
11467 unsigned int present;
11468 unsigned char bits;
11469
11470 present = snd_hda_codec_read(codec, 0x15, 0,
11471 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11472 bits = present ? AMP_IN_MUTE(0) : 0;
11473 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11474 AMP_IN_MUTE(0), bits);
11475 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11476 AMP_IN_MUTE(0), bits);
11477
11478 snd_hda_codec_write(codec, 0x20, 0,
11479 AC_VERB_SET_COEF_INDEX, 0x0c);
11480 snd_hda_codec_write(codec, 0x20, 0,
11481 AC_VERB_SET_PROC_COEF, 0x680);
11482
11483 snd_hda_codec_write(codec, 0x20, 0,
11484 AC_VERB_SET_COEF_INDEX, 0x0c);
11485 snd_hda_codec_write(codec, 0x20, 0,
11486 AC_VERB_SET_PROC_COEF, 0x480);
11487}
11488
11489static void alc269_quanta_fl1_mic_automute(struct hda_codec *codec)
11490{
11491 unsigned int present;
11492
11493 present = snd_hda_codec_read(codec, 0x18, 0,
11494 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11495 snd_hda_codec_write(codec, 0x23, 0,
11496 AC_VERB_SET_CONNECT_SEL, present ? 0x0 : 0x1);
11497}
11498
11499static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
11500 unsigned int res)
11501{
11502 if ((res >> 26) == ALC880_HP_EVENT)
11503 alc269_quanta_fl1_speaker_automute(codec);
11504 if ((res >> 26) == ALC880_MIC_EVENT)
11505 alc269_quanta_fl1_mic_automute(codec);
11506}
11507
11508static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
11509{
11510 alc269_quanta_fl1_speaker_automute(codec);
11511 alc269_quanta_fl1_mic_automute(codec);
11512}
11513
11514static struct hda_verb alc269_eeepc_dmic_init_verbs[] = {
11515 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11516 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
11517 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11518 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
11519 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11520 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11521 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11522 {}
11523};
11524
11525static struct hda_verb alc269_eeepc_amic_init_verbs[] = {
11526 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
11527 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
11528 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
11529 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
11530 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11531 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11532 {}
11533};
11534
11535/* toggle speaker-output according to the hp-jack state */
11536static void alc269_speaker_automute(struct hda_codec *codec)
11537{
11538 unsigned int present;
11539 unsigned char bits;
11540
11541 present = snd_hda_codec_read(codec, 0x15, 0,
11542 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11543 bits = present ? AMP_IN_MUTE(0) : 0;
11544 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
11545 AMP_IN_MUTE(0), bits);
11546 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
11547 AMP_IN_MUTE(0), bits);
11548}
11549
11550static void alc269_eeepc_dmic_automute(struct hda_codec *codec)
11551{
11552 unsigned int present;
11553
11554 present = snd_hda_codec_read(codec, 0x18, 0,
11555 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11556 snd_hda_codec_write(codec, 0x23, 0,
11557 AC_VERB_SET_CONNECT_SEL, (present ? 0 : 5));
11558}
11559
11560static void alc269_eeepc_amic_automute(struct hda_codec *codec)
11561{
11562 unsigned int present;
11563
11564 present = snd_hda_codec_read(codec, 0x18, 0,
11565 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
11566 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11567 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
11568 snd_hda_codec_write(codec, 0x24, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11569 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
11570}
11571
11572/* unsolicited event for HP jack sensing */
11573static void alc269_eeepc_dmic_unsol_event(struct hda_codec *codec,
11574 unsigned int res)
11575{
11576 if ((res >> 26) == ALC880_HP_EVENT)
11577 alc269_speaker_automute(codec);
11578
11579 if ((res >> 26) == ALC880_MIC_EVENT)
11580 alc269_eeepc_dmic_automute(codec);
11581}
11582
11583static void alc269_eeepc_dmic_inithook(struct hda_codec *codec)
11584{
11585 alc269_speaker_automute(codec);
11586 alc269_eeepc_dmic_automute(codec);
11587}
11588
11589/* unsolicited event for HP jack sensing */
11590static void alc269_eeepc_amic_unsol_event(struct hda_codec *codec,
11591 unsigned int res)
11592{
11593 if ((res >> 26) == ALC880_HP_EVENT)
11594 alc269_speaker_automute(codec);
11595
11596 if ((res >> 26) == ALC880_MIC_EVENT)
11597 alc269_eeepc_amic_automute(codec);
11598}
11599
11600static void alc269_eeepc_amic_inithook(struct hda_codec *codec)
11601{
11602 alc269_speaker_automute(codec);
11603 alc269_eeepc_amic_automute(codec);
11604}
11605
Kailang Yangf6a92242007-12-13 16:52:54 +010011606/*
11607 * generic initialization of ADC, input mixers and output mixers
11608 */
11609static struct hda_verb alc269_init_verbs[] = {
11610 /*
11611 * Unmute ADC0 and set the default input to mic-in
11612 */
Kailang Yang60db6b52008-08-26 13:13:00 +020011613 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011614
11615 /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
11616 * analog-loopback mixer widget
11617 * Note: PASD motherboards uses the Line In 2 as the input for
11618 * front panel mic (mic 2)
11619 */
11620 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
11621 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11622 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11623 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11624 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11625 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11626
11627 /*
11628 * Set up output mixers (0x0c - 0x0e)
11629 */
11630 /* set vol=0 to output mixers */
11631 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11632 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11633
11634 /* set up input amps for analog loopback */
11635 /* Amp Indices: DAC = 0, mixer = 1 */
11636 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11637 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11638 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11639 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11640 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11641 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11642
11643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11644 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11645 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11646 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11647 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11648 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11649 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11650
11651 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11652 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11654 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11655 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11656 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11657 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11658
11659 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11660 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11661
11662 /* FIXME: use matrix-type input source selection */
11663 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
11664 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang60db6b52008-08-26 13:13:00 +020011665 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11666 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangf6a92242007-12-13 16:52:54 +010011667 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11668 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11669
11670 /* set EAPD */
11671 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11672 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11673 { }
11674};
11675
11676/* add playback controls from the parsed DAC table */
11677static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
11678 const struct auto_pin_cfg *cfg)
11679{
11680 hda_nid_t nid;
11681 int err;
11682
11683 spec->multiout.num_dacs = 1; /* only use one dac */
11684 spec->multiout.dac_nids = spec->private_dac_nids;
11685 spec->multiout.dac_nids[0] = 2;
11686
11687 nid = cfg->line_out_pins[0];
11688 if (nid) {
11689 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11690 "Front Playback Volume",
11691 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
11692 if (err < 0)
11693 return err;
11694 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11695 "Front Playback Switch",
11696 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
11697 if (err < 0)
11698 return err;
11699 }
11700
11701 nid = cfg->speaker_pins[0];
11702 if (nid) {
11703 if (!cfg->line_out_pins[0]) {
11704 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11705 "Speaker Playback Volume",
11706 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11707 HDA_OUTPUT));
11708 if (err < 0)
11709 return err;
11710 }
11711 if (nid == 0x16) {
11712 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11713 "Speaker Playback Switch",
11714 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11715 HDA_OUTPUT));
11716 if (err < 0)
11717 return err;
11718 } else {
11719 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11720 "Speaker Playback Switch",
11721 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11722 HDA_OUTPUT));
11723 if (err < 0)
11724 return err;
11725 }
11726 }
11727 nid = cfg->hp_pins[0];
11728 if (nid) {
11729 /* spec->multiout.hp_nid = 2; */
11730 if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
11731 err = add_control(spec, ALC_CTL_WIDGET_VOL,
11732 "Headphone Playback Volume",
11733 HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
11734 HDA_OUTPUT));
11735 if (err < 0)
11736 return err;
11737 }
11738 if (nid == 0x16) {
11739 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11740 "Headphone Playback Switch",
11741 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
11742 HDA_OUTPUT));
11743 if (err < 0)
11744 return err;
11745 } else {
11746 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
11747 "Headphone Playback Switch",
11748 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
11749 HDA_OUTPUT));
11750 if (err < 0)
11751 return err;
11752 }
11753 }
11754 return 0;
11755}
11756
11757#define alc269_auto_create_analog_input_ctls \
11758 alc880_auto_create_analog_input_ctls
11759
11760#ifdef CONFIG_SND_HDA_POWER_SAVE
11761#define alc269_loopbacks alc880_loopbacks
11762#endif
11763
11764/* pcm configuration: identiacal with ALC880 */
11765#define alc269_pcm_analog_playback alc880_pcm_analog_playback
11766#define alc269_pcm_analog_capture alc880_pcm_analog_capture
11767#define alc269_pcm_digital_playback alc880_pcm_digital_playback
11768#define alc269_pcm_digital_capture alc880_pcm_digital_capture
11769
11770/*
11771 * BIOS auto configuration
11772 */
11773static int alc269_parse_auto_config(struct hda_codec *codec)
11774{
11775 struct alc_spec *spec = codec->spec;
Takashi Iwai2005af22008-08-20 18:38:26 +020011776 int i, err;
Kailang Yangf6a92242007-12-13 16:52:54 +010011777 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
11778
11779 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
11780 alc269_ignore);
11781 if (err < 0)
11782 return err;
11783
11784 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
11785 if (err < 0)
11786 return err;
11787 err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
11788 if (err < 0)
11789 return err;
11790
11791 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
11792
11793 if (spec->autocfg.dig_out_pin)
11794 spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
11795
11796 if (spec->kctl_alloc)
11797 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
11798
Takashi Iwai2005af22008-08-20 18:38:26 +020011799 /* create a beep mixer control if the pin 0x1d isn't assigned */
11800 for (i = 0; i < ARRAY_SIZE(spec->autocfg.input_pins); i++)
11801 if (spec->autocfg.input_pins[i] == 0x1d)
11802 break;
11803 if (i >= ARRAY_SIZE(spec->autocfg.input_pins))
11804 spec->mixers[spec->num_mixers++] = alc269_beep_mixer;
11805
Kailang Yangf6a92242007-12-13 16:52:54 +010011806 spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
11807 spec->num_mux_defs = 1;
11808 spec->input_mux = &spec->private_imux;
Takashi Iwaie01bf502008-08-21 16:25:07 +020011809 /* set default input source */
11810 snd_hda_codec_write_cache(codec, alc269_capsrc_nids[0],
11811 0, AC_VERB_SET_CONNECT_SEL,
11812 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010011813
11814 err = alc_auto_add_mic_boost(codec);
11815 if (err < 0)
11816 return err;
11817
Kailang Yangf53281e2008-07-18 12:36:43 +020011818 spec->mixers[spec->num_mixers] = alc269_capture_mixer;
11819 spec->num_mixers++;
11820
Kailang Yangf6a92242007-12-13 16:52:54 +010011821 return 1;
11822}
11823
11824#define alc269_auto_init_multi_out alc882_auto_init_multi_out
11825#define alc269_auto_init_hp_out alc882_auto_init_hp_out
11826#define alc269_auto_init_analog_input alc882_auto_init_analog_input
11827
11828
11829/* init callback for auto-configuration model -- overriding the default init */
11830static void alc269_auto_init(struct hda_codec *codec)
11831{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011832 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010011833 alc269_auto_init_multi_out(codec);
11834 alc269_auto_init_hp_out(codec);
11835 alc269_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010011836 if (spec->unsol_event)
11837 alc_sku_automute(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010011838}
11839
11840/*
11841 * configuration and preset
11842 */
11843static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020011844 [ALC269_BASIC] = "basic",
11845 [ALC269_QUANTA_FL1] = "Quanta",
11846 [ALC269_ASUS_EEEPC_P901] = "Asus_Epc_Dmic"
Kailang Yangf6a92242007-12-13 16:52:54 +010011847};
11848
11849static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020011850 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangf53281e2008-07-18 12:36:43 +020011851 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
11852 ALC269_ASUS_EEEPC_P703),
11853 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
11854 ALC269_ASUS_EEEPC_P901),
Kailang Yang60db6b52008-08-26 13:13:00 +020011855 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
11856 ALC269_ASUS_EEEPC_P901),
Kailang Yangf6a92242007-12-13 16:52:54 +010011857 {}
11858};
11859
11860static struct alc_config_preset alc269_presets[] = {
11861 [ALC269_BASIC] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020011862 .mixers = { alc269_base_mixer, alc269_capture_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010011863 .init_verbs = { alc269_init_verbs },
11864 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11865 .dac_nids = alc269_dac_nids,
11866 .hp_nid = 0x03,
11867 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11868 .channel_mode = alc269_modes,
11869 .input_mux = &alc269_capture_source,
11870 },
Kailang Yang60db6b52008-08-26 13:13:00 +020011871 [ALC269_QUANTA_FL1] = {
11872 .mixers = { alc269_quanta_fl1_mixer },
11873 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
11874 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11875 .dac_nids = alc269_dac_nids,
11876 .hp_nid = 0x03,
11877 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11878 .channel_mode = alc269_modes,
11879 .input_mux = &alc269_capture_source,
11880 .unsol_event = alc269_quanta_fl1_unsol_event,
11881 .init_hook = alc269_quanta_fl1_init_hook,
11882 },
Kailang Yangf53281e2008-07-18 12:36:43 +020011883 [ALC269_ASUS_EEEPC_P703] = {
11884 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer },
11885 .init_verbs = { alc269_init_verbs,
11886 alc269_eeepc_amic_init_verbs },
11887 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11888 .dac_nids = alc269_dac_nids,
11889 .hp_nid = 0x03,
11890 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11891 .channel_mode = alc269_modes,
11892 .input_mux = &alc269_eeepc_amic_capture_source,
11893 .unsol_event = alc269_eeepc_amic_unsol_event,
11894 .init_hook = alc269_eeepc_amic_inithook,
11895 },
11896 [ALC269_ASUS_EEEPC_P901] = {
11897 .mixers = { alc269_eeepc_mixer, alc269_epc_capture_mixer},
11898 .init_verbs = { alc269_init_verbs,
11899 alc269_eeepc_dmic_init_verbs },
11900 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
11901 .dac_nids = alc269_dac_nids,
11902 .hp_nid = 0x03,
11903 .num_channel_mode = ARRAY_SIZE(alc269_modes),
11904 .channel_mode = alc269_modes,
11905 .input_mux = &alc269_eeepc_dmic_capture_source,
11906 .unsol_event = alc269_eeepc_dmic_unsol_event,
11907 .init_hook = alc269_eeepc_dmic_inithook,
11908 },
Kailang Yangf6a92242007-12-13 16:52:54 +010011909};
11910
11911static int patch_alc269(struct hda_codec *codec)
11912{
11913 struct alc_spec *spec;
11914 int board_config;
11915 int err;
11916
11917 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
11918 if (spec == NULL)
11919 return -ENOMEM;
11920
11921 codec->spec = spec;
11922
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020011923 alc_fix_pll_init(codec, 0x20, 0x04, 15);
11924
Kailang Yangf6a92242007-12-13 16:52:54 +010011925 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
11926 alc269_models,
11927 alc269_cfg_tbl);
11928
11929 if (board_config < 0) {
11930 printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
11931 "trying auto-probe from BIOS...\n");
11932 board_config = ALC269_AUTO;
11933 }
11934
11935 if (board_config == ALC269_AUTO) {
11936 /* automatic parse from the BIOS config */
11937 err = alc269_parse_auto_config(codec);
11938 if (err < 0) {
11939 alc_free(codec);
11940 return err;
11941 } else if (!err) {
11942 printk(KERN_INFO
11943 "hda_codec: Cannot set up configuration "
11944 "from BIOS. Using base mode...\n");
11945 board_config = ALC269_BASIC;
11946 }
11947 }
11948
11949 if (board_config != ALC269_AUTO)
11950 setup_preset(spec, &alc269_presets[board_config]);
11951
11952 spec->stream_name_analog = "ALC269 Analog";
11953 spec->stream_analog_playback = &alc269_pcm_analog_playback;
11954 spec->stream_analog_capture = &alc269_pcm_analog_capture;
11955
11956 spec->stream_name_digital = "ALC269 Digital";
11957 spec->stream_digital_playback = &alc269_pcm_digital_playback;
11958 spec->stream_digital_capture = &alc269_pcm_digital_capture;
11959
11960 spec->adc_nids = alc269_adc_nids;
11961 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
Takashi Iwaie01bf502008-08-21 16:25:07 +020011962 spec->capsrc_nids = alc269_capsrc_nids;
Kailang Yangf6a92242007-12-13 16:52:54 +010011963
11964 codec->patch_ops = alc_patch_ops;
11965 if (board_config == ALC269_AUTO)
11966 spec->init_hook = alc269_auto_init;
11967#ifdef CONFIG_SND_HDA_POWER_SAVE
11968 if (!spec->loopback.amplist)
11969 spec->loopback.amplist = alc269_loopbacks;
11970#endif
11971
11972 return 0;
11973}
11974
11975/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011976 * ALC861 channel source setting (2/6 channel selection for 3-stack)
11977 */
11978
11979/*
11980 * set the path ways for 2 channel output
11981 * need to set the codec line out and mic 1 pin widgets to inputs
11982 */
11983static struct hda_verb alc861_threestack_ch2_init[] = {
11984 /* set pin widget 1Ah (line in) for input */
11985 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011986 /* set pin widget 18h (mic1/2) for input, for mic also enable
11987 * the vref
11988 */
Kailang Yangdf694da2005-12-05 19:42:22 +010011989 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
11990
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011991 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
11992#if 0
11993 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
11994 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
11995#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010011996 { } /* end */
11997};
11998/*
11999 * 6ch mode
12000 * need to set the codec line out and mic 1 pin widgets to outputs
12001 */
12002static struct hda_verb alc861_threestack_ch6_init[] = {
12003 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12004 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12005 /* set pin widget 18h (mic1) for output (CLFE)*/
12006 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12007
12008 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012009 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012010
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012011 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12012#if 0
12013 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12014 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12015#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010012016 { } /* end */
12017};
12018
12019static struct hda_channel_mode alc861_threestack_modes[2] = {
12020 { 2, alc861_threestack_ch2_init },
12021 { 6, alc861_threestack_ch6_init },
12022};
Takashi Iwai22309c32006-08-09 16:57:28 +020012023/* Set mic1 as input and unmute the mixer */
12024static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
12025 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12026 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12027 { } /* end */
12028};
12029/* Set mic1 as output and mute mixer */
12030static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
12031 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12032 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12033 { } /* end */
12034};
12035
12036static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
12037 { 2, alc861_uniwill_m31_ch2_init },
12038 { 4, alc861_uniwill_m31_ch4_init },
12039};
Kailang Yangdf694da2005-12-05 19:42:22 +010012040
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012041/* Set mic1 and line-in as input and unmute the mixer */
12042static struct hda_verb alc861_asus_ch2_init[] = {
12043 /* set pin widget 1Ah (line in) for input */
12044 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012045 /* set pin widget 18h (mic1/2) for input, for mic also enable
12046 * the vref
12047 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012048 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12049
12050 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
12051#if 0
12052 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
12053 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
12054#endif
12055 { } /* end */
12056};
12057/* Set mic1 nad line-in as output and mute mixer */
12058static struct hda_verb alc861_asus_ch6_init[] = {
12059 /* set pin widget 1Ah (line in) for output (Back Surround)*/
12060 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12061 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12062 /* set pin widget 18h (mic1) for output (CLFE)*/
12063 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12064 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
12065 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
12066 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
12067
12068 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
12069#if 0
12070 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
12071 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
12072#endif
12073 { } /* end */
12074};
12075
12076static struct hda_channel_mode alc861_asus_modes[2] = {
12077 { 2, alc861_asus_ch2_init },
12078 { 6, alc861_asus_ch6_init },
12079};
12080
Kailang Yangdf694da2005-12-05 19:42:22 +010012081/* patch-ALC861 */
12082
12083static struct snd_kcontrol_new alc861_base_mixer[] = {
12084 /* output mixer control */
12085 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12086 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12087 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12088 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12089 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12090
12091 /*Input mixer control */
12092 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12093 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12094 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12095 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12096 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12097 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12099 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12100 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12101 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012102
Kailang Yangdf694da2005-12-05 19:42:22 +010012103 /* Capture mixer control */
12104 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12105 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12106 {
12107 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12108 .name = "Capture Source",
12109 .count = 1,
12110 .info = alc_mux_enum_info,
12111 .get = alc_mux_enum_get,
12112 .put = alc_mux_enum_put,
12113 },
12114 { } /* end */
12115};
12116
12117static struct snd_kcontrol_new alc861_3ST_mixer[] = {
12118 /* output mixer control */
12119 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12120 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12121 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12122 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12123 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12124
12125 /* Input mixer control */
12126 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12127 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12128 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12129 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12130 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12131 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12132 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12133 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12134 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12135 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012136
Kailang Yangdf694da2005-12-05 19:42:22 +010012137 /* Capture mixer control */
12138 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12139 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12140 {
12141 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12142 .name = "Capture Source",
12143 .count = 1,
12144 .info = alc_mux_enum_info,
12145 .get = alc_mux_enum_get,
12146 .put = alc_mux_enum_put,
12147 },
12148 {
12149 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12150 .name = "Channel Mode",
12151 .info = alc_ch_mode_info,
12152 .get = alc_ch_mode_get,
12153 .put = alc_ch_mode_put,
12154 .private_value = ARRAY_SIZE(alc861_threestack_modes),
12155 },
12156 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012157};
12158
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012159static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012160 /* output mixer control */
12161 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12162 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12163 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020012164
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012165 /*Capture mixer control */
12166 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12167 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12168 {
12169 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12170 .name = "Capture Source",
12171 .count = 1,
12172 .info = alc_mux_enum_info,
12173 .get = alc_mux_enum_get,
12174 .put = alc_mux_enum_put,
12175 },
12176
12177 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012178};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012179
Takashi Iwai22309c32006-08-09 16:57:28 +020012180static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
12181 /* output mixer control */
12182 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12183 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12184 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12185 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12186 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
12187
12188 /* Input mixer control */
12189 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12190 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
12191 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12192 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12193 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12194 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12195 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12196 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12197 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
12198 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012199
Takashi Iwai22309c32006-08-09 16:57:28 +020012200 /* Capture mixer control */
12201 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12202 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12203 {
12204 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12205 .name = "Capture Source",
12206 .count = 1,
12207 .info = alc_mux_enum_info,
12208 .get = alc_mux_enum_get,
12209 .put = alc_mux_enum_put,
12210 },
12211 {
12212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12213 .name = "Channel Mode",
12214 .info = alc_ch_mode_info,
12215 .get = alc_ch_mode_get,
12216 .put = alc_ch_mode_put,
12217 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
12218 },
12219 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012220};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012221
12222static struct snd_kcontrol_new alc861_asus_mixer[] = {
12223 /* output mixer control */
12224 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
12225 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
12226 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
12227 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
12228 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
12229
12230 /* Input mixer control */
12231 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
12232 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
12233 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12234 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12235 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
12236 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
12237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
12238 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
12239 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012240 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
12241
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012242 /* Capture mixer control */
12243 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12244 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12245 {
12246 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12247 .name = "Capture Source",
12248 .count = 1,
12249 .info = alc_mux_enum_info,
12250 .get = alc_mux_enum_get,
12251 .put = alc_mux_enum_put,
12252 },
12253 {
12254 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12255 .name = "Channel Mode",
12256 .info = alc_ch_mode_info,
12257 .get = alc_ch_mode_get,
12258 .put = alc_ch_mode_put,
12259 .private_value = ARRAY_SIZE(alc861_asus_modes),
12260 },
12261 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012262};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012263
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012264/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010012265static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012266 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
12267 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
12268 HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
12269 HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
12270 { }
12271};
12272
Kailang Yangdf694da2005-12-05 19:42:22 +010012273/*
12274 * generic initialization of ADC, input mixers and output mixers
12275 */
12276static struct hda_verb alc861_base_init_verbs[] = {
12277 /*
12278 * Unmute ADC0 and set the default input to mic-in
12279 */
12280 /* port-A for surround (rear panel) */
12281 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12282 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
12283 /* port-B for mic-in (rear panel) with vref */
12284 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12285 /* port-C for line-in (rear panel) */
12286 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12287 /* port-D for Front */
12288 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12289 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12290 /* port-E for HP out (front panel) */
12291 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12292 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012293 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012294 /* port-F for mic-in (front panel) with vref */
12295 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12296 /* port-G for CLFE (rear panel) */
12297 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12298 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
12299 /* port-H for side (rear panel) */
12300 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12301 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
12302 /* CD-in */
12303 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12304 /* route front mic to ADC1*/
12305 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12306 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012307
Kailang Yangdf694da2005-12-05 19:42:22 +010012308 /* Unmute DAC0~3 & spdif out*/
12309 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12310 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12311 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12312 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012314
Kailang Yangdf694da2005-12-05 19:42:22 +010012315 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12316 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12317 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12318 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12319 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012320
Kailang Yangdf694da2005-12-05 19:42:22 +010012321 /* Unmute Stereo Mixer 15 */
12322 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12323 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12324 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012325 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012326
12327 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12328 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12329 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12330 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12331 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12332 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12333 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12334 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012335 /* hp used DAC 3 (Front) */
12336 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012337 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12338
12339 { }
12340};
12341
12342static struct hda_verb alc861_threestack_init_verbs[] = {
12343 /*
12344 * Unmute ADC0 and set the default input to mic-in
12345 */
12346 /* port-A for surround (rear panel) */
12347 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12348 /* port-B for mic-in (rear panel) with vref */
12349 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12350 /* port-C for line-in (rear panel) */
12351 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12352 /* port-D for Front */
12353 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12354 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12355 /* port-E for HP out (front panel) */
12356 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
12357 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012358 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012359 /* port-F for mic-in (front panel) with vref */
12360 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12361 /* port-G for CLFE (rear panel) */
12362 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12363 /* port-H for side (rear panel) */
12364 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12365 /* CD-in */
12366 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12367 /* route front mic to ADC1*/
12368 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12369 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12370 /* Unmute DAC0~3 & spdif out*/
12371 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12372 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12373 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12374 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012376
Kailang Yangdf694da2005-12-05 19:42:22 +010012377 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12378 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12379 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12380 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12381 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012382
Kailang Yangdf694da2005-12-05 19:42:22 +010012383 /* Unmute Stereo Mixer 15 */
12384 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12385 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12386 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012387 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010012388
12389 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12390 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12391 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12392 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12393 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12394 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12395 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12396 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012397 /* hp used DAC 3 (Front) */
12398 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012399 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12400 { }
12401};
Takashi Iwai22309c32006-08-09 16:57:28 +020012402
12403static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
12404 /*
12405 * Unmute ADC0 and set the default input to mic-in
12406 */
12407 /* port-A for surround (rear panel) */
12408 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12409 /* port-B for mic-in (rear panel) with vref */
12410 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12411 /* port-C for line-in (rear panel) */
12412 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12413 /* port-D for Front */
12414 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12415 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12416 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012417 /* this has to be set to VREF80 */
12418 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012419 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012420 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020012421 /* port-F for mic-in (front panel) with vref */
12422 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12423 /* port-G for CLFE (rear panel) */
12424 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12425 /* port-H for side (rear panel) */
12426 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
12427 /* CD-in */
12428 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12429 /* route front mic to ADC1*/
12430 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12431 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12432 /* Unmute DAC0~3 & spdif out*/
12433 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12434 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12435 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12436 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12437 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012438
Takashi Iwai22309c32006-08-09 16:57:28 +020012439 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12440 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12441 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12442 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12443 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012444
Takashi Iwai22309c32006-08-09 16:57:28 +020012445 /* Unmute Stereo Mixer 15 */
12446 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12447 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12448 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012449 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020012450
12451 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12452 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12453 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12454 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12455 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12456 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12457 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12458 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012459 /* hp used DAC 3 (Front) */
12460 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020012461 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12462 { }
12463};
12464
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012465static struct hda_verb alc861_asus_init_verbs[] = {
12466 /*
12467 * Unmute ADC0 and set the default input to mic-in
12468 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012469 /* port-A for surround (rear panel)
12470 * according to codec#0 this is the HP jack
12471 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012472 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
12473 /* route front PCM to HP */
12474 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
12475 /* port-B for mic-in (rear panel) with vref */
12476 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12477 /* port-C for line-in (rear panel) */
12478 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12479 /* port-D for Front */
12480 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12481 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
12482 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012483 /* this has to be set to VREF80 */
12484 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012485 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010012486 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012487 /* port-F for mic-in (front panel) with vref */
12488 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
12489 /* port-G for CLFE (rear panel) */
12490 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12491 /* port-H for side (rear panel) */
12492 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
12493 /* CD-in */
12494 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
12495 /* route front mic to ADC1*/
12496 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12497 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12498 /* Unmute DAC0~3 & spdif out*/
12499 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12500 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12501 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12502 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12503 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
12504 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12505 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12506 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12507 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12508 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012509
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012510 /* Unmute Stereo Mixer 15 */
12511 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12512 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12513 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012514 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012515
12516 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12517 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12518 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12519 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12520 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12521 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12522 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12523 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012524 /* hp used DAC 3 (Front) */
12525 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012526 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12527 { }
12528};
12529
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010012530/* additional init verbs for ASUS laptops */
12531static struct hda_verb alc861_asus_laptop_init_verbs[] = {
12532 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
12533 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
12534 { }
12535};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020012536
Kailang Yangdf694da2005-12-05 19:42:22 +010012537/*
12538 * generic initialization of ADC, input mixers and output mixers
12539 */
12540static struct hda_verb alc861_auto_init_verbs[] = {
12541 /*
12542 * Unmute ADC0 and set the default input to mic-in
12543 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012544 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010012545 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012546
Kailang Yangdf694da2005-12-05 19:42:22 +010012547 /* Unmute DAC0~3 & spdif out*/
12548 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12549 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12550 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12551 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
12552 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020012553
Kailang Yangdf694da2005-12-05 19:42:22 +010012554 /* Unmute Mixer 14 (mic) 1c (Line in)*/
12555 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12556 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12557 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12558 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012559
Kailang Yangdf694da2005-12-05 19:42:22 +010012560 /* Unmute Stereo Mixer 15 */
12561 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
12565
12566 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12567 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12568 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12569 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12570 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12571 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12572 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12573 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12574
12575 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012577 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12578 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012579 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12580 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012581 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
12582 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012583
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012584 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012585
12586 { }
12587};
12588
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012589static struct hda_verb alc861_toshiba_init_verbs[] = {
12590 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012591
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012592 { }
12593};
12594
12595/* toggle speaker-output according to the hp-jack state */
12596static void alc861_toshiba_automute(struct hda_codec *codec)
12597{
12598 unsigned int present;
12599
12600 present = snd_hda_codec_read(codec, 0x0f, 0,
12601 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020012602 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
12603 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
12604 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
12605 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012606}
12607
12608static void alc861_toshiba_unsol_event(struct hda_codec *codec,
12609 unsigned int res)
12610{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020012611 if ((res >> 26) == ALC880_HP_EVENT)
12612 alc861_toshiba_automute(codec);
12613}
12614
Kailang Yangdf694da2005-12-05 19:42:22 +010012615/* pcm configuration: identiacal with ALC880 */
12616#define alc861_pcm_analog_playback alc880_pcm_analog_playback
12617#define alc861_pcm_analog_capture alc880_pcm_analog_capture
12618#define alc861_pcm_digital_playback alc880_pcm_digital_playback
12619#define alc861_pcm_digital_capture alc880_pcm_digital_capture
12620
12621
12622#define ALC861_DIGOUT_NID 0x07
12623
12624static struct hda_channel_mode alc861_8ch_modes[1] = {
12625 { 8, NULL }
12626};
12627
12628static hda_nid_t alc861_dac_nids[4] = {
12629 /* front, surround, clfe, side */
12630 0x03, 0x06, 0x05, 0x04
12631};
12632
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012633static hda_nid_t alc660_dac_nids[3] = {
12634 /* front, clfe, surround */
12635 0x03, 0x05, 0x06
12636};
12637
Kailang Yangdf694da2005-12-05 19:42:22 +010012638static hda_nid_t alc861_adc_nids[1] = {
12639 /* ADC0-2 */
12640 0x08,
12641};
12642
12643static struct hda_input_mux alc861_capture_source = {
12644 .num_items = 5,
12645 .items = {
12646 { "Mic", 0x0 },
12647 { "Front Mic", 0x3 },
12648 { "Line", 0x1 },
12649 { "CD", 0x4 },
12650 { "Mixer", 0x5 },
12651 },
12652};
12653
12654/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012655static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
12656 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012657{
12658 int i;
12659 hda_nid_t nid;
12660
12661 spec->multiout.dac_nids = spec->private_dac_nids;
12662 for (i = 0; i < cfg->line_outs; i++) {
12663 nid = cfg->line_out_pins[i];
12664 if (nid) {
12665 if (i >= ARRAY_SIZE(alc861_dac_nids))
12666 continue;
12667 spec->multiout.dac_nids[i] = alc861_dac_nids[i];
12668 }
12669 }
12670 spec->multiout.num_dacs = cfg->line_outs;
12671 return 0;
12672}
12673
12674/* add playback controls from the parsed DAC table */
12675static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
12676 const struct auto_pin_cfg *cfg)
12677{
12678 char name[32];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012679 static const char *chname[4] = {
12680 "Front", "Surround", NULL /*CLFE*/, "Side"
12681 };
Kailang Yangdf694da2005-12-05 19:42:22 +010012682 hda_nid_t nid;
12683 int i, idx, err;
12684
12685 for (i = 0; i < cfg->line_outs; i++) {
12686 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012687 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010012688 continue;
12689 if (nid == 0x05) {
12690 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012691 err = add_control(spec, ALC_CTL_BIND_MUTE,
12692 "Center Playback Switch",
12693 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
12694 HDA_OUTPUT));
12695 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012696 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012697 err = add_control(spec, ALC_CTL_BIND_MUTE,
12698 "LFE Playback Switch",
12699 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
12700 HDA_OUTPUT));
12701 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012702 return err;
12703 } else {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012704 for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
12705 idx++)
Kailang Yangdf694da2005-12-05 19:42:22 +010012706 if (nid == alc861_dac_nids[idx])
12707 break;
12708 sprintf(name, "%s Playback Switch", chname[idx]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012709 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
12710 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
12711 HDA_OUTPUT));
12712 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012713 return err;
12714 }
12715 }
12716 return 0;
12717}
12718
12719static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
12720{
12721 int err;
12722 hda_nid_t nid;
12723
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012724 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010012725 return 0;
12726
12727 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
12728 nid = 0x03;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012729 err = add_control(spec, ALC_CTL_WIDGET_MUTE,
12730 "Headphone Playback Switch",
12731 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
12732 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012733 return err;
12734 spec->multiout.hp_nid = nid;
12735 }
12736 return 0;
12737}
12738
12739/* create playback/capture controls for input pins */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012740static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
12741 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012742{
Kailang Yangdf694da2005-12-05 19:42:22 +010012743 struct hda_input_mux *imux = &spec->private_imux;
12744 int i, err, idx, idx1;
12745
12746 for (i = 0; i < AUTO_PIN_LAST; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012747 switch (cfg->input_pins[i]) {
Kailang Yangdf694da2005-12-05 19:42:22 +010012748 case 0x0c:
12749 idx1 = 1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012750 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012751 break;
12752 case 0x0f:
12753 idx1 = 2;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012754 idx = 2; /* Line In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012755 break;
12756 case 0x0d:
12757 idx1 = 0;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012758 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012759 break;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012760 case 0x10:
Kailang Yangdf694da2005-12-05 19:42:22 +010012761 idx1 = 3;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012762 idx = 1; /* Mic In */
Kailang Yangdf694da2005-12-05 19:42:22 +010012763 break;
12764 case 0x11:
12765 idx1 = 4;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012766 idx = 0; /* CD */
Kailang Yangdf694da2005-12-05 19:42:22 +010012767 break;
12768 default:
12769 continue;
12770 }
12771
Takashi Iwai4a471b72005-12-07 13:56:29 +010012772 err = new_analog_input(spec, cfg->input_pins[i],
12773 auto_pin_cfg_labels[i], idx, 0x15);
Kailang Yangdf694da2005-12-05 19:42:22 +010012774 if (err < 0)
12775 return err;
12776
Takashi Iwai4a471b72005-12-07 13:56:29 +010012777 imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
Kailang Yangdf694da2005-12-05 19:42:22 +010012778 imux->items[imux->num_items].index = idx1;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012779 imux->num_items++;
Kailang Yangdf694da2005-12-05 19:42:22 +010012780 }
12781 return 0;
12782}
12783
12784static struct snd_kcontrol_new alc861_capture_mixer[] = {
12785 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
12786 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
12787
12788 {
12789 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12790 /* The multiple "Capture Source" controls confuse alsamixer
12791 * So call somewhat different..
Kailang Yangdf694da2005-12-05 19:42:22 +010012792 */
12793 /* .name = "Capture Source", */
12794 .name = "Input Source",
12795 .count = 1,
12796 .info = alc_mux_enum_info,
12797 .get = alc_mux_enum_get,
12798 .put = alc_mux_enum_put,
12799 },
12800 { } /* end */
12801};
12802
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012803static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
12804 hda_nid_t nid,
Kailang Yangdf694da2005-12-05 19:42:22 +010012805 int pin_type, int dac_idx)
12806{
Jacek Luczak564c5be2008-05-03 18:41:23 +020012807 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
12808 pin_type);
12809 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
12810 AMP_OUT_UNMUTE);
Kailang Yangdf694da2005-12-05 19:42:22 +010012811}
12812
12813static void alc861_auto_init_multi_out(struct hda_codec *codec)
12814{
12815 struct alc_spec *spec = codec->spec;
12816 int i;
12817
Kailang Yangbc9f98a2007-04-12 13:06:07 +020012818 alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
Kailang Yangdf694da2005-12-05 19:42:22 +010012819 for (i = 0; i < spec->autocfg.line_outs; i++) {
12820 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012821 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010012822 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020012823 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012824 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012825 }
12826}
12827
12828static void alc861_auto_init_hp_out(struct hda_codec *codec)
12829{
12830 struct alc_spec *spec = codec->spec;
12831 hda_nid_t pin;
12832
Takashi Iwaieb06ed82006-09-20 17:10:27 +020012833 pin = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012834 if (pin) /* connect to front */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012835 alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
12836 spec->multiout.dac_nids[0]);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012837 pin = spec->autocfg.speaker_pins[0];
12838 if (pin)
12839 alc861_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010012840}
12841
12842static void alc861_auto_init_analog_input(struct hda_codec *codec)
12843{
12844 struct alc_spec *spec = codec->spec;
12845 int i;
12846
12847 for (i = 0; i < AUTO_PIN_LAST; i++) {
12848 hda_nid_t nid = spec->autocfg.input_pins[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012849 if (nid >= 0x0c && nid <= 0x11) {
12850 snd_hda_codec_write(codec, nid, 0,
12851 AC_VERB_SET_PIN_WIDGET_CONTROL,
12852 i <= AUTO_PIN_FRONT_MIC ?
12853 PIN_VREF80 : PIN_IN);
Kailang Yangdf694da2005-12-05 19:42:22 +010012854 }
12855 }
12856}
12857
12858/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012859/* return 1 if successful, 0 if the proper config is not found,
12860 * or a negative error code
12861 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012862static int alc861_parse_auto_config(struct hda_codec *codec)
12863{
12864 struct alc_spec *spec = codec->spec;
12865 int err;
12866 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
12867
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012868 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12869 alc861_ignore);
12870 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012871 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012872 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010012873 return 0; /* can't find valid BIOS pin config */
12874
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012875 err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
12876 if (err < 0)
12877 return err;
12878 err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
12879 if (err < 0)
12880 return err;
12881 err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
12882 if (err < 0)
12883 return err;
12884 err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
12885 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012886 return err;
12887
12888 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12889
12890 if (spec->autocfg.dig_out_pin)
12891 spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
12892
12893 if (spec->kctl_alloc)
12894 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
12895
12896 spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
12897
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012898 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +010012899 spec->input_mux = &spec->private_imux;
12900
12901 spec->adc_nids = alc861_adc_nids;
12902 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
12903 spec->mixers[spec->num_mixers] = alc861_capture_mixer;
12904 spec->num_mixers++;
12905
12906 return 1;
12907}
12908
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012909/* additional initialization for auto-configuration model */
12910static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012911{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012912 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012913 alc861_auto_init_multi_out(codec);
12914 alc861_auto_init_hp_out(codec);
12915 alc861_auto_init_analog_input(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012916 if (spec->unsol_event)
12917 alc_sku_automute(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012918}
12919
Takashi Iwaicb53c622007-08-10 17:21:45 +020012920#ifdef CONFIG_SND_HDA_POWER_SAVE
12921static struct hda_amp_list alc861_loopbacks[] = {
12922 { 0x15, HDA_INPUT, 0 },
12923 { 0x15, HDA_INPUT, 1 },
12924 { 0x15, HDA_INPUT, 2 },
12925 { 0x15, HDA_INPUT, 3 },
12926 { } /* end */
12927};
12928#endif
12929
Kailang Yangdf694da2005-12-05 19:42:22 +010012930
12931/*
12932 * configuration and preset
12933 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012934static const char *alc861_models[ALC861_MODEL_LAST] = {
12935 [ALC861_3ST] = "3stack",
12936 [ALC660_3ST] = "3stack-660",
12937 [ALC861_3ST_DIG] = "3stack-dig",
12938 [ALC861_6ST_DIG] = "6stack-dig",
12939 [ALC861_UNIWILL_M31] = "uniwill-m31",
12940 [ALC861_TOSHIBA] = "toshiba",
12941 [ALC861_ASUS] = "asus",
12942 [ALC861_ASUS_LAPTOP] = "asus-laptop",
12943 [ALC861_AUTO] = "auto",
12944};
12945
12946static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010012947 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012948 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12949 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
12950 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012951 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020012952 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010012953 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020012954 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
12955 * Any other models that need this preset?
12956 */
12957 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020012958 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
12959 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012960 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
12961 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
12962 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
12963 /* FIXME: the below seems conflict */
12964 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
12965 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
12966 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010012967 {}
12968};
12969
12970static struct alc_config_preset alc861_presets[] = {
12971 [ALC861_3ST] = {
12972 .mixers = { alc861_3ST_mixer },
12973 .init_verbs = { alc861_threestack_init_verbs },
12974 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12975 .dac_nids = alc861_dac_nids,
12976 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12977 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012978 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012979 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12980 .adc_nids = alc861_adc_nids,
12981 .input_mux = &alc861_capture_source,
12982 },
12983 [ALC861_3ST_DIG] = {
12984 .mixers = { alc861_base_mixer },
12985 .init_verbs = { alc861_threestack_init_verbs },
12986 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
12987 .dac_nids = alc861_dac_nids,
12988 .dig_out_nid = ALC861_DIGOUT_NID,
12989 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
12990 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020012991 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010012992 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
12993 .adc_nids = alc861_adc_nids,
12994 .input_mux = &alc861_capture_source,
12995 },
12996 [ALC861_6ST_DIG] = {
12997 .mixers = { alc861_base_mixer },
12998 .init_verbs = { alc861_base_init_verbs },
12999 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13000 .dac_nids = alc861_dac_nids,
13001 .dig_out_nid = ALC861_DIGOUT_NID,
13002 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
13003 .channel_mode = alc861_8ch_modes,
13004 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13005 .adc_nids = alc861_adc_nids,
13006 .input_mux = &alc861_capture_source,
13007 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013008 [ALC660_3ST] = {
13009 .mixers = { alc861_3ST_mixer },
13010 .init_verbs = { alc861_threestack_init_verbs },
13011 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
13012 .dac_nids = alc660_dac_nids,
13013 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
13014 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020013015 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013016 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13017 .adc_nids = alc861_adc_nids,
13018 .input_mux = &alc861_capture_source,
13019 },
Takashi Iwai22309c32006-08-09 16:57:28 +020013020 [ALC861_UNIWILL_M31] = {
13021 .mixers = { alc861_uniwill_m31_mixer },
13022 .init_verbs = { alc861_uniwill_m31_init_verbs },
13023 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13024 .dac_nids = alc861_dac_nids,
13025 .dig_out_nid = ALC861_DIGOUT_NID,
13026 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
13027 .channel_mode = alc861_uniwill_m31_modes,
13028 .need_dac_fix = 1,
13029 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13030 .adc_nids = alc861_adc_nids,
13031 .input_mux = &alc861_capture_source,
13032 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013033 [ALC861_TOSHIBA] = {
13034 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013035 .init_verbs = { alc861_base_init_verbs,
13036 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020013037 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13038 .dac_nids = alc861_dac_nids,
13039 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13040 .channel_mode = alc883_3ST_2ch_modes,
13041 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13042 .adc_nids = alc861_adc_nids,
13043 .input_mux = &alc861_capture_source,
13044 .unsol_event = alc861_toshiba_unsol_event,
13045 .init_hook = alc861_toshiba_automute,
13046 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020013047 [ALC861_ASUS] = {
13048 .mixers = { alc861_asus_mixer },
13049 .init_verbs = { alc861_asus_init_verbs },
13050 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13051 .dac_nids = alc861_dac_nids,
13052 .dig_out_nid = ALC861_DIGOUT_NID,
13053 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
13054 .channel_mode = alc861_asus_modes,
13055 .need_dac_fix = 1,
13056 .hp_nid = 0x06,
13057 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13058 .adc_nids = alc861_adc_nids,
13059 .input_mux = &alc861_capture_source,
13060 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010013061 [ALC861_ASUS_LAPTOP] = {
13062 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
13063 .init_verbs = { alc861_asus_init_verbs,
13064 alc861_asus_laptop_init_verbs },
13065 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
13066 .dac_nids = alc861_dac_nids,
13067 .dig_out_nid = ALC861_DIGOUT_NID,
13068 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
13069 .channel_mode = alc883_3ST_2ch_modes,
13070 .need_dac_fix = 1,
13071 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
13072 .adc_nids = alc861_adc_nids,
13073 .input_mux = &alc861_capture_source,
13074 },
13075};
Kailang Yangdf694da2005-12-05 19:42:22 +010013076
13077
13078static int patch_alc861(struct hda_codec *codec)
13079{
13080 struct alc_spec *spec;
13081 int board_config;
13082 int err;
13083
Robert P. J. Daydc041e02006-12-19 14:44:15 +010013084 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010013085 if (spec == NULL)
13086 return -ENOMEM;
13087
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013088 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010013089
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013090 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
13091 alc861_models,
13092 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013093
Takashi Iwaif5fcc132006-11-24 17:07:44 +010013094 if (board_config < 0) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013095 printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
13096 "trying auto-probe from BIOS...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013097 board_config = ALC861_AUTO;
13098 }
13099
13100 if (board_config == ALC861_AUTO) {
13101 /* automatic parse from the BIOS config */
13102 err = alc861_parse_auto_config(codec);
13103 if (err < 0) {
13104 alc_free(codec);
13105 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013106 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020013107 printk(KERN_INFO
13108 "hda_codec: Cannot set up configuration "
13109 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010013110 board_config = ALC861_3ST_DIG;
13111 }
13112 }
13113
13114 if (board_config != ALC861_AUTO)
13115 setup_preset(spec, &alc861_presets[board_config]);
13116
13117 spec->stream_name_analog = "ALC861 Analog";
13118 spec->stream_analog_playback = &alc861_pcm_analog_playback;
13119 spec->stream_analog_capture = &alc861_pcm_analog_capture;
13120
13121 spec->stream_name_digital = "ALC861 Digital";
13122 spec->stream_digital_playback = &alc861_pcm_digital_playback;
13123 spec->stream_digital_capture = &alc861_pcm_digital_capture;
13124
Takashi Iwai2134ea42008-01-10 16:53:55 +010013125 spec->vmaster_nid = 0x03;
13126
Kailang Yangdf694da2005-12-05 19:42:22 +010013127 codec->patch_ops = alc_patch_ops;
13128 if (board_config == ALC861_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010013129 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020013130#ifdef CONFIG_SND_HDA_POWER_SAVE
13131 if (!spec->loopback.amplist)
13132 spec->loopback.amplist = alc861_loopbacks;
13133#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020013134
Kailang Yangdf694da2005-12-05 19:42:22 +010013135 return 0;
13136}
13137
13138/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013139 * ALC861-VD support
13140 *
13141 * Based on ALC882
13142 *
13143 * In addition, an independent DAC
13144 */
13145#define ALC861VD_DIGOUT_NID 0x06
13146
13147static hda_nid_t alc861vd_dac_nids[4] = {
13148 /* front, surr, clfe, side surr */
13149 0x02, 0x03, 0x04, 0x05
13150};
13151
13152/* dac_nids for ALC660vd are in a different order - according to
13153 * Realtek's driver.
13154 * This should probably tesult in a different mixer for 6stack models
13155 * of ALC660vd codecs, but for now there is only 3stack mixer
13156 * - and it is the same as in 861vd.
13157 * adc_nids in ALC660vd are (is) the same as in 861vd
13158 */
13159static hda_nid_t alc660vd_dac_nids[3] = {
13160 /* front, rear, clfe, rear_surr */
13161 0x02, 0x04, 0x03
13162};
13163
13164static hda_nid_t alc861vd_adc_nids[1] = {
13165 /* ADC0 */
13166 0x09,
13167};
13168
Takashi Iwaie1406342008-02-11 18:32:32 +010013169static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
13170
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013171/* input MUX */
13172/* FIXME: should be a matrix-type input source selection */
13173static struct hda_input_mux alc861vd_capture_source = {
13174 .num_items = 4,
13175 .items = {
13176 { "Mic", 0x0 },
13177 { "Front Mic", 0x1 },
13178 { "Line", 0x2 },
13179 { "CD", 0x4 },
13180 },
13181};
13182
Kailang Yang272a5272007-05-14 11:00:38 +020013183static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010013184 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020013185 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010013186 { "Ext Mic", 0x0 },
13187 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020013188 },
13189};
13190
Kailang Yangd1a991a2007-08-15 16:21:59 +020013191static struct hda_input_mux alc861vd_hp_capture_source = {
13192 .num_items = 2,
13193 .items = {
13194 { "Front Mic", 0x0 },
13195 { "ATAPI Mic", 0x1 },
13196 },
13197};
13198
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013199#define alc861vd_mux_enum_info alc_mux_enum_info
13200#define alc861vd_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010013201/* ALC861VD has the ALC882-type input selection (but has only one ADC) */
13202#define alc861vd_mux_enum_put alc882_mux_enum_put
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013203
13204/*
13205 * 2ch mode
13206 */
13207static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
13208 { 2, NULL }
13209};
13210
13211/*
13212 * 6ch mode
13213 */
13214static struct hda_verb alc861vd_6stack_ch6_init[] = {
13215 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
13216 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13217 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13218 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13219 { } /* end */
13220};
13221
13222/*
13223 * 8ch mode
13224 */
13225static struct hda_verb alc861vd_6stack_ch8_init[] = {
13226 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13227 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13228 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13229 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
13230 { } /* end */
13231};
13232
13233static struct hda_channel_mode alc861vd_6stack_modes[2] = {
13234 { 6, alc861vd_6stack_ch6_init },
13235 { 8, alc861vd_6stack_ch8_init },
13236};
13237
13238static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
13239 {
13240 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13241 .name = "Channel Mode",
13242 .info = alc_ch_mode_info,
13243 .get = alc_ch_mode_get,
13244 .put = alc_ch_mode_put,
13245 },
13246 { } /* end */
13247};
13248
13249static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
13250 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
13251 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
13252
13253 {
13254 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13255 /* The multiple "Capture Source" controls confuse alsamixer
13256 * So call somewhat different..
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013257 */
13258 /* .name = "Capture Source", */
13259 .name = "Input Source",
13260 .count = 1,
13261 .info = alc861vd_mux_enum_info,
13262 .get = alc861vd_mux_enum_get,
13263 .put = alc861vd_mux_enum_put,
13264 },
13265 { } /* end */
13266};
13267
13268/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
13269 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
13270 */
13271static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
13272 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13273 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13274
13275 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13276 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
13277
13278 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
13279 HDA_OUTPUT),
13280 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
13281 HDA_OUTPUT),
13282 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13283 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
13284
13285 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
13286 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
13287
13288 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13289
13290 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13292 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13293
13294 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13295 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13296 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13297
13298 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13299 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13300
13301 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13302 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13303
13304 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13305 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13306
13307 { } /* end */
13308};
13309
13310static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
13311 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13312 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13313
13314 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13315
13316 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13318 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13319
13320 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13321 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13322 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13323
13324 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13325 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13326
13327 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13328 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13329
13330 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
13331 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
13332
13333 { } /* end */
13334};
13335
Kailang Yangbdd148a2007-05-08 15:19:08 +020013336static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
13337 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13338 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
13339 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13340
13341 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
13342
13343 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13344 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13345 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13346
13347 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13348 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13349 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13350
13351 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
13352 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
13353
13354 { } /* end */
13355};
13356
Tobin Davisb419f342008-03-07 11:57:51 +010013357/* Pin assignment: Speaker=0x14, HP = 0x15,
13358 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020013359 */
13360static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010013361 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13362 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013363 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13364 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010013365 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13366 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13367 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13368 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13369 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13370 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
13371 HDA_CODEC_VOLUME("PC Beep Volume", 0x0b, 0x05, HDA_INPUT),
13372 HDA_CODEC_MUTE("PC Beep Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020013373 { } /* end */
13374};
13375
Kailang Yangd1a991a2007-08-15 16:21:59 +020013376/* Pin assignment: Speaker=0x14, Line-out = 0x15,
13377 * Front Mic=0x18, ATAPI Mic = 0x19,
13378 */
13379static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
13380 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13381 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
13382 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13383 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
13384 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13385 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13386 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
13387 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020013388
Kailang Yangd1a991a2007-08-15 16:21:59 +020013389 { } /* end */
13390};
13391
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013392/*
13393 * generic initialization of ADC, input mixers and output mixers
13394 */
13395static struct hda_verb alc861vd_volume_init_verbs[] = {
13396 /*
13397 * Unmute ADC0 and set the default input to mic-in
13398 */
13399 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
13400 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13401
13402 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
13403 * the analog-loopback mixer widget
13404 */
13405 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020013406 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13407 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13408 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13409 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13410 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013411
13412 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020013413 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13414 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13415 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013416 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013417
13418 /*
13419 * Set up output mixers (0x02 - 0x05)
13420 */
13421 /* set vol=0 to output mixers */
13422 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13423 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13424 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13425 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13426
13427 /* set up input amps for analog loopback */
13428 /* Amp Indices: DAC = 0, mixer = 1 */
13429 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13431 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13432 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13433 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13435 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13436 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13437
13438 { }
13439};
13440
13441/*
13442 * 3-stack pin configuration:
13443 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
13444 */
13445static struct hda_verb alc861vd_3stack_init_verbs[] = {
13446 /*
13447 * Set pin mode and muting
13448 */
13449 /* set front pin widgets 0x14 for output */
13450 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13451 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13452 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13453
13454 /* Mic (rear) pin: input vref at 80% */
13455 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13456 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13457 /* Front Mic pin: input vref at 80% */
13458 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13459 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13460 /* Line In pin: input */
13461 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13462 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13463 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13464 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13465 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13466 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13467 /* CD pin widget for input */
13468 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13469
13470 { }
13471};
13472
13473/*
13474 * 6-stack pin configuration:
13475 */
13476static struct hda_verb alc861vd_6stack_init_verbs[] = {
13477 /*
13478 * Set pin mode and muting
13479 */
13480 /* set front pin widgets 0x14 for output */
13481 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13482 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13483 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
13484
13485 /* Rear Pin: output 1 (0x0d) */
13486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13487 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
13489 /* CLFE Pin: output 2 (0x0e) */
13490 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13491 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13492 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
13493 /* Side Pin: output 3 (0x0f) */
13494 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13495 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13496 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
13497
13498 /* Mic (rear) pin: input vref at 80% */
13499 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13500 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13501 /* Front Mic pin: input vref at 80% */
13502 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13503 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13504 /* Line In pin: input */
13505 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13506 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13507 /* Line-2 In: Headphone output (output 0 - 0x0c) */
13508 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13509 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13510 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
13511 /* CD pin widget for input */
13512 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13513
13514 { }
13515};
13516
Kailang Yangbdd148a2007-05-08 15:19:08 +020013517static struct hda_verb alc861vd_eapd_verbs[] = {
13518 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13519 { }
13520};
13521
Kailang Yangf9423e72008-05-27 12:32:25 +020013522static struct hda_verb alc660vd_eapd_verbs[] = {
13523 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13524 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13525 { }
13526};
13527
Kailang Yangbdd148a2007-05-08 15:19:08 +020013528static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
13529 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13530 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13531 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
13532 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020013533 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020013534 {}
13535};
13536
13537/* toggle speaker-output according to the hp-jack state */
13538static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
13539{
13540 unsigned int present;
13541 unsigned char bits;
13542
13543 present = snd_hda_codec_read(codec, 0x1b, 0,
13544 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013545 bits = present ? HDA_AMP_MUTE : 0;
13546 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13547 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013548}
13549
13550static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
13551{
13552 unsigned int present;
13553 unsigned char bits;
13554
13555 present = snd_hda_codec_read(codec, 0x18, 0,
13556 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013557 bits = present ? HDA_AMP_MUTE : 0;
13558 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
13559 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020013560}
13561
13562static void alc861vd_lenovo_automute(struct hda_codec *codec)
13563{
13564 alc861vd_lenovo_hp_automute(codec);
13565 alc861vd_lenovo_mic_automute(codec);
13566}
13567
13568static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
13569 unsigned int res)
13570{
13571 switch (res >> 26) {
13572 case ALC880_HP_EVENT:
13573 alc861vd_lenovo_hp_automute(codec);
13574 break;
13575 case ALC880_MIC_EVENT:
13576 alc861vd_lenovo_mic_automute(codec);
13577 break;
13578 }
13579}
13580
Kailang Yang272a5272007-05-14 11:00:38 +020013581static struct hda_verb alc861vd_dallas_verbs[] = {
13582 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13583 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13584 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13585 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13586
13587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
13589 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13591 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13592 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13593 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
13594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013595
Kailang Yang272a5272007-05-14 11:00:38 +020013596 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13597 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13598 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13599 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13600 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13601 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13602 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
13603 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13604
13605 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13606 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13607 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
13608 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13609 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13610 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13611 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13612 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13613
13614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
13616 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
13617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
13618
13619 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020013620 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020013621 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
13622
13623 { } /* end */
13624};
13625
13626/* toggle speaker-output according to the hp-jack state */
13627static void alc861vd_dallas_automute(struct hda_codec *codec)
13628{
13629 unsigned int present;
13630
13631 present = snd_hda_codec_read(codec, 0x15, 0,
13632 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020013633 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
13634 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +020013635}
13636
13637static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
13638{
13639 if ((res >> 26) == ALC880_HP_EVENT)
13640 alc861vd_dallas_automute(codec);
13641}
13642
Takashi Iwaicb53c622007-08-10 17:21:45 +020013643#ifdef CONFIG_SND_HDA_POWER_SAVE
13644#define alc861vd_loopbacks alc880_loopbacks
13645#endif
13646
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013647/* pcm configuration: identiacal with ALC880 */
13648#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
13649#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
13650#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
13651#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
13652
13653/*
13654 * configuration and preset
13655 */
13656static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
13657 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013658 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013659 [ALC861VD_3ST] = "3stack",
13660 [ALC861VD_3ST_DIG] = "3stack-digout",
13661 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020013662 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020013663 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013664 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013665 [ALC861VD_AUTO] = "auto",
13666};
13667
13668static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013669 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
13670 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010013671 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013672 SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
Alexander Holler2522d732008-07-17 23:36:15 +020013673 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC861VD_LENOVO),
Mike Crash6963f842007-06-25 12:12:51 +020013674 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013675 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013676 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020013677 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Kailang Yang272a5272007-05-14 11:00:38 +020013678 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
Takashi Iwai542d7c62007-08-16 18:57:30 +020013679 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010013680 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020013681 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013682 SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
13683 SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
Takashi Iwaibe321a892008-07-07 16:04:04 +020013684 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 N200", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020013685 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013686 {}
13687};
13688
13689static struct alc_config_preset alc861vd_presets[] = {
13690 [ALC660VD_3ST] = {
13691 .mixers = { alc861vd_3st_mixer },
13692 .init_verbs = { alc861vd_volume_init_verbs,
13693 alc861vd_3stack_init_verbs },
13694 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13695 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013696 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13697 .channel_mode = alc861vd_3stack_2ch_modes,
13698 .input_mux = &alc861vd_capture_source,
13699 },
Mike Crash6963f842007-06-25 12:12:51 +020013700 [ALC660VD_3ST_DIG] = {
13701 .mixers = { alc861vd_3st_mixer },
13702 .init_verbs = { alc861vd_volume_init_verbs,
13703 alc861vd_3stack_init_verbs },
13704 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13705 .dac_nids = alc660vd_dac_nids,
13706 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020013707 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13708 .channel_mode = alc861vd_3stack_2ch_modes,
13709 .input_mux = &alc861vd_capture_source,
13710 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013711 [ALC861VD_3ST] = {
13712 .mixers = { alc861vd_3st_mixer },
13713 .init_verbs = { alc861vd_volume_init_verbs,
13714 alc861vd_3stack_init_verbs },
13715 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13716 .dac_nids = alc861vd_dac_nids,
13717 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13718 .channel_mode = alc861vd_3stack_2ch_modes,
13719 .input_mux = &alc861vd_capture_source,
13720 },
13721 [ALC861VD_3ST_DIG] = {
13722 .mixers = { alc861vd_3st_mixer },
13723 .init_verbs = { alc861vd_volume_init_verbs,
13724 alc861vd_3stack_init_verbs },
13725 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13726 .dac_nids = alc861vd_dac_nids,
13727 .dig_out_nid = ALC861VD_DIGOUT_NID,
13728 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13729 .channel_mode = alc861vd_3stack_2ch_modes,
13730 .input_mux = &alc861vd_capture_source,
13731 },
13732 [ALC861VD_6ST_DIG] = {
13733 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
13734 .init_verbs = { alc861vd_volume_init_verbs,
13735 alc861vd_6stack_init_verbs },
13736 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13737 .dac_nids = alc861vd_dac_nids,
13738 .dig_out_nid = ALC861VD_DIGOUT_NID,
13739 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
13740 .channel_mode = alc861vd_6stack_modes,
13741 .input_mux = &alc861vd_capture_source,
13742 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020013743 [ALC861VD_LENOVO] = {
13744 .mixers = { alc861vd_lenovo_mixer },
13745 .init_verbs = { alc861vd_volume_init_verbs,
13746 alc861vd_3stack_init_verbs,
13747 alc861vd_eapd_verbs,
13748 alc861vd_lenovo_unsol_verbs },
13749 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
13750 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013751 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13752 .channel_mode = alc861vd_3stack_2ch_modes,
13753 .input_mux = &alc861vd_capture_source,
13754 .unsol_event = alc861vd_lenovo_unsol_event,
13755 .init_hook = alc861vd_lenovo_automute,
13756 },
Kailang Yang272a5272007-05-14 11:00:38 +020013757 [ALC861VD_DALLAS] = {
13758 .mixers = { alc861vd_dallas_mixer },
13759 .init_verbs = { alc861vd_dallas_verbs },
13760 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13761 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020013762 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13763 .channel_mode = alc861vd_3stack_2ch_modes,
13764 .input_mux = &alc861vd_dallas_capture_source,
13765 .unsol_event = alc861vd_dallas_unsol_event,
13766 .init_hook = alc861vd_dallas_automute,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013767 },
13768 [ALC861VD_HP] = {
13769 .mixers = { alc861vd_hp_mixer },
13770 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
13771 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
13772 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013773 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013774 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
13775 .channel_mode = alc861vd_3stack_2ch_modes,
13776 .input_mux = &alc861vd_hp_capture_source,
13777 .unsol_event = alc861vd_dallas_unsol_event,
13778 .init_hook = alc861vd_dallas_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020013779 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013780};
13781
13782/*
13783 * BIOS auto configuration
13784 */
13785static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
13786 hda_nid_t nid, int pin_type, int dac_idx)
13787{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013788 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013789}
13790
13791static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
13792{
13793 struct alc_spec *spec = codec->spec;
13794 int i;
13795
Kailang Yangbc9f98a2007-04-12 13:06:07 +020013796 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013797 for (i = 0; i <= HDA_SIDE; i++) {
13798 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013799 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013800 if (nid)
13801 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020013802 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013803 }
13804}
13805
13806
13807static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
13808{
13809 struct alc_spec *spec = codec->spec;
13810 hda_nid_t pin;
13811
13812 pin = spec->autocfg.hp_pins[0];
13813 if (pin) /* connect to front and use dac 0 */
13814 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013815 pin = spec->autocfg.speaker_pins[0];
13816 if (pin)
13817 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013818}
13819
13820#define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
13821#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
13822
13823static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
13824{
13825 struct alc_spec *spec = codec->spec;
13826 int i;
13827
13828 for (i = 0; i < AUTO_PIN_LAST; i++) {
13829 hda_nid_t nid = spec->autocfg.input_pins[i];
13830 if (alc861vd_is_input_pin(nid)) {
13831 snd_hda_codec_write(codec, nid, 0,
13832 AC_VERB_SET_PIN_WIDGET_CONTROL,
13833 i <= AUTO_PIN_FRONT_MIC ?
13834 PIN_VREF80 : PIN_IN);
13835 if (nid != ALC861VD_PIN_CD_NID)
13836 snd_hda_codec_write(codec, nid, 0,
13837 AC_VERB_SET_AMP_GAIN_MUTE,
13838 AMP_OUT_MUTE);
13839 }
13840 }
13841}
13842
Takashi Iwaif511b012008-08-15 16:46:42 +020013843#define alc861vd_auto_init_input_src alc882_auto_init_input_src
13844
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013845#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
13846#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
13847
13848/* add playback controls from the parsed DAC table */
13849/* Based on ALC880 version. But ALC861VD has separate,
13850 * different NIDs for mute/unmute switch and volume control */
13851static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
13852 const struct auto_pin_cfg *cfg)
13853{
13854 char name[32];
13855 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
13856 hda_nid_t nid_v, nid_s;
13857 int i, err;
13858
13859 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013860 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013861 continue;
13862 nid_v = alc861vd_idx_to_mixer_vol(
13863 alc880_dac_to_idx(
13864 spec->multiout.dac_nids[i]));
13865 nid_s = alc861vd_idx_to_mixer_switch(
13866 alc880_dac_to_idx(
13867 spec->multiout.dac_nids[i]));
13868
13869 if (i == 2) {
13870 /* Center/LFE */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013871 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13872 "Center Playback Volume",
13873 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
13874 HDA_OUTPUT));
13875 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013876 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013877 err = add_control(spec, ALC_CTL_WIDGET_VOL,
13878 "LFE Playback Volume",
13879 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
13880 HDA_OUTPUT));
13881 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013882 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013883 err = add_control(spec, ALC_CTL_BIND_MUTE,
13884 "Center Playback Switch",
13885 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
13886 HDA_INPUT));
13887 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013888 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013889 err = add_control(spec, ALC_CTL_BIND_MUTE,
13890 "LFE Playback Switch",
13891 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
13892 HDA_INPUT));
13893 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013894 return err;
13895 } else {
13896 sprintf(name, "%s Playback Volume", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013897 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13898 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
13899 HDA_OUTPUT));
13900 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013901 return err;
13902 sprintf(name, "%s Playback Switch", chname[i]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013903 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Kailang Yangbdd148a2007-05-08 15:19:08 +020013904 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013905 HDA_INPUT));
13906 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013907 return err;
13908 }
13909 }
13910 return 0;
13911}
13912
13913/* add playback controls for speaker and HP outputs */
13914/* Based on ALC880 version. But ALC861VD has separate,
13915 * different NIDs for mute/unmute switch and volume control */
13916static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
13917 hda_nid_t pin, const char *pfx)
13918{
13919 hda_nid_t nid_v, nid_s;
13920 int err;
13921 char name[32];
13922
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013923 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013924 return 0;
13925
13926 if (alc880_is_fixed_pin(pin)) {
13927 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
13928 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013929 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013930 spec->multiout.hp_nid = nid_v;
13931 else
13932 spec->multiout.extra_out_nid[0] = nid_v;
13933 /* control HP volume/switch on the output mixer amp */
13934 nid_v = alc861vd_idx_to_mixer_vol(
13935 alc880_fixed_pin_idx(pin));
13936 nid_s = alc861vd_idx_to_mixer_switch(
13937 alc880_fixed_pin_idx(pin));
13938
13939 sprintf(name, "%s Playback Volume", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013940 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
13941 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
13942 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013943 return err;
13944 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013945 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
13946 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
13947 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013948 return err;
13949 } else if (alc880_is_multi_pin(pin)) {
13950 /* set manual connection */
13951 /* we have only a switch on HP-out PIN */
13952 sprintf(name, "%s Playback Switch", pfx);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013953 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
13954 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
13955 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013956 return err;
13957 }
13958 return 0;
13959}
13960
13961/* parse the BIOS configuration and set up the alc_spec
13962 * return 1 if successful, 0 if the proper config is not found,
13963 * or a negative error code
13964 * Based on ALC880 version - had to change it to override
13965 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
13966static int alc861vd_parse_auto_config(struct hda_codec *codec)
13967{
13968 struct alc_spec *spec = codec->spec;
13969 int err;
13970 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
13971
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013972 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13973 alc861vd_ignore);
13974 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013975 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013976 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013977 return 0; /* can't find valid BIOS pin config */
13978
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020013979 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
13980 if (err < 0)
13981 return err;
13982 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
13983 if (err < 0)
13984 return err;
13985 err = alc861vd_auto_create_extra_out(spec,
13986 spec->autocfg.speaker_pins[0],
13987 "Speaker");
13988 if (err < 0)
13989 return err;
13990 err = alc861vd_auto_create_extra_out(spec,
13991 spec->autocfg.hp_pins[0],
13992 "Headphone");
13993 if (err < 0)
13994 return err;
13995 err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
13996 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010013997 return err;
13998
13999 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14000
14001 if (spec->autocfg.dig_out_pin)
14002 spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
14003
14004 if (spec->kctl_alloc)
14005 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
14006
14007 spec->init_verbs[spec->num_init_verbs++]
14008 = alc861vd_volume_init_verbs;
14009
14010 spec->num_mux_defs = 1;
14011 spec->input_mux = &spec->private_imux;
14012
Takashi Iwai776e1842007-08-29 15:07:11 +020014013 err = alc_auto_add_mic_boost(codec);
14014 if (err < 0)
14015 return err;
14016
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014017 return 1;
14018}
14019
14020/* additional initialization for auto-configuration model */
14021static void alc861vd_auto_init(struct hda_codec *codec)
14022{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014023 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014024 alc861vd_auto_init_multi_out(codec);
14025 alc861vd_auto_init_hp_out(codec);
14026 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020014027 alc861vd_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014028 if (spec->unsol_event)
14029 alc_sku_automute(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014030}
14031
14032static int patch_alc861vd(struct hda_codec *codec)
14033{
14034 struct alc_spec *spec;
14035 int err, board_config;
14036
14037 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14038 if (spec == NULL)
14039 return -ENOMEM;
14040
14041 codec->spec = spec;
14042
14043 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
14044 alc861vd_models,
14045 alc861vd_cfg_tbl);
14046
14047 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
14048 printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
14049 "ALC861VD, trying auto-probe from BIOS...\n");
14050 board_config = ALC861VD_AUTO;
14051 }
14052
14053 if (board_config == ALC861VD_AUTO) {
14054 /* automatic parse from the BIOS config */
14055 err = alc861vd_parse_auto_config(codec);
14056 if (err < 0) {
14057 alc_free(codec);
14058 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014059 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014060 printk(KERN_INFO
14061 "hda_codec: Cannot set up configuration "
14062 "from BIOS. Using base mode...\n");
14063 board_config = ALC861VD_3ST;
14064 }
14065 }
14066
14067 if (board_config != ALC861VD_AUTO)
14068 setup_preset(spec, &alc861vd_presets[board_config]);
14069
Kailang Yang2f893282008-05-27 12:14:47 +020014070 if (codec->vendor_id == 0x10ec0660) {
14071 spec->stream_name_analog = "ALC660-VD Analog";
14072 spec->stream_name_digital = "ALC660-VD Digital";
Kailang Yangf9423e72008-05-27 12:32:25 +020014073 /* always turn on EAPD */
14074 spec->init_verbs[spec->num_init_verbs++] = alc660vd_eapd_verbs;
Kailang Yang2f893282008-05-27 12:14:47 +020014075 } else {
14076 spec->stream_name_analog = "ALC861VD Analog";
14077 spec->stream_name_digital = "ALC861VD Digital";
14078 }
14079
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014080 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
14081 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
14082
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014083 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
14084 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
14085
14086 spec->adc_nids = alc861vd_adc_nids;
14087 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
Takashi Iwaie1406342008-02-11 18:32:32 +010014088 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014089
14090 spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
14091 spec->num_mixers++;
14092
Takashi Iwai2134ea42008-01-10 16:53:55 +010014093 spec->vmaster_nid = 0x02;
14094
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014095 codec->patch_ops = alc_patch_ops;
14096
14097 if (board_config == ALC861VD_AUTO)
14098 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020014099#ifdef CONFIG_SND_HDA_POWER_SAVE
14100 if (!spec->loopback.amplist)
14101 spec->loopback.amplist = alc861vd_loopbacks;
14102#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010014103
14104 return 0;
14105}
14106
14107/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014108 * ALC662 support
14109 *
14110 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
14111 * configuration. Each pin widget can choose any input DACs and a mixer.
14112 * Each ADC is connected from a mixer of all inputs. This makes possible
14113 * 6-channel independent captures.
14114 *
14115 * In addition, an independent DAC for the multi-playback (not used in this
14116 * driver yet).
14117 */
14118#define ALC662_DIGOUT_NID 0x06
14119#define ALC662_DIGIN_NID 0x0a
14120
14121static hda_nid_t alc662_dac_nids[4] = {
14122 /* front, rear, clfe, rear_surr */
14123 0x02, 0x03, 0x04
14124};
14125
14126static hda_nid_t alc662_adc_nids[1] = {
14127 /* ADC1-2 */
14128 0x09,
14129};
Takashi Iwaie1406342008-02-11 18:32:32 +010014130
Kailang Yang77a261b2008-02-19 11:38:05 +010014131static hda_nid_t alc662_capsrc_nids[1] = { 0x22 };
Takashi Iwaie1406342008-02-11 18:32:32 +010014132
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014133/* input MUX */
14134/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014135static struct hda_input_mux alc662_capture_source = {
14136 .num_items = 4,
14137 .items = {
14138 { "Mic", 0x0 },
14139 { "Front Mic", 0x1 },
14140 { "Line", 0x2 },
14141 { "CD", 0x4 },
14142 },
14143};
14144
14145static struct hda_input_mux alc662_lenovo_101e_capture_source = {
14146 .num_items = 2,
14147 .items = {
14148 { "Mic", 0x1 },
14149 { "Line", 0x2 },
14150 },
14151};
Kailang Yang291702f2007-10-16 14:28:03 +020014152
14153static struct hda_input_mux alc662_eeepc_capture_source = {
14154 .num_items = 2,
14155 .items = {
14156 { "i-Mic", 0x1 },
14157 { "e-Mic", 0x0 },
14158 },
14159};
14160
Kailang Yang6dda9f42008-05-27 12:05:31 +020014161static struct hda_input_mux alc663_capture_source = {
14162 .num_items = 3,
14163 .items = {
14164 { "Mic", 0x0 },
14165 { "Front Mic", 0x1 },
14166 { "Line", 0x2 },
14167 },
14168};
14169
14170static struct hda_input_mux alc663_m51va_capture_source = {
14171 .num_items = 2,
14172 .items = {
14173 { "Ext-Mic", 0x0 },
14174 { "D-Mic", 0x9 },
14175 },
14176};
14177
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014178#define alc662_mux_enum_info alc_mux_enum_info
14179#define alc662_mux_enum_get alc_mux_enum_get
Takashi Iwaie1406342008-02-11 18:32:32 +010014180#define alc662_mux_enum_put alc882_mux_enum_put
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014181
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014182/*
14183 * 2ch mode
14184 */
14185static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
14186 { 2, NULL }
14187};
14188
14189/*
14190 * 2ch mode
14191 */
14192static struct hda_verb alc662_3ST_ch2_init[] = {
14193 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
14194 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14195 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
14196 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
14197 { } /* end */
14198};
14199
14200/*
14201 * 6ch mode
14202 */
14203static struct hda_verb alc662_3ST_ch6_init[] = {
14204 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14205 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14206 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
14207 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14208 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
14209 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
14210 { } /* end */
14211};
14212
14213static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
14214 { 2, alc662_3ST_ch2_init },
14215 { 6, alc662_3ST_ch6_init },
14216};
14217
14218/*
14219 * 2ch mode
14220 */
14221static struct hda_verb alc662_sixstack_ch6_init[] = {
14222 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14223 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
14224 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14225 { } /* end */
14226};
14227
14228/*
14229 * 6ch mode
14230 */
14231static struct hda_verb alc662_sixstack_ch8_init[] = {
14232 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14233 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14234 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
14235 { } /* end */
14236};
14237
14238static struct hda_channel_mode alc662_5stack_modes[2] = {
14239 { 2, alc662_sixstack_ch6_init },
14240 { 6, alc662_sixstack_ch8_init },
14241};
14242
14243/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
14244 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
14245 */
14246
14247static struct snd_kcontrol_new alc662_base_mixer[] = {
14248 /* output mixer control */
14249 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014250 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014251 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014252 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014253 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14254 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014255 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14256 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014257 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14258
14259 /*Input mixer control */
14260 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
14261 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
14262 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
14263 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
14264 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
14265 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
14266 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
14267 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014268 { } /* end */
14269};
14270
14271static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
14272 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014273 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014274 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14275 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14276 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14277 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14278 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14279 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14280 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14281 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14282 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14283 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14284 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014285 { } /* end */
14286};
14287
14288static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
14289 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014290 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014291 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014292 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014293 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14294 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010014295 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
14296 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014297 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14298 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
14299 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
14300 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14301 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14302 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14303 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14304 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14305 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14306 HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
14307 HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014308 { } /* end */
14309};
14310
14311static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
14312 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14313 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014314 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14315 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014316 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
14317 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14318 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14319 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14320 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014321 { } /* end */
14322};
14323
Kailang Yang291702f2007-10-16 14:28:03 +020014324static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010014325 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014326
Herton Ronaldo Krzesinskib4818492008-02-23 11:34:12 +010014327 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14328 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020014329
14330 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
14331 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14332 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14333
14334 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
14335 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14336 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14337 { } /* end */
14338};
14339
Kailang Yang8c427222008-01-10 13:03:59 +010014340static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai31bffaa2008-02-27 16:10:44 +010014341 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14342 HDA_CODEC_MUTE("Line-Out Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014343 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14344 HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
14345 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
14346 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
14347 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
14348 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010014349 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010014350 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
14351 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14352 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14353 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14354 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14355 { } /* end */
14356};
14357
Kailang Yang6dda9f42008-05-27 12:05:31 +020014358static struct snd_kcontrol_new alc663_m51va_mixer[] = {
14359 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14360 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14361 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14362 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14363 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14364 HDA_CODEC_MUTE("DMic Playback Switch", 0x23, 0x9, HDA_INPUT),
14365 { } /* end */
14366};
14367
14368static struct snd_kcontrol_new alc663_g71v_mixer[] = {
14369 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14370 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14371 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14372 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14373 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14374
14375 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14376 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14377 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14378 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14379 { } /* end */
14380};
14381
14382static struct snd_kcontrol_new alc663_g50v_mixer[] = {
14383 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14384 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14386
14387 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14388 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14389 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
14390 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
14391 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14392 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14393 { } /* end */
14394};
14395
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014396static struct snd_kcontrol_new alc662_chmode_mixer[] = {
14397 {
14398 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14399 .name = "Channel Mode",
14400 .info = alc_ch_mode_info,
14401 .get = alc_ch_mode_get,
14402 .put = alc_ch_mode_put,
14403 },
14404 { } /* end */
14405};
14406
14407static struct hda_verb alc662_init_verbs[] = {
14408 /* ADC: mute amp left and right */
14409 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14410 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14411 /* Front mixer: unmute input/output amp left and right (volume = 0) */
14412
Takashi Iwaicb53c622007-08-10 17:21:45 +020014413 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14414 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14415 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14416 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14417 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014418
Kailang Yangb60dd392007-09-20 12:50:29 +020014419 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14420 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14421 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14422 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14423 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14424 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014425
14426 /* Front Pin: output 0 (0x0c) */
14427 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14428 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14429
14430 /* Rear Pin: output 1 (0x0d) */
14431 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14432 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14433
14434 /* CLFE Pin: output 2 (0x0e) */
14435 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14436 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14437
14438 /* Mic (rear) pin: input vref at 80% */
14439 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14440 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14441 /* Front Mic pin: input vref at 80% */
14442 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14443 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14444 /* Line In pin: input */
14445 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14446 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
14447 /* Line-2 In: Headphone output (output 0 - 0x0c) */
14448 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14449 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14450 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
14451 /* CD pin widget for input */
14452 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14453
14454 /* FIXME: use matrix-type input source selection */
14455 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14456 /* Input mixer */
14457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14460 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang291702f2007-10-16 14:28:03 +020014461
14462 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14463 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
14465 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020014466
14467 /* always trun on EAPD */
14468 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
14469 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
14470
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014471 { }
14472};
14473
14474static struct hda_verb alc662_sue_init_verbs[] = {
14475 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14476 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020014477 {}
14478};
14479
14480static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
14481 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14482 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14483 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014484};
14485
Kailang Yang8c427222008-01-10 13:03:59 +010014486/* Set Unsolicited Event*/
14487static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
14488 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14489 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14490 {}
14491};
14492
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014493/*
14494 * generic initialization of ADC, input mixers and output mixers
14495 */
14496static struct hda_verb alc662_auto_init_verbs[] = {
14497 /*
14498 * Unmute ADC and set the default input to mic-in
14499 */
14500 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
14501 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14502
14503 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
14504 * mixer widget
14505 * Note: PASD motherboards uses the Line In 2 as the input for front
14506 * panel mic (mic 2)
14507 */
14508 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020014509 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
14510 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
14511 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
14512 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
14513 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014514
14515 /*
14516 * Set up output mixers (0x0c - 0x0f)
14517 */
14518 /* set vol=0 to output mixers */
14519 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14520 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14521 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14522
14523 /* set up input amps for analog loopback */
14524 /* Amp Indices: DAC = 0, mixer = 1 */
Kailang Yangb60dd392007-09-20 12:50:29 +020014525 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14526 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14527 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14528 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14529 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14530 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014531
14532
14533 /* FIXME: use matrix-type input source selection */
14534 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
14535 /* Input mixer */
14536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangd1a991a2007-08-15 16:21:59 +020014537 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014538 { }
14539};
14540
Takashi Iwai24fb9172008-09-02 14:48:20 +020014541/* additional verbs for ALC663 */
14542static struct hda_verb alc663_auto_init_verbs[] = {
14543 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14544 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14545 { }
14546};
14547
Kailang Yang6dda9f42008-05-27 12:05:31 +020014548static struct hda_verb alc663_m51va_init_verbs[] = {
14549 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14550 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14551 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14552
14553 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
14554
14555 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14556 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14557 {}
14558};
14559
14560static struct hda_verb alc663_g71v_init_verbs[] = {
14561 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14562 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
14563 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
14564
14565 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14566 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14567 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14568
14569 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
14570 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
14571 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
14572 {}
14573};
14574
14575static struct hda_verb alc663_g50v_init_verbs[] = {
14576 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14577 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14578 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
14579
14580 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14581 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14582 {}
14583};
14584
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014585/* capture mixer elements */
14586static struct snd_kcontrol_new alc662_capture_mixer[] = {
14587 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14588 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14589 {
14590 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14591 /* The multiple "Capture Source" controls confuse alsamixer
14592 * So call somewhat different..
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014593 */
14594 /* .name = "Capture Source", */
14595 .name = "Input Source",
14596 .count = 1,
Herton Ronaldo Krzesinski6e7939b2007-12-19 17:49:02 +010014597 .info = alc662_mux_enum_info,
14598 .get = alc662_mux_enum_get,
14599 .put = alc662_mux_enum_put,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014600 },
14601 { } /* end */
14602};
14603
14604static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
14605{
14606 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014607 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014608
14609 present = snd_hda_codec_read(codec, 0x14, 0,
14610 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014611 bits = present ? HDA_AMP_MUTE : 0;
14612 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14613 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014614}
14615
14616static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
14617{
14618 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014619 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014620
14621 present = snd_hda_codec_read(codec, 0x1b, 0,
14622 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
Takashi Iwai47fd8302007-08-10 17:11:07 +020014623 bits = present ? HDA_AMP_MUTE : 0;
14624 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14625 HDA_AMP_MUTE, bits);
14626 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14627 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014628}
14629
14630static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
14631 unsigned int res)
14632{
14633 if ((res >> 26) == ALC880_HP_EVENT)
14634 alc662_lenovo_101e_all_automute(codec);
14635 if ((res >> 26) == ALC880_FRONT_EVENT)
14636 alc662_lenovo_101e_ispeaker_automute(codec);
14637}
14638
Kailang Yang291702f2007-10-16 14:28:03 +020014639static void alc662_eeepc_mic_automute(struct hda_codec *codec)
14640{
14641 unsigned int present;
14642
14643 present = snd_hda_codec_read(codec, 0x18, 0,
14644 AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
14645 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14646 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14647 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14648 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
14649 snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14650 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14651 snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
14652 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
14653}
14654
14655/* unsolicited event for HP jack sensing */
14656static void alc662_eeepc_unsol_event(struct hda_codec *codec,
14657 unsigned int res)
14658{
14659 if ((res >> 26) == ALC880_HP_EVENT)
14660 alc262_hippo1_automute( codec );
14661
14662 if ((res >> 26) == ALC880_MIC_EVENT)
14663 alc662_eeepc_mic_automute(codec);
14664}
14665
14666static void alc662_eeepc_inithook(struct hda_codec *codec)
14667{
14668 alc262_hippo1_automute( codec );
14669 alc662_eeepc_mic_automute(codec);
14670}
14671
Kailang Yang8c427222008-01-10 13:03:59 +010014672static void alc662_eeepc_ep20_automute(struct hda_codec *codec)
14673{
14674 unsigned int mute;
14675 unsigned int present;
14676
14677 snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
14678 present = snd_hda_codec_read(codec, 0x14, 0,
14679 AC_VERB_GET_PIN_SENSE, 0);
14680 present = (present & 0x80000000) != 0;
14681 if (present) {
14682 /* mute internal speaker */
14683 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014684 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yang8c427222008-01-10 13:03:59 +010014685 } else {
14686 /* unmute internal speaker if necessary */
14687 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
14688 snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014689 HDA_AMP_MUTE, mute);
Kailang Yang8c427222008-01-10 13:03:59 +010014690 }
14691}
14692
14693/* unsolicited event for HP jack sensing */
14694static void alc662_eeepc_ep20_unsol_event(struct hda_codec *codec,
14695 unsigned int res)
14696{
14697 if ((res >> 26) == ALC880_HP_EVENT)
14698 alc662_eeepc_ep20_automute(codec);
14699}
14700
14701static void alc662_eeepc_ep20_inithook(struct hda_codec *codec)
14702{
14703 alc662_eeepc_ep20_automute(codec);
14704}
14705
Kailang Yang6dda9f42008-05-27 12:05:31 +020014706static void alc663_m51va_speaker_automute(struct hda_codec *codec)
14707{
14708 unsigned int present;
14709 unsigned char bits;
14710
14711 present = snd_hda_codec_read(codec, 0x21, 0,
14712 AC_VERB_GET_PIN_SENSE, 0)
14713 & AC_PINSENSE_PRESENCE;
14714 bits = present ? HDA_AMP_MUTE : 0;
14715 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14716 HDA_AMP_MUTE, bits);
14717}
14718
14719static void alc663_m51va_mic_automute(struct hda_codec *codec)
14720{
14721 unsigned int present;
14722
14723 present = snd_hda_codec_read(codec, 0x18, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +020014724 AC_VERB_GET_PIN_SENSE, 0)
14725 & AC_PINSENSE_PRESENCE;
Kailang Yang6dda9f42008-05-27 12:05:31 +020014726 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014727 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014728 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014729 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014730 snd_hda_codec_write_cache(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014731 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014732 snd_hda_codec_write_cache(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangea1fb292008-08-26 12:58:38 +020014733 0x7000 | (0x09 << 8) | (present ? 0x80 : 0));
Kailang Yang6dda9f42008-05-27 12:05:31 +020014734}
14735
14736static void alc663_m51va_unsol_event(struct hda_codec *codec,
14737 unsigned int res)
14738{
14739 switch (res >> 26) {
14740 case ALC880_HP_EVENT:
14741 alc663_m51va_speaker_automute(codec);
14742 break;
14743 case ALC880_MIC_EVENT:
14744 alc663_m51va_mic_automute(codec);
14745 break;
14746 }
14747}
14748
14749static void alc663_m51va_inithook(struct hda_codec *codec)
14750{
14751 alc663_m51va_speaker_automute(codec);
14752 alc663_m51va_mic_automute(codec);
14753}
14754
14755static void alc663_g71v_hp_automute(struct hda_codec *codec)
14756{
14757 unsigned int present;
14758 unsigned char bits;
14759
14760 present = snd_hda_codec_read(codec, 0x21, 0,
14761 AC_VERB_GET_PIN_SENSE, 0)
14762 & AC_PINSENSE_PRESENCE;
14763 bits = present ? HDA_AMP_MUTE : 0;
14764 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
14765 HDA_AMP_MUTE, bits);
14766 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14767 HDA_AMP_MUTE, bits);
14768}
14769
14770static void alc663_g71v_front_automute(struct hda_codec *codec)
14771{
14772 unsigned int present;
14773 unsigned char bits;
14774
14775 present = snd_hda_codec_read(codec, 0x15, 0,
14776 AC_VERB_GET_PIN_SENSE, 0)
14777 & AC_PINSENSE_PRESENCE;
14778 bits = present ? HDA_AMP_MUTE : 0;
14779 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
14780 HDA_AMP_MUTE, bits);
14781}
14782
14783static void alc663_g71v_unsol_event(struct hda_codec *codec,
14784 unsigned int res)
14785{
14786 switch (res >> 26) {
14787 case ALC880_HP_EVENT:
14788 alc663_g71v_hp_automute(codec);
14789 break;
14790 case ALC880_FRONT_EVENT:
14791 alc663_g71v_front_automute(codec);
14792 break;
14793 case ALC880_MIC_EVENT:
14794 alc662_eeepc_mic_automute(codec);
14795 break;
14796 }
14797}
14798
14799static void alc663_g71v_inithook(struct hda_codec *codec)
14800{
14801 alc663_g71v_front_automute(codec);
14802 alc663_g71v_hp_automute(codec);
14803 alc662_eeepc_mic_automute(codec);
14804}
14805
14806static void alc663_g50v_unsol_event(struct hda_codec *codec,
14807 unsigned int res)
14808{
14809 switch (res >> 26) {
14810 case ALC880_HP_EVENT:
14811 alc663_m51va_speaker_automute(codec);
14812 break;
14813 case ALC880_MIC_EVENT:
14814 alc662_eeepc_mic_automute(codec);
14815 break;
14816 }
14817}
14818
14819static void alc663_g50v_inithook(struct hda_codec *codec)
14820{
14821 alc663_m51va_speaker_automute(codec);
14822 alc662_eeepc_mic_automute(codec);
14823}
14824
Takashi Iwaicb53c622007-08-10 17:21:45 +020014825#ifdef CONFIG_SND_HDA_POWER_SAVE
14826#define alc662_loopbacks alc880_loopbacks
14827#endif
14828
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014829
14830/* pcm configuration: identiacal with ALC880 */
14831#define alc662_pcm_analog_playback alc880_pcm_analog_playback
14832#define alc662_pcm_analog_capture alc880_pcm_analog_capture
14833#define alc662_pcm_digital_playback alc880_pcm_digital_playback
14834#define alc662_pcm_digital_capture alc880_pcm_digital_capture
14835
14836/*
14837 * configuration and preset
14838 */
14839static const char *alc662_models[ALC662_MODEL_LAST] = {
14840 [ALC662_3ST_2ch_DIG] = "3stack-dig",
14841 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
14842 [ALC662_3ST_6ch] = "3stack-6ch",
14843 [ALC662_5ST_DIG] = "6stack-dig",
14844 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020014845 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010014846 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yang6dda9f42008-05-27 12:05:31 +020014847 [ALC663_ASUS_M51VA] = "m51va",
14848 [ALC663_ASUS_G71V] = "g71v",
14849 [ALC663_ASUS_H13] = "h13",
14850 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014851 [ALC662_AUTO] = "auto",
14852};
14853
14854static struct snd_pci_quirk alc662_cfg_tbl[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020014855 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS G71V", ALC663_ASUS_G71V),
14856 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
14857 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS M51VA", ALC663_ASUS_G50V),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010014858 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020014859 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010014860 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010014861 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Kailang Yang6dda9f42008-05-27 12:05:31 +020014862 SND_PCI_QUIRK(0x1854, 0x2000, "ASUS H13-2000", ALC663_ASUS_H13),
14863 SND_PCI_QUIRK(0x1854, 0x2001, "ASUS H13-2001", ALC663_ASUS_H13),
14864 SND_PCI_QUIRK(0x1854, 0x2002, "ASUS H13-2002", ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014865 {}
14866};
14867
14868static struct alc_config_preset alc662_presets[] = {
14869 [ALC662_3ST_2ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014870 .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014871 .init_verbs = { alc662_init_verbs },
14872 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14873 .dac_nids = alc662_dac_nids,
14874 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014875 .dig_in_nid = ALC662_DIGIN_NID,
14876 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14877 .channel_mode = alc662_3ST_2ch_modes,
14878 .input_mux = &alc662_capture_source,
14879 },
14880 [ALC662_3ST_6ch_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014881 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14882 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014883 .init_verbs = { alc662_init_verbs },
14884 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14885 .dac_nids = alc662_dac_nids,
14886 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014887 .dig_in_nid = ALC662_DIGIN_NID,
14888 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14889 .channel_mode = alc662_3ST_6ch_modes,
14890 .need_dac_fix = 1,
14891 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014892 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014893 [ALC662_3ST_6ch] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014894 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
14895 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014896 .init_verbs = { alc662_init_verbs },
14897 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14898 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014899 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14900 .channel_mode = alc662_3ST_6ch_modes,
14901 .need_dac_fix = 1,
14902 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020014903 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014904 [ALC662_5ST_DIG] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014905 .mixers = { alc662_base_mixer, alc662_chmode_mixer,
14906 alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014907 .init_verbs = { alc662_init_verbs },
14908 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14909 .dac_nids = alc662_dac_nids,
14910 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014911 .dig_in_nid = ALC662_DIGIN_NID,
14912 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
14913 .channel_mode = alc662_5stack_modes,
14914 .input_mux = &alc662_capture_source,
14915 },
14916 [ALC662_LENOVO_101E] = {
Kailang Yang291702f2007-10-16 14:28:03 +020014917 .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014918 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
14919 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14920 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014921 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14922 .channel_mode = alc662_3ST_2ch_modes,
14923 .input_mux = &alc662_lenovo_101e_capture_source,
14924 .unsol_event = alc662_lenovo_101e_unsol_event,
14925 .init_hook = alc662_lenovo_101e_all_automute,
14926 },
Kailang Yang291702f2007-10-16 14:28:03 +020014927 [ALC662_ASUS_EEEPC_P701] = {
14928 .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
14929 .init_verbs = { alc662_init_verbs,
14930 alc662_eeepc_sue_init_verbs },
14931 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14932 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020014933 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14934 .channel_mode = alc662_3ST_2ch_modes,
14935 .input_mux = &alc662_eeepc_capture_source,
14936 .unsol_event = alc662_eeepc_unsol_event,
14937 .init_hook = alc662_eeepc_inithook,
14938 },
Kailang Yang8c427222008-01-10 13:03:59 +010014939 [ALC662_ASUS_EEEPC_EP20] = {
14940 .mixers = { alc662_eeepc_ep20_mixer, alc662_capture_mixer,
14941 alc662_chmode_mixer },
14942 .init_verbs = { alc662_init_verbs,
14943 alc662_eeepc_ep20_sue_init_verbs },
14944 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14945 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010014946 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14947 .channel_mode = alc662_3ST_6ch_modes,
14948 .input_mux = &alc662_lenovo_101e_capture_source,
14949 .unsol_event = alc662_eeepc_ep20_unsol_event,
14950 .init_hook = alc662_eeepc_ep20_inithook,
14951 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020014952 [ALC663_ASUS_M51VA] = {
14953 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14954 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14955 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14956 .dac_nids = alc662_dac_nids,
14957 .dig_out_nid = ALC662_DIGOUT_NID,
14958 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14959 .channel_mode = alc662_3ST_2ch_modes,
14960 .input_mux = &alc663_m51va_capture_source,
14961 .unsol_event = alc663_m51va_unsol_event,
14962 .init_hook = alc663_m51va_inithook,
14963 },
14964 [ALC663_ASUS_G71V] = {
14965 .mixers = { alc663_g71v_mixer, alc662_capture_mixer},
14966 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
14967 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14968 .dac_nids = alc662_dac_nids,
14969 .dig_out_nid = ALC662_DIGOUT_NID,
14970 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14971 .channel_mode = alc662_3ST_2ch_modes,
14972 .input_mux = &alc662_eeepc_capture_source,
14973 .unsol_event = alc663_g71v_unsol_event,
14974 .init_hook = alc663_g71v_inithook,
14975 },
14976 [ALC663_ASUS_H13] = {
14977 .mixers = { alc663_m51va_mixer, alc662_capture_mixer},
14978 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
14979 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14980 .dac_nids = alc662_dac_nids,
14981 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
14982 .channel_mode = alc662_3ST_2ch_modes,
14983 .input_mux = &alc663_m51va_capture_source,
14984 .unsol_event = alc663_m51va_unsol_event,
14985 .init_hook = alc663_m51va_inithook,
14986 },
14987 [ALC663_ASUS_G50V] = {
14988 .mixers = { alc663_g50v_mixer, alc662_capture_mixer},
14989 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
14990 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
14991 .dac_nids = alc662_dac_nids,
14992 .dig_out_nid = ALC662_DIGOUT_NID,
14993 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
14994 .channel_mode = alc662_3ST_6ch_modes,
14995 .input_mux = &alc663_capture_source,
14996 .unsol_event = alc663_g50v_unsol_event,
14997 .init_hook = alc663_g50v_inithook,
14998 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020014999};
15000
15001
15002/*
15003 * BIOS auto configuration
15004 */
15005
15006/* add playback controls from the parsed DAC table */
15007static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
15008 const struct auto_pin_cfg *cfg)
15009{
15010 char name[32];
15011 static const char *chname[4] = {
15012 "Front", "Surround", NULL /*CLFE*/, "Side"
15013 };
15014 hda_nid_t nid;
15015 int i, err;
15016
15017 for (i = 0; i < cfg->line_outs; i++) {
15018 if (!spec->multiout.dac_nids[i])
15019 continue;
Kailang Yangb60dd392007-09-20 12:50:29 +020015020 nid = alc880_idx_to_dac(i);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015021 if (i == 2) {
15022 /* Center/LFE */
15023 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15024 "Center Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015025 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
15026 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015027 if (err < 0)
15028 return err;
15029 err = add_control(spec, ALC_CTL_WIDGET_VOL,
15030 "LFE Playback Volume",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015031 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
15032 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015033 if (err < 0)
15034 return err;
15035 err = add_control(spec, ALC_CTL_BIND_MUTE,
15036 "Center Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015037 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
15038 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015039 if (err < 0)
15040 return err;
15041 err = add_control(spec, ALC_CTL_BIND_MUTE,
15042 "LFE Playback Switch",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015043 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
15044 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015045 if (err < 0)
15046 return err;
15047 } else {
15048 sprintf(name, "%s Playback Volume", chname[i]);
15049 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015050 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
15051 HDA_OUTPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015052 if (err < 0)
15053 return err;
15054 sprintf(name, "%s Playback Switch", chname[i]);
15055 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015056 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
15057 HDA_INPUT));
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015058 if (err < 0)
15059 return err;
15060 }
15061 }
15062 return 0;
15063}
15064
15065/* add playback controls for speaker and HP outputs */
15066static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
15067 const char *pfx)
15068{
15069 hda_nid_t nid;
15070 int err;
15071 char name[32];
15072
15073 if (!pin)
15074 return 0;
15075
Takashi Iwai24fb9172008-09-02 14:48:20 +020015076 if (pin == 0x17) {
15077 /* ALC663 has a mono output pin on 0x17 */
15078 sprintf(name, "%s Playback Switch", pfx);
15079 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15080 HDA_COMPOSE_AMP_VAL(pin, 2, 0, HDA_OUTPUT));
15081 return err;
15082 }
15083
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015084 if (alc880_is_fixed_pin(pin)) {
15085 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15086 /* printk("DAC nid=%x\n",nid); */
15087 /* specify the DAC as the extra output */
15088 if (!spec->multiout.hp_nid)
15089 spec->multiout.hp_nid = nid;
15090 else
15091 spec->multiout.extra_out_nid[0] = nid;
15092 /* control HP volume/switch on the output mixer amp */
15093 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
15094 sprintf(name, "%s Playback Volume", pfx);
15095 err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
15096 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
15097 if (err < 0)
15098 return err;
15099 sprintf(name, "%s Playback Switch", pfx);
15100 err = add_control(spec, ALC_CTL_BIND_MUTE, name,
15101 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
15102 if (err < 0)
15103 return err;
15104 } else if (alc880_is_multi_pin(pin)) {
15105 /* set manual connection */
15106 /* we have only a switch on HP-out PIN */
15107 sprintf(name, "%s Playback Switch", pfx);
15108 err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
15109 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
15110 if (err < 0)
15111 return err;
15112 }
15113 return 0;
15114}
15115
15116/* create playback/capture controls for input pins */
15117static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
15118 const struct auto_pin_cfg *cfg)
15119{
15120 struct hda_input_mux *imux = &spec->private_imux;
15121 int i, err, idx;
15122
15123 for (i = 0; i < AUTO_PIN_LAST; i++) {
15124 if (alc880_is_input_pin(cfg->input_pins[i])) {
15125 idx = alc880_input_pin_idx(cfg->input_pins[i]);
15126 err = new_analog_input(spec, cfg->input_pins[i],
15127 auto_pin_cfg_labels[i],
15128 idx, 0x0b);
15129 if (err < 0)
15130 return err;
15131 imux->items[imux->num_items].label =
15132 auto_pin_cfg_labels[i];
15133 imux->items[imux->num_items].index =
15134 alc880_input_pin_idx(cfg->input_pins[i]);
15135 imux->num_items++;
15136 }
15137 }
15138 return 0;
15139}
15140
15141static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
15142 hda_nid_t nid, int pin_type,
15143 int dac_idx)
15144{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015145 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015146 /* need the manual connection? */
15147 if (alc880_is_multi_pin(nid)) {
15148 struct alc_spec *spec = codec->spec;
15149 int idx = alc880_multi_pin_idx(nid);
15150 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
15151 AC_VERB_SET_CONNECT_SEL,
15152 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
15153 }
15154}
15155
15156static void alc662_auto_init_multi_out(struct hda_codec *codec)
15157{
15158 struct alc_spec *spec = codec->spec;
15159 int i;
15160
Kailang Yang8c427222008-01-10 13:03:59 +010015161 alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015162 for (i = 0; i <= HDA_SIDE; i++) {
15163 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015164 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015165 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015166 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015167 i);
15168 }
15169}
15170
15171static void alc662_auto_init_hp_out(struct hda_codec *codec)
15172{
15173 struct alc_spec *spec = codec->spec;
15174 hda_nid_t pin;
15175
15176 pin = spec->autocfg.hp_pins[0];
15177 if (pin) /* connect to front */
15178 /* use dac 0 */
15179 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015180 pin = spec->autocfg.speaker_pins[0];
15181 if (pin)
15182 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015183}
15184
15185#define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
15186#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
15187
15188static void alc662_auto_init_analog_input(struct hda_codec *codec)
15189{
15190 struct alc_spec *spec = codec->spec;
15191 int i;
15192
15193 for (i = 0; i < AUTO_PIN_LAST; i++) {
15194 hda_nid_t nid = spec->autocfg.input_pins[i];
15195 if (alc662_is_input_pin(nid)) {
15196 snd_hda_codec_write(codec, nid, 0,
15197 AC_VERB_SET_PIN_WIDGET_CONTROL,
15198 (i <= AUTO_PIN_FRONT_MIC ?
15199 PIN_VREF80 : PIN_IN));
15200 if (nid != ALC662_PIN_CD_NID)
15201 snd_hda_codec_write(codec, nid, 0,
15202 AC_VERB_SET_AMP_GAIN_MUTE,
15203 AMP_OUT_MUTE);
15204 }
15205 }
15206}
15207
Takashi Iwaif511b012008-08-15 16:46:42 +020015208#define alc662_auto_init_input_src alc882_auto_init_input_src
15209
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015210static int alc662_parse_auto_config(struct hda_codec *codec)
15211{
15212 struct alc_spec *spec = codec->spec;
15213 int err;
15214 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
15215
15216 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15217 alc662_ignore);
15218 if (err < 0)
15219 return err;
15220 if (!spec->autocfg.line_outs)
15221 return 0; /* can't find valid BIOS pin config */
15222
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015223 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
15224 if (err < 0)
15225 return err;
15226 err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
15227 if (err < 0)
15228 return err;
15229 err = alc662_auto_create_extra_out(spec,
15230 spec->autocfg.speaker_pins[0],
15231 "Speaker");
15232 if (err < 0)
15233 return err;
15234 err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
15235 "Headphone");
15236 if (err < 0)
15237 return err;
15238 err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
15239 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015240 return err;
15241
15242 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15243
15244 if (spec->autocfg.dig_out_pin)
15245 spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
15246
15247 if (spec->kctl_alloc)
15248 spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
15249
15250 spec->num_mux_defs = 1;
15251 spec->input_mux = &spec->private_imux;
Kailang Yangea1fb292008-08-26 12:58:38 +020015252
Takashi Iwai8c87286f2007-06-19 12:11:16 +020015253 spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
Takashi Iwai24fb9172008-09-02 14:48:20 +020015254 if (codec->vendor_id == 0x10ec0663)
15255 spec->init_verbs[spec->num_init_verbs++] =
15256 alc663_auto_init_verbs;
Takashi Iwaiee979a142008-09-02 15:42:20 +020015257
15258 err = alc_auto_add_mic_boost(codec);
15259 if (err < 0)
15260 return err;
15261
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015262 spec->mixers[spec->num_mixers] = alc662_capture_mixer;
15263 spec->num_mixers++;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020015264 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015265}
15266
15267/* additional initialization for auto-configuration model */
15268static void alc662_auto_init(struct hda_codec *codec)
15269{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015270 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015271 alc662_auto_init_multi_out(codec);
15272 alc662_auto_init_hp_out(codec);
15273 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020015274 alc662_auto_init_input_src(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015275 if (spec->unsol_event)
15276 alc_sku_automute(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015277}
15278
15279static int patch_alc662(struct hda_codec *codec)
15280{
15281 struct alc_spec *spec;
15282 int err, board_config;
15283
15284 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15285 if (!spec)
15286 return -ENOMEM;
15287
15288 codec->spec = spec;
15289
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020015290 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15291
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015292 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
15293 alc662_models,
15294 alc662_cfg_tbl);
15295 if (board_config < 0) {
15296 printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
15297 "trying auto-probe from BIOS...\n");
15298 board_config = ALC662_AUTO;
15299 }
15300
15301 if (board_config == ALC662_AUTO) {
15302 /* automatic parse from the BIOS config */
15303 err = alc662_parse_auto_config(codec);
15304 if (err < 0) {
15305 alc_free(codec);
15306 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020015307 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015308 printk(KERN_INFO
15309 "hda_codec: Cannot set up configuration "
15310 "from BIOS. Using base mode...\n");
15311 board_config = ALC662_3ST_2ch_DIG;
15312 }
15313 }
15314
15315 if (board_config != ALC662_AUTO)
15316 setup_preset(spec, &alc662_presets[board_config]);
15317
Kailang Yang6dda9f42008-05-27 12:05:31 +020015318 if (codec->vendor_id == 0x10ec0663) {
15319 spec->stream_name_analog = "ALC663 Analog";
15320 spec->stream_name_digital = "ALC663 Digital";
15321 } else {
15322 spec->stream_name_analog = "ALC662 Analog";
15323 spec->stream_name_digital = "ALC662 Digital";
15324 }
15325
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015326 spec->stream_analog_playback = &alc662_pcm_analog_playback;
15327 spec->stream_analog_capture = &alc662_pcm_analog_capture;
15328
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015329 spec->stream_digital_playback = &alc662_pcm_digital_playback;
15330 spec->stream_digital_capture = &alc662_pcm_digital_capture;
15331
Takashi Iwaie1406342008-02-11 18:32:32 +010015332 spec->adc_nids = alc662_adc_nids;
15333 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
15334 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015335
Takashi Iwai2134ea42008-01-10 16:53:55 +010015336 spec->vmaster_nid = 0x02;
15337
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015338 codec->patch_ops = alc_patch_ops;
15339 if (board_config == ALC662_AUTO)
15340 spec->init_hook = alc662_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020015341#ifdef CONFIG_SND_HDA_POWER_SAVE
15342 if (!spec->loopback.amplist)
15343 spec->loopback.amplist = alc662_loopbacks;
15344#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015345
15346 return 0;
15347}
15348
15349/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070015350 * patch entries
15351 */
15352struct hda_codec_preset snd_hda_preset_realtek[] = {
15353 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015354 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015355 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020015356 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015357 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015358 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015359 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015360 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
15361 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
15362 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020015363 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
15364 .patch = patch_alc883 },
15365 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
15366 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020015367 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010015368 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070015369 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015370 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020015371 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai7943a8a2008-04-16 17:29:09 +020015372 .patch = patch_alc882 }, /* should be patch_alc883() in future */
Kailang Yangdf694da2005-12-05 19:42:22 +010015373 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015374 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015375 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070015376 {} /* terminator */
15377};