blob: bb3cf3b7282b1dc065f12c53ad8f79e4a4103117 [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>
Kailang Yang9ad0e492010-09-14 23:22:00 +020031#include <sound/jack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "hda_codec.h"
33#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090034#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Kailang Yangccc656c2006-10-17 12:32:26 +020036#define ALC880_FRONT_EVENT 0x01
37#define ALC880_DCVOL_EVENT 0x02
38#define ALC880_HP_EVENT 0x04
39#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/* ALC880 board config type */
42enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 ALC880_3ST,
44 ALC880_3ST_DIG,
45 ALC880_5ST,
46 ALC880_5ST_DIG,
47 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020048 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020049 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020050 ALC880_6ST_DIG,
51 ALC880_F1734,
52 ALC880_ASUS,
53 ALC880_ASUS_DIG,
54 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010055 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010056 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020057 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020058 ALC880_UNIWILL,
59 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010060 ALC880_CLEVO,
61 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010062 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010063 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020064 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020065#ifdef CONFIG_SND_DEBUG
66 ALC880_TEST,
67#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010068 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020069 ALC880_MODEL_LAST /* last tag */
70};
71
72/* ALC260 models */
73enum {
74 ALC260_BASIC,
75 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020076 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010077 ALC260_HP_3013,
78 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010079 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020080 ALC260_WILL,
81 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010082 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010083#ifdef CONFIG_SND_DEBUG
84 ALC260_TEST,
85#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010086 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020087 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
Kailang Yangdf694da2005-12-05 19:42:22 +010090/* ALC262 models */
91enum {
92 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020093 ALC262_HIPPO,
94 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010095 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020096 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010097 ALC262_HP_BPC_D7000_WL,
98 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010099 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +0100100 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200101 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200102 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200103 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200104 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100105 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200106 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200107 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200108 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000109 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100110 ALC262_AUTO,
111 ALC262_MODEL_LAST /* last tag */
112};
113
Kailang Yanga361d842007-06-05 12:30:55 +0200114/* ALC268 models */
115enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200116 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200117 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200118 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200119 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100120 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200121 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100122 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100123 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100124#ifdef CONFIG_SND_DEBUG
125 ALC268_TEST,
126#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200127 ALC268_AUTO,
128 ALC268_MODEL_LAST /* last tag */
129};
130
Kailang Yangf6a92242007-12-13 16:52:54 +0100131/* ALC269 models */
132enum {
133 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200134 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100135 ALC269_AMIC,
136 ALC269_DMIC,
137 ALC269VB_AMIC,
138 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100139 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000140 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200141 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100142 ALC269_AUTO,
143 ALC269_MODEL_LAST /* last tag */
144};
145
Kailang Yangdf694da2005-12-05 19:42:22 +0100146/* ALC861 models */
147enum {
148 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200149 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_3ST_DIG,
151 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200152 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200153 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200154 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100155 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100156 ALC861_AUTO,
157 ALC861_MODEL_LAST,
158};
159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160/* ALC861-VD models */
161enum {
162 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200163 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100164 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_3ST,
166 ALC861VD_3ST_DIG,
167 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200168 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200170 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100171 ALC861VD_AUTO,
172 ALC861VD_MODEL_LAST,
173};
174
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200175/* ALC662 models */
176enum {
177 ALC662_3ST_2ch_DIG,
178 ALC662_3ST_6ch_DIG,
179 ALC662_3ST_6ch,
180 ALC662_5ST_DIG,
181 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200182 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100183 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200184 ALC663_ASUS_M51VA,
185 ALC663_ASUS_G71V,
186 ALC663_ASUS_H13,
187 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200188 ALC662_ECS,
189 ALC663_ASUS_MODE1,
190 ALC662_ASUS_MODE2,
191 ALC663_ASUS_MODE3,
192 ALC663_ASUS_MODE4,
193 ALC663_ASUS_MODE5,
194 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100195 ALC663_ASUS_MODE7,
196 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200197 ALC272_DELL,
198 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200199 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200200 ALC662_AUTO,
201 ALC662_MODEL_LAST,
202};
203
Kailang Yangdf694da2005-12-05 19:42:22 +0100204/* ALC882 models */
205enum {
206 ALC882_3ST_DIG,
207 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200208 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200209 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC882_TARGA,
211 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200212 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100213 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800214 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200215 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200216 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100217 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200218 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800219 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220 ALC883_3ST_2ch_DIG,
221 ALC883_3ST_6ch_DIG,
222 ALC883_3ST_6ch,
223 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200224 ALC883_TARGA_DIG,
225 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200226 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200234 ALC883_MEDION_MD2,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200235 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100236 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200237 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200238 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200239 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200240 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200241 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200242 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100243 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100244 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430245 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100246 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100247 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800248 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200249 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200250 ALC889A_INTEL,
251 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200252 ALC888_ASUS_M90V,
253 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200254 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100255 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200256 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200257 ALC882_AUTO,
258 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200259};
260
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200261/* ALC680 models */
262enum {
263 ALC680_BASE,
264 ALC680_AUTO,
265 ALC680_MODEL_LAST,
266};
267
Kailang Yangdf694da2005-12-05 19:42:22 +0100268/* for GPIO Poll */
269#define GPIO_MASK 0x03
270
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200271/* extra amp-initialization sequence types */
272enum {
273 ALC_INIT_NONE,
274 ALC_INIT_DEFAULT,
275 ALC_INIT_GPIO1,
276 ALC_INIT_GPIO2,
277 ALC_INIT_GPIO3,
278};
279
Takashi Iwai6c819492009-08-10 18:47:44 +0200280struct alc_mic_route {
281 hda_nid_t pin;
282 unsigned char mux_idx;
283 unsigned char amix_idx;
284};
285
Kailang Yang9ad0e492010-09-14 23:22:00 +0200286struct alc_jack {
287 hda_nid_t nid;
288 int type;
289 struct snd_jack *jack;
290};
291
Takashi Iwai6c819492009-08-10 18:47:44 +0200292#define MUX_IDX_UNDEF ((unsigned char)-1)
293
Kailang Yangda00c242010-03-19 11:23:45 +0100294struct alc_customize_define {
295 unsigned int sku_cfg;
296 unsigned char port_connectivity;
297 unsigned char check_sum;
298 unsigned char customization;
299 unsigned char external_amp;
300 unsigned int enable_pcbeep:1;
301 unsigned int platform_type:1;
302 unsigned int swap:1;
303 unsigned int override:1;
304};
305
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306struct alc_spec {
307 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100308 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100310 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100311 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200313 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200314 * don't forget NULL
315 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200316 */
317 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200319 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 struct hda_pcm_stream *stream_analog_playback;
321 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100322 struct hda_pcm_stream *stream_analog_alt_playback;
323 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200325 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 struct hda_pcm_stream *stream_digital_playback;
327 struct hda_pcm_stream *stream_digital_capture;
328
329 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200330 struct hda_multi_out multiout; /* playback set-up
331 * max_channels, dacs must be set
332 * dig_out_nid and hp_nid are optional
333 */
Takashi Iwai63300792008-01-24 15:31:36 +0100334 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100335 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100336 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337
338 /* capture */
339 unsigned int num_adc_nids;
340 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100341 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200342 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Takashi Iwai840b64c2010-07-13 22:49:01 +0200344 /* capture setup for dynamic dual-adc switch */
345 unsigned int cur_adc_idx;
346 hda_nid_t cur_adc;
347 unsigned int cur_adc_stream_tag;
348 unsigned int cur_adc_format;
349
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200351 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 const struct hda_input_mux *input_mux;
353 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200354 struct alc_mic_route ext_mic;
355 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
357 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100358 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200360 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200361 int const_channel_count;
362 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363
364 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100365 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200366
Kailang Yang9ad0e492010-09-14 23:22:00 +0200367 /* jack detection */
368 struct snd_array jacks;
369
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200370 /* dynamic controls, init_verbs and input_mux */
371 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100372 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200373 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200374 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200375 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200376 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
377 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100378
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100379 /* hooks */
380 void (*init_hook)(struct hda_codec *codec);
381 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100382#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500383 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100384#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100385
Takashi Iwai834be882006-03-01 14:16:17 +0100386 /* for pin sensing */
387 unsigned int sense_updated: 1;
388 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100389 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200390 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200391
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100392 /* other flags */
393 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200394 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200395 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100396
Takashi Iwai2134ea42008-01-10 16:53:55 +0100397 /* for virtual master */
398 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200399#ifdef CONFIG_SND_HDA_POWER_SAVE
400 struct hda_loopback_check loopback;
401#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200402
403 /* for PLL fix */
404 hda_nid_t pll_nid;
405 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100406};
407
408/*
409 * configuration template - to be copied to the spec instance
410 */
411struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200412 struct snd_kcontrol_new *mixers[5]; /* should be identical size
413 * with spec
414 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100415 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100416 const struct hda_verb *init_verbs[5];
417 unsigned int num_dacs;
418 hda_nid_t *dac_nids;
419 hda_nid_t dig_out_nid; /* optional */
420 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800421 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100422 unsigned int num_adc_nids;
423 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100424 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100425 hda_nid_t dig_in_nid;
426 unsigned int num_channel_mode;
427 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200428 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200429 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200430 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100431 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100432 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200433 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100434 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200435#ifdef CONFIG_SND_HDA_POWER_SAVE
436 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500437 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200438#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439};
440
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
442/*
443 * input MUX handling
444 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200445static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447{
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200450 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
451 if (mux_idx >= spec->num_mux_defs)
452 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100453 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
454 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200455 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456}
457
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
463 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
464
465 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
466 return 0;
467}
468
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200469static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
470 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471{
472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100474 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100476 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100477 hda_nid_t nid = spec->capsrc_nids ?
478 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200479 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480
Takashi Iwaicd896c32008-11-18 12:36:33 +0100481 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
482 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100483 if (!imux->num_items && mux_idx > 0)
484 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100485
Takashi Iwaia22d5432009-07-27 12:54:26 +0200486 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200487 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100488 /* Matrix-mixer style (e.g. ALC882) */
489 unsigned int *cur_val = &spec->cur_mux[adc_idx];
490 unsigned int i, idx;
491
492 idx = ucontrol->value.enumerated.item[0];
493 if (idx >= imux->num_items)
494 idx = imux->num_items - 1;
495 if (*cur_val == idx)
496 return 0;
497 for (i = 0; i < imux->num_items; i++) {
498 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
499 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
500 imux->items[i].index,
501 HDA_AMP_MUTE, v);
502 }
503 *cur_val = idx;
504 return 1;
505 } else {
506 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100507 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100508 &spec->cur_mux[adc_idx]);
509 }
510}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200511
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512/*
513 * channel mode setting
514 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200515static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517{
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100520 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
521 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522}
523
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200524static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526{
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100529 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200531 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532}
533
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200534static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
535 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536{
537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
538 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200539 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
540 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200541 &spec->ext_channel_count);
542 if (err >= 0 && !spec->const_channel_count) {
543 spec->multiout.max_channels = spec->ext_channel_count;
544 if (spec->need_dac_fix)
545 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
546 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200547 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548}
549
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100551 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200552 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553 * being part of a format specifier. Maximum allowed length of a value is
554 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100555 *
556 * Note: some retasking pin complexes seem to ignore requests for input
557 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
558 * are requested. Therefore order this list so that this behaviour will not
559 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200560 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
561 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200562 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100564 "Mic 50pc bias", "Mic 80pc bias",
565 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566};
567static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100568 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100569};
570/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200571 * in the pin being assumed to be exclusively an input or an output pin. In
572 * addition, "input" pins may or may not process the mic bias option
573 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
574 * accept requests for bias as of chip versions up to March 2006) and/or
575 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200577#define ALC_PIN_DIR_IN 0x00
578#define ALC_PIN_DIR_OUT 0x01
579#define ALC_PIN_DIR_INOUT 0x02
580#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
581#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582
Kailang Yangea1fb292008-08-26 12:58:38 +0200583/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100584 * For each direction the minimum and maximum values are given.
585 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200586static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100587 { 0, 2 }, /* ALC_PIN_DIR_IN */
588 { 3, 4 }, /* ALC_PIN_DIR_OUT */
589 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200590 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
591 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592};
593#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
594#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
595#define alc_pin_mode_n_items(_dir) \
596 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
597
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200598static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
599 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200600{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100601 unsigned int item_num = uinfo->value.enumerated.item;
602 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
603
604 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200605 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100606 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
607
608 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
609 item_num = alc_pin_mode_min(dir);
610 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200611 return 0;
612}
613
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200614static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200616{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100617 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
619 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100620 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200621 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200622 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
623 AC_VERB_GET_PIN_WIDGET_CONTROL,
624 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200625
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100626 /* Find enumerated value for current pinctl setting */
627 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200628 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100629 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200630 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100631 return 0;
632}
633
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200634static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
635 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100636{
637 signed int change;
638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
639 hda_nid_t nid = kcontrol->private_value & 0xffff;
640 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
641 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200642 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
643 AC_VERB_GET_PIN_WIDGET_CONTROL,
644 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100645
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200646 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100647 val = alc_pin_mode_min(dir);
648
649 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100650 if (change) {
651 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200652 snd_hda_codec_write_cache(codec, nid, 0,
653 AC_VERB_SET_PIN_WIDGET_CONTROL,
654 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100655
Kailang Yangea1fb292008-08-26 12:58:38 +0200656 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100657 * for the requested pin mode. Enum values of 2 or less are
658 * input modes.
659 *
660 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200661 * reduces noise slightly (particularly on input) so we'll
662 * do it. However, having both input and output buffers
663 * enabled simultaneously doesn't seem to be problematic if
664 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100665 */
666 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200667 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
668 HDA_AMP_MUTE, HDA_AMP_MUTE);
669 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
670 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100671 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200672 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
673 HDA_AMP_MUTE, HDA_AMP_MUTE);
674 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
675 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100676 }
677 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200678 return change;
679}
680
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100681#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200682 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100683 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100684 .info = alc_pin_mode_info, \
685 .get = alc_pin_mode_get, \
686 .put = alc_pin_mode_put, \
687 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100688
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100689/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
690 * together using a mask with more than one bit set. This control is
691 * currently used only by the ALC260 test model. At this stage they are not
692 * needed for any "production" models.
693 */
694#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200695#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200696
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200697static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
698 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100699{
700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
701 hda_nid_t nid = kcontrol->private_value & 0xffff;
702 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
703 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200704 unsigned int val = snd_hda_codec_read(codec, nid, 0,
705 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100706
707 *valp = (val & mask) != 0;
708 return 0;
709}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200710static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
711 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100712{
713 signed int change;
714 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
715 hda_nid_t nid = kcontrol->private_value & 0xffff;
716 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
717 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200718 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
719 AC_VERB_GET_GPIO_DATA,
720 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100721
722 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200723 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
724 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100725 gpio_data &= ~mask;
726 else
727 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200728 snd_hda_codec_write_cache(codec, nid, 0,
729 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100730
731 return change;
732}
733#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
734 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100735 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100736 .info = alc_gpio_data_info, \
737 .get = alc_gpio_data_get, \
738 .put = alc_gpio_data_put, \
739 .private_value = nid | (mask<<16) }
740#endif /* CONFIG_SND_DEBUG */
741
Jonathan Woithe92621f12006-02-28 11:47:47 +0100742/* A switch control to allow the enabling of the digital IO pins on the
743 * ALC260. This is incredibly simplistic; the intention of this control is
744 * to provide something in the test model allowing digital outputs to be
745 * identified if present. If models are found which can utilise these
746 * outputs a more complete mixer control can be devised for those models if
747 * necessary.
748 */
749#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200750#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200751
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200752static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
753 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100754{
755 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
756 hda_nid_t nid = kcontrol->private_value & 0xffff;
757 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
758 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200759 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100760 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100761
762 *valp = (val & mask) != 0;
763 return 0;
764}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200765static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100767{
768 signed int change;
769 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
770 hda_nid_t nid = kcontrol->private_value & 0xffff;
771 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
772 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200773 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100774 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200775 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100776
777 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200778 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100779 if (val==0)
780 ctrl_data &= ~mask;
781 else
782 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200783 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
784 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100785
786 return change;
787}
788#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
789 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100790 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100791 .info = alc_spdif_ctrl_info, \
792 .get = alc_spdif_ctrl_get, \
793 .put = alc_spdif_ctrl_put, \
794 .private_value = nid | (mask<<16) }
795#endif /* CONFIG_SND_DEBUG */
796
Jonathan Woithef8225f62008-01-08 12:16:54 +0100797/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
798 * Again, this is only used in the ALC26x test models to help identify when
799 * the EAPD line must be asserted for features to work.
800 */
801#ifdef CONFIG_SND_DEBUG
802#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
803
804static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
805 struct snd_ctl_elem_value *ucontrol)
806{
807 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
808 hda_nid_t nid = kcontrol->private_value & 0xffff;
809 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
810 long *valp = ucontrol->value.integer.value;
811 unsigned int val = snd_hda_codec_read(codec, nid, 0,
812 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
813
814 *valp = (val & mask) != 0;
815 return 0;
816}
817
818static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
819 struct snd_ctl_elem_value *ucontrol)
820{
821 int change;
822 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
823 hda_nid_t nid = kcontrol->private_value & 0xffff;
824 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
825 long val = *ucontrol->value.integer.value;
826 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
827 AC_VERB_GET_EAPD_BTLENABLE,
828 0x00);
829
830 /* Set/unset the masked control bit(s) as needed */
831 change = (!val ? 0 : mask) != (ctrl_data & mask);
832 if (!val)
833 ctrl_data &= ~mask;
834 else
835 ctrl_data |= mask;
836 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
837 ctrl_data);
838
839 return change;
840}
841
842#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
843 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100844 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100845 .info = alc_eapd_ctrl_info, \
846 .get = alc_eapd_ctrl_get, \
847 .put = alc_eapd_ctrl_put, \
848 .private_value = nid | (mask<<16) }
849#endif /* CONFIG_SND_DEBUG */
850
Kailang Yangdf694da2005-12-05 19:42:22 +0100851/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100852 * set up the input pin config (depending on the given auto-pin type)
853 */
854static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
855 int auto_pin_type)
856{
857 unsigned int val = PIN_IN;
858
Takashi Iwai86e29592010-09-09 14:50:17 +0200859 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100860 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200861 unsigned int oldval;
862 oldval = snd_hda_codec_read(codec, nid, 0,
863 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100864 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100865 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200866 /* if the default pin setup is vref50, we give it priority */
867 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100868 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200869 else if (pincap & AC_PINCAP_VREF_50)
870 val = PIN_VREF50;
871 else if (pincap & AC_PINCAP_VREF_100)
872 val = PIN_VREF100;
873 else if (pincap & AC_PINCAP_VREF_GRD)
874 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100875 }
876 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
877}
878
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200879static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
880{
881 struct alc_spec *spec = codec->spec;
882 struct auto_pin_cfg *cfg = &spec->autocfg;
883
884 if (!cfg->line_outs) {
885 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
886 cfg->line_out_pins[cfg->line_outs])
887 cfg->line_outs++;
888 }
889 if (!cfg->speaker_outs) {
890 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
891 cfg->speaker_pins[cfg->speaker_outs])
892 cfg->speaker_outs++;
893 }
894 if (!cfg->hp_outs) {
895 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
896 cfg->hp_pins[cfg->hp_outs])
897 cfg->hp_outs++;
898 }
899}
900
Takashi Iwai23f0c042009-02-26 13:03:58 +0100901/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100902 */
903static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
904{
905 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
906 return;
907 spec->mixers[spec->num_mixers++] = mix;
908}
909
910static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
911{
912 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
913 return;
914 spec->init_verbs[spec->num_init_verbs++] = verb;
915}
916
917/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100918 * set up from the preset table
919 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200920static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200921 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100922{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200923 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100924 int i;
925
926 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100927 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100928 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200929 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
930 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100931 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200932
Kailang Yangdf694da2005-12-05 19:42:22 +0100933 spec->channel_mode = preset->channel_mode;
934 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200935 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200936 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100937
Hector Martin3b315d72009-06-02 10:54:19 +0200938 if (preset->const_channel_count)
939 spec->multiout.max_channels = preset->const_channel_count;
940 else
941 spec->multiout.max_channels = spec->channel_mode[0].channels;
942 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100943
944 spec->multiout.num_dacs = preset->num_dacs;
945 spec->multiout.dac_nids = preset->dac_nids;
946 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800947 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100948 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200949
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200950 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200951 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200952 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100953 spec->input_mux = preset->input_mux;
954
955 spec->num_adc_nids = preset->num_adc_nids;
956 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100957 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100958 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100959
960 spec->unsol_event = preset->unsol_event;
961 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200962#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100963 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200964 spec->loopback.amplist = preset->loopbacks;
965#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200966
967 if (preset->setup)
968 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200969
970 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100971}
972
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200973/* Enable GPIO mask and set output */
974static struct hda_verb alc_gpio1_init_verbs[] = {
975 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
976 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
977 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
978 { }
979};
980
981static struct hda_verb alc_gpio2_init_verbs[] = {
982 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
983 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
984 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
985 { }
986};
987
Kailang Yangbdd148a2007-05-08 15:19:08 +0200988static struct hda_verb alc_gpio3_init_verbs[] = {
989 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
990 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
991 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
992 { }
993};
994
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200995/*
996 * Fix hardware PLL issue
997 * On some codecs, the analog PLL gating control must be off while
998 * the default value is 1.
999 */
1000static void alc_fix_pll(struct hda_codec *codec)
1001{
1002 struct alc_spec *spec = codec->spec;
1003 unsigned int val;
1004
1005 if (!spec->pll_nid)
1006 return;
1007 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1008 spec->pll_coef_idx);
1009 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1010 AC_VERB_GET_PROC_COEF, 0);
1011 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1012 spec->pll_coef_idx);
1013 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1014 val & ~(1 << spec->pll_coef_bit));
1015}
1016
1017static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1018 unsigned int coef_idx, unsigned int coef_bit)
1019{
1020 struct alc_spec *spec = codec->spec;
1021 spec->pll_nid = nid;
1022 spec->pll_coef_idx = coef_idx;
1023 spec->pll_coef_bit = coef_bit;
1024 alc_fix_pll(codec);
1025}
1026
Kailang Yang9ad0e492010-09-14 23:22:00 +02001027#ifdef CONFIG_SND_HDA_INPUT_JACK
1028static void alc_free_jack_priv(struct snd_jack *jack)
1029{
1030 struct alc_jack *jacks = jack->private_data;
1031 jacks->nid = 0;
1032 jacks->jack = NULL;
1033}
1034
1035static int alc_add_jack(struct hda_codec *codec,
1036 hda_nid_t nid, int type)
1037{
1038 struct alc_spec *spec;
1039 struct alc_jack *jack;
1040 const char *name;
1041 int err;
1042
1043 spec = codec->spec;
1044 snd_array_init(&spec->jacks, sizeof(*jack), 32);
1045 jack = snd_array_new(&spec->jacks);
1046 if (!jack)
1047 return -ENOMEM;
1048
1049 jack->nid = nid;
1050 jack->type = type;
1051 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
1052
1053 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
1054 if (err < 0)
1055 return err;
1056 jack->jack->private_data = jack;
1057 jack->jack->private_free = alc_free_jack_priv;
1058 return 0;
1059}
1060
1061static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1062{
1063 struct alc_spec *spec = codec->spec;
1064 struct alc_jack *jacks = spec->jacks.list;
1065
1066 if (jacks) {
1067 int i;
1068 for (i = 0; i < spec->jacks.used; i++) {
1069 if (jacks->nid == nid) {
1070 unsigned int present;
1071 present = snd_hda_jack_detect(codec, nid);
1072
1073 present = (present) ? jacks->type : 0;
1074
1075 snd_jack_report(jacks->jack, present);
1076 }
1077 jacks++;
1078 }
1079 }
1080}
1081
1082static int alc_init_jacks(struct hda_codec *codec)
1083{
1084 struct alc_spec *spec = codec->spec;
1085 int err;
1086 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1087 unsigned int mic_nid = spec->ext_mic.pin;
1088
1089 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1090 if (err < 0)
1091 return err;
1092 alc_report_jack(codec, hp_nid);
1093
1094 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1095 if (err < 0)
1096 return err;
1097 alc_report_jack(codec, mic_nid);
1098
1099 return 0;
1100}
1101#else
1102static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1103{
1104}
1105
1106static inline int alc_init_jacks(struct hda_codec *codec)
1107{
1108 return 0;
1109}
1110#endif
1111
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001112static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001113{
1114 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001115 unsigned int mute;
1116 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001117 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001118
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001119 spec->jack_present = 0;
1120 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1121 nid = spec->autocfg.hp_pins[i];
1122 if (!nid)
1123 break;
1124 if (snd_hda_jack_detect(codec, nid)) {
1125 spec->jack_present = 1;
1126 break;
1127 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001128 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001129 }
1130
1131 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1132 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001133 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1134 nid = spec->autocfg.speaker_pins[i];
1135 if (!nid)
1136 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001137 if (pinctl) {
1138 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001139 AC_VERB_SET_PIN_WIDGET_CONTROL,
1140 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001141 } else {
1142 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1143 HDA_AMP_MUTE, mute);
1144 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001145 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001146}
1147
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001148static void alc_automute_pin(struct hda_codec *codec)
1149{
1150 alc_automute_speaker(codec, 1);
1151}
1152
Takashi Iwai6c819492009-08-10 18:47:44 +02001153static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1154 hda_nid_t nid)
1155{
1156 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1157 int i, nums;
1158
1159 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1160 for (i = 0; i < nums; i++)
1161 if (conn[i] == nid)
1162 return i;
1163 return -1;
1164}
1165
Takashi Iwai840b64c2010-07-13 22:49:01 +02001166/* switch the current ADC according to the jack state */
1167static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1168{
1169 struct alc_spec *spec = codec->spec;
1170 unsigned int present;
1171 hda_nid_t new_adc;
1172
1173 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1174 if (present)
1175 spec->cur_adc_idx = 1;
1176 else
1177 spec->cur_adc_idx = 0;
1178 new_adc = spec->adc_nids[spec->cur_adc_idx];
1179 if (spec->cur_adc && spec->cur_adc != new_adc) {
1180 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001181 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001182 spec->cur_adc = new_adc;
1183 snd_hda_codec_setup_stream(codec, new_adc,
1184 spec->cur_adc_stream_tag, 0,
1185 spec->cur_adc_format);
1186 }
1187}
1188
Kailang Yang7fb0d782008-10-15 11:12:35 +02001189static void alc_mic_automute(struct hda_codec *codec)
1190{
1191 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001192 struct alc_mic_route *dead, *alive;
1193 unsigned int present, type;
1194 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001195
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001196 if (!spec->auto_mic)
1197 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001198 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1199 return;
1200 if (snd_BUG_ON(!spec->adc_nids))
1201 return;
1202
Takashi Iwai840b64c2010-07-13 22:49:01 +02001203 if (spec->dual_adc_switch) {
1204 alc_dual_mic_adc_auto_switch(codec);
1205 return;
1206 }
1207
Takashi Iwai6c819492009-08-10 18:47:44 +02001208 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1209
Wu Fengguang864f92b2009-11-18 12:38:02 +08001210 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001211 if (present) {
1212 alive = &spec->ext_mic;
1213 dead = &spec->int_mic;
1214 } else {
1215 alive = &spec->int_mic;
1216 dead = &spec->ext_mic;
1217 }
1218
Takashi Iwai6c819492009-08-10 18:47:44 +02001219 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1220 if (type == AC_WID_AUD_MIX) {
1221 /* Matrix-mixer style (e.g. ALC882) */
1222 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1223 alive->mux_idx,
1224 HDA_AMP_MUTE, 0);
1225 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1226 dead->mux_idx,
1227 HDA_AMP_MUTE, HDA_AMP_MUTE);
1228 } else {
1229 /* MUX style (e.g. ALC880) */
1230 snd_hda_codec_write_cache(codec, cap_nid, 0,
1231 AC_VERB_SET_CONNECT_SEL,
1232 alive->mux_idx);
1233 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001234 alc_report_jack(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001235
1236 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001237}
1238
Kailang Yangc9b58002007-10-16 14:30:01 +02001239/* unsolicited event for HP jack sensing */
1240static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1241{
1242 if (codec->vendor_id == 0x10ec0880)
1243 res >>= 28;
1244 else
1245 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001246 switch (res) {
1247 case ALC880_HP_EVENT:
1248 alc_automute_pin(codec);
1249 break;
1250 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001251 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001252 break;
1253 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001254}
1255
1256static void alc_inithook(struct hda_codec *codec)
1257{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001258 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001259 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001260}
1261
Kailang Yangf9423e72008-05-27 12:32:25 +02001262/* additional initialization for ALC888 variants */
1263static void alc888_coef_init(struct hda_codec *codec)
1264{
1265 unsigned int tmp;
1266
1267 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1268 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1269 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001270 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001271 /* alc888S-VC */
1272 snd_hda_codec_read(codec, 0x20, 0,
1273 AC_VERB_SET_PROC_COEF, 0x830);
1274 else
1275 /* alc888-VB */
1276 snd_hda_codec_read(codec, 0x20, 0,
1277 AC_VERB_SET_PROC_COEF, 0x3030);
1278}
1279
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001280static void alc889_coef_init(struct hda_codec *codec)
1281{
1282 unsigned int tmp;
1283
1284 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1285 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1286 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1287 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1288}
1289
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001290/* turn on/off EAPD control (only if available) */
1291static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1292{
1293 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1294 return;
1295 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1296 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1297 on ? 2 : 0);
1298}
1299
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001300static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001301{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001302 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001303
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001304 switch (type) {
1305 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001306 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1307 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001308 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001309 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1310 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001311 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001312 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1313 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001314 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001315 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001316 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001317 set_eapd(codec, 0x0f, 1);
1318 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001319 break;
1320 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001321 case 0x10ec0267:
1322 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001323 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001324 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001325 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001326 case 0x10ec0660:
1327 case 0x10ec0662:
1328 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001329 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001330 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001331 set_eapd(codec, 0x14, 1);
1332 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001333 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001334 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001335 switch (codec->vendor_id) {
1336 case 0x10ec0260:
1337 snd_hda_codec_write(codec, 0x1a, 0,
1338 AC_VERB_SET_COEF_INDEX, 7);
1339 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1340 AC_VERB_GET_PROC_COEF, 0);
1341 snd_hda_codec_write(codec, 0x1a, 0,
1342 AC_VERB_SET_COEF_INDEX, 7);
1343 snd_hda_codec_write(codec, 0x1a, 0,
1344 AC_VERB_SET_PROC_COEF,
1345 tmp | 0x2010);
1346 break;
1347 case 0x10ec0262:
1348 case 0x10ec0880:
1349 case 0x10ec0882:
1350 case 0x10ec0883:
1351 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001352 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001353 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001354 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001355 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001356 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001357 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001358 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001359#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001360 case 0x10ec0267:
1361 case 0x10ec0268:
1362 snd_hda_codec_write(codec, 0x20, 0,
1363 AC_VERB_SET_COEF_INDEX, 7);
1364 tmp = snd_hda_codec_read(codec, 0x20, 0,
1365 AC_VERB_GET_PROC_COEF, 0);
1366 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001367 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001368 snd_hda_codec_write(codec, 0x20, 0,
1369 AC_VERB_SET_PROC_COEF,
1370 tmp | 0x3000);
1371 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001372#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001373 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001374 break;
1375 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001376}
Kailang Yangea1fb292008-08-26 12:58:38 +02001377
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001378static void alc_init_auto_hp(struct hda_codec *codec)
1379{
1380 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001381 struct auto_pin_cfg *cfg = &spec->autocfg;
1382 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001383
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001384 if (!cfg->hp_pins[0]) {
1385 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001386 return;
1387 }
1388
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001389 if (!cfg->speaker_pins[0]) {
1390 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1391 return;
1392 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1393 sizeof(cfg->speaker_pins));
1394 cfg->speaker_outs = cfg->line_outs;
1395 }
1396
1397 if (!cfg->hp_pins[0]) {
1398 memcpy(cfg->hp_pins, cfg->line_out_pins,
1399 sizeof(cfg->hp_pins));
1400 cfg->hp_outs = cfg->line_outs;
1401 }
1402
1403 for (i = 0; i < cfg->hp_outs; i++) {
1404 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1405 cfg->hp_pins[i]);
1406 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001407 AC_VERB_SET_UNSOLICITED_ENABLE,
1408 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001409 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001410 spec->unsol_event = alc_sku_unsol_event;
1411}
1412
Takashi Iwai6c819492009-08-10 18:47:44 +02001413static void alc_init_auto_mic(struct hda_codec *codec)
1414{
1415 struct alc_spec *spec = codec->spec;
1416 struct auto_pin_cfg *cfg = &spec->autocfg;
1417 hda_nid_t fixed, ext;
1418 int i;
1419
1420 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001421 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001422 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001423 return;
1424
1425 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001426 for (i = 0; i < cfg->num_inputs; i++) {
1427 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001428 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001429 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001430 switch (snd_hda_get_input_pin_attr(defcfg)) {
1431 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001432 if (fixed)
1433 return; /* already occupied */
1434 fixed = nid;
1435 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001436 case INPUT_PIN_ATTR_UNUSED:
1437 return; /* invalid entry */
1438 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001439 if (ext)
1440 return; /* already occupied */
1441 ext = nid;
1442 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001443 }
1444 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001445 if (!ext || !fixed)
1446 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001447 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1448 return; /* no unsol support */
1449 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1450 ext, fixed);
1451 spec->ext_mic.pin = ext;
1452 spec->int_mic.pin = fixed;
1453 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1454 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1455 spec->auto_mic = 1;
1456 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1457 AC_VERB_SET_UNSOLICITED_ENABLE,
1458 AC_USRSP_EN | ALC880_MIC_EVENT);
1459 spec->unsol_event = alc_sku_unsol_event;
1460}
1461
Kailang Yangda00c242010-03-19 11:23:45 +01001462static int alc_auto_parse_customize_define(struct hda_codec *codec)
1463{
1464 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001465 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001466 struct alc_spec *spec = codec->spec;
1467
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001468 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1469
Kailang Yangda00c242010-03-19 11:23:45 +01001470 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001471 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001472 goto do_sku;
1473
1474 nid = 0x1d;
1475 if (codec->vendor_id == 0x10ec0260)
1476 nid = 0x17;
1477 ass = snd_hda_codec_get_pincfg(codec, nid);
1478
1479 if (!(ass & 1)) {
1480 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1481 codec->chip_name, ass);
1482 return -1;
1483 }
1484
1485 /* check sum */
1486 tmp = 0;
1487 for (i = 1; i < 16; i++) {
1488 if ((ass >> i) & 1)
1489 tmp++;
1490 }
1491 if (((ass >> 16) & 0xf) != tmp)
1492 return -1;
1493
1494 spec->cdefine.port_connectivity = ass >> 30;
1495 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1496 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1497 spec->cdefine.customization = ass >> 8;
1498do_sku:
1499 spec->cdefine.sku_cfg = ass;
1500 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1501 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1502 spec->cdefine.swap = (ass & 0x2) >> 1;
1503 spec->cdefine.override = ass & 0x1;
1504
1505 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1506 nid, spec->cdefine.sku_cfg);
1507 snd_printd("SKU: port_connectivity=0x%x\n",
1508 spec->cdefine.port_connectivity);
1509 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1510 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1511 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1512 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1513 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1514 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1515 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1516
1517 return 0;
1518}
1519
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001520/* check subsystem ID and set up device-specific initialization;
1521 * return 1 if initialized, 0 if invalid SSID
1522 */
1523/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1524 * 31 ~ 16 : Manufacture ID
1525 * 15 ~ 8 : SKU ID
1526 * 7 ~ 0 : Assembly ID
1527 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1528 */
1529static int alc_subsystem_id(struct hda_codec *codec,
1530 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001531 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001532{
1533 unsigned int ass, tmp, i;
1534 unsigned nid;
1535 struct alc_spec *spec = codec->spec;
1536
1537 ass = codec->subsystem_id & 0xffff;
1538 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1539 goto do_sku;
1540
1541 /* invalid SSID, check the special NID pin defcfg instead */
1542 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001543 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001544 * 29~21 : reserve
1545 * 20 : PCBEEP input
1546 * 19~16 : Check sum (15:1)
1547 * 15~1 : Custom
1548 * 0 : override
1549 */
1550 nid = 0x1d;
1551 if (codec->vendor_id == 0x10ec0260)
1552 nid = 0x17;
1553 ass = snd_hda_codec_get_pincfg(codec, nid);
1554 snd_printd("realtek: No valid SSID, "
1555 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001556 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001557 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001558 return 0;
1559 if ((ass >> 30) != 1) /* no physical connection */
1560 return 0;
1561
1562 /* check sum */
1563 tmp = 0;
1564 for (i = 1; i < 16; i++) {
1565 if ((ass >> i) & 1)
1566 tmp++;
1567 }
1568 if (((ass >> 16) & 0xf) != tmp)
1569 return 0;
1570do_sku:
1571 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1572 ass & 0xffff, codec->vendor_id);
1573 /*
1574 * 0 : override
1575 * 1 : Swap Jack
1576 * 2 : 0 --> Desktop, 1 --> Laptop
1577 * 3~5 : External Amplifier control
1578 * 7~6 : Reserved
1579 */
1580 tmp = (ass & 0x38) >> 3; /* external Amp control */
1581 switch (tmp) {
1582 case 1:
1583 spec->init_amp = ALC_INIT_GPIO1;
1584 break;
1585 case 3:
1586 spec->init_amp = ALC_INIT_GPIO2;
1587 break;
1588 case 7:
1589 spec->init_amp = ALC_INIT_GPIO3;
1590 break;
1591 case 5:
1592 spec->init_amp = ALC_INIT_DEFAULT;
1593 break;
1594 }
1595
1596 /* is laptop or Desktop and enable the function "Mute internal speaker
1597 * when the external headphone out jack is plugged"
1598 */
1599 if (!(ass & 0x8000))
1600 return 1;
1601 /*
1602 * 10~8 : Jack location
1603 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1604 * 14~13: Resvered
1605 * 15 : 1 --> enable the function "Mute internal speaker
1606 * when the external headphone out jack is plugged"
1607 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001608 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001609 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001610 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1611 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001612 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001613 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001614 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001615 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001616 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001617 else if (tmp == 3)
1618 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001619 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001620 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001621 for (i = 0; i < spec->autocfg.line_outs; i++)
1622 if (spec->autocfg.line_out_pins[i] == nid)
1623 return 1;
1624 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001625 }
1626
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001627 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001628 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001629 return 1;
1630}
Kailang Yangea1fb292008-08-26 12:58:38 +02001631
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001632static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001633 hda_nid_t porta, hda_nid_t porte,
1634 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001635{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001636 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001637 struct alc_spec *spec = codec->spec;
1638 snd_printd("realtek: "
1639 "Enable default setup for auto mode as fallback\n");
1640 spec->init_amp = ALC_INIT_DEFAULT;
1641 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001642 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001643 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001644}
1645
Takashi Iwai41e41f12005-06-08 14:48:49 +02001646/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001647 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001648 */
1649
1650struct alc_pincfg {
1651 hda_nid_t nid;
1652 u32 val;
1653};
1654
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001655struct alc_fixup {
1656 const struct alc_pincfg *pins;
1657 const struct hda_verb *verbs;
1658};
1659
1660static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001661 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001662 const struct alc_fixup *fix,
1663 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001664{
1665 const struct alc_pincfg *cfg;
1666
1667 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1668 if (!quirk)
1669 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001670 fix += quirk->value;
1671 cfg = fix->pins;
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001672 if (pre_init && cfg) {
1673#ifdef CONFIG_SND_DEBUG_VERBOSE
1674 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1675 codec->chip_name, quirk->name);
1676#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001677 for (; cfg->nid; cfg++)
1678 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1679 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001680 if (!pre_init && fix->verbs) {
1681#ifdef CONFIG_SND_DEBUG_VERBOSE
1682 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1683 codec->chip_name, quirk->name);
1684#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001685 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001686 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001687}
1688
Kailang Yang274693f2009-12-03 10:07:50 +01001689static int alc_read_coef_idx(struct hda_codec *codec,
1690 unsigned int coef_idx)
1691{
1692 unsigned int val;
1693 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1694 coef_idx);
1695 val = snd_hda_codec_read(codec, 0x20, 0,
1696 AC_VERB_GET_PROC_COEF, 0);
1697 return val;
1698}
1699
Kailang Yang977ddd62010-09-15 10:02:29 +02001700static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1701 unsigned int coef_val)
1702{
1703 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1704 coef_idx);
1705 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1706 coef_val);
1707}
1708
Takashi Iwai757899a2010-07-30 10:48:14 +02001709/* set right pin controls for digital I/O */
1710static void alc_auto_init_digital(struct hda_codec *codec)
1711{
1712 struct alc_spec *spec = codec->spec;
1713 int i;
1714 hda_nid_t pin;
1715
1716 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1717 pin = spec->autocfg.dig_out_pins[i];
1718 if (pin) {
1719 snd_hda_codec_write(codec, pin, 0,
1720 AC_VERB_SET_PIN_WIDGET_CONTROL,
1721 PIN_OUT);
1722 }
1723 }
1724 pin = spec->autocfg.dig_in_pin;
1725 if (pin)
1726 snd_hda_codec_write(codec, pin, 0,
1727 AC_VERB_SET_PIN_WIDGET_CONTROL,
1728 PIN_IN);
1729}
1730
1731/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1732static void alc_auto_parse_digital(struct hda_codec *codec)
1733{
1734 struct alc_spec *spec = codec->spec;
1735 int i, err;
1736 hda_nid_t dig_nid;
1737
1738 /* support multiple SPDIFs; the secondary is set up as a slave */
1739 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1740 err = snd_hda_get_connections(codec,
1741 spec->autocfg.dig_out_pins[i],
1742 &dig_nid, 1);
1743 if (err < 0)
1744 continue;
1745 if (!i) {
1746 spec->multiout.dig_out_nid = dig_nid;
1747 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1748 } else {
1749 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1750 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1751 break;
1752 spec->slave_dig_outs[i - 1] = dig_nid;
1753 }
1754 }
1755
1756 if (spec->autocfg.dig_in_pin) {
1757 hda_nid_t dig_nid;
1758 err = snd_hda_get_connections(codec,
1759 spec->autocfg.dig_in_pin,
1760 &dig_nid, 1);
1761 if (err > 0)
1762 spec->dig_in_nid = dig_nid;
1763 }
1764}
1765
Takashi Iwaif95474e2007-07-10 00:47:43 +02001766/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001767 * ALC888
1768 */
1769
1770/*
1771 * 2ch mode
1772 */
1773static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1774/* Mic-in jack as mic in */
1775 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1776 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1777/* Line-in jack as Line in */
1778 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1779 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1780/* Line-Out as Front */
1781 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1782 { } /* end */
1783};
1784
1785/*
1786 * 4ch mode
1787 */
1788static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1789/* Mic-in jack as mic in */
1790 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1791 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1792/* Line-in jack as Surround */
1793 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1794 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1795/* Line-Out as Front */
1796 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1797 { } /* end */
1798};
1799
1800/*
1801 * 6ch mode
1802 */
1803static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1804/* Mic-in jack as CLFE */
1805 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1806 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1807/* Line-in jack as Surround */
1808 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1809 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1810/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1811 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1812 { } /* end */
1813};
1814
1815/*
1816 * 8ch mode
1817 */
1818static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1819/* Mic-in jack as CLFE */
1820 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1821 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1822/* Line-in jack as Surround */
1823 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1824 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1825/* Line-Out as Side */
1826 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1827 { } /* end */
1828};
1829
1830static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1831 { 2, alc888_4ST_ch2_intel_init },
1832 { 4, alc888_4ST_ch4_intel_init },
1833 { 6, alc888_4ST_ch6_intel_init },
1834 { 8, alc888_4ST_ch8_intel_init },
1835};
1836
1837/*
1838 * ALC888 Fujitsu Siemens Amillo xa3530
1839 */
1840
1841static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1842/* Front Mic: set to PIN_IN (empty by default) */
1843 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1844/* Connect Internal HP to Front */
1845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1846 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1847 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1848/* Connect Bass HP to Front */
1849 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1850 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1851 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1852/* Connect Line-Out side jack (SPDIF) to Side */
1853 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1854 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1855 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1856/* Connect Mic jack to CLFE */
1857 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1858 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1859 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1860/* Connect Line-in jack to Surround */
1861 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1862 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1863 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1864/* Connect HP out jack to Front */
1865 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1866 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1867 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1868/* Enable unsolicited event for HP jack and Line-out jack */
1869 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1870 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1871 {}
1872};
1873
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001874static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001875{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001876 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001877}
1878
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001879static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1880 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001881{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001882 if (codec->vendor_id == 0x10ec0880)
1883 res >>= 28;
1884 else
1885 res >>= 26;
1886 if (res == ALC880_HP_EVENT)
1887 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001888}
1889
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001890static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001891{
1892 struct alc_spec *spec = codec->spec;
1893
1894 spec->autocfg.hp_pins[0] = 0x15;
1895 spec->autocfg.speaker_pins[0] = 0x14;
1896 spec->autocfg.speaker_pins[1] = 0x16;
1897 spec->autocfg.speaker_pins[2] = 0x17;
1898 spec->autocfg.speaker_pins[3] = 0x19;
1899 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001900}
1901
1902static void alc889_intel_init_hook(struct hda_codec *codec)
1903{
1904 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001905 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001906}
1907
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001908static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001909{
1910 struct alc_spec *spec = codec->spec;
1911
1912 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1913 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1914 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1915 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001916}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001917
1918/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001919 * ALC888 Acer Aspire 4930G model
1920 */
1921
1922static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1923/* Front Mic: set to PIN_IN (empty by default) */
1924 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1925/* Unselect Front Mic by default in input mixer 3 */
1926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001927/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001928 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1929/* Connect Internal HP to front */
1930 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1931 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1932 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1933/* Connect HP out to front */
1934 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1936 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1937 { }
1938};
1939
Hector Martin3b315d72009-06-02 10:54:19 +02001940/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001941 * ALC888 Acer Aspire 6530G model
1942 */
1943
1944static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001945/* Route to built-in subwoofer as well as speakers */
1946 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1948 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1949 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001950/* Bias voltage on for external mic port */
1951 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001952/* Front Mic: set to PIN_IN (empty by default) */
1953 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1954/* Unselect Front Mic by default in input mixer 3 */
1955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001956/* Enable unsolicited event for HP jack */
1957 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1958/* Enable speaker output */
1959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01001961 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001962/* Enable headphone output */
1963 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1964 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1965 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01001966 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001967 { }
1968};
1969
1970/*
Hector Martin018df412009-06-04 00:13:40 +02001971 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001972 */
1973
Hector Martin018df412009-06-04 00:13:40 +02001974static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001975/* Front Mic: set to PIN_IN (empty by default) */
1976 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1977/* Unselect Front Mic by default in input mixer 3 */
1978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1979/* Enable unsolicited event for HP jack */
1980 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1981/* Connect Internal Front to Front */
1982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1983 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1984 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1985/* Connect Internal Rear to Rear */
1986 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1987 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1988 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1989/* Connect Internal CLFE to CLFE */
1990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1991 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1992 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1993/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001994 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001995 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1996 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1997/* Enable all DACs */
1998/* DAC DISABLE/MUTE 1? */
1999/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2000 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2001 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2002/* DAC DISABLE/MUTE 2? */
2003/* some bit here disables the other DACs. Init=0x4900 */
2004 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2005 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002006/* DMIC fix
2007 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2008 * which makes the stereo useless. However, either the mic or the ALC889
2009 * makes the signal become a difference/sum signal instead of standard
2010 * stereo, which is annoying. So instead we flip this bit which makes the
2011 * codec replicate the sum signal to both channels, turning it into a
2012 * normal mono mic.
2013 */
2014/* DMIC_CONTROL? Init value = 0x0001 */
2015 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2016 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002017 { }
2018};
2019
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002020static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002021 /* Front mic only available on one ADC */
2022 {
2023 .num_items = 4,
2024 .items = {
2025 { "Mic", 0x0 },
2026 { "Line", 0x2 },
2027 { "CD", 0x4 },
2028 { "Front Mic", 0xb },
2029 },
2030 },
2031 {
2032 .num_items = 3,
2033 .items = {
2034 { "Mic", 0x0 },
2035 { "Line", 0x2 },
2036 { "CD", 0x4 },
2037 },
2038 }
2039};
2040
Tony Vroond2fd4b02009-06-21 00:40:10 +01002041static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2042 /* Interal mic only available on one ADC */
2043 {
Tony Vroon684a8842009-06-26 09:27:50 +01002044 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002045 .items = {
2046 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002047 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002048 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002049 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002050 { "Int Mic", 0xb },
2051 },
2052 },
2053 {
Tony Vroon684a8842009-06-26 09:27:50 +01002054 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002055 .items = {
2056 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002057 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002058 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002059 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002060 },
2061 }
2062};
2063
Hector Martin018df412009-06-04 00:13:40 +02002064static struct hda_input_mux alc889_capture_sources[3] = {
2065 /* Digital mic only available on first "ADC" */
2066 {
2067 .num_items = 5,
2068 .items = {
2069 { "Mic", 0x0 },
2070 { "Line", 0x2 },
2071 { "CD", 0x4 },
2072 { "Front Mic", 0xb },
2073 { "Input Mix", 0xa },
2074 },
2075 },
2076 {
2077 .num_items = 4,
2078 .items = {
2079 { "Mic", 0x0 },
2080 { "Line", 0x2 },
2081 { "CD", 0x4 },
2082 { "Input Mix", 0xa },
2083 },
2084 },
2085 {
2086 .num_items = 4,
2087 .items = {
2088 { "Mic", 0x0 },
2089 { "Line", 0x2 },
2090 { "CD", 0x4 },
2091 { "Input Mix", 0xa },
2092 },
2093 }
2094};
2095
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002096static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002097 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2098 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2099 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2100 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2101 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2102 HDA_OUTPUT),
2103 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2104 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2105 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2106 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2107 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002115 { } /* end */
2116};
2117
Hector Martin556eea92009-12-20 22:51:23 +01002118static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2119 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2120 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2121 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2122 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2123 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2124 HDA_OUTPUT),
2125 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2126 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2127 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2128 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2129 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2132 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2133 { } /* end */
2134};
2135
2136
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002137static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002138{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002139 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002140
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002141 spec->autocfg.hp_pins[0] = 0x15;
2142 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002143 spec->autocfg.speaker_pins[1] = 0x16;
2144 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002145}
2146
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002147static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002148{
2149 struct alc_spec *spec = codec->spec;
2150
2151 spec->autocfg.hp_pins[0] = 0x15;
2152 spec->autocfg.speaker_pins[0] = 0x14;
2153 spec->autocfg.speaker_pins[1] = 0x16;
2154 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002155}
2156
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002157static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002158{
2159 struct alc_spec *spec = codec->spec;
2160
2161 spec->autocfg.hp_pins[0] = 0x15;
2162 spec->autocfg.speaker_pins[0] = 0x14;
2163 spec->autocfg.speaker_pins[1] = 0x16;
2164 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002165}
2166
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002167/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002168 * ALC880 3-stack model
2169 *
2170 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002171 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2172 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002173 */
2174
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002175static hda_nid_t alc880_dac_nids[4] = {
2176 /* front, rear, clfe, rear_surr */
2177 0x02, 0x05, 0x04, 0x03
2178};
2179
2180static hda_nid_t alc880_adc_nids[3] = {
2181 /* ADC0-2 */
2182 0x07, 0x08, 0x09,
2183};
2184
2185/* The datasheet says the node 0x07 is connected from inputs,
2186 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002187 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002189static hda_nid_t alc880_adc_nids_alt[2] = {
2190 /* ADC1-2 */
2191 0x08, 0x09,
2192};
2193
2194#define ALC880_DIGOUT_NID 0x06
2195#define ALC880_DIGIN_NID 0x0a
2196
2197static struct hda_input_mux alc880_capture_source = {
2198 .num_items = 4,
2199 .items = {
2200 { "Mic", 0x0 },
2201 { "Front Mic", 0x3 },
2202 { "Line", 0x2 },
2203 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002205};
2206
2207/* channel source setting (2/6 channel selection for 3-stack) */
2208/* 2ch mode */
2209static struct hda_verb alc880_threestack_ch2_init[] = {
2210 /* set line-in to input, mute it */
2211 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2212 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2213 /* set mic-in to input vref 80%, mute it */
2214 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2215 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002216 { } /* end */
2217};
2218
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002219/* 6ch mode */
2220static struct hda_verb alc880_threestack_ch6_init[] = {
2221 /* set line-in to output, unmute it */
2222 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2223 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2224 /* set mic-in to output, unmute it */
2225 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2226 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2227 { } /* end */
2228};
2229
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002230static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002231 { 2, alc880_threestack_ch2_init },
2232 { 6, alc880_threestack_ch6_init },
2233};
2234
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002235static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002236 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002237 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002238 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002239 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002240 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2241 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002242 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2243 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002244 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2245 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2246 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2247 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2248 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2249 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2250 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2251 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002253 {
2254 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2255 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002256 .info = alc_ch_mode_info,
2257 .get = alc_ch_mode_get,
2258 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002259 },
2260 { } /* end */
2261};
2262
2263/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002264static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2265 struct snd_ctl_elem_info *uinfo)
2266{
2267 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2268 struct alc_spec *spec = codec->spec;
2269 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002270
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002271 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002272 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2273 HDA_INPUT);
2274 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002275 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002276 return err;
2277}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002279static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2280 unsigned int size, unsigned int __user *tlv)
2281{
2282 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2283 struct alc_spec *spec = codec->spec;
2284 int err;
2285
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002286 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002287 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2288 HDA_INPUT);
2289 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002290 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002291 return err;
2292}
2293
2294typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2295 struct snd_ctl_elem_value *ucontrol);
2296
2297static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2298 struct snd_ctl_elem_value *ucontrol,
2299 getput_call_t func)
2300{
2301 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2302 struct alc_spec *spec = codec->spec;
2303 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2304 int err;
2305
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002306 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002307 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2308 3, 0, HDA_INPUT);
2309 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002310 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002311 return err;
2312}
2313
2314static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2315 struct snd_ctl_elem_value *ucontrol)
2316{
2317 return alc_cap_getput_caller(kcontrol, ucontrol,
2318 snd_hda_mixer_amp_volume_get);
2319}
2320
2321static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2322 struct snd_ctl_elem_value *ucontrol)
2323{
2324 return alc_cap_getput_caller(kcontrol, ucontrol,
2325 snd_hda_mixer_amp_volume_put);
2326}
2327
2328/* capture mixer elements */
2329#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2330
2331static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2332 struct snd_ctl_elem_value *ucontrol)
2333{
2334 return alc_cap_getput_caller(kcontrol, ucontrol,
2335 snd_hda_mixer_amp_switch_get);
2336}
2337
2338static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2339 struct snd_ctl_elem_value *ucontrol)
2340{
2341 return alc_cap_getput_caller(kcontrol, ucontrol,
2342 snd_hda_mixer_amp_switch_put);
2343}
2344
Takashi Iwaia23b6882009-03-23 15:21:36 +01002345#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002346 { \
2347 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2348 .name = "Capture Switch", \
2349 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2350 .count = num, \
2351 .info = alc_cap_sw_info, \
2352 .get = alc_cap_sw_get, \
2353 .put = alc_cap_sw_put, \
2354 }, \
2355 { \
2356 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2357 .name = "Capture Volume", \
2358 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2359 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2360 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2361 .count = num, \
2362 .info = alc_cap_vol_info, \
2363 .get = alc_cap_vol_get, \
2364 .put = alc_cap_vol_put, \
2365 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002366 }
2367
2368#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002369 { \
2370 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2371 /* .name = "Capture Source", */ \
2372 .name = "Input Source", \
2373 .count = num, \
2374 .info = alc_mux_enum_info, \
2375 .get = alc_mux_enum_get, \
2376 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002377 }
2378
2379#define DEFINE_CAPMIX(num) \
2380static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2381 _DEFINE_CAPMIX(num), \
2382 _DEFINE_CAPSRC(num), \
2383 { } /* end */ \
2384}
2385
2386#define DEFINE_CAPMIX_NOSRC(num) \
2387static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2388 _DEFINE_CAPMIX(num), \
2389 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002390}
2391
2392/* up to three ADCs */
2393DEFINE_CAPMIX(1);
2394DEFINE_CAPMIX(2);
2395DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002396DEFINE_CAPMIX_NOSRC(1);
2397DEFINE_CAPMIX_NOSRC(2);
2398DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002399
2400/*
2401 * ALC880 5-stack model
2402 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002403 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2404 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002405 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2406 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2407 */
2408
2409/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002410static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002411 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002412 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413 { } /* end */
2414};
2415
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002416/* channel source setting (6/8 channel selection for 5-stack) */
2417/* 6ch mode */
2418static struct hda_verb alc880_fivestack_ch6_init[] = {
2419 /* set line-in to input, mute it */
2420 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2421 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002422 { } /* end */
2423};
2424
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002425/* 8ch mode */
2426static struct hda_verb alc880_fivestack_ch8_init[] = {
2427 /* set line-in to output, unmute it */
2428 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2429 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2430 { } /* end */
2431};
2432
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002433static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002434 { 6, alc880_fivestack_ch6_init },
2435 { 8, alc880_fivestack_ch8_init },
2436};
2437
2438
2439/*
2440 * ALC880 6-stack model
2441 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002442 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2443 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002444 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2445 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2446 */
2447
2448static hda_nid_t alc880_6st_dac_nids[4] = {
2449 /* front, rear, clfe, rear_surr */
2450 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002451};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002452
2453static struct hda_input_mux alc880_6stack_capture_source = {
2454 .num_items = 4,
2455 .items = {
2456 { "Mic", 0x0 },
2457 { "Front Mic", 0x1 },
2458 { "Line", 0x2 },
2459 { "CD", 0x4 },
2460 },
2461};
2462
2463/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002464static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002465 { 8, NULL },
2466};
2467
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002468static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002469 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002470 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002471 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002472 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002473 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2474 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002475 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2476 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002477 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002478 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002479 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2480 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2481 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2482 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2484 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2485 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2486 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002487 {
2488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2489 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002490 .info = alc_ch_mode_info,
2491 .get = alc_ch_mode_get,
2492 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002493 },
2494 { } /* end */
2495};
2496
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002497
2498/*
2499 * ALC880 W810 model
2500 *
2501 * W810 has rear IO for:
2502 * Front (DAC 02)
2503 * Surround (DAC 03)
2504 * Center/LFE (DAC 04)
2505 * Digital out (06)
2506 *
2507 * The system also has a pair of internal speakers, and a headphone jack.
2508 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002509 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002510 * There is a variable resistor to control the speaker or headphone
2511 * volume. This is a hardware-only device without a software API.
2512 *
2513 * Plugging headphones in will disable the internal speakers. This is
2514 * implemented in hardware, not via the driver using jack sense. In
2515 * a similar fashion, plugging into the rear socket marked "front" will
2516 * disable both the speakers and headphones.
2517 *
2518 * For input, there's a microphone jack, and an "audio in" jack.
2519 * These may not do anything useful with this driver yet, because I
2520 * haven't setup any initialization verbs for these yet...
2521 */
2522
2523static hda_nid_t alc880_w810_dac_nids[3] = {
2524 /* front, rear/surround, clfe */
2525 0x02, 0x03, 0x04
2526};
2527
2528/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002529static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002530 { 6, NULL }
2531};
2532
2533/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002534static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002535 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002536 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002537 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002538 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002539 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2540 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002541 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2542 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002543 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2544 { } /* end */
2545};
2546
2547
2548/*
2549 * Z710V model
2550 *
2551 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002552 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2553 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002554 */
2555
2556static hda_nid_t alc880_z71v_dac_nids[1] = {
2557 0x02
2558};
2559#define ALC880_Z71V_HP_DAC 0x03
2560
2561/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002562static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002563 { 2, NULL }
2564};
2565
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002566static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002567 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002568 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002569 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002570 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002571 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2572 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2573 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2574 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2575 { } /* end */
2576};
2577
2578
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002579/*
2580 * ALC880 F1734 model
2581 *
2582 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2583 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2584 */
2585
2586static hda_nid_t alc880_f1734_dac_nids[1] = {
2587 0x03
2588};
2589#define ALC880_F1734_HP_DAC 0x02
2590
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002591static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002592 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002593 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002594 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2595 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002596 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2597 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002598 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2599 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002600 { } /* end */
2601};
2602
Takashi Iwai937b4162008-02-11 14:52:36 +01002603static struct hda_input_mux alc880_f1734_capture_source = {
2604 .num_items = 2,
2605 .items = {
2606 { "Mic", 0x1 },
2607 { "CD", 0x4 },
2608 },
2609};
2610
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002611
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002612/*
2613 * ALC880 ASUS model
2614 *
2615 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2616 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2617 * Mic = 0x18, Line = 0x1a
2618 */
2619
2620#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2621#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2622
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002623static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002624 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002625 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002626 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002627 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002628 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2629 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002630 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2631 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2633 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2634 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2635 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002638 {
2639 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2640 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002641 .info = alc_ch_mode_info,
2642 .get = alc_ch_mode_get,
2643 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002644 },
2645 { } /* end */
2646};
2647
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002648/*
2649 * ALC880 ASUS W1V model
2650 *
2651 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2652 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2653 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2654 */
2655
2656/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002657static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002658 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2659 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002660 { } /* end */
2661};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662
Kailang Yangdf694da2005-12-05 19:42:22 +01002663/* TCL S700 */
2664static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2665 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2666 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2667 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2668 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2669 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2671 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2672 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2673 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002674 { } /* end */
2675};
2676
Kailang Yangccc656c2006-10-17 12:32:26 +02002677/* Uniwill */
2678static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002679 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2680 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2681 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2682 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002683 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2684 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2685 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2686 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2687 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2688 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2689 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2690 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2692 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2693 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2694 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002695 {
2696 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2697 .name = "Channel Mode",
2698 .info = alc_ch_mode_info,
2699 .get = alc_ch_mode_get,
2700 .put = alc_ch_mode_put,
2701 },
2702 { } /* end */
2703};
2704
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002705static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2706 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2707 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2708 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2709 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2710 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2711 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2712 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2713 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2714 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2715 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2716 { } /* end */
2717};
2718
Kailang Yangccc656c2006-10-17 12:32:26 +02002719static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002720 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2721 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2722 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2723 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2725 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2726 { } /* end */
2727};
2728
Linus Torvalds1da177e2005-04-16 15:20:36 -07002729/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002730 * virtual master controls
2731 */
2732
2733/*
2734 * slave controls for virtual master
2735 */
2736static const char *alc_slave_vols[] = {
2737 "Front Playback Volume",
2738 "Surround Playback Volume",
2739 "Center Playback Volume",
2740 "LFE Playback Volume",
2741 "Side Playback Volume",
2742 "Headphone Playback Volume",
2743 "Speaker Playback Volume",
2744 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002745 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002746 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002747 NULL,
2748};
2749
2750static const char *alc_slave_sws[] = {
2751 "Front Playback Switch",
2752 "Surround Playback Switch",
2753 "Center Playback Switch",
2754 "LFE Playback Switch",
2755 "Side Playback Switch",
2756 "Headphone Playback Switch",
2757 "Speaker Playback Switch",
2758 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002759 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002760 "Line-Out Playback Switch",
2761 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002762 NULL,
2763};
2764
2765/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002766 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002767 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002768
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002769#define NID_MAPPING (-1)
2770
2771#define SUBDEV_SPEAKER_ (0 << 6)
2772#define SUBDEV_HP_ (1 << 6)
2773#define SUBDEV_LINE_ (2 << 6)
2774#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2775#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2776#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2777
Takashi Iwai603c4012008-07-30 15:01:44 +02002778static void alc_free_kctls(struct hda_codec *codec);
2779
Takashi Iwai67d634c2009-11-16 15:35:59 +01002780#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002781/* additional beep mixers; the actual parameters are overwritten at build */
2782static struct snd_kcontrol_new alc_beep_mixer[] = {
2783 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002784 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002785 { } /* end */
2786};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002787#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002788
Linus Torvalds1da177e2005-04-16 15:20:36 -07002789static int alc_build_controls(struct hda_codec *codec)
2790{
2791 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002792 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002793 struct snd_kcontrol_new *knew;
2794 int i, j, err;
2795 unsigned int u;
2796 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002797
2798 for (i = 0; i < spec->num_mixers; i++) {
2799 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2800 if (err < 0)
2801 return err;
2802 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002803 if (spec->cap_mixer) {
2804 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2805 if (err < 0)
2806 return err;
2807 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002808 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002809 err = snd_hda_create_spdif_out_ctls(codec,
2810 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002811 if (err < 0)
2812 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002813 if (!spec->no_analog) {
2814 err = snd_hda_create_spdif_share_sw(codec,
2815 &spec->multiout);
2816 if (err < 0)
2817 return err;
2818 spec->multiout.share_spdif = 1;
2819 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002820 }
2821 if (spec->dig_in_nid) {
2822 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2823 if (err < 0)
2824 return err;
2825 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002826
Takashi Iwai67d634c2009-11-16 15:35:59 +01002827#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002828 /* create beep controls if needed */
2829 if (spec->beep_amp) {
2830 struct snd_kcontrol_new *knew;
2831 for (knew = alc_beep_mixer; knew->name; knew++) {
2832 struct snd_kcontrol *kctl;
2833 kctl = snd_ctl_new1(knew, codec);
2834 if (!kctl)
2835 return -ENOMEM;
2836 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002837 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002838 if (err < 0)
2839 return err;
2840 }
2841 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002842#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002843
Takashi Iwai2134ea42008-01-10 16:53:55 +01002844 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002845 if (!spec->no_analog &&
2846 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002847 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002848 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002849 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002850 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002851 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002852 if (err < 0)
2853 return err;
2854 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002855 if (!spec->no_analog &&
2856 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002857 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2858 NULL, alc_slave_sws);
2859 if (err < 0)
2860 return err;
2861 }
2862
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002863 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002864 if (spec->capsrc_nids || spec->adc_nids) {
2865 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2866 if (!kctl)
2867 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2868 for (i = 0; kctl && i < kctl->count; i++) {
2869 hda_nid_t *nids = spec->capsrc_nids;
2870 if (!nids)
2871 nids = spec->adc_nids;
2872 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2873 if (err < 0)
2874 return err;
2875 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002876 }
2877 if (spec->cap_mixer) {
2878 const char *kname = kctl ? kctl->id.name : NULL;
2879 for (knew = spec->cap_mixer; knew->name; knew++) {
2880 if (kname && strcmp(knew->name, kname) == 0)
2881 continue;
2882 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2883 for (i = 0; kctl && i < kctl->count; i++) {
2884 err = snd_hda_add_nid(codec, kctl, i,
2885 spec->adc_nids[i]);
2886 if (err < 0)
2887 return err;
2888 }
2889 }
2890 }
2891
2892 /* other nid->control mapping */
2893 for (i = 0; i < spec->num_mixers; i++) {
2894 for (knew = spec->mixers[i]; knew->name; knew++) {
2895 if (knew->iface != NID_MAPPING)
2896 continue;
2897 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2898 if (kctl == NULL)
2899 continue;
2900 u = knew->subdevice;
2901 for (j = 0; j < 4; j++, u >>= 8) {
2902 nid = u & 0x3f;
2903 if (nid == 0)
2904 continue;
2905 switch (u & 0xc0) {
2906 case SUBDEV_SPEAKER_:
2907 nid = spec->autocfg.speaker_pins[nid];
2908 break;
2909 case SUBDEV_LINE_:
2910 nid = spec->autocfg.line_out_pins[nid];
2911 break;
2912 case SUBDEV_HP_:
2913 nid = spec->autocfg.hp_pins[nid];
2914 break;
2915 default:
2916 continue;
2917 }
2918 err = snd_hda_add_nid(codec, kctl, 0, nid);
2919 if (err < 0)
2920 return err;
2921 }
2922 u = knew->private_value;
2923 for (j = 0; j < 4; j++, u >>= 8) {
2924 nid = u & 0xff;
2925 if (nid == 0)
2926 continue;
2927 err = snd_hda_add_nid(codec, kctl, 0, nid);
2928 if (err < 0)
2929 return err;
2930 }
2931 }
2932 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002933
2934 alc_free_kctls(codec); /* no longer needed */
2935
Linus Torvalds1da177e2005-04-16 15:20:36 -07002936 return 0;
2937}
2938
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002939
Linus Torvalds1da177e2005-04-16 15:20:36 -07002940/*
2941 * initialize the codec volumes, etc
2942 */
2943
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002944/*
2945 * generic initialization of ADC, input mixers and output mixers
2946 */
2947static struct hda_verb alc880_volume_init_verbs[] = {
2948 /*
2949 * Unmute ADC0-2 and set the default input to mic-in
2950 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002951 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002952 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002953 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002954 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002955 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002956 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002957
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002958 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2959 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002960 * Note: PASD motherboards uses the Line In 2 as the input for front
2961 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002962 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002963 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002964 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2965 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2966 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2967 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2968 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2969 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2970 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002971
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002972 /*
2973 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002974 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002975 /* set vol=0 to output mixers */
2976 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2977 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2978 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2979 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2980 /* set up input amps for analog loopback */
2981 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002982 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002984 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2985 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002986 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2987 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002988 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2989 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002990
2991 { }
2992};
2993
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002994/*
2995 * 3-stack pin configuration:
2996 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2997 */
2998static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2999 /*
3000 * preset connection lists of input pins
3001 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3002 */
3003 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3004 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3005 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3006
3007 /*
3008 * Set pin mode and muting
3009 */
3010 /* set front pin widgets 0x14 for output */
3011 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3012 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3013 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3014 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3015 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3016 /* Mic2 (as headphone out) for HP output */
3017 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3018 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3019 /* Line In pin widget for input */
3020 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3021 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3022 /* Line2 (as front mic) pin widget for input and vref at 80% */
3023 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3024 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3025 /* CD pin widget for input */
3026 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3027
3028 { }
3029};
3030
3031/*
3032 * 5-stack pin configuration:
3033 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3034 * line-in/side = 0x1a, f-mic = 0x1b
3035 */
3036static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3037 /*
3038 * preset connection lists of input pins
3039 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3040 */
3041 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3042 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3043
3044 /*
3045 * Set pin mode and muting
3046 */
3047 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3049 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3050 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3051 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003052 /* unmute pins for output (no gain on this amp) */
3053 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3054 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3055 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3056 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3057
Linus Torvalds1da177e2005-04-16 15:20:36 -07003058 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003059 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003060 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3061 /* Mic2 (as headphone out) for HP output */
3062 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003063 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003064 /* Line In pin widget for input */
3065 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3066 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3067 /* Line2 (as front mic) pin widget for input and vref at 80% */
3068 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3069 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3070 /* CD pin widget for input */
3071 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003072
3073 { }
3074};
3075
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003076/*
3077 * W810 pin configuration:
3078 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3079 */
3080static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003081 /* hphone/speaker input selector: front DAC */
3082 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3083
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3085 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3086 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3088 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3089 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3090
3091 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003092 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003093
Linus Torvalds1da177e2005-04-16 15:20:36 -07003094 { }
3095};
3096
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003097/*
3098 * Z71V pin configuration:
3099 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3100 */
3101static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003102 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003103 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003104 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003105 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003106
Takashi Iwai16ded522005-06-10 19:58:24 +02003107 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003109 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003110 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003111
3112 { }
3113};
3114
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003115/*
3116 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003117 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3118 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003119 */
3120static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3121 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3122
Takashi Iwai16ded522005-06-10 19:58:24 +02003123 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003124 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003125 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003127 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003128 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003129 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003130 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3131
Takashi Iwai16ded522005-06-10 19:58:24 +02003132 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003134 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003135 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003136 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003137 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003138 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003140 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003141
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003142 { }
3143};
Takashi Iwai16ded522005-06-10 19:58:24 +02003144
Kailang Yangccc656c2006-10-17 12:32:26 +02003145/*
3146 * Uniwill pin configuration:
3147 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3148 * line = 0x1a
3149 */
3150static struct hda_verb alc880_uniwill_init_verbs[] = {
3151 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3152
3153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3154 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3155 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3157 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3158 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3159 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3160 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3161 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3163 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3164 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3165 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3166 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3167
3168 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3169 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3170 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3171 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3172 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3173 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3174 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3175 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3176 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3177
3178 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3179 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3180
3181 { }
3182};
3183
3184/*
3185* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003186* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003187 */
3188static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3189 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3190
3191 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3192 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3195 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3196 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3199 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3200 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3201 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3202 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3203
3204 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3205 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3206 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3207 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3208 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3209 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3210
3211 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3212 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3213
3214 { }
3215};
3216
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003217static struct hda_verb alc880_beep_init_verbs[] = {
3218 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3219 { }
3220};
3221
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003222/* auto-toggle front mic */
3223static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3224{
3225 unsigned int present;
3226 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003227
Wu Fengguang864f92b2009-11-18 12:38:02 +08003228 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003229 bits = present ? HDA_AMP_MUTE : 0;
3230 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003231}
3232
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003233static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003234{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003235 struct alc_spec *spec = codec->spec;
3236
3237 spec->autocfg.hp_pins[0] = 0x14;
3238 spec->autocfg.speaker_pins[0] = 0x15;
3239 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003240}
3241
3242static void alc880_uniwill_init_hook(struct hda_codec *codec)
3243{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003244 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003245 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003246}
3247
3248static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3249 unsigned int res)
3250{
3251 /* Looks like the unsol event is incompatible with the standard
3252 * definition. 4bit tag is placed at 28 bit!
3253 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003254 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003255 case ALC880_MIC_EVENT:
3256 alc880_uniwill_mic_automute(codec);
3257 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003258 default:
3259 alc_automute_amp_unsol_event(codec, res);
3260 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003261 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003262}
3263
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003264static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003265{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003266 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003267
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003268 spec->autocfg.hp_pins[0] = 0x14;
3269 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003270}
3271
3272static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3273{
3274 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003275
Kailang Yangccc656c2006-10-17 12:32:26 +02003276 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003277 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3278 present &= HDA_AMP_VOLMASK;
3279 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3280 HDA_AMP_VOLMASK, present);
3281 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3282 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003283}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003284
Kailang Yangccc656c2006-10-17 12:32:26 +02003285static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3286 unsigned int res)
3287{
3288 /* Looks like the unsol event is incompatible with the standard
3289 * definition. 4bit tag is placed at 28 bit!
3290 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003291 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003292 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003293 else
3294 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003295}
3296
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003297/*
3298 * F1734 pin configuration:
3299 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3300 */
3301static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003302 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003303 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3304 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3305 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3306 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3307
3308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3309 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3310 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3311 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3312
3313 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3314 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003315 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003316 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3317 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3318 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3319 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3320 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3321 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003322
Takashi Iwai937b4162008-02-11 14:52:36 +01003323 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3324 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3325
Takashi Iwai16ded522005-06-10 19:58:24 +02003326 { }
3327};
3328
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003329/*
3330 * ASUS pin configuration:
3331 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3332 */
3333static struct hda_verb alc880_pin_asus_init_verbs[] = {
3334 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3335 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3336 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3337 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3338
3339 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3340 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3341 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3342 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3343 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3344 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3345 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3346 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3347
3348 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3349 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3350 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3352 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3353 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3354 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3355 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3356 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003357
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003358 { }
3359};
3360
3361/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003362#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3363#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003364#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003365
Kailang Yangdf694da2005-12-05 19:42:22 +01003366/* Clevo m520g init */
3367static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3368 /* headphone output */
3369 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3370 /* line-out */
3371 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3372 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3373 /* Line-in */
3374 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3375 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3376 /* CD */
3377 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3378 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3379 /* Mic1 (rear panel) */
3380 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3381 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3382 /* Mic2 (front panel) */
3383 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3384 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3385 /* headphone */
3386 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3387 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3388 /* change to EAPD mode */
3389 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3390 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3391
3392 { }
3393};
3394
3395static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003396 /* change to EAPD mode */
3397 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3398 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3399
Kailang Yangdf694da2005-12-05 19:42:22 +01003400 /* Headphone output */
3401 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3402 /* Front output*/
3403 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3404 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3405
3406 /* Line In pin widget for input */
3407 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3408 /* CD pin widget for input */
3409 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3410 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3411 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3412
3413 /* change to EAPD mode */
3414 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3415 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3416
3417 { }
3418};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003419
3420/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003421 * LG m1 express dual
3422 *
3423 * Pin assignment:
3424 * Rear Line-In/Out (blue): 0x14
3425 * Build-in Mic-In: 0x15
3426 * Speaker-out: 0x17
3427 * HP-Out (green): 0x1b
3428 * Mic-In/Out (red): 0x19
3429 * SPDIF-Out: 0x1e
3430 */
3431
3432/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3433static hda_nid_t alc880_lg_dac_nids[3] = {
3434 0x05, 0x02, 0x03
3435};
3436
3437/* seems analog CD is not working */
3438static struct hda_input_mux alc880_lg_capture_source = {
3439 .num_items = 3,
3440 .items = {
3441 { "Mic", 0x1 },
3442 { "Line", 0x5 },
3443 { "Internal Mic", 0x6 },
3444 },
3445};
3446
3447/* 2,4,6 channel modes */
3448static struct hda_verb alc880_lg_ch2_init[] = {
3449 /* set line-in and mic-in to input */
3450 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3451 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3452 { }
3453};
3454
3455static struct hda_verb alc880_lg_ch4_init[] = {
3456 /* set line-in to out and mic-in to input */
3457 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3458 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3459 { }
3460};
3461
3462static struct hda_verb alc880_lg_ch6_init[] = {
3463 /* set line-in and mic-in to output */
3464 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3465 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3466 { }
3467};
3468
3469static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3470 { 2, alc880_lg_ch2_init },
3471 { 4, alc880_lg_ch4_init },
3472 { 6, alc880_lg_ch6_init },
3473};
3474
3475static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003476 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3477 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003478 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3479 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3480 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3481 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3482 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3483 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3485 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3486 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3487 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3488 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3489 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3490 {
3491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3492 .name = "Channel Mode",
3493 .info = alc_ch_mode_info,
3494 .get = alc_ch_mode_get,
3495 .put = alc_ch_mode_put,
3496 },
3497 { } /* end */
3498};
3499
3500static struct hda_verb alc880_lg_init_verbs[] = {
3501 /* set capture source to mic-in */
3502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3504 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3505 /* mute all amp mixer inputs */
3506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003509 /* line-in to input */
3510 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3511 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3512 /* built-in mic */
3513 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3514 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3515 /* speaker-out */
3516 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3517 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3518 /* mic-in to input */
3519 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3520 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3521 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3522 /* HP-out */
3523 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3524 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3525 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3526 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003527 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003528 { }
3529};
3530
3531/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003532static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003533{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003534 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003535
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003536 spec->autocfg.hp_pins[0] = 0x1b;
3537 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003538}
3539
3540/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003541 * LG LW20
3542 *
3543 * Pin assignment:
3544 * Speaker-out: 0x14
3545 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003546 * Built-in Mic-In: 0x19
3547 * Line-In: 0x1b
3548 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003549 * SPDIF-Out: 0x1e
3550 */
3551
Takashi Iwaid6815182006-03-23 16:06:23 +01003552static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003553 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003554 .items = {
3555 { "Mic", 0x0 },
3556 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003557 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003558 },
3559};
3560
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003561#define alc880_lg_lw_modes alc880_threestack_modes
3562
Takashi Iwaid6815182006-03-23 16:06:23 +01003563static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003564 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3565 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3566 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3567 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3568 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3569 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3570 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3571 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3572 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3573 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3575 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3576 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3577 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003578 {
3579 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3580 .name = "Channel Mode",
3581 .info = alc_ch_mode_info,
3582 .get = alc_ch_mode_get,
3583 .put = alc_ch_mode_put,
3584 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003585 { } /* end */
3586};
3587
3588static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003589 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3590 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3591 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3592
Takashi Iwaid6815182006-03-23 16:06:23 +01003593 /* set capture source to mic-in */
3594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3595 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3596 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003597 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003598 /* speaker-out */
3599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3601 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003602 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3603 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3604 /* mic-in to input */
3605 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3606 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3607 /* built-in mic */
3608 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3609 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3610 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003611 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003612 { }
3613};
3614
3615/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003616static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003617{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003618 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003619
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003620 spec->autocfg.hp_pins[0] = 0x1b;
3621 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003622}
3623
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003624static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3625 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3626 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3628 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3629 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3630 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3631 { } /* end */
3632};
3633
3634static struct hda_input_mux alc880_medion_rim_capture_source = {
3635 .num_items = 2,
3636 .items = {
3637 { "Mic", 0x0 },
3638 { "Internal Mic", 0x1 },
3639 },
3640};
3641
3642static struct hda_verb alc880_medion_rim_init_verbs[] = {
3643 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3644
3645 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3646 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3647
3648 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3649 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3650 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3651 /* Mic2 (as headphone out) for HP output */
3652 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3653 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3654 /* Internal Speaker */
3655 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3656 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3657
3658 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3659 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3660
3661 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3662 { }
3663};
3664
3665/* toggle speaker-output according to the hp-jack state */
3666static void alc880_medion_rim_automute(struct hda_codec *codec)
3667{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003668 struct alc_spec *spec = codec->spec;
3669 alc_automute_amp(codec);
3670 /* toggle EAPD */
3671 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003672 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3673 else
3674 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3675}
3676
3677static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3678 unsigned int res)
3679{
3680 /* Looks like the unsol event is incompatible with the standard
3681 * definition. 4bit tag is placed at 28 bit!
3682 */
3683 if ((res >> 28) == ALC880_HP_EVENT)
3684 alc880_medion_rim_automute(codec);
3685}
3686
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003687static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003688{
3689 struct alc_spec *spec = codec->spec;
3690
3691 spec->autocfg.hp_pins[0] = 0x14;
3692 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003693}
3694
Takashi Iwaicb53c622007-08-10 17:21:45 +02003695#ifdef CONFIG_SND_HDA_POWER_SAVE
3696static struct hda_amp_list alc880_loopbacks[] = {
3697 { 0x0b, HDA_INPUT, 0 },
3698 { 0x0b, HDA_INPUT, 1 },
3699 { 0x0b, HDA_INPUT, 2 },
3700 { 0x0b, HDA_INPUT, 3 },
3701 { 0x0b, HDA_INPUT, 4 },
3702 { } /* end */
3703};
3704
3705static struct hda_amp_list alc880_lg_loopbacks[] = {
3706 { 0x0b, HDA_INPUT, 1 },
3707 { 0x0b, HDA_INPUT, 6 },
3708 { 0x0b, HDA_INPUT, 7 },
3709 { } /* end */
3710};
3711#endif
3712
Takashi Iwaid6815182006-03-23 16:06:23 +01003713/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003714 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003715 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003716
Linus Torvalds1da177e2005-04-16 15:20:36 -07003717static int alc_init(struct hda_codec *codec)
3718{
3719 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003720 unsigned int i;
3721
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003722 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003723 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003724
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003725 for (i = 0; i < spec->num_init_verbs; i++)
3726 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003727
3728 if (spec->init_hook)
3729 spec->init_hook(codec);
3730
Takashi Iwaiad358792010-03-30 18:00:59 +02003731#ifdef CONFIG_SND_HDA_POWER_SAVE
3732 if (codec->patch_ops.check_power_status)
3733 codec->patch_ops.check_power_status(codec, 0x01);
3734#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003735 return 0;
3736}
3737
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003738static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3739{
3740 struct alc_spec *spec = codec->spec;
3741
3742 if (spec->unsol_event)
3743 spec->unsol_event(codec, res);
3744}
3745
Takashi Iwaicb53c622007-08-10 17:21:45 +02003746#ifdef CONFIG_SND_HDA_POWER_SAVE
3747static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3748{
3749 struct alc_spec *spec = codec->spec;
3750 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3751}
3752#endif
3753
Linus Torvalds1da177e2005-04-16 15:20:36 -07003754/*
3755 * Analog playback callbacks
3756 */
3757static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3758 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003759 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003760{
3761 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003762 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3763 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003764}
3765
3766static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3767 struct hda_codec *codec,
3768 unsigned int stream_tag,
3769 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003770 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003771{
3772 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003773 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3774 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003775}
3776
3777static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3778 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003779 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003780{
3781 struct alc_spec *spec = codec->spec;
3782 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3783}
3784
3785/*
3786 * Digital out
3787 */
3788static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3789 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003790 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003791{
3792 struct alc_spec *spec = codec->spec;
3793 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3794}
3795
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003796static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3797 struct hda_codec *codec,
3798 unsigned int stream_tag,
3799 unsigned int format,
3800 struct snd_pcm_substream *substream)
3801{
3802 struct alc_spec *spec = codec->spec;
3803 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3804 stream_tag, format, substream);
3805}
3806
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003807static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3808 struct hda_codec *codec,
3809 struct snd_pcm_substream *substream)
3810{
3811 struct alc_spec *spec = codec->spec;
3812 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3813}
3814
Linus Torvalds1da177e2005-04-16 15:20:36 -07003815static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3816 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003817 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003818{
3819 struct alc_spec *spec = codec->spec;
3820 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3821}
3822
3823/*
3824 * Analog capture
3825 */
Takashi Iwai63300792008-01-24 15:31:36 +01003826static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003827 struct hda_codec *codec,
3828 unsigned int stream_tag,
3829 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003830 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003831{
3832 struct alc_spec *spec = codec->spec;
3833
Takashi Iwai63300792008-01-24 15:31:36 +01003834 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003835 stream_tag, 0, format);
3836 return 0;
3837}
3838
Takashi Iwai63300792008-01-24 15:31:36 +01003839static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003840 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003841 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003842{
3843 struct alc_spec *spec = codec->spec;
3844
Takashi Iwai888afa12008-03-18 09:57:50 +01003845 snd_hda_codec_cleanup_stream(codec,
3846 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003847 return 0;
3848}
3849
Takashi Iwai840b64c2010-07-13 22:49:01 +02003850/* analog capture with dynamic dual-adc changes */
3851static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3852 struct hda_codec *codec,
3853 unsigned int stream_tag,
3854 unsigned int format,
3855 struct snd_pcm_substream *substream)
3856{
3857 struct alc_spec *spec = codec->spec;
3858 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3859 spec->cur_adc_stream_tag = stream_tag;
3860 spec->cur_adc_format = format;
3861 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3862 return 0;
3863}
3864
3865static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3866 struct hda_codec *codec,
3867 struct snd_pcm_substream *substream)
3868{
3869 struct alc_spec *spec = codec->spec;
3870 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
3871 spec->cur_adc = 0;
3872 return 0;
3873}
3874
3875static struct hda_pcm_stream dualmic_pcm_analog_capture = {
3876 .substreams = 1,
3877 .channels_min = 2,
3878 .channels_max = 2,
3879 .nid = 0, /* fill later */
3880 .ops = {
3881 .prepare = dualmic_capture_pcm_prepare,
3882 .cleanup = dualmic_capture_pcm_cleanup
3883 },
3884};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003885
3886/*
3887 */
3888static struct hda_pcm_stream alc880_pcm_analog_playback = {
3889 .substreams = 1,
3890 .channels_min = 2,
3891 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003892 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003893 .ops = {
3894 .open = alc880_playback_pcm_open,
3895 .prepare = alc880_playback_pcm_prepare,
3896 .cleanup = alc880_playback_pcm_cleanup
3897 },
3898};
3899
3900static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003901 .substreams = 1,
3902 .channels_min = 2,
3903 .channels_max = 2,
3904 /* NID is set in alc_build_pcms */
3905};
3906
3907static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3908 .substreams = 1,
3909 .channels_min = 2,
3910 .channels_max = 2,
3911 /* NID is set in alc_build_pcms */
3912};
3913
3914static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3915 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003916 .channels_min = 2,
3917 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003918 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003919 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003920 .prepare = alc880_alt_capture_pcm_prepare,
3921 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003922 },
3923};
3924
3925static struct hda_pcm_stream alc880_pcm_digital_playback = {
3926 .substreams = 1,
3927 .channels_min = 2,
3928 .channels_max = 2,
3929 /* NID is set in alc_build_pcms */
3930 .ops = {
3931 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003932 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003933 .prepare = alc880_dig_playback_pcm_prepare,
3934 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003935 },
3936};
3937
3938static struct hda_pcm_stream alc880_pcm_digital_capture = {
3939 .substreams = 1,
3940 .channels_min = 2,
3941 .channels_max = 2,
3942 /* NID is set in alc_build_pcms */
3943};
3944
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003945/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003946static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003947 .substreams = 0,
3948 .channels_min = 0,
3949 .channels_max = 0,
3950};
3951
Linus Torvalds1da177e2005-04-16 15:20:36 -07003952static int alc_build_pcms(struct hda_codec *codec)
3953{
3954 struct alc_spec *spec = codec->spec;
3955 struct hda_pcm *info = spec->pcm_rec;
3956 int i;
3957
3958 codec->num_pcms = 1;
3959 codec->pcm_info = info;
3960
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003961 if (spec->no_analog)
3962 goto skip_analog;
3963
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003964 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3965 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003966 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003967
Takashi Iwai4a471b72005-12-07 13:56:29 +01003968 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003969 if (snd_BUG_ON(!spec->multiout.dac_nids))
3970 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003971 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3972 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3973 }
3974 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003975 if (snd_BUG_ON(!spec->adc_nids))
3976 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003977 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3978 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3979 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003980
Takashi Iwai4a471b72005-12-07 13:56:29 +01003981 if (spec->channel_mode) {
3982 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3983 for (i = 0; i < spec->num_channel_mode; i++) {
3984 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3985 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3986 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003987 }
3988 }
3989
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003990 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003991 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003992 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003993 snprintf(spec->stream_name_digital,
3994 sizeof(spec->stream_name_digital),
3995 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003996 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003997 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003998 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003999 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004000 if (spec->dig_out_type)
4001 info->pcm_type = spec->dig_out_type;
4002 else
4003 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004004 if (spec->multiout.dig_out_nid &&
4005 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004006 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4007 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4008 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004009 if (spec->dig_in_nid &&
4010 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004011 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4012 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4013 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004014 /* FIXME: do we need this for all Realtek codec models? */
4015 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004016 }
4017
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004018 if (spec->no_analog)
4019 return 0;
4020
Takashi Iwaie08a0072006-09-07 17:52:14 +02004021 /* If the use of more than one ADC is requested for the current
4022 * model, configure a second analog capture-only PCM.
4023 */
4024 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004025 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4026 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004027 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004028 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004029 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004030 if (spec->alt_dac_nid) {
4031 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4032 *spec->stream_analog_alt_playback;
4033 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4034 spec->alt_dac_nid;
4035 } else {
4036 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4037 alc_pcm_null_stream;
4038 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4039 }
4040 if (spec->num_adc_nids > 1) {
4041 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4042 *spec->stream_analog_alt_capture;
4043 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4044 spec->adc_nids[1];
4045 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4046 spec->num_adc_nids - 1;
4047 } else {
4048 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4049 alc_pcm_null_stream;
4050 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004051 }
4052 }
4053
Linus Torvalds1da177e2005-04-16 15:20:36 -07004054 return 0;
4055}
4056
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004057static inline void alc_shutup(struct hda_codec *codec)
4058{
4059 snd_hda_shutup_pins(codec);
4060}
4061
Takashi Iwai603c4012008-07-30 15:01:44 +02004062static void alc_free_kctls(struct hda_codec *codec)
4063{
4064 struct alc_spec *spec = codec->spec;
4065
4066 if (spec->kctls.list) {
4067 struct snd_kcontrol_new *kctl = spec->kctls.list;
4068 int i;
4069 for (i = 0; i < spec->kctls.used; i++)
4070 kfree(kctl[i].name);
4071 }
4072 snd_array_free(&spec->kctls);
4073}
4074
Linus Torvalds1da177e2005-04-16 15:20:36 -07004075static void alc_free(struct hda_codec *codec)
4076{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004077 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004078
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004079 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004080 return;
4081
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004082 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004083 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004084 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004085 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004086}
4087
Hector Martinf5de24b2009-12-20 22:51:31 +01004088#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004089static void alc_power_eapd(struct hda_codec *codec)
4090{
4091 /* We currently only handle front, HP */
4092 switch (codec->vendor_id) {
4093 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004094 set_eapd(codec, 0x0f, 0);
4095 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004096 break;
4097 case 0x10ec0262:
4098 case 0x10ec0267:
4099 case 0x10ec0268:
4100 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004101 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004102 case 0x10ec0272:
4103 case 0x10ec0660:
4104 case 0x10ec0662:
4105 case 0x10ec0663:
4106 case 0x10ec0862:
4107 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004108 set_eapd(codec, 0x14, 0);
4109 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004110 break;
4111 }
4112}
4113
Hector Martinf5de24b2009-12-20 22:51:31 +01004114static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4115{
4116 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004117 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004118 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004119 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004120 return 0;
4121}
4122#endif
4123
Takashi Iwaie044c392008-10-27 16:56:24 +01004124#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004125static int alc_resume(struct hda_codec *codec)
4126{
Takashi Iwaie044c392008-10-27 16:56:24 +01004127 codec->patch_ops.init(codec);
4128 snd_hda_codec_resume_amp(codec);
4129 snd_hda_codec_resume_cache(codec);
Takashi Iwaiad358792010-03-30 18:00:59 +02004130#ifdef CONFIG_SND_HDA_POWER_SAVE
4131 if (codec->patch_ops.check_power_status)
4132 codec->patch_ops.check_power_status(codec, 0x01);
4133#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01004134 return 0;
4135}
Takashi Iwaie044c392008-10-27 16:56:24 +01004136#endif
4137
Linus Torvalds1da177e2005-04-16 15:20:36 -07004138/*
4139 */
4140static struct hda_codec_ops alc_patch_ops = {
4141 .build_controls = alc_build_controls,
4142 .build_pcms = alc_build_pcms,
4143 .init = alc_init,
4144 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004145 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004146#ifdef SND_HDA_NEEDS_RESUME
4147 .resume = alc_resume,
4148#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004149#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004150 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004151 .check_power_status = alc_check_power_status,
4152#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004153 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004154};
4155
Kailang Yangc027ddc2010-03-19 11:33:06 +01004156/* replace the codec chip_name with the given string */
4157static int alc_codec_rename(struct hda_codec *codec, const char *name)
4158{
4159 kfree(codec->chip_name);
4160 codec->chip_name = kstrdup(name, GFP_KERNEL);
4161 if (!codec->chip_name) {
4162 alc_free(codec);
4163 return -ENOMEM;
4164 }
4165 return 0;
4166}
4167
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004168/*
4169 * Test configuration for debugging
4170 *
4171 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4172 * enum controls.
4173 */
4174#ifdef CONFIG_SND_DEBUG
4175static hda_nid_t alc880_test_dac_nids[4] = {
4176 0x02, 0x03, 0x04, 0x05
4177};
4178
4179static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004180 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004181 .items = {
4182 { "In-1", 0x0 },
4183 { "In-2", 0x1 },
4184 { "In-3", 0x2 },
4185 { "In-4", 0x3 },
4186 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004187 { "Front", 0x5 },
4188 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004189 },
4190};
4191
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004192static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004193 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004194 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004195 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004196 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004197};
4198
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004199static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4200 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004201{
4202 static char *texts[] = {
4203 "N/A", "Line Out", "HP Out",
4204 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4205 };
4206 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4207 uinfo->count = 1;
4208 uinfo->value.enumerated.items = 8;
4209 if (uinfo->value.enumerated.item >= 8)
4210 uinfo->value.enumerated.item = 7;
4211 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4212 return 0;
4213}
4214
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004215static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4216 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004217{
4218 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4219 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4220 unsigned int pin_ctl, item = 0;
4221
4222 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4223 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4224 if (pin_ctl & AC_PINCTL_OUT_EN) {
4225 if (pin_ctl & AC_PINCTL_HP_EN)
4226 item = 2;
4227 else
4228 item = 1;
4229 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4230 switch (pin_ctl & AC_PINCTL_VREFEN) {
4231 case AC_PINCTL_VREF_HIZ: item = 3; break;
4232 case AC_PINCTL_VREF_50: item = 4; break;
4233 case AC_PINCTL_VREF_GRD: item = 5; break;
4234 case AC_PINCTL_VREF_80: item = 6; break;
4235 case AC_PINCTL_VREF_100: item = 7; break;
4236 }
4237 }
4238 ucontrol->value.enumerated.item[0] = item;
4239 return 0;
4240}
4241
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004242static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4243 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004244{
4245 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4246 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4247 static unsigned int ctls[] = {
4248 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4249 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4250 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4251 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4252 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4253 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4254 };
4255 unsigned int old_ctl, new_ctl;
4256
4257 old_ctl = snd_hda_codec_read(codec, nid, 0,
4258 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4259 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4260 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004261 int val;
4262 snd_hda_codec_write_cache(codec, nid, 0,
4263 AC_VERB_SET_PIN_WIDGET_CONTROL,
4264 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004265 val = ucontrol->value.enumerated.item[0] >= 3 ?
4266 HDA_AMP_MUTE : 0;
4267 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4268 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004269 return 1;
4270 }
4271 return 0;
4272}
4273
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004274static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4275 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004276{
4277 static char *texts[] = {
4278 "Front", "Surround", "CLFE", "Side"
4279 };
4280 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4281 uinfo->count = 1;
4282 uinfo->value.enumerated.items = 4;
4283 if (uinfo->value.enumerated.item >= 4)
4284 uinfo->value.enumerated.item = 3;
4285 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4286 return 0;
4287}
4288
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004289static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4290 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004291{
4292 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4293 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4294 unsigned int sel;
4295
4296 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4297 ucontrol->value.enumerated.item[0] = sel & 3;
4298 return 0;
4299}
4300
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004301static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4302 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004303{
4304 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4305 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4306 unsigned int sel;
4307
4308 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4309 if (ucontrol->value.enumerated.item[0] != sel) {
4310 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004311 snd_hda_codec_write_cache(codec, nid, 0,
4312 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004313 return 1;
4314 }
4315 return 0;
4316}
4317
4318#define PIN_CTL_TEST(xname,nid) { \
4319 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4320 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004321 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004322 .info = alc_test_pin_ctl_info, \
4323 .get = alc_test_pin_ctl_get, \
4324 .put = alc_test_pin_ctl_put, \
4325 .private_value = nid \
4326 }
4327
4328#define PIN_SRC_TEST(xname,nid) { \
4329 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4330 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004331 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004332 .info = alc_test_pin_src_info, \
4333 .get = alc_test_pin_src_get, \
4334 .put = alc_test_pin_src_put, \
4335 .private_value = nid \
4336 }
4337
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004338static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004339 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4340 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4341 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4342 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004343 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4344 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4345 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4346 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004347 PIN_CTL_TEST("Front Pin Mode", 0x14),
4348 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4349 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4350 PIN_CTL_TEST("Side Pin Mode", 0x17),
4351 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4352 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4353 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4354 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4355 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4356 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4357 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4358 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4359 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4360 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4361 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4362 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4363 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4364 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4365 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4366 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4367 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4368 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004369 {
4370 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4371 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004372 .info = alc_ch_mode_info,
4373 .get = alc_ch_mode_get,
4374 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004375 },
4376 { } /* end */
4377};
4378
4379static struct hda_verb alc880_test_init_verbs[] = {
4380 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4383 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4387 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4388 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004389 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004390 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4391 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4392 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4393 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004394 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004395 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4396 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4397 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4398 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004399 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004400 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4401 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4402 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4403 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004404 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004405 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4406 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004407 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4408 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4409 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004410 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4412 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4413 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4414 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004415 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004417 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004418 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004419 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004420 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004421 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004422 /* Analog input/passthru */
4423 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4424 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4425 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4426 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4427 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004428 { }
4429};
4430#endif
4431
Linus Torvalds1da177e2005-04-16 15:20:36 -07004432/*
4433 */
4434
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004435static const char *alc880_models[ALC880_MODEL_LAST] = {
4436 [ALC880_3ST] = "3stack",
4437 [ALC880_TCL_S700] = "tcl",
4438 [ALC880_3ST_DIG] = "3stack-digout",
4439 [ALC880_CLEVO] = "clevo",
4440 [ALC880_5ST] = "5stack",
4441 [ALC880_5ST_DIG] = "5stack-digout",
4442 [ALC880_W810] = "w810",
4443 [ALC880_Z71V] = "z71v",
4444 [ALC880_6ST] = "6stack",
4445 [ALC880_6ST_DIG] = "6stack-digout",
4446 [ALC880_ASUS] = "asus",
4447 [ALC880_ASUS_W1V] = "asus-w1v",
4448 [ALC880_ASUS_DIG] = "asus-dig",
4449 [ALC880_ASUS_DIG2] = "asus-dig2",
4450 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004451 [ALC880_UNIWILL_P53] = "uniwill-p53",
4452 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004453 [ALC880_F1734] = "F1734",
4454 [ALC880_LG] = "lg",
4455 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004456 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004457#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004458 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004459#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004460 [ALC880_AUTO] = "auto",
4461};
4462
4463static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004464 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004465 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4466 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4467 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4468 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4469 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4470 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4471 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4472 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004473 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4474 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004475 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4476 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4477 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4478 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4479 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4480 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4481 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4482 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4483 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4484 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004485 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004486 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4487 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4488 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004489 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004490 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004491 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4492 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004493 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4494 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004495 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4496 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4497 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4498 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004499 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4500 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004501 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004502 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004503 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004504 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004505 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4506 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004507 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004508 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004509 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004510 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004511 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004512 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004513 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004514 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004515 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004516 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4517 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004518 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004519 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4520 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4521 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4522 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004523 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4524 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004525 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004526 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004527 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4528 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004529 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4530 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4531 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004532 /* default Intel */
4533 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004534 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4535 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004536 {}
4537};
4538
Takashi Iwai16ded522005-06-10 19:58:24 +02004539/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004540 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004541 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004542static struct alc_config_preset alc880_presets[] = {
4543 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004544 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004545 .init_verbs = { alc880_volume_init_verbs,
4546 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004547 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004548 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004549 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4550 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004551 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004552 .input_mux = &alc880_capture_source,
4553 },
4554 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004555 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004556 .init_verbs = { alc880_volume_init_verbs,
4557 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004558 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004559 .dac_nids = alc880_dac_nids,
4560 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004561 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4562 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004563 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004564 .input_mux = &alc880_capture_source,
4565 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004566 [ALC880_TCL_S700] = {
4567 .mixers = { alc880_tcl_s700_mixer },
4568 .init_verbs = { alc880_volume_init_verbs,
4569 alc880_pin_tcl_S700_init_verbs,
4570 alc880_gpio2_init_verbs },
4571 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4572 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004573 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4574 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004575 .hp_nid = 0x03,
4576 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4577 .channel_mode = alc880_2_jack_modes,
4578 .input_mux = &alc880_capture_source,
4579 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004580 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004581 .mixers = { alc880_three_stack_mixer,
4582 alc880_five_stack_mixer},
4583 .init_verbs = { alc880_volume_init_verbs,
4584 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004585 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4586 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004587 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4588 .channel_mode = alc880_fivestack_modes,
4589 .input_mux = &alc880_capture_source,
4590 },
4591 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004592 .mixers = { alc880_three_stack_mixer,
4593 alc880_five_stack_mixer },
4594 .init_verbs = { alc880_volume_init_verbs,
4595 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004596 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4597 .dac_nids = alc880_dac_nids,
4598 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004599 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4600 .channel_mode = alc880_fivestack_modes,
4601 .input_mux = &alc880_capture_source,
4602 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004603 [ALC880_6ST] = {
4604 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004605 .init_verbs = { alc880_volume_init_verbs,
4606 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004607 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4608 .dac_nids = alc880_6st_dac_nids,
4609 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4610 .channel_mode = alc880_sixstack_modes,
4611 .input_mux = &alc880_6stack_capture_source,
4612 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004613 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004614 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004615 .init_verbs = { alc880_volume_init_verbs,
4616 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004617 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4618 .dac_nids = alc880_6st_dac_nids,
4619 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004620 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4621 .channel_mode = alc880_sixstack_modes,
4622 .input_mux = &alc880_6stack_capture_source,
4623 },
4624 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004625 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004626 .init_verbs = { alc880_volume_init_verbs,
4627 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004628 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004629 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4630 .dac_nids = alc880_w810_dac_nids,
4631 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004632 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4633 .channel_mode = alc880_w810_modes,
4634 .input_mux = &alc880_capture_source,
4635 },
4636 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004637 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004638 .init_verbs = { alc880_volume_init_verbs,
4639 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004640 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4641 .dac_nids = alc880_z71v_dac_nids,
4642 .dig_out_nid = ALC880_DIGOUT_NID,
4643 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004644 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4645 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004646 .input_mux = &alc880_capture_source,
4647 },
4648 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004649 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004650 .init_verbs = { alc880_volume_init_verbs,
4651 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004652 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4653 .dac_nids = alc880_f1734_dac_nids,
4654 .hp_nid = 0x02,
4655 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4656 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004657 .input_mux = &alc880_f1734_capture_source,
4658 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004659 .setup = alc880_uniwill_p53_setup,
4660 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004661 },
4662 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004663 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004664 .init_verbs = { alc880_volume_init_verbs,
4665 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004666 alc880_gpio1_init_verbs },
4667 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4668 .dac_nids = alc880_asus_dac_nids,
4669 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4670 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004671 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004672 .input_mux = &alc880_capture_source,
4673 },
4674 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004675 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004676 .init_verbs = { alc880_volume_init_verbs,
4677 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004678 alc880_gpio1_init_verbs },
4679 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4680 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004681 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004682 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4683 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004684 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004685 .input_mux = &alc880_capture_source,
4686 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004687 [ALC880_ASUS_DIG2] = {
4688 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004689 .init_verbs = { alc880_volume_init_verbs,
4690 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004691 alc880_gpio2_init_verbs }, /* use GPIO2 */
4692 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4693 .dac_nids = alc880_asus_dac_nids,
4694 .dig_out_nid = ALC880_DIGOUT_NID,
4695 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4696 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004697 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004698 .input_mux = &alc880_capture_source,
4699 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004700 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004701 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004702 .init_verbs = { alc880_volume_init_verbs,
4703 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004704 alc880_gpio1_init_verbs },
4705 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4706 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004707 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004708 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4709 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004710 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004711 .input_mux = &alc880_capture_source,
4712 },
4713 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004714 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004715 .init_verbs = { alc880_volume_init_verbs,
4716 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004717 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4718 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004719 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004720 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4721 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004722 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004723 .input_mux = &alc880_capture_source,
4724 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004725 [ALC880_UNIWILL] = {
4726 .mixers = { alc880_uniwill_mixer },
4727 .init_verbs = { alc880_volume_init_verbs,
4728 alc880_uniwill_init_verbs },
4729 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4730 .dac_nids = alc880_asus_dac_nids,
4731 .dig_out_nid = ALC880_DIGOUT_NID,
4732 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4733 .channel_mode = alc880_threestack_modes,
4734 .need_dac_fix = 1,
4735 .input_mux = &alc880_capture_source,
4736 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004737 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004738 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004739 },
4740 [ALC880_UNIWILL_P53] = {
4741 .mixers = { alc880_uniwill_p53_mixer },
4742 .init_verbs = { alc880_volume_init_verbs,
4743 alc880_uniwill_p53_init_verbs },
4744 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4745 .dac_nids = alc880_asus_dac_nids,
4746 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004747 .channel_mode = alc880_threestack_modes,
4748 .input_mux = &alc880_capture_source,
4749 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004750 .setup = alc880_uniwill_p53_setup,
4751 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004752 },
4753 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004754 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004755 .init_verbs = { alc880_volume_init_verbs,
4756 alc880_uniwill_p53_init_verbs,
4757 alc880_beep_init_verbs },
4758 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4759 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004760 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004761 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4762 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004763 .input_mux = &alc880_capture_source,
4764 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004765 .setup = alc880_uniwill_p53_setup,
4766 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004767 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004768 [ALC880_CLEVO] = {
4769 .mixers = { alc880_three_stack_mixer },
4770 .init_verbs = { alc880_volume_init_verbs,
4771 alc880_pin_clevo_init_verbs },
4772 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4773 .dac_nids = alc880_dac_nids,
4774 .hp_nid = 0x03,
4775 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4776 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004777 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004778 .input_mux = &alc880_capture_source,
4779 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004780 [ALC880_LG] = {
4781 .mixers = { alc880_lg_mixer },
4782 .init_verbs = { alc880_volume_init_verbs,
4783 alc880_lg_init_verbs },
4784 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4785 .dac_nids = alc880_lg_dac_nids,
4786 .dig_out_nid = ALC880_DIGOUT_NID,
4787 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4788 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004789 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004790 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004791 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004792 .setup = alc880_lg_setup,
4793 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004794#ifdef CONFIG_SND_HDA_POWER_SAVE
4795 .loopbacks = alc880_lg_loopbacks,
4796#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004797 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004798 [ALC880_LG_LW] = {
4799 .mixers = { alc880_lg_lw_mixer },
4800 .init_verbs = { alc880_volume_init_verbs,
4801 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004802 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004803 .dac_nids = alc880_dac_nids,
4804 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004805 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4806 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004807 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004808 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004809 .setup = alc880_lg_lw_setup,
4810 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004811 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004812 [ALC880_MEDION_RIM] = {
4813 .mixers = { alc880_medion_rim_mixer },
4814 .init_verbs = { alc880_volume_init_verbs,
4815 alc880_medion_rim_init_verbs,
4816 alc_gpio2_init_verbs },
4817 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4818 .dac_nids = alc880_dac_nids,
4819 .dig_out_nid = ALC880_DIGOUT_NID,
4820 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4821 .channel_mode = alc880_2_jack_modes,
4822 .input_mux = &alc880_medion_rim_capture_source,
4823 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004824 .setup = alc880_medion_rim_setup,
4825 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004826 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004827#ifdef CONFIG_SND_DEBUG
4828 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004829 .mixers = { alc880_test_mixer },
4830 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004831 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4832 .dac_nids = alc880_test_dac_nids,
4833 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004834 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4835 .channel_mode = alc880_test_modes,
4836 .input_mux = &alc880_test_capture_source,
4837 },
4838#endif
4839};
4840
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004841/*
4842 * Automatic parse of I/O pins from the BIOS configuration
4843 */
4844
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004845enum {
4846 ALC_CTL_WIDGET_VOL,
4847 ALC_CTL_WIDGET_MUTE,
4848 ALC_CTL_BIND_MUTE,
4849};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004850static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004851 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4852 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004853 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004854};
4855
4856/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004857static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004858 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004859{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004860 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004861
Takashi Iwai603c4012008-07-30 15:01:44 +02004862 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4863 knew = snd_array_new(&spec->kctls);
4864 if (!knew)
4865 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004866 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004867 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004868 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004869 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004870 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004871 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004872 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004873 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004874 return 0;
4875}
4876
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004877static int add_control_with_pfx(struct alc_spec *spec, int type,
4878 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004879 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004880{
4881 char name[32];
4882 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004883 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004884}
4885
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004886#define add_pb_vol_ctrl(spec, type, pfx, val) \
4887 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
4888#define add_pb_sw_ctrl(spec, type, pfx, val) \
4889 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
4890#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
4891 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
4892#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
4893 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004894
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004895#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4896#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4897#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4898#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004899#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4900#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4901#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4902#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4903#define ALC880_PIN_CD_NID 0x1c
4904
4905/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004906static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4907 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004908{
4909 hda_nid_t nid;
4910 int assigned[4];
4911 int i, j;
4912
4913 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004914 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004915
4916 /* check the pins hardwired to audio widget */
4917 for (i = 0; i < cfg->line_outs; i++) {
4918 nid = cfg->line_out_pins[i];
4919 if (alc880_is_fixed_pin(nid)) {
4920 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004921 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004922 assigned[idx] = 1;
4923 }
4924 }
4925 /* left pins can be connect to any audio widget */
4926 for (i = 0; i < cfg->line_outs; i++) {
4927 nid = cfg->line_out_pins[i];
4928 if (alc880_is_fixed_pin(nid))
4929 continue;
4930 /* search for an empty channel */
4931 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004932 if (!assigned[j]) {
4933 spec->multiout.dac_nids[i] =
4934 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004935 assigned[j] = 1;
4936 break;
4937 }
4938 }
4939 }
4940 spec->multiout.num_dacs = cfg->line_outs;
4941 return 0;
4942}
4943
4944/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004945static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4946 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004947{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004948 static const char *chname[4] = {
4949 "Front", "Surround", NULL /*CLFE*/, "Side"
4950 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004951 hda_nid_t nid;
4952 int i, err;
4953
4954 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004955 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004956 continue;
4957 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4958 if (i == 2) {
4959 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004960 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4961 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004962 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4963 HDA_OUTPUT));
4964 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004965 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004966 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4967 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004968 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4969 HDA_OUTPUT));
4970 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004971 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004972 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4973 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004974 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4975 HDA_INPUT));
4976 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004977 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004978 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4979 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004980 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4981 HDA_INPUT));
4982 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004983 return err;
4984 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004985 const char *pfx;
4986 if (cfg->line_outs == 1 &&
4987 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4988 pfx = "Speaker";
4989 else
4990 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004991 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004992 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4993 HDA_OUTPUT));
4994 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004995 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004996 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004997 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4998 HDA_INPUT));
4999 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005000 return err;
5001 }
5002 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005003 return 0;
5004}
5005
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005006/* add playback controls for speaker and HP outputs */
5007static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5008 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005009{
5010 hda_nid_t nid;
5011 int err;
5012
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005013 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005014 return 0;
5015
5016 if (alc880_is_fixed_pin(pin)) {
5017 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005018 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005019 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005020 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005021 else
5022 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005023 /* control HP volume/switch on the output mixer amp */
5024 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005025 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005026 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5027 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005028 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005029 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005030 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5031 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005032 return err;
5033 } else if (alc880_is_multi_pin(pin)) {
5034 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005035 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005036 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5038 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005039 return err;
5040 }
5041 return 0;
5042}
5043
5044/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005045static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005046 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005047 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005048{
Kailang Yangdf694da2005-12-05 19:42:22 +01005049 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005050
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005051 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005052 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5053 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005054 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005055 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005056 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5057 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005058 return err;
5059 return 0;
5060}
5061
Takashi Iwai05f5f472009-08-25 13:10:18 +02005062static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005063{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005064 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5065 return (pincap & AC_PINCAP_IN) != 0;
5066}
5067
5068/* create playback/capture controls for input pins */
5069static int alc_auto_create_input_ctls(struct hda_codec *codec,
5070 const struct auto_pin_cfg *cfg,
5071 hda_nid_t mixer,
5072 hda_nid_t cap1, hda_nid_t cap2)
5073{
5074 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005075 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005076 int i, err, idx, type, type_idx = 0;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005077
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005078 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005079 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005080 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005081
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005082 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005083 if (!alc_is_input_pin(codec, pin))
5084 continue;
5085
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005086 type = cfg->inputs[i].type;
5087 if (i > 0 && type == cfg->inputs[i - 1].type)
5088 type_idx++;
5089 else
5090 type_idx = 0;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005091 label = hda_get_autocfg_input_label(codec, cfg, i);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005092 if (mixer) {
5093 idx = get_connection_index(codec, mixer, pin);
5094 if (idx >= 0) {
5095 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005096 label, type_idx,
5097 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005098 if (err < 0)
5099 return err;
5100 }
5101 }
5102
5103 if (!cap1)
5104 continue;
5105 idx = get_connection_index(codec, cap1, pin);
5106 if (idx < 0 && cap2)
5107 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005108 if (idx >= 0)
5109 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005110 }
5111 return 0;
5112}
5113
Takashi Iwai05f5f472009-08-25 13:10:18 +02005114static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5115 const struct auto_pin_cfg *cfg)
5116{
5117 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5118}
5119
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005120static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5121 unsigned int pin_type)
5122{
5123 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5124 pin_type);
5125 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005126 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5127 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005128}
5129
Kailang Yangdf694da2005-12-05 19:42:22 +01005130static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5131 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005132 int dac_idx)
5133{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005134 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005135 /* need the manual connection? */
5136 if (alc880_is_multi_pin(nid)) {
5137 struct alc_spec *spec = codec->spec;
5138 int idx = alc880_multi_pin_idx(nid);
5139 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5140 AC_VERB_SET_CONNECT_SEL,
5141 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5142 }
5143}
5144
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005145static int get_pin_type(int line_out_type)
5146{
5147 if (line_out_type == AUTO_PIN_HP_OUT)
5148 return PIN_HP;
5149 else
5150 return PIN_OUT;
5151}
5152
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005153static void alc880_auto_init_multi_out(struct hda_codec *codec)
5154{
5155 struct alc_spec *spec = codec->spec;
5156 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005157
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005158 for (i = 0; i < spec->autocfg.line_outs; i++) {
5159 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005160 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5161 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005162 }
5163}
5164
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005165static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005166{
5167 struct alc_spec *spec = codec->spec;
5168 hda_nid_t pin;
5169
Takashi Iwai82bc9552006-03-21 11:24:42 +01005170 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005171 if (pin) /* connect to front */
5172 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005173 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005174 if (pin) /* connect to front */
5175 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5176}
5177
5178static void alc880_auto_init_analog_input(struct hda_codec *codec)
5179{
5180 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005181 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005182 int i;
5183
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005184 for (i = 0; i < cfg->num_inputs; i++) {
5185 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005186 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005187 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005188 if (nid != ALC880_PIN_CD_NID &&
5189 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005190 snd_hda_codec_write(codec, nid, 0,
5191 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005192 AMP_OUT_MUTE);
5193 }
5194 }
5195}
5196
Takashi Iwai7f311a42010-04-09 17:32:23 +02005197static void alc880_auto_init_input_src(struct hda_codec *codec)
5198{
5199 struct alc_spec *spec = codec->spec;
5200 int c;
5201
5202 for (c = 0; c < spec->num_adc_nids; c++) {
5203 unsigned int mux_idx;
5204 const struct hda_input_mux *imux;
5205 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5206 imux = &spec->input_mux[mux_idx];
5207 if (!imux->num_items && mux_idx > 0)
5208 imux = &spec->input_mux[0];
5209 if (imux)
5210 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5211 AC_VERB_SET_CONNECT_SEL,
5212 imux->items[0].index);
5213 }
5214}
5215
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005216/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005217/* return 1 if successful, 0 if the proper config is not found,
5218 * or a negative error code
5219 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005220static int alc880_parse_auto_config(struct hda_codec *codec)
5221{
5222 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005223 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005224 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005225
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005226 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5227 alc880_ignore);
5228 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005229 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005230 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005231 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005232
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005233 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5234 if (err < 0)
5235 return err;
5236 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5237 if (err < 0)
5238 return err;
5239 err = alc880_auto_create_extra_out(spec,
5240 spec->autocfg.speaker_pins[0],
5241 "Speaker");
5242 if (err < 0)
5243 return err;
5244 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5245 "Headphone");
5246 if (err < 0)
5247 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005248 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005249 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005250 return err;
5251
5252 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5253
Takashi Iwai757899a2010-07-30 10:48:14 +02005254 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005255
Takashi Iwai603c4012008-07-30 15:01:44 +02005256 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005257 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005258
Takashi Iwaid88897e2008-10-31 15:01:37 +01005259 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005260
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005261 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005262 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005263
Kailang Yang6227cdc2010-02-25 08:36:52 +01005264 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005265
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005266 return 1;
5267}
5268
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005269/* additional initialization for auto-configuration model */
5270static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005271{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005272 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005273 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005274 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005275 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005276 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005277 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005278 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005279 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005280}
5281
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005282/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5283 * one of two digital mic pins, e.g. on ALC272
5284 */
5285static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005286{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005287 struct alc_spec *spec = codec->spec;
5288 int i;
5289
5290 for (i = 0; i < spec->num_adc_nids; i++) {
5291 hda_nid_t cap = spec->capsrc_nids ?
5292 spec->capsrc_nids[i] : spec->adc_nids[i];
5293 int iidx, eidx;
5294
5295 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5296 if (iidx < 0)
5297 continue;
5298 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5299 if (eidx < 0)
5300 continue;
5301 spec->int_mic.mux_idx = iidx;
5302 spec->ext_mic.mux_idx = eidx;
5303 if (spec->capsrc_nids)
5304 spec->capsrc_nids += i;
5305 spec->adc_nids += i;
5306 spec->num_adc_nids = 1;
5307 return;
5308 }
5309 snd_printd(KERN_INFO "hda_codec: %s: "
5310 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5311 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5312 spec->auto_mic = 0; /* disable auto-mic to be sure */
5313}
5314
Takashi Iwai748cce42010-08-04 07:37:39 +02005315/* select or unmute the given capsrc route */
5316static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5317 int idx)
5318{
5319 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5320 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5321 HDA_AMP_MUTE, 0);
5322 } else {
5323 snd_hda_codec_write_cache(codec, cap, 0,
5324 AC_VERB_SET_CONNECT_SEL, idx);
5325 }
5326}
5327
Takashi Iwai840b64c2010-07-13 22:49:01 +02005328/* set the default connection to that pin */
5329static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5330{
5331 struct alc_spec *spec = codec->spec;
5332 int i;
5333
5334 for (i = 0; i < spec->num_adc_nids; i++) {
5335 hda_nid_t cap = spec->capsrc_nids ?
5336 spec->capsrc_nids[i] : spec->adc_nids[i];
5337 int idx;
5338
5339 idx = get_connection_index(codec, cap, pin);
5340 if (idx < 0)
5341 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005342 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005343 return i; /* return the found index */
5344 }
5345 return -1; /* not found */
5346}
5347
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005348/* choose the ADC/MUX containing the input pin and initialize the setup */
5349static void fixup_single_adc(struct hda_codec *codec)
5350{
5351 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005352 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005353 int i;
5354
5355 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005356 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005357 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005358 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005359 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005360 /* use only this ADC */
5361 if (spec->capsrc_nids)
5362 spec->capsrc_nids += i;
5363 spec->adc_nids += i;
5364 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005365 }
5366}
5367
Takashi Iwai840b64c2010-07-13 22:49:01 +02005368/* initialize dual adcs */
5369static void fixup_dual_adc_switch(struct hda_codec *codec)
5370{
5371 struct alc_spec *spec = codec->spec;
5372 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5373 init_capsrc_for_pin(codec, spec->int_mic.pin);
5374}
5375
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005376static void set_capture_mixer(struct hda_codec *codec)
5377{
5378 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005379 static struct snd_kcontrol_new *caps[2][3] = {
5380 { alc_capture_mixer_nosrc1,
5381 alc_capture_mixer_nosrc2,
5382 alc_capture_mixer_nosrc3 },
5383 { alc_capture_mixer1,
5384 alc_capture_mixer2,
5385 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005386 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005387 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005388 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005389 int num_adcs = spec->num_adc_nids;
5390 if (spec->dual_adc_switch)
5391 fixup_dual_adc_switch(codec);
5392 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005393 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005394 else if (spec->input_mux) {
5395 if (spec->input_mux->num_items > 1)
5396 mux = 1;
5397 else if (spec->input_mux->num_items == 1)
5398 fixup_single_adc(codec);
5399 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005400 if (spec->dual_adc_switch)
5401 num_adcs = 1;
5402 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005403 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005404}
5405
Takashi Iwai66946352010-03-29 17:21:45 +02005406/* fill adc_nids (and capsrc_nids) containing all active input pins */
5407static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5408 int num_nids)
5409{
5410 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005411 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005412 int n;
5413 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5414
5415 for (n = 0; n < num_nids; n++) {
5416 hda_nid_t adc, cap;
5417 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5418 int nconns, i, j;
5419
5420 adc = nids[n];
5421 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5422 continue;
5423 cap = adc;
5424 nconns = snd_hda_get_connections(codec, cap, conn,
5425 ARRAY_SIZE(conn));
5426 if (nconns == 1) {
5427 cap = conn[0];
5428 nconns = snd_hda_get_connections(codec, cap, conn,
5429 ARRAY_SIZE(conn));
5430 }
5431 if (nconns <= 0)
5432 continue;
5433 if (!fallback_adc) {
5434 fallback_adc = adc;
5435 fallback_cap = cap;
5436 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005437 for (i = 0; i < cfg->num_inputs; i++) {
5438 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005439 for (j = 0; j < nconns; j++) {
5440 if (conn[j] == nid)
5441 break;
5442 }
5443 if (j >= nconns)
5444 break;
5445 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005446 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005447 int num_adcs = spec->num_adc_nids;
5448 spec->private_adc_nids[num_adcs] = adc;
5449 spec->private_capsrc_nids[num_adcs] = cap;
5450 spec->num_adc_nids++;
5451 spec->adc_nids = spec->private_adc_nids;
5452 if (adc != cap)
5453 spec->capsrc_nids = spec->private_capsrc_nids;
5454 }
5455 }
5456 if (!spec->num_adc_nids) {
5457 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005458 " using fallback 0x%x\n",
5459 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005460 spec->private_adc_nids[0] = fallback_adc;
5461 spec->adc_nids = spec->private_adc_nids;
5462 if (fallback_adc != fallback_cap) {
5463 spec->private_capsrc_nids[0] = fallback_cap;
5464 spec->capsrc_nids = spec->private_adc_nids;
5465 }
5466 }
5467}
5468
Takashi Iwai67d634c2009-11-16 15:35:59 +01005469#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005470#define set_beep_amp(spec, nid, idx, dir) \
5471 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005472
5473static struct snd_pci_quirk beep_white_list[] = {
5474 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005475 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005476 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005477 {}
5478};
5479
5480static inline int has_cdefine_beep(struct hda_codec *codec)
5481{
5482 struct alc_spec *spec = codec->spec;
5483 const struct snd_pci_quirk *q;
5484 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5485 if (q)
5486 return q->value;
5487 return spec->cdefine.enable_pcbeep;
5488}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005489#else
5490#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005491#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005492#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005493
5494/*
5495 * OK, here we have finally the patch for ALC880
5496 */
5497
Linus Torvalds1da177e2005-04-16 15:20:36 -07005498static int patch_alc880(struct hda_codec *codec)
5499{
5500 struct alc_spec *spec;
5501 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005502 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005503
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005504 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005505 if (spec == NULL)
5506 return -ENOMEM;
5507
5508 codec->spec = spec;
5509
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005510 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5511 alc880_models,
5512 alc880_cfg_tbl);
5513 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005514 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5515 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005516 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005517 }
5518
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005519 if (board_config == ALC880_AUTO) {
5520 /* automatic parse from the BIOS config */
5521 err = alc880_parse_auto_config(codec);
5522 if (err < 0) {
5523 alc_free(codec);
5524 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005525 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005526 printk(KERN_INFO
5527 "hda_codec: Cannot set up configuration "
5528 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005529 board_config = ALC880_3ST;
5530 }
5531 }
5532
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005533 err = snd_hda_attach_beep_device(codec, 0x1);
5534 if (err < 0) {
5535 alc_free(codec);
5536 return err;
5537 }
5538
Kailang Yangdf694da2005-12-05 19:42:22 +01005539 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005540 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005541
Linus Torvalds1da177e2005-04-16 15:20:36 -07005542 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5543 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005544 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005545
Linus Torvalds1da177e2005-04-16 15:20:36 -07005546 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5547 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5548
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005549 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005550 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005551 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005552 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005553 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005554 if (wcap != AC_WID_AUD_IN) {
5555 spec->adc_nids = alc880_adc_nids_alt;
5556 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005557 } else {
5558 spec->adc_nids = alc880_adc_nids;
5559 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005560 }
5561 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005562 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005563 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005564
Takashi Iwai2134ea42008-01-10 16:53:55 +01005565 spec->vmaster_nid = 0x0c;
5566
Linus Torvalds1da177e2005-04-16 15:20:36 -07005567 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005568 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005569 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005570#ifdef CONFIG_SND_HDA_POWER_SAVE
5571 if (!spec->loopback.amplist)
5572 spec->loopback.amplist = alc880_loopbacks;
5573#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005574
5575 return 0;
5576}
5577
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005578
Linus Torvalds1da177e2005-04-16 15:20:36 -07005579/*
5580 * ALC260 support
5581 */
5582
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005583static hda_nid_t alc260_dac_nids[1] = {
5584 /* front */
5585 0x02,
5586};
5587
5588static hda_nid_t alc260_adc_nids[1] = {
5589 /* ADC0 */
5590 0x04,
5591};
5592
Kailang Yangdf694da2005-12-05 19:42:22 +01005593static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005594 /* ADC1 */
5595 0x05,
5596};
5597
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005598/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5599 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5600 */
5601static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005602 /* ADC0, ADC1 */
5603 0x04, 0x05
5604};
5605
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005606#define ALC260_DIGOUT_NID 0x03
5607#define ALC260_DIGIN_NID 0x06
5608
5609static struct hda_input_mux alc260_capture_source = {
5610 .num_items = 4,
5611 .items = {
5612 { "Mic", 0x0 },
5613 { "Front Mic", 0x1 },
5614 { "Line", 0x2 },
5615 { "CD", 0x4 },
5616 },
5617};
5618
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005619/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005620 * headphone jack and the internal CD lines since these are the only pins at
5621 * which audio can appear. For flexibility, also allow the option of
5622 * recording the mixer output on the second ADC (ADC0 doesn't have a
5623 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005624 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005625static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5626 {
5627 .num_items = 3,
5628 .items = {
5629 { "Mic/Line", 0x0 },
5630 { "CD", 0x4 },
5631 { "Headphone", 0x2 },
5632 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005633 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005634 {
5635 .num_items = 4,
5636 .items = {
5637 { "Mic/Line", 0x0 },
5638 { "CD", 0x4 },
5639 { "Headphone", 0x2 },
5640 { "Mixer", 0x5 },
5641 },
5642 },
5643
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005644};
5645
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005646/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5647 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005648 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005649static struct hda_input_mux alc260_acer_capture_sources[2] = {
5650 {
5651 .num_items = 4,
5652 .items = {
5653 { "Mic", 0x0 },
5654 { "Line", 0x2 },
5655 { "CD", 0x4 },
5656 { "Headphone", 0x5 },
5657 },
5658 },
5659 {
5660 .num_items = 5,
5661 .items = {
5662 { "Mic", 0x0 },
5663 { "Line", 0x2 },
5664 { "CD", 0x4 },
5665 { "Headphone", 0x6 },
5666 { "Mixer", 0x5 },
5667 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005668 },
5669};
Michael Schwingencc959482009-02-22 18:58:45 +01005670
5671/* Maxdata Favorit 100XS */
5672static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5673 {
5674 .num_items = 2,
5675 .items = {
5676 { "Line/Mic", 0x0 },
5677 { "CD", 0x4 },
5678 },
5679 },
5680 {
5681 .num_items = 3,
5682 .items = {
5683 { "Line/Mic", 0x0 },
5684 { "CD", 0x4 },
5685 { "Mixer", 0x5 },
5686 },
5687 },
5688};
5689
Linus Torvalds1da177e2005-04-16 15:20:36 -07005690/*
5691 * This is just place-holder, so there's something for alc_build_pcms to look
5692 * at when it calculates the maximum number of channels. ALC260 has no mixer
5693 * element which allows changing the channel mode, so the verb list is
5694 * never used.
5695 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005696static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005697 { 2, NULL },
5698};
5699
Kailang Yangdf694da2005-12-05 19:42:22 +01005700
5701/* Mixer combinations
5702 *
5703 * basic: base_output + input + pc_beep + capture
5704 * HP: base_output + input + capture_alt
5705 * HP_3013: hp_3013 + input + capture
5706 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005707 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005708 */
5709
5710static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005711 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005712 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005713 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5714 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5715 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5716 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5717 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005718};
Kailang Yangdf694da2005-12-05 19:42:22 +01005719
5720static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005721 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5722 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5723 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5724 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5726 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5727 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5728 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005729 { } /* end */
5730};
5731
Takashi Iwaibec15c32008-01-28 18:16:30 +01005732/* update HP, line and mono out pins according to the master switch */
5733static void alc260_hp_master_update(struct hda_codec *codec,
5734 hda_nid_t hp, hda_nid_t line,
5735 hda_nid_t mono)
5736{
5737 struct alc_spec *spec = codec->spec;
5738 unsigned int val = spec->master_sw ? PIN_HP : 0;
5739 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005740 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005741 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005742 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005743 val);
5744 /* mono (speaker) depending on the HP jack sense */
5745 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005746 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005747 val);
5748}
5749
5750static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5751 struct snd_ctl_elem_value *ucontrol)
5752{
5753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5754 struct alc_spec *spec = codec->spec;
5755 *ucontrol->value.integer.value = spec->master_sw;
5756 return 0;
5757}
5758
5759static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5760 struct snd_ctl_elem_value *ucontrol)
5761{
5762 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5763 struct alc_spec *spec = codec->spec;
5764 int val = !!*ucontrol->value.integer.value;
5765 hda_nid_t hp, line, mono;
5766
5767 if (val == spec->master_sw)
5768 return 0;
5769 spec->master_sw = val;
5770 hp = (kcontrol->private_value >> 16) & 0xff;
5771 line = (kcontrol->private_value >> 8) & 0xff;
5772 mono = kcontrol->private_value & 0xff;
5773 alc260_hp_master_update(codec, hp, line, mono);
5774 return 1;
5775}
5776
5777static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5778 {
5779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5780 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005781 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005782 .info = snd_ctl_boolean_mono_info,
5783 .get = alc260_hp_master_sw_get,
5784 .put = alc260_hp_master_sw_put,
5785 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5786 },
5787 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5788 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5789 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5790 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5791 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5792 HDA_OUTPUT),
5793 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5794 { } /* end */
5795};
5796
5797static struct hda_verb alc260_hp_unsol_verbs[] = {
5798 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5799 {},
5800};
5801
5802static void alc260_hp_automute(struct hda_codec *codec)
5803{
5804 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005805
Wu Fengguang864f92b2009-11-18 12:38:02 +08005806 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005807 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5808}
5809
5810static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5811{
5812 if ((res >> 26) == ALC880_HP_EVENT)
5813 alc260_hp_automute(codec);
5814}
5815
Kailang Yangdf694da2005-12-05 19:42:22 +01005816static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005817 {
5818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5819 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005820 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005821 .info = snd_ctl_boolean_mono_info,
5822 .get = alc260_hp_master_sw_get,
5823 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005824 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005825 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005826 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5827 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5828 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5829 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5830 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5831 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005832 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5833 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005834 { } /* end */
5835};
5836
Kailang Yang3f878302008-08-26 13:02:23 +02005837static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5838 .ops = &snd_hda_bind_vol,
5839 .values = {
5840 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5841 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5842 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5843 0
5844 },
5845};
5846
5847static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5848 .ops = &snd_hda_bind_sw,
5849 .values = {
5850 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5851 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5852 0
5853 },
5854};
5855
5856static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5857 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5858 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5859 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5860 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5861 { } /* end */
5862};
5863
Takashi Iwaibec15c32008-01-28 18:16:30 +01005864static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5865 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5866 {},
5867};
5868
5869static void alc260_hp_3013_automute(struct hda_codec *codec)
5870{
5871 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005872
Wu Fengguang864f92b2009-11-18 12:38:02 +08005873 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005874 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005875}
5876
5877static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5878 unsigned int res)
5879{
5880 if ((res >> 26) == ALC880_HP_EVENT)
5881 alc260_hp_3013_automute(codec);
5882}
5883
Kailang Yang3f878302008-08-26 13:02:23 +02005884static void alc260_hp_3012_automute(struct hda_codec *codec)
5885{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005886 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005887
Kailang Yang3f878302008-08-26 13:02:23 +02005888 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5889 bits);
5890 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5891 bits);
5892 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5893 bits);
5894}
5895
5896static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5897 unsigned int res)
5898{
5899 if ((res >> 26) == ALC880_HP_EVENT)
5900 alc260_hp_3012_automute(codec);
5901}
5902
5903/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005904 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5905 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005906static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005907 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005908 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005909 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005910 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5911 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5912 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5913 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005914 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005915 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5916 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005917 { } /* end */
5918};
5919
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005920/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5921 * versions of the ALC260 don't act on requests to enable mic bias from NID
5922 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5923 * datasheet doesn't mention this restriction. At this stage it's not clear
5924 * whether this behaviour is intentional or is a hardware bug in chip
5925 * revisions available in early 2006. Therefore for now allow the
5926 * "Headphone Jack Mode" control to span all choices, but if it turns out
5927 * that the lack of mic bias for this NID is intentional we could change the
5928 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5929 *
5930 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5931 * don't appear to make the mic bias available from the "line" jack, even
5932 * though the NID used for this jack (0x14) can supply it. The theory is
5933 * that perhaps Acer have included blocking capacitors between the ALC260
5934 * and the output jack. If this turns out to be the case for all such
5935 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5936 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005937 *
5938 * The C20x Tablet series have a mono internal speaker which is controlled
5939 * via the chip's Mono sum widget and pin complex, so include the necessary
5940 * controls for such models. On models without a "mono speaker" the control
5941 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005942 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005943static struct snd_kcontrol_new alc260_acer_mixer[] = {
5944 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5945 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005946 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005947 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005948 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005949 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005950 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005951 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5952 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5954 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5955 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5956 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5957 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5958 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005959 { } /* end */
5960};
5961
Michael Schwingencc959482009-02-22 18:58:45 +01005962/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5963 */
5964static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5965 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5966 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5967 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5968 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5969 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5970 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5971 { } /* end */
5972};
5973
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005974/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5975 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5976 */
5977static struct snd_kcontrol_new alc260_will_mixer[] = {
5978 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5979 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5981 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5982 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5983 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5984 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5985 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5986 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5987 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005988 { } /* end */
5989};
5990
5991/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5992 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5993 */
5994static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5995 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5996 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5998 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5999 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6000 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6001 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6002 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6003 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6004 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6005 { } /* end */
6006};
6007
Kailang Yangdf694da2005-12-05 19:42:22 +01006008/*
6009 * initialization verbs
6010 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006011static struct hda_verb alc260_init_verbs[] = {
6012 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006013 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006014 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006015 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006016 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006017 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006018 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006019 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006020 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006021 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006022 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006023 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006024 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006025 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006026 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006027 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006028 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006029 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6030 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006031 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006032 /* set connection select to line in (default select for this ADC) */
6033 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006034 /* mute capture amp left and right */
6035 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6036 /* set connection select to line in (default select for this ADC) */
6037 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006038 /* set vol=0 Line-Out mixer amp left and right */
6039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6040 /* unmute pin widget amp left and right (no gain on this amp) */
6041 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6042 /* set vol=0 HP mixer amp left and right */
6043 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6044 /* unmute pin widget amp left and right (no gain on this amp) */
6045 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6046 /* set vol=0 Mono mixer amp left and right */
6047 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6048 /* unmute pin widget amp left and right (no gain on this amp) */
6049 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6050 /* unmute LINE-2 out pin */
6051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006052 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6053 * Line In 2 = 0x03
6054 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006055 /* mute analog inputs */
6056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6058 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006061 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006062 /* mute Front out path */
6063 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6064 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6065 /* mute Headphone out path */
6066 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6067 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6068 /* mute Mono out path */
6069 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6070 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006071 { }
6072};
6073
Takashi Iwai474167d2006-05-17 17:17:43 +02006074#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006075static struct hda_verb alc260_hp_init_verbs[] = {
6076 /* Headphone and output */
6077 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6078 /* mono output */
6079 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6080 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6081 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6082 /* Mic2 (front panel) pin widget for input and vref at 80% */
6083 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6084 /* Line In pin widget for input */
6085 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6086 /* Line-2 pin widget for output */
6087 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6088 /* CD pin widget for input */
6089 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6090 /* unmute amp left and right */
6091 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6092 /* set connection select to line in (default select for this ADC) */
6093 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6094 /* unmute Line-Out mixer amp left and right (volume = 0) */
6095 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6096 /* mute pin widget amp left and right (no gain on this amp) */
6097 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6098 /* unmute HP mixer amp left and right (volume = 0) */
6099 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6100 /* mute pin widget amp left and right (no gain on this amp) */
6101 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006102 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6103 * Line In 2 = 0x03
6104 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006105 /* mute analog inputs */
6106 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6107 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006111 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6112 /* Unmute Front out path */
6113 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6115 /* Unmute Headphone out path */
6116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6117 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6118 /* Unmute Mono out path */
6119 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6120 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6121 { }
6122};
Takashi Iwai474167d2006-05-17 17:17:43 +02006123#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006124
6125static struct hda_verb alc260_hp_3013_init_verbs[] = {
6126 /* Line out and output */
6127 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6128 /* mono output */
6129 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6130 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6131 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6132 /* Mic2 (front panel) pin widget for input and vref at 80% */
6133 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6134 /* Line In pin widget for input */
6135 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6136 /* Headphone pin widget for output */
6137 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6138 /* CD pin widget for input */
6139 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6140 /* unmute amp left and right */
6141 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6142 /* set connection select to line in (default select for this ADC) */
6143 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6144 /* unmute Line-Out mixer amp left and right (volume = 0) */
6145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6146 /* mute pin widget amp left and right (no gain on this amp) */
6147 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6148 /* unmute HP mixer amp left and right (volume = 0) */
6149 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6150 /* mute pin widget amp left and right (no gain on this amp) */
6151 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006152 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6153 * Line In 2 = 0x03
6154 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006155 /* mute analog inputs */
6156 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6158 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006161 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6162 /* Unmute Front out path */
6163 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6164 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6165 /* Unmute Headphone out path */
6166 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6167 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6168 /* Unmute Mono out path */
6169 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6170 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6171 { }
6172};
6173
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006174/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006175 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6176 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006177 */
6178static struct hda_verb alc260_fujitsu_init_verbs[] = {
6179 /* Disable all GPIOs */
6180 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6181 /* Internal speaker is connected to headphone pin */
6182 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6183 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6184 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006185 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6186 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6187 /* Ensure all other unused pins are disabled and muted. */
6188 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6189 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006190 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006191 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006192 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006193 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6194 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6195 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006196
Jonathan Woithef7ace402006-02-28 11:46:14 +01006197 /* Disable digital (SPDIF) pins */
6198 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6199 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006200
Kailang Yangea1fb292008-08-26 12:58:38 +02006201 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006202 * when acting as an output.
6203 */
6204 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6205
6206 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006207 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6208 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6209 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6210 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6211 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6212 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6213 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6214 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6215 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006216
Jonathan Woithef7ace402006-02-28 11:46:14 +01006217 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6218 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6219 /* Unmute Line1 pin widget output buffer since it starts as an output.
6220 * If the pin mode is changed by the user the pin mode control will
6221 * take care of enabling the pin's input/output buffers as needed.
6222 * Therefore there's no need to enable the input buffer at this
6223 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006224 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006225 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006226 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006227 * mixer ctrl)
6228 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006229 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006230
Jonathan Woithef7ace402006-02-28 11:46:14 +01006231 /* Mute capture amp left and right */
6232 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006233 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006234 * in (on mic1 pin)
6235 */
6236 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006237
Jonathan Woithef7ace402006-02-28 11:46:14 +01006238 /* Do the same for the second ADC: mute capture input amp and
6239 * set ADC connection to line in (on mic1 pin)
6240 */
6241 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6242 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006243
Jonathan Woithef7ace402006-02-28 11:46:14 +01006244 /* Mute all inputs to mixer widget (even unconnected ones) */
6245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006253
6254 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006255};
6256
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006257/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6258 * similar laptops (adapted from Fujitsu init verbs).
6259 */
6260static struct hda_verb alc260_acer_init_verbs[] = {
6261 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6262 * the headphone jack. Turn this on and rely on the standard mute
6263 * methods whenever the user wants to turn these outputs off.
6264 */
6265 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6266 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6267 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6268 /* Internal speaker/Headphone jack is connected to Line-out pin */
6269 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6270 /* Internal microphone/Mic jack is connected to Mic1 pin */
6271 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6272 /* Line In jack is connected to Line1 pin */
6273 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006274 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6275 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006276 /* Ensure all other unused pins are disabled and muted. */
6277 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6278 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006279 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6280 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6281 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6283 /* Disable digital (SPDIF) pins */
6284 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6285 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6286
Kailang Yangea1fb292008-08-26 12:58:38 +02006287 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006288 * bus when acting as outputs.
6289 */
6290 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6291 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6292
6293 /* Start with output sum widgets muted and their output gains at min */
6294 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6295 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6297 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6298 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6299 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6300 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6301 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6302 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6303
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006304 /* Unmute Line-out pin widget amp left and right
6305 * (no equiv mixer ctrl)
6306 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006307 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006308 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6309 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006310 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6311 * inputs. If the pin mode is changed by the user the pin mode control
6312 * will take care of enabling the pin's input/output buffers as needed.
6313 * Therefore there's no need to enable the input buffer at this
6314 * stage.
6315 */
6316 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6317 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6318
6319 /* Mute capture amp left and right */
6320 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6321 /* Set ADC connection select to match default mixer setting - mic
6322 * (on mic1 pin)
6323 */
6324 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6325
6326 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006327 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006328 */
6329 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006330 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006331
6332 /* Mute all inputs to mixer widget (even unconnected ones) */
6333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6341
6342 { }
6343};
6344
Michael Schwingencc959482009-02-22 18:58:45 +01006345/* Initialisation sequence for Maxdata Favorit 100XS
6346 * (adapted from Acer init verbs).
6347 */
6348static struct hda_verb alc260_favorit100_init_verbs[] = {
6349 /* GPIO 0 enables the output jack.
6350 * Turn this on and rely on the standard mute
6351 * methods whenever the user wants to turn these outputs off.
6352 */
6353 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6354 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6355 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6356 /* Line/Mic input jack is connected to Mic1 pin */
6357 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6358 /* Ensure all other unused pins are disabled and muted. */
6359 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6360 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6361 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6362 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6363 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6364 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6365 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6366 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6369 /* Disable digital (SPDIF) pins */
6370 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6371 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6372
6373 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6374 * bus when acting as outputs.
6375 */
6376 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6377 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6378
6379 /* Start with output sum widgets muted and their output gains at min */
6380 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6381 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6382 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6383 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6384 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6385 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6386 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6387 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6388 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6389
6390 /* Unmute Line-out pin widget amp left and right
6391 * (no equiv mixer ctrl)
6392 */
6393 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6394 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6395 * inputs. If the pin mode is changed by the user the pin mode control
6396 * will take care of enabling the pin's input/output buffers as needed.
6397 * Therefore there's no need to enable the input buffer at this
6398 * stage.
6399 */
6400 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6401
6402 /* Mute capture amp left and right */
6403 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6404 /* Set ADC connection select to match default mixer setting - mic
6405 * (on mic1 pin)
6406 */
6407 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6408
6409 /* Do similar with the second ADC: mute capture input amp and
6410 * set ADC connection to mic to match ALSA's default state.
6411 */
6412 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6413 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6414
6415 /* Mute all inputs to mixer widget (even unconnected ones) */
6416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6423 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6424
6425 { }
6426};
6427
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006428static struct hda_verb alc260_will_verbs[] = {
6429 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6430 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6431 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6432 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6433 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6434 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6435 {}
6436};
6437
6438static struct hda_verb alc260_replacer_672v_verbs[] = {
6439 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6440 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6441 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6442
6443 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6444 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6445 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6446
6447 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6448 {}
6449};
6450
6451/* toggle speaker-output according to the hp-jack state */
6452static void alc260_replacer_672v_automute(struct hda_codec *codec)
6453{
6454 unsigned int present;
6455
6456 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006457 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006458 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006459 snd_hda_codec_write_cache(codec, 0x01, 0,
6460 AC_VERB_SET_GPIO_DATA, 1);
6461 snd_hda_codec_write_cache(codec, 0x0f, 0,
6462 AC_VERB_SET_PIN_WIDGET_CONTROL,
6463 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006464 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006465 snd_hda_codec_write_cache(codec, 0x01, 0,
6466 AC_VERB_SET_GPIO_DATA, 0);
6467 snd_hda_codec_write_cache(codec, 0x0f, 0,
6468 AC_VERB_SET_PIN_WIDGET_CONTROL,
6469 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006470 }
6471}
6472
6473static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6474 unsigned int res)
6475{
6476 if ((res >> 26) == ALC880_HP_EVENT)
6477 alc260_replacer_672v_automute(codec);
6478}
6479
Kailang Yang3f878302008-08-26 13:02:23 +02006480static struct hda_verb alc260_hp_dc7600_verbs[] = {
6481 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6482 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6483 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6484 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6485 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6487 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6488 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6489 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6490 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6491 {}
6492};
6493
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006494/* Test configuration for debugging, modelled after the ALC880 test
6495 * configuration.
6496 */
6497#ifdef CONFIG_SND_DEBUG
6498static hda_nid_t alc260_test_dac_nids[1] = {
6499 0x02,
6500};
6501static hda_nid_t alc260_test_adc_nids[2] = {
6502 0x04, 0x05,
6503};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006504/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006505 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006506 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006507 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006508static struct hda_input_mux alc260_test_capture_sources[2] = {
6509 {
6510 .num_items = 7,
6511 .items = {
6512 { "MIC1 pin", 0x0 },
6513 { "MIC2 pin", 0x1 },
6514 { "LINE1 pin", 0x2 },
6515 { "LINE2 pin", 0x3 },
6516 { "CD pin", 0x4 },
6517 { "LINE-OUT pin", 0x5 },
6518 { "HP-OUT pin", 0x6 },
6519 },
6520 },
6521 {
6522 .num_items = 8,
6523 .items = {
6524 { "MIC1 pin", 0x0 },
6525 { "MIC2 pin", 0x1 },
6526 { "LINE1 pin", 0x2 },
6527 { "LINE2 pin", 0x3 },
6528 { "CD pin", 0x4 },
6529 { "Mixer", 0x5 },
6530 { "LINE-OUT pin", 0x6 },
6531 { "HP-OUT pin", 0x7 },
6532 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006533 },
6534};
6535static struct snd_kcontrol_new alc260_test_mixer[] = {
6536 /* Output driver widgets */
6537 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6538 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6539 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6540 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6541 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6542 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6543
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006544 /* Modes for retasking pin widgets
6545 * Note: the ALC260 doesn't seem to act on requests to enable mic
6546 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6547 * mention this restriction. At this stage it's not clear whether
6548 * this behaviour is intentional or is a hardware bug in chip
6549 * revisions available at least up until early 2006. Therefore for
6550 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6551 * choices, but if it turns out that the lack of mic bias for these
6552 * NIDs is intentional we could change their modes from
6553 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6554 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006555 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6556 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6557 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6558 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6559 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6560 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6561
6562 /* Loopback mixer controls */
6563 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6564 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6565 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6566 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6567 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6568 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6569 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6570 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6571 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6572 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006573 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6574 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6575 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6576 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006577
6578 /* Controls for GPIO pins, assuming they are configured as outputs */
6579 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6580 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6581 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6582 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6583
Jonathan Woithe92621f12006-02-28 11:47:47 +01006584 /* Switches to allow the digital IO pins to be enabled. The datasheet
6585 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006586 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006587 */
6588 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6589 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6590
Jonathan Woithef8225f62008-01-08 12:16:54 +01006591 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6592 * this output to turn on an external amplifier.
6593 */
6594 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6595 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6596
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006597 { } /* end */
6598};
6599static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006600 /* Enable all GPIOs as outputs with an initial value of 0 */
6601 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6602 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6603 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6604
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006605 /* Enable retasking pins as output, initially without power amp */
6606 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6607 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6608 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6609 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6610 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6611 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6612
Jonathan Woithe92621f12006-02-28 11:47:47 +01006613 /* Disable digital (SPDIF) pins initially, but users can enable
6614 * them via a mixer switch. In the case of SPDIF-out, this initverb
6615 * payload also sets the generation to 0, output to be in "consumer"
6616 * PCM format, copyright asserted, no pre-emphasis and no validity
6617 * control.
6618 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006619 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6620 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6621
Kailang Yangea1fb292008-08-26 12:58:38 +02006622 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006623 * OUT1 sum bus when acting as an output.
6624 */
6625 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6626 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6627 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6628 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6629
6630 /* Start with output sum widgets muted and their output gains at min */
6631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6632 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6634 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6635 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6637 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6638 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6639 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6640
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006641 /* Unmute retasking pin widget output buffers since the default
6642 * state appears to be output. As the pin mode is changed by the
6643 * user the pin mode control will take care of enabling the pin's
6644 * input/output buffers as needed.
6645 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006646 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6647 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6649 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6650 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6651 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6652 /* Also unmute the mono-out pin widget */
6653 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6654
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006655 /* Mute capture amp left and right */
6656 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006657 /* Set ADC connection select to match default mixer setting (mic1
6658 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006659 */
6660 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6661
6662 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006663 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006664 */
6665 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6666 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6667
6668 /* Mute all inputs to mixer widget (even unconnected ones) */
6669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6677
6678 { }
6679};
6680#endif
6681
Takashi Iwai63300792008-01-24 15:31:36 +01006682#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6683#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006684
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006685#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6686#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6687
Kailang Yangdf694da2005-12-05 19:42:22 +01006688/*
6689 * for BIOS auto-configuration
6690 */
6691
6692static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006693 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006694{
6695 hda_nid_t nid_vol;
6696 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006697 int err;
6698
6699 if (nid >= 0x0f && nid < 0x11) {
6700 nid_vol = nid - 0x7;
6701 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6702 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6703 } else if (nid == 0x11) {
6704 nid_vol = nid - 0x7;
6705 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6706 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6707 } else if (nid >= 0x12 && nid <= 0x15) {
6708 nid_vol = 0x08;
6709 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6710 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6711 } else
6712 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006713
Takashi Iwai863b4512008-10-21 17:01:47 +02006714 if (!(*vol_bits & (1 << nid_vol))) {
6715 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006716 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006717 if (err < 0)
6718 return err;
6719 *vol_bits |= (1 << nid_vol);
6720 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006721 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006722 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006723 return err;
6724 return 1;
6725}
6726
6727/* add playback controls from the parsed DAC table */
6728static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6729 const struct auto_pin_cfg *cfg)
6730{
6731 hda_nid_t nid;
6732 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006733 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006734
6735 spec->multiout.num_dacs = 1;
6736 spec->multiout.dac_nids = spec->private_dac_nids;
6737 spec->multiout.dac_nids[0] = 0x02;
6738
6739 nid = cfg->line_out_pins[0];
6740 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006741 const char *pfx;
6742 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6743 pfx = "Master";
6744 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6745 pfx = "Speaker";
6746 else
6747 pfx = "Front";
6748 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006749 if (err < 0)
6750 return err;
6751 }
6752
Takashi Iwai82bc9552006-03-21 11:24:42 +01006753 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006754 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006755 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006756 if (err < 0)
6757 return err;
6758 }
6759
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006760 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006761 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006762 err = alc260_add_playback_controls(spec, nid, "Headphone",
6763 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006764 if (err < 0)
6765 return err;
6766 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006767 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006768}
6769
6770/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006771static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006772 const struct auto_pin_cfg *cfg)
6773{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006774 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006775}
6776
6777static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6778 hda_nid_t nid, int pin_type,
6779 int sel_idx)
6780{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006781 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006782 /* need the manual connection? */
6783 if (nid >= 0x12) {
6784 int idx = nid - 0x12;
6785 snd_hda_codec_write(codec, idx + 0x0b, 0,
6786 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006787 }
6788}
6789
6790static void alc260_auto_init_multi_out(struct hda_codec *codec)
6791{
6792 struct alc_spec *spec = codec->spec;
6793 hda_nid_t nid;
6794
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006795 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006796 if (nid) {
6797 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6798 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6799 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006800
Takashi Iwai82bc9552006-03-21 11:24:42 +01006801 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006802 if (nid)
6803 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6804
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006805 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006806 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006807 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006808}
Kailang Yangdf694da2005-12-05 19:42:22 +01006809
6810#define ALC260_PIN_CD_NID 0x16
6811static void alc260_auto_init_analog_input(struct hda_codec *codec)
6812{
6813 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006814 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006815 int i;
6816
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006817 for (i = 0; i < cfg->num_inputs; i++) {
6818 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006819 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006820 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006821 if (nid != ALC260_PIN_CD_NID &&
6822 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006823 snd_hda_codec_write(codec, nid, 0,
6824 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006825 AMP_OUT_MUTE);
6826 }
6827 }
6828}
6829
Takashi Iwai7f311a42010-04-09 17:32:23 +02006830#define alc260_auto_init_input_src alc880_auto_init_input_src
6831
Kailang Yangdf694da2005-12-05 19:42:22 +01006832/*
6833 * generic initialization of ADC, input mixers and output mixers
6834 */
6835static struct hda_verb alc260_volume_init_verbs[] = {
6836 /*
6837 * Unmute ADC0-1 and set the default input to mic-in
6838 */
6839 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6840 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6841 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6842 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006843
Kailang Yangdf694da2005-12-05 19:42:22 +01006844 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6845 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006846 * Note: PASD motherboards uses the Line In 2 as the input for
6847 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006848 */
6849 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006850 /* mute analog inputs */
6851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006856
6857 /*
6858 * Set up output mixers (0x08 - 0x0a)
6859 */
6860 /* set vol=0 to output mixers */
6861 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6863 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6864 /* set up input amps for analog loopback */
6865 /* Amp Indices: DAC = 0, mixer = 1 */
6866 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6868 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6870 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6871 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006872
Kailang Yangdf694da2005-12-05 19:42:22 +01006873 { }
6874};
6875
6876static int alc260_parse_auto_config(struct hda_codec *codec)
6877{
6878 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006879 int err;
6880 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6881
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006882 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6883 alc260_ignore);
6884 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006885 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006886 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6887 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006888 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006889 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006890 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006891 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006892 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006893 return err;
6894
6895 spec->multiout.max_channels = 2;
6896
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006897 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006898 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006899 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006900 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006901
Takashi Iwaid88897e2008-10-31 15:01:37 +01006902 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006903
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006904 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006905 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006906
Kailang Yang6227cdc2010-02-25 08:36:52 +01006907 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006908
Kailang Yangdf694da2005-12-05 19:42:22 +01006909 return 1;
6910}
6911
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006912/* additional initialization for auto-configuration model */
6913static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006914{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006915 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006916 alc260_auto_init_multi_out(codec);
6917 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006918 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02006919 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006920 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006921 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006922}
6923
Takashi Iwaicb53c622007-08-10 17:21:45 +02006924#ifdef CONFIG_SND_HDA_POWER_SAVE
6925static struct hda_amp_list alc260_loopbacks[] = {
6926 { 0x07, HDA_INPUT, 0 },
6927 { 0x07, HDA_INPUT, 1 },
6928 { 0x07, HDA_INPUT, 2 },
6929 { 0x07, HDA_INPUT, 3 },
6930 { 0x07, HDA_INPUT, 4 },
6931 { } /* end */
6932};
6933#endif
6934
Kailang Yangdf694da2005-12-05 19:42:22 +01006935/*
Takashi Iwaifc091762010-08-04 23:53:36 +02006936 * Pin config fixes
6937 */
6938enum {
6939 PINFIX_HP_DC5750,
6940};
6941
Takashi Iwaifc091762010-08-04 23:53:36 +02006942static const struct alc_fixup alc260_fixups[] = {
6943 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02006944 .pins = (const struct alc_pincfg[]) {
6945 { 0x11, 0x90130110 }, /* speaker */
6946 { }
6947 }
Takashi Iwaifc091762010-08-04 23:53:36 +02006948 },
6949};
6950
6951static struct snd_pci_quirk alc260_fixup_tbl[] = {
6952 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
6953 {}
6954};
6955
6956/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006957 * ALC260 configurations
6958 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006959static const char *alc260_models[ALC260_MODEL_LAST] = {
6960 [ALC260_BASIC] = "basic",
6961 [ALC260_HP] = "hp",
6962 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006963 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006964 [ALC260_FUJITSU_S702X] = "fujitsu",
6965 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006966 [ALC260_WILL] = "will",
6967 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006968 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006969#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006970 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006971#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006972 [ALC260_AUTO] = "auto",
6973};
6974
6975static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006976 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006977 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006978 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006979 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006980 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006981 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006982 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006983 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006984 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006985 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6986 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6987 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6988 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6989 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6990 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6991 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6992 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6993 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006994 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006995 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006996 {}
6997};
6998
Kailang Yangdf694da2005-12-05 19:42:22 +01006999static struct alc_config_preset alc260_presets[] = {
7000 [ALC260_BASIC] = {
7001 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007002 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007003 .init_verbs = { alc260_init_verbs },
7004 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7005 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007006 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007007 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007008 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7009 .channel_mode = alc260_modes,
7010 .input_mux = &alc260_capture_source,
7011 },
7012 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007013 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007014 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007015 .init_verbs = { alc260_init_verbs,
7016 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007017 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7018 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007019 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7020 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007021 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7022 .channel_mode = alc260_modes,
7023 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007024 .unsol_event = alc260_hp_unsol_event,
7025 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007026 },
Kailang Yang3f878302008-08-26 13:02:23 +02007027 [ALC260_HP_DC7600] = {
7028 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007029 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007030 .init_verbs = { alc260_init_verbs,
7031 alc260_hp_dc7600_verbs },
7032 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7033 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007034 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7035 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007036 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7037 .channel_mode = alc260_modes,
7038 .input_mux = &alc260_capture_source,
7039 .unsol_event = alc260_hp_3012_unsol_event,
7040 .init_hook = alc260_hp_3012_automute,
7041 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007042 [ALC260_HP_3013] = {
7043 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007044 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007045 .init_verbs = { alc260_hp_3013_init_verbs,
7046 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007047 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7048 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007049 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7050 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007051 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7052 .channel_mode = alc260_modes,
7053 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007054 .unsol_event = alc260_hp_3013_unsol_event,
7055 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007056 },
7057 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007058 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007059 .init_verbs = { alc260_fujitsu_init_verbs },
7060 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7061 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007062 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7063 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007064 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7065 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007066 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7067 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007068 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007069 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007070 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007071 .init_verbs = { alc260_acer_init_verbs },
7072 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7073 .dac_nids = alc260_dac_nids,
7074 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7075 .adc_nids = alc260_dual_adc_nids,
7076 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7077 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007078 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7079 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007080 },
Michael Schwingencc959482009-02-22 18:58:45 +01007081 [ALC260_FAVORIT100] = {
7082 .mixers = { alc260_favorit100_mixer },
7083 .init_verbs = { alc260_favorit100_init_verbs },
7084 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7085 .dac_nids = alc260_dac_nids,
7086 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7087 .adc_nids = alc260_dual_adc_nids,
7088 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7089 .channel_mode = alc260_modes,
7090 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7091 .input_mux = alc260_favorit100_capture_sources,
7092 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007093 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007094 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007095 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7096 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7097 .dac_nids = alc260_dac_nids,
7098 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7099 .adc_nids = alc260_adc_nids,
7100 .dig_out_nid = ALC260_DIGOUT_NID,
7101 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7102 .channel_mode = alc260_modes,
7103 .input_mux = &alc260_capture_source,
7104 },
7105 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007106 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007107 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7108 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7109 .dac_nids = alc260_dac_nids,
7110 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7111 .adc_nids = alc260_adc_nids,
7112 .dig_out_nid = ALC260_DIGOUT_NID,
7113 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7114 .channel_mode = alc260_modes,
7115 .input_mux = &alc260_capture_source,
7116 .unsol_event = alc260_replacer_672v_unsol_event,
7117 .init_hook = alc260_replacer_672v_automute,
7118 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007119#ifdef CONFIG_SND_DEBUG
7120 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007121 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007122 .init_verbs = { alc260_test_init_verbs },
7123 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7124 .dac_nids = alc260_test_dac_nids,
7125 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7126 .adc_nids = alc260_test_adc_nids,
7127 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7128 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007129 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7130 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007131 },
7132#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007133};
7134
Linus Torvalds1da177e2005-04-16 15:20:36 -07007135static int patch_alc260(struct hda_codec *codec)
7136{
7137 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007138 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007139
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007140 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007141 if (spec == NULL)
7142 return -ENOMEM;
7143
7144 codec->spec = spec;
7145
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007146 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7147 alc260_models,
7148 alc260_cfg_tbl);
7149 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007150 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007151 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007152 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007153 }
7154
Takashi Iwaifc091762010-08-04 23:53:36 +02007155 if (board_config == ALC260_AUTO)
7156 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7157
Kailang Yangdf694da2005-12-05 19:42:22 +01007158 if (board_config == ALC260_AUTO) {
7159 /* automatic parse from the BIOS config */
7160 err = alc260_parse_auto_config(codec);
7161 if (err < 0) {
7162 alc_free(codec);
7163 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007164 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007165 printk(KERN_INFO
7166 "hda_codec: Cannot set up configuration "
7167 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007168 board_config = ALC260_BASIC;
7169 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007170 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007171
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007172 err = snd_hda_attach_beep_device(codec, 0x1);
7173 if (err < 0) {
7174 alc_free(codec);
7175 return err;
7176 }
7177
Kailang Yangdf694da2005-12-05 19:42:22 +01007178 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007179 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007180
Linus Torvalds1da177e2005-04-16 15:20:36 -07007181 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7182 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307183 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007184
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007185 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7186 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7187
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007188 if (!spec->adc_nids && spec->input_mux) {
7189 /* check whether NID 0x04 is valid */
7190 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007191 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007192 /* get type */
7193 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7194 spec->adc_nids = alc260_adc_nids_alt;
7195 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7196 } else {
7197 spec->adc_nids = alc260_adc_nids;
7198 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7199 }
7200 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007201 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007202 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007203
Takashi Iwaifc091762010-08-04 23:53:36 +02007204 if (board_config == ALC260_AUTO)
7205 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7206
Takashi Iwai2134ea42008-01-10 16:53:55 +01007207 spec->vmaster_nid = 0x08;
7208
Linus Torvalds1da177e2005-04-16 15:20:36 -07007209 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007210 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007211 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007212#ifdef CONFIG_SND_HDA_POWER_SAVE
7213 if (!spec->loopback.amplist)
7214 spec->loopback.amplist = alc260_loopbacks;
7215#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007216
7217 return 0;
7218}
7219
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007220
Linus Torvalds1da177e2005-04-16 15:20:36 -07007221/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007222 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007223 *
7224 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7225 * configuration. Each pin widget can choose any input DACs and a mixer.
7226 * Each ADC is connected from a mixer of all inputs. This makes possible
7227 * 6-channel independent captures.
7228 *
7229 * In addition, an independent DAC for the multi-playback (not used in this
7230 * driver yet).
7231 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007232#define ALC882_DIGOUT_NID 0x06
7233#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007234#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7235#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7236#define ALC1200_DIGOUT_NID 0x10
7237
Linus Torvalds1da177e2005-04-16 15:20:36 -07007238
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007239static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007240 { 8, NULL }
7241};
7242
Takashi Iwai4953550a2009-06-30 15:28:30 +02007243/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007244static hda_nid_t alc882_dac_nids[4] = {
7245 /* front, rear, clfe, rear_surr */
7246 0x02, 0x03, 0x04, 0x05
7247};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007248#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007249
Takashi Iwai4953550a2009-06-30 15:28:30 +02007250/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007251#define alc882_adc_nids alc880_adc_nids
7252#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007253#define alc883_adc_nids alc882_adc_nids_alt
7254static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7255static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7256#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007257
Takashi Iwaie1406342008-02-11 18:32:32 +01007258static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7259static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007260#define alc883_capsrc_nids alc882_capsrc_nids_alt
7261static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7262#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007263
Linus Torvalds1da177e2005-04-16 15:20:36 -07007264/* input MUX */
7265/* FIXME: should be a matrix-type input source selection */
7266
7267static struct hda_input_mux alc882_capture_source = {
7268 .num_items = 4,
7269 .items = {
7270 { "Mic", 0x0 },
7271 { "Front Mic", 0x1 },
7272 { "Line", 0x2 },
7273 { "CD", 0x4 },
7274 },
7275};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007276
Takashi Iwai4953550a2009-06-30 15:28:30 +02007277#define alc883_capture_source alc882_capture_source
7278
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007279static struct hda_input_mux alc889_capture_source = {
7280 .num_items = 3,
7281 .items = {
7282 { "Front Mic", 0x0 },
7283 { "Mic", 0x3 },
7284 { "Line", 0x2 },
7285 },
7286};
7287
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007288static struct hda_input_mux mb5_capture_source = {
7289 .num_items = 3,
7290 .items = {
7291 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307292 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007293 { "CD", 0x4 },
7294 },
7295};
7296
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007297static struct hda_input_mux macmini3_capture_source = {
7298 .num_items = 2,
7299 .items = {
7300 { "Line", 0x2 },
7301 { "CD", 0x4 },
7302 },
7303};
7304
Takashi Iwai4953550a2009-06-30 15:28:30 +02007305static struct hda_input_mux alc883_3stack_6ch_intel = {
7306 .num_items = 4,
7307 .items = {
7308 { "Mic", 0x1 },
7309 { "Front Mic", 0x0 },
7310 { "Line", 0x2 },
7311 { "CD", 0x4 },
7312 },
7313};
7314
7315static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7316 .num_items = 2,
7317 .items = {
7318 { "Mic", 0x1 },
7319 { "Line", 0x2 },
7320 },
7321};
7322
7323static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7324 .num_items = 4,
7325 .items = {
7326 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007327 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007328 { "Line", 0x2 },
7329 { "CD", 0x4 },
7330 },
7331};
7332
7333static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7334 .num_items = 2,
7335 .items = {
7336 { "Mic", 0x0 },
7337 { "Int Mic", 0x1 },
7338 },
7339};
7340
7341static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7342 .num_items = 3,
7343 .items = {
7344 { "Mic", 0x0 },
7345 { "Front Mic", 0x1 },
7346 { "Line", 0x4 },
7347 },
7348};
7349
7350static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7351 .num_items = 2,
7352 .items = {
7353 { "Mic", 0x0 },
7354 { "Line", 0x2 },
7355 },
7356};
7357
7358static struct hda_input_mux alc889A_mb31_capture_source = {
7359 .num_items = 2,
7360 .items = {
7361 { "Mic", 0x0 },
7362 /* Front Mic (0x01) unused */
7363 { "Line", 0x2 },
7364 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007365 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007366 },
7367};
7368
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007369static struct hda_input_mux alc889A_imac91_capture_source = {
7370 .num_items = 2,
7371 .items = {
7372 { "Mic", 0x01 },
7373 { "Line", 0x2 }, /* Not sure! */
7374 },
7375};
7376
Takashi Iwai4953550a2009-06-30 15:28:30 +02007377/*
7378 * 2ch mode
7379 */
7380static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7381 { 2, NULL }
7382};
7383
Kailang Yangdf694da2005-12-05 19:42:22 +01007384/*
Kailang Yang272a5272007-05-14 11:00:38 +02007385 * 2ch mode
7386 */
7387static struct hda_verb alc882_3ST_ch2_init[] = {
7388 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7389 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7390 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7391 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7392 { } /* end */
7393};
7394
7395/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007396 * 4ch mode
7397 */
7398static struct hda_verb alc882_3ST_ch4_init[] = {
7399 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7400 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7401 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7402 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7403 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7404 { } /* end */
7405};
7406
7407/*
Kailang Yang272a5272007-05-14 11:00:38 +02007408 * 6ch mode
7409 */
7410static struct hda_verb alc882_3ST_ch6_init[] = {
7411 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7412 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7413 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7414 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7415 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7416 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7417 { } /* end */
7418};
7419
Takashi Iwai4953550a2009-06-30 15:28:30 +02007420static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007421 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007422 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007423 { 6, alc882_3ST_ch6_init },
7424};
7425
Takashi Iwai4953550a2009-06-30 15:28:30 +02007426#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7427
Kailang Yang272a5272007-05-14 11:00:38 +02007428/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307429 * 2ch mode
7430 */
7431static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7432 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7433 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7434 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7435 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7436 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7437 { } /* end */
7438};
7439
7440/*
7441 * 4ch mode
7442 */
7443static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7444 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7445 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7446 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7447 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7448 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7449 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7450 { } /* end */
7451};
7452
7453/*
7454 * 6ch mode
7455 */
7456static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7457 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7458 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7459 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7460 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7461 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7462 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7463 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7464 { } /* end */
7465};
7466
7467static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7468 { 2, alc883_3ST_ch2_clevo_init },
7469 { 4, alc883_3ST_ch4_clevo_init },
7470 { 6, alc883_3ST_ch6_clevo_init },
7471};
7472
7473
7474/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007475 * 6ch mode
7476 */
7477static struct hda_verb alc882_sixstack_ch6_init[] = {
7478 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7479 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7480 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7481 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7482 { } /* end */
7483};
7484
7485/*
7486 * 8ch mode
7487 */
7488static struct hda_verb alc882_sixstack_ch8_init[] = {
7489 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7490 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7491 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7492 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7493 { } /* end */
7494};
7495
7496static struct hda_channel_mode alc882_sixstack_modes[2] = {
7497 { 6, alc882_sixstack_ch6_init },
7498 { 8, alc882_sixstack_ch8_init },
7499};
7500
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007501
7502/* Macbook Air 2,1 */
7503
7504static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7505 { 2, NULL },
7506};
7507
Takashi Iwai87350ad2007-08-16 18:19:38 +02007508/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007509 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007510 */
7511
7512/*
7513 * 2ch mode
7514 */
7515static struct hda_verb alc885_mbp_ch2_init[] = {
7516 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7517 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7518 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7519 { } /* end */
7520};
7521
7522/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007523 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007524 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007525static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007526 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7527 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7528 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7529 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7530 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7531 { } /* end */
7532};
7533
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007534static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007535 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007536 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007537};
7538
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007539/*
7540 * 2ch
7541 * Speakers/Woofer/HP = Front
7542 * LineIn = Input
7543 */
7544static struct hda_verb alc885_mb5_ch2_init[] = {
7545 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7546 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7547 { } /* end */
7548};
7549
7550/*
7551 * 6ch mode
7552 * Speakers/HP = Front
7553 * Woofer = LFE
7554 * LineIn = Surround
7555 */
7556static struct hda_verb alc885_mb5_ch6_init[] = {
7557 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7559 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7560 { } /* end */
7561};
7562
7563static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7564 { 2, alc885_mb5_ch2_init },
7565 { 6, alc885_mb5_ch6_init },
7566};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007567
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007568#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007569
7570/*
7571 * 2ch mode
7572 */
7573static struct hda_verb alc883_4ST_ch2_init[] = {
7574 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7575 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7576 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7577 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7578 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7579 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7580 { } /* end */
7581};
7582
7583/*
7584 * 4ch mode
7585 */
7586static struct hda_verb alc883_4ST_ch4_init[] = {
7587 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7588 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7589 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7590 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7591 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7592 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7593 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7594 { } /* end */
7595};
7596
7597/*
7598 * 6ch mode
7599 */
7600static struct hda_verb alc883_4ST_ch6_init[] = {
7601 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7602 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7603 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7604 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7605 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7606 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7607 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7608 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7609 { } /* end */
7610};
7611
7612/*
7613 * 8ch mode
7614 */
7615static struct hda_verb alc883_4ST_ch8_init[] = {
7616 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7617 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7618 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7619 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7620 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7621 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7622 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7623 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7624 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7625 { } /* end */
7626};
7627
7628static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7629 { 2, alc883_4ST_ch2_init },
7630 { 4, alc883_4ST_ch4_init },
7631 { 6, alc883_4ST_ch6_init },
7632 { 8, alc883_4ST_ch8_init },
7633};
7634
7635
7636/*
7637 * 2ch mode
7638 */
7639static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7640 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7641 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7642 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7643 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7644 { } /* end */
7645};
7646
7647/*
7648 * 4ch mode
7649 */
7650static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7651 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7652 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7653 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7654 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7655 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7656 { } /* end */
7657};
7658
7659/*
7660 * 6ch mode
7661 */
7662static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7663 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7664 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7665 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7666 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7667 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7668 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7669 { } /* end */
7670};
7671
7672static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7673 { 2, alc883_3ST_ch2_intel_init },
7674 { 4, alc883_3ST_ch4_intel_init },
7675 { 6, alc883_3ST_ch6_intel_init },
7676};
7677
7678/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007679 * 2ch mode
7680 */
7681static struct hda_verb alc889_ch2_intel_init[] = {
7682 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7683 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7684 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7685 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7686 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7687 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7688 { } /* end */
7689};
7690
7691/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007692 * 6ch mode
7693 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007694static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007695 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7696 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7697 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7698 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7699 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007700 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7701 { } /* end */
7702};
7703
7704/*
7705 * 8ch mode
7706 */
7707static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007708 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7709 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7710 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7711 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7712 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007713 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7714 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007715 { } /* end */
7716};
7717
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007718static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7719 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007720 { 6, alc889_ch6_intel_init },
7721 { 8, alc889_ch8_intel_init },
7722};
7723
7724/*
7725 * 6ch mode
7726 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007727static struct hda_verb alc883_sixstack_ch6_init[] = {
7728 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7729 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7730 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7731 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7732 { } /* end */
7733};
7734
7735/*
7736 * 8ch mode
7737 */
7738static struct hda_verb alc883_sixstack_ch8_init[] = {
7739 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7740 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7741 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7742 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7743 { } /* end */
7744};
7745
7746static struct hda_channel_mode alc883_sixstack_modes[2] = {
7747 { 6, alc883_sixstack_ch6_init },
7748 { 8, alc883_sixstack_ch8_init },
7749};
7750
7751
Linus Torvalds1da177e2005-04-16 15:20:36 -07007752/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7753 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7754 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007755static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007756 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007757 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007758 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007759 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007760 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7761 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007762 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7763 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007764 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007765 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007766 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7767 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7768 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7769 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7770 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007772 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007773 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7774 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007775 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007776 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007777 { } /* end */
7778};
7779
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007780/* Macbook Air 2,1 same control for HP and internal Speaker */
7781
7782static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7783 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7784 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7785 { }
7786};
7787
7788
Takashi Iwai87350ad2007-08-16 18:19:38 +02007789static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007790 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7791 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7792 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7793 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7794 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7796 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7798 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007799 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007800 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7801 { } /* end */
7802};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007803
7804static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007805 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7806 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7807 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7808 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7809 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7810 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307811 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7812 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307813 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7814 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7816 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7817 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7818 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7819 { } /* end */
7820};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007821
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007822static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7823 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7824 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7825 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7826 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7827 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7828 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7829 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7830 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7831 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7832 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7833 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7834 { } /* end */
7835};
7836
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007837static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007838 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7839 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007840 { } /* end */
7841};
7842
7843
Kailang Yangbdd148a2007-05-08 15:19:08 +02007844static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7845 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7846 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7847 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7848 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7849 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7850 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7851 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7852 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007854 { } /* end */
7855};
7856
Kailang Yang272a5272007-05-14 11:00:38 +02007857static struct snd_kcontrol_new alc882_targa_mixer[] = {
7858 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7859 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7860 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7861 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7862 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7863 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7864 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7865 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7866 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007867 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007868 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7869 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007870 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007871 { } /* end */
7872};
7873
7874/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7875 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7876 */
7877static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7878 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7879 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7880 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7881 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7882 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7883 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7884 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7885 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7886 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7887 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007890 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007891 { } /* end */
7892};
7893
Takashi Iwai914759b2007-09-06 14:52:04 +02007894static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7895 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7896 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7898 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7899 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7900 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7901 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7903 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007905 { } /* end */
7906};
7907
Kailang Yangdf694da2005-12-05 19:42:22 +01007908static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7909 {
7910 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7911 .name = "Channel Mode",
7912 .info = alc_ch_mode_info,
7913 .get = alc_ch_mode_get,
7914 .put = alc_ch_mode_put,
7915 },
7916 { } /* end */
7917};
7918
Takashi Iwai4953550a2009-06-30 15:28:30 +02007919static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007920 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007921 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007923 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007924 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7925 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007926 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007927 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7928 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007929 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007930 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7931 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007932
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007933 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007934 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007935 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007936 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007937 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007940 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007941 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007942 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007943 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007944 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007945 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007946 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007947 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007948 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007949 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007950 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007951 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7952 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007953 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007954 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7955 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007956 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007957 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7958 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7959 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7960 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7961 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007962 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007963 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007964
7965 /* FIXME: use matrix-type input source selection */
7966 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007967 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007968 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007969 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007971 /* ADC2: mute amp left and right */
7972 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007973 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007974 /* ADC3: mute amp left and right */
7975 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007976 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007977
7978 { }
7979};
7980
Takashi Iwai4953550a2009-06-30 15:28:30 +02007981static struct hda_verb alc882_adc1_init_verbs[] = {
7982 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7983 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7987 /* ADC1: mute amp left and right */
7988 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7989 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7990 { }
7991};
7992
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007993static struct hda_verb alc882_eapd_verbs[] = {
7994 /* change to EAPD mode */
7995 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007996 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007997 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007998};
7999
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008000static struct hda_verb alc889_eapd_verbs[] = {
8001 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8002 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8003 { }
8004};
8005
Wu Fengguang6732bd02009-07-30 09:19:14 +02008006static struct hda_verb alc_hp15_unsol_verbs[] = {
8007 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8008 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8009 {}
8010};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008011
8012static struct hda_verb alc885_init_verbs[] = {
8013 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8015 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008016 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008017 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8018 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008019 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008020 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8021 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008022 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008023 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8024 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008025
8026 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008027 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008028 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8029 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8030 /* Front Pin: output 0 (0x0c) */
8031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8033 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8034 /* Rear Pin: output 1 (0x0d) */
8035 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8036 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8037 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8038 /* CLFE Pin: output 2 (0x0e) */
8039 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8040 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8041 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8042 /* Side Pin: output 3 (0x0f) */
8043 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8044 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8045 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8046 /* Mic (rear) pin: input vref at 80% */
8047 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8048 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8049 /* Front Mic pin: input vref at 80% */
8050 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8051 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8052 /* Line In pin: input */
8053 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8054 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8055
8056 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8057 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008058 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008059 /* Input mixer2 */
8060 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008061 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008063 /* ADC2: mute amp left and right */
8064 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8065 /* ADC3: mute amp left and right */
8066 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8067
8068 { }
8069};
8070
8071static struct hda_verb alc885_init_input_verbs[] = {
8072 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8073 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8074 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8075 { }
8076};
8077
8078
8079/* Unmute Selector 24h and set the default input to front mic */
8080static struct hda_verb alc889_init_input_verbs[] = {
8081 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8082 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8083 { }
8084};
8085
8086
Takashi Iwai4953550a2009-06-30 15:28:30 +02008087#define alc883_init_verbs alc882_base_init_verbs
8088
Tobin Davis9102cd12006-12-15 10:02:12 +01008089/* Mac Pro test */
8090static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8092 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8093 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8094 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8095 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008096 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008097 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8098 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008099 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008100 { } /* end */
8101};
8102
8103static struct hda_verb alc882_macpro_init_verbs[] = {
8104 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8108 /* Front Pin: output 0 (0x0c) */
8109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8111 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8112 /* Front Mic pin: input vref at 80% */
8113 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8114 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8115 /* Speaker: output */
8116 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8117 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8118 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8119 /* Headphone output (output 0 - 0x0c) */
8120 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8122 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8123
8124 /* FIXME: use matrix-type input source selection */
8125 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8126 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8127 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8128 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8129 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8130 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8131 /* Input mixer2 */
8132 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8133 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8134 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8135 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8136 /* Input mixer3 */
8137 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8138 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8139 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8140 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8141 /* ADC1: mute amp left and right */
8142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8143 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8144 /* ADC2: mute amp left and right */
8145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8146 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8147 /* ADC3: mute amp left and right */
8148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8149 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8150
8151 { }
8152};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008153
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008154/* Macbook 5,1 */
8155static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008156 /* DACs */
8157 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8158 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8159 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8160 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008161 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8164 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008165 /* Surround mixer */
8166 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8169 /* LFE mixer */
8170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8171 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8172 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8173 /* HP mixer */
8174 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8175 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8176 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8177 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008178 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8179 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008180 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8181 /* LFE Pin (0x0e) */
8182 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8183 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8184 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8185 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008186 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8187 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008188 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308189 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008190 /* Front Mic pin: input vref at 80% */
8191 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8192 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8193 /* Line In pin */
8194 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8195 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8196
Alex Murrayb8f171e2010-06-14 12:08:43 +09308197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008200 { }
8201};
8202
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008203/* Macmini 3,1 */
8204static struct hda_verb alc885_macmini3_init_verbs[] = {
8205 /* DACs */
8206 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8207 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8208 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8209 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8210 /* Front mixer */
8211 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8212 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8214 /* Surround mixer */
8215 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8216 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8217 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8218 /* LFE mixer */
8219 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8220 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8221 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8222 /* HP mixer */
8223 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8224 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8225 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8226 /* Front Pin (0x0c) */
8227 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8228 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8229 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8230 /* LFE Pin (0x0e) */
8231 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8232 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8233 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8234 /* HP Pin (0x0f) */
8235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8237 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8238 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8239 /* Line In pin */
8240 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8242
8243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8247 { }
8248};
8249
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008250
8251static struct hda_verb alc885_mba21_init_verbs[] = {
8252 /*Internal and HP Speaker Mixer*/
8253 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8255 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8256 /*Internal Speaker Pin (0x0c)*/
8257 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8258 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8259 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8260 /* HP Pin: output 0 (0x0e) */
8261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8262 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8263 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8264 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8265 /* Line in (is hp when jack connected)*/
8266 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8267 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8268
8269 { }
8270 };
8271
8272
Takashi Iwai87350ad2007-08-16 18:19:38 +02008273/* Macbook Pro rev3 */
8274static struct hda_verb alc885_mbp3_init_verbs[] = {
8275 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8276 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8279 /* Rear mixer */
8280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8281 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008283 /* HP mixer */
8284 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008287 /* Front Pin: output 0 (0x0c) */
8288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8289 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8290 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008291 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008292 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008293 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8294 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008295 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8296 /* Mic (rear) pin: input vref at 80% */
8297 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8298 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8299 /* Front Mic pin: input vref at 80% */
8300 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8301 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8302 /* Line In pin: use output 1 when in LineOut mode */
8303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8305 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8306
8307 /* FIXME: use matrix-type input source selection */
8308 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8309 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8310 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8311 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8312 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8313 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8314 /* Input mixer2 */
8315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8316 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8319 /* Input mixer3 */
8320 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8321 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8324 /* ADC1: mute amp left and right */
8325 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8326 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8327 /* ADC2: mute amp left and right */
8328 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8329 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8330 /* ADC3: mute amp left and right */
8331 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8332 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8333
8334 { }
8335};
8336
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008337/* iMac 9,1 */
8338static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008339 /* Internal Speaker Pin (0x0c) */
8340 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8341 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8342 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8343 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8344 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8345 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8346 /* HP Pin: Rear */
8347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8348 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8349 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8350 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8351 /* Line in Rear */
8352 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8354 /* Front Mic pin: input vref at 80% */
8355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8356 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008357 /* Rear mixer */
8358 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8359 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008361 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8365 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008366 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008370 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008375 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008380 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8382 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008383 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008384 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8385 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008386 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008387 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8388 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008389 { }
8390};
8391
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008392/* iMac 24 mixer. */
8393static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8394 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8395 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8396 { } /* end */
8397};
8398
8399/* iMac 24 init verbs. */
8400static struct hda_verb alc885_imac24_init_verbs[] = {
8401 /* Internal speakers: output 0 (0x0c) */
8402 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8403 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8404 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8405 /* Internal speakers: output 0 (0x0c) */
8406 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8407 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8408 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8409 /* Headphone: output 0 (0x0c) */
8410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8411 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8412 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8413 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8414 /* Front Mic: input vref at 80% */
8415 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8416 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8417 { }
8418};
8419
8420/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008421static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008422{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008423 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008424
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008425 spec->autocfg.hp_pins[0] = 0x14;
8426 spec->autocfg.speaker_pins[0] = 0x18;
8427 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008428}
8429
Takashi Iwai9d54f082010-02-22 08:34:40 +01008430#define alc885_mb5_setup alc885_imac24_setup
8431#define alc885_macmini3_setup alc885_imac24_setup
8432
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008433/* Macbook Air 2,1 */
8434static void alc885_mba21_setup(struct hda_codec *codec)
8435{
8436 struct alc_spec *spec = codec->spec;
8437
8438 spec->autocfg.hp_pins[0] = 0x14;
8439 spec->autocfg.speaker_pins[0] = 0x18;
8440}
8441
8442
8443
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008444static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008445{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008446 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008447
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008448 spec->autocfg.hp_pins[0] = 0x15;
8449 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008450}
8451
Takashi Iwai9d54f082010-02-22 08:34:40 +01008452static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308453{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008454 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308455
Takashi Iwai9d54f082010-02-22 08:34:40 +01008456 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008457 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008458 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008459}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008460
Kailang Yang272a5272007-05-14 11:00:38 +02008461static struct hda_verb alc882_targa_verbs[] = {
8462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8464
8465 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8466 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008467
Kailang Yang272a5272007-05-14 11:00:38 +02008468 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8469 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8470 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8471
8472 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008473 { } /* end */
8474};
8475
8476/* toggle speaker-output according to the hp-jack state */
8477static void alc882_targa_automute(struct hda_codec *codec)
8478{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008479 struct alc_spec *spec = codec->spec;
8480 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008481 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008482 spec->jack_present ? 1 : 3);
8483}
8484
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008485static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008486{
8487 struct alc_spec *spec = codec->spec;
8488
8489 spec->autocfg.hp_pins[0] = 0x14;
8490 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008491}
8492
8493static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8494{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008495 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008496 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008497}
8498
8499static struct hda_verb alc882_asus_a7j_verbs[] = {
8500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8502
8503 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8505 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008506
Kailang Yang272a5272007-05-14 11:00:38 +02008507 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8508 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8509 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8510
8511 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8512 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8513 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8514 { } /* end */
8515};
8516
Takashi Iwai914759b2007-09-06 14:52:04 +02008517static struct hda_verb alc882_asus_a7m_verbs[] = {
8518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8520
8521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8522 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8523 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008524
Takashi Iwai914759b2007-09-06 14:52:04 +02008525 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8526 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8527 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8528
8529 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8530 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8531 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8532 { } /* end */
8533};
8534
Tobin Davis9102cd12006-12-15 10:02:12 +01008535static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8536{
8537 unsigned int gpiostate, gpiomask, gpiodir;
8538
8539 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8540 AC_VERB_GET_GPIO_DATA, 0);
8541
8542 if (!muted)
8543 gpiostate |= (1 << pin);
8544 else
8545 gpiostate &= ~(1 << pin);
8546
8547 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8548 AC_VERB_GET_GPIO_MASK, 0);
8549 gpiomask |= (1 << pin);
8550
8551 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8552 AC_VERB_GET_GPIO_DIRECTION, 0);
8553 gpiodir |= (1 << pin);
8554
8555
8556 snd_hda_codec_write(codec, codec->afg, 0,
8557 AC_VERB_SET_GPIO_MASK, gpiomask);
8558 snd_hda_codec_write(codec, codec->afg, 0,
8559 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8560
8561 msleep(1);
8562
8563 snd_hda_codec_write(codec, codec->afg, 0,
8564 AC_VERB_SET_GPIO_DATA, gpiostate);
8565}
8566
Takashi Iwai7debbe52007-08-16 15:01:03 +02008567/* set up GPIO at initialization */
8568static void alc885_macpro_init_hook(struct hda_codec *codec)
8569{
8570 alc882_gpio_mute(codec, 0, 0);
8571 alc882_gpio_mute(codec, 1, 0);
8572}
8573
8574/* set up GPIO and update auto-muting at initialization */
8575static void alc885_imac24_init_hook(struct hda_codec *codec)
8576{
8577 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008578 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008579}
8580
Kailang Yangdf694da2005-12-05 19:42:22 +01008581/*
8582 * generic initialization of ADC, input mixers and output mixers
8583 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008584static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008585 /*
8586 * Unmute ADC0-2 and set the default input to mic-in
8587 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008588 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8589 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8590 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8592
Kailang Yangdf694da2005-12-05 19:42:22 +01008593 /*
8594 * Set up output mixers (0x0c - 0x0f)
8595 */
8596 /* set vol=0 to output mixers */
8597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8598 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8600 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8601 /* set up input amps for analog loopback */
8602 /* Amp Indices: DAC = 0, mixer = 1 */
8603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8605 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8606 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8607 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8608 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8609 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8610 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8611 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8612 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8613
8614 /* FIXME: use matrix-type input source selection */
8615 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008616 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008618 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008620 { }
8621};
8622
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008623/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8624static struct hda_verb alc889A_mb31_ch2_init[] = {
8625 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8626 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8627 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8628 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8629 { } /* end */
8630};
8631
8632/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8633static struct hda_verb alc889A_mb31_ch4_init[] = {
8634 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8635 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8636 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8637 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8638 { } /* end */
8639};
8640
8641/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8642static struct hda_verb alc889A_mb31_ch5_init[] = {
8643 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8644 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8645 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8646 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8647 { } /* end */
8648};
8649
8650/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8651static struct hda_verb alc889A_mb31_ch6_init[] = {
8652 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8654 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8655 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8656 { } /* end */
8657};
8658
8659static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8660 { 2, alc889A_mb31_ch2_init },
8661 { 4, alc889A_mb31_ch4_init },
8662 { 5, alc889A_mb31_ch5_init },
8663 { 6, alc889A_mb31_ch6_init },
8664};
8665
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008666static struct hda_verb alc883_medion_eapd_verbs[] = {
8667 /* eanable EAPD on medion laptop */
8668 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8669 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8670 { }
8671};
8672
Takashi Iwai4953550a2009-06-30 15:28:30 +02008673#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008674
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008675static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8676 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8677 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8678 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8679 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8680 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8681 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8683 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8684 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8685 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8686 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8687 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8688 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008689 { } /* end */
8690};
8691
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008692static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008693 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8694 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8695 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8696 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8697 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8698 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8699 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8700 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8701 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8702 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008703 { } /* end */
8704};
8705
Jiang zhefb97dc62008-03-06 11:07:11 +01008706static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8707 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8708 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8709 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8710 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8711 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8712 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8713 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8714 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8715 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8716 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008717 { } /* end */
8718};
8719
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008720static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8721 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8722 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8723 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8724 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8725 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8726 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8727 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8728 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008729 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008730 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8731 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008732 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008733 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008734 { } /* end */
8735};
8736
8737static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8738 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8739 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8740 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8741 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8742 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8743 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8744 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8745 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8746 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8747 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8748 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8749 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8750 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8751 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008752 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008753 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8754 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008755 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008756 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008757 { } /* end */
8758};
8759
Jiang zhe17bba1b2008-06-04 12:11:07 +02008760static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8761 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8762 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8763 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8764 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8765 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8766 HDA_OUTPUT),
8767 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8768 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8769 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8771 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8772 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8776 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8778 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8779 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008781 { } /* end */
8782};
8783
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008784static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8785 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8786 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8787 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8788 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8789 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8790 HDA_OUTPUT),
8791 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8792 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8793 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8794 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8795 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8796 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8797 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8798 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8800 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8801 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8802 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8803 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8804 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8805 { } /* end */
8806};
8807
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008808static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008809 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008810 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008811 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008812 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008813 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8814 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008815 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8816 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008817 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8818 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8819 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8820 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8821 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8822 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008823 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008824 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8825 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008826 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008827 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008828 { } /* end */
8829};
8830
Sasha Alexandrc2592492009-06-16 14:52:54 -04008831static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008832 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008833 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008834 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008835 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008836 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8837 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8838 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8839 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8840 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8841 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8842 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8843 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8844 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8845 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008847 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008849 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008850};
Kailang Yangccc656c2006-10-17 12:32:26 +02008851
Sasha Alexandrc2592492009-06-16 14:52:54 -04008852static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008853 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008854 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008855 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008856 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008857 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8858 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008860 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008862 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8863 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8864 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008865 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008866};
Kailang Yangccc656c2006-10-17 12:32:26 +02008867
Takashi Iwaib99dba32009-09-17 18:23:00 +02008868static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8869 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8870 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8871 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8872 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8873 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8874 { } /* end */
8875};
8876
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008877static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8878 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8879 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008880 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8881 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8883 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8884 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8885 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008886 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008887};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008888
Kailang Yang272a5272007-05-14 11:00:38 +02008889static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8890 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8891 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8893 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8894 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8896 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02008897 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8898 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008899 { } /* end */
8900};
8901
8902static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8903 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8904 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8905 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8906 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8907 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8908 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8909 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8910 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8911 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008912 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008913};
Kailang Yang272a5272007-05-14 11:00:38 +02008914
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008915static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8916 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8917 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8918 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8919 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8920 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8921 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8922 { } /* end */
8923};
8924
8925static struct hda_verb alc883_medion_wim2160_verbs[] = {
8926 /* Unmute front mixer */
8927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8928 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8929
8930 /* Set speaker pin to front mixer */
8931 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8932
8933 /* Init headphone pin */
8934 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8935 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8936 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8937 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8938
8939 { } /* end */
8940};
8941
8942/* toggle speaker-output according to the hp-jack state */
8943static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8944{
8945 struct alc_spec *spec = codec->spec;
8946
8947 spec->autocfg.hp_pins[0] = 0x1a;
8948 spec->autocfg.speaker_pins[0] = 0x15;
8949}
8950
Tobin Davis2880a862007-08-07 11:50:26 +02008951static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008952 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8953 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008954 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008955 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8956 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8958 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8959 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008960 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008961};
Tobin Davis2880a862007-08-07 11:50:26 +02008962
Tony Vroond2fd4b02009-06-21 00:40:10 +01008963static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008965 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008966 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8967 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008968 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8969 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8970 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8971 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8972 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8973 { } /* end */
8974};
8975
Kailang Yange2757d52008-08-26 13:17:46 +02008976static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8977 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8978 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8979 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8980 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8981 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8982 0x0d, 1, 0x0, HDA_OUTPUT),
8983 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8984 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8985 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8986 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8987 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8993 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8996 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008998 { } /* end */
8999};
9000
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009001static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9002 /* Output mixers */
9003 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9004 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9005 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9006 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9007 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9008 HDA_OUTPUT),
9009 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9010 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9011 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9012 /* Output switches */
9013 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9014 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9015 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9016 /* Boost mixers */
9017 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
9018 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
9019 /* Input mixers */
9020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9024 { } /* end */
9025};
9026
Guido Günther3e1647c2009-06-05 00:47:26 +02009027static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9028 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9029 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9030 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9032 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
9033 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9034 { } /* end */
9035};
9036
Kailang Yange2757d52008-08-26 13:17:46 +02009037static struct hda_bind_ctls alc883_bind_cap_vol = {
9038 .ops = &snd_hda_bind_vol,
9039 .values = {
9040 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9041 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9042 0
9043 },
9044};
9045
9046static struct hda_bind_ctls alc883_bind_cap_switch = {
9047 .ops = &snd_hda_bind_sw,
9048 .values = {
9049 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9050 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9051 0
9052 },
9053};
9054
9055static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9056 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9057 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9058 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9060 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9062 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009064 { } /* end */
9065};
9066
9067static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009068 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9069 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9070 {
9071 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9072 /* .name = "Capture Source", */
9073 .name = "Input Source",
9074 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009075 .info = alc_mux_enum_info,
9076 .get = alc_mux_enum_get,
9077 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009078 },
9079 { } /* end */
9080};
9081
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009082static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9083 {
9084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9085 .name = "Channel Mode",
9086 .info = alc_ch_mode_info,
9087 .get = alc_ch_mode_get,
9088 .put = alc_ch_mode_put,
9089 },
9090 { } /* end */
9091};
9092
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009093/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009094static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009095{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009096 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009097
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009098 spec->autocfg.hp_pins[0] = 0x15;
9099 spec->autocfg.speaker_pins[0] = 0x14;
9100 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009101}
9102
9103/* auto-toggle front mic */
9104/*
9105static void alc883_mitac_mic_automute(struct hda_codec *codec)
9106{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009107 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009108
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009109 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
9110}
9111*/
9112
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009113static struct hda_verb alc883_mitac_verbs[] = {
9114 /* HP */
9115 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9116 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9117 /* Subwoofer */
9118 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9119 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9120
9121 /* enable unsolicited event */
9122 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9123 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9124
9125 { } /* end */
9126};
9127
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309128static struct hda_verb alc883_clevo_m540r_verbs[] = {
9129 /* HP */
9130 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9131 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9132 /* Int speaker */
9133 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9134
9135 /* enable unsolicited event */
9136 /*
9137 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9138 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9139 */
9140
9141 { } /* end */
9142};
9143
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009144static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009145 /* HP */
9146 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9147 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9148 /* Int speaker */
9149 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9150 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9151
9152 /* enable unsolicited event */
9153 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009154 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009155
9156 { } /* end */
9157};
9158
Jiang zhefb97dc62008-03-06 11:07:11 +01009159static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9160 /* HP */
9161 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9162 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9163 /* Subwoofer */
9164 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9166
9167 /* enable unsolicited event */
9168 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9169
9170 { } /* end */
9171};
9172
Sasha Alexandrc2592492009-06-16 14:52:54 -04009173static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009174 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9176
9177 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9178 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009179
David Heidelberger64a8be72009-06-08 16:15:18 +02009180/* Connect Line-Out side jack (SPDIF) to Side */
9181 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9182 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9183 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9184/* Connect Mic jack to CLFE */
9185 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9186 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9187 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9188/* Connect Line-in jack to Surround */
9189 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9190 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9191 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9192/* Connect HP out jack to Front */
9193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9195 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009196
9197 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009198
9199 { } /* end */
9200};
9201
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009202static struct hda_verb alc883_lenovo_101e_verbs[] = {
9203 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9204 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9205 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9206 { } /* end */
9207};
9208
Kailang Yang272a5272007-05-14 11:00:38 +02009209static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9210 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9212 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9213 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9214 { } /* end */
9215};
9216
9217static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9220 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9221 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9222 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9223 { } /* end */
9224};
9225
Kailang Yang189609a2007-08-20 11:31:23 +02009226static struct hda_verb alc883_haier_w66_verbs[] = {
9227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9229
9230 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9231
9232 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9233 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9234 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9235 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9236 { } /* end */
9237};
9238
Kailang Yange2757d52008-08-26 13:17:46 +02009239static struct hda_verb alc888_lenovo_sky_verbs[] = {
9240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9242 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9243 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9244 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9245 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9246 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9247 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9248 { } /* end */
9249};
9250
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009251static struct hda_verb alc888_6st_dell_verbs[] = {
9252 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9253 { }
9254};
9255
Guido Günther3e1647c2009-06-05 00:47:26 +02009256static struct hda_verb alc883_vaiott_verbs[] = {
9257 /* HP */
9258 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9259 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9260
9261 /* enable unsolicited event */
9262 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9263
9264 { } /* end */
9265};
9266
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009267static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009268{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009269 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009270
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009271 spec->autocfg.hp_pins[0] = 0x1b;
9272 spec->autocfg.speaker_pins[0] = 0x14;
9273 spec->autocfg.speaker_pins[1] = 0x16;
9274 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009275}
9276
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009277static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009278 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009279 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9280 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009281 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009282 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009283};
9284
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009285/*
9286 * 2ch mode
9287 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009288static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009289 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9290 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9291 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9292 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009293 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009294};
9295
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009296/*
9297 * 4ch mode
9298 */
9299static struct hda_verb alc888_3st_hp_4ch_init[] = {
9300 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9301 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9302 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9303 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9304 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9305 { } /* end */
9306};
9307
9308/*
9309 * 6ch mode
9310 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009311static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009312 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9313 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009314 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009315 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9316 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009317 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9318 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009319};
9320
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009321static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009322 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009323 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009324 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009325};
9326
Kailang Yang272a5272007-05-14 11:00:38 +02009327/* toggle front-jack and RCA according to the hp-jack state */
9328static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9329{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009330 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009331
Takashi Iwai47fd8302007-08-10 17:11:07 +02009332 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9333 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9334 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9335 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009336}
9337
9338/* toggle RCA according to the front-jack state */
9339static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9340{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009341 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009342
Takashi Iwai47fd8302007-08-10 17:11:07 +02009343 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9344 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009345}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009346
Kailang Yang272a5272007-05-14 11:00:38 +02009347static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9348 unsigned int res)
9349{
9350 if ((res >> 26) == ALC880_HP_EVENT)
9351 alc888_lenovo_ms7195_front_automute(codec);
9352 if ((res >> 26) == ALC880_FRONT_EVENT)
9353 alc888_lenovo_ms7195_rca_automute(codec);
9354}
9355
9356static struct hda_verb alc883_medion_md2_verbs[] = {
9357 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9359
9360 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9361
9362 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9363 { } /* end */
9364};
9365
9366/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009367static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009368{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009369 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009370
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009371 spec->autocfg.hp_pins[0] = 0x14;
9372 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009373}
9374
Kailang Yangccc656c2006-10-17 12:32:26 +02009375/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009376#define alc883_targa_init_hook alc882_targa_init_hook
9377#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009378
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009379static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9380{
9381 unsigned int present;
9382
Takashi Iwaid56757a2009-11-18 08:00:14 +01009383 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009384 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9385 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9386}
9387
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009388static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009389{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009390 struct alc_spec *spec = codec->spec;
9391
9392 spec->autocfg.hp_pins[0] = 0x15;
9393 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009394}
9395
9396static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9397{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009398 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009399 alc883_clevo_m720_mic_automute(codec);
9400}
9401
9402static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009403 unsigned int res)
9404{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009405 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009406 case ALC880_MIC_EVENT:
9407 alc883_clevo_m720_mic_automute(codec);
9408 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009409 default:
9410 alc_automute_amp_unsol_event(codec, res);
9411 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009412 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009413}
9414
Jiang zhefb97dc62008-03-06 11:07:11 +01009415/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009416static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009417{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009418 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009419
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009420 spec->autocfg.hp_pins[0] = 0x14;
9421 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009422}
9423
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009424static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009425{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009426 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009427
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009428 spec->autocfg.hp_pins[0] = 0x1b;
9429 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009430}
9431
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009432static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9433{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009434 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009435
Takashi Iwai47fd8302007-08-10 17:11:07 +02009436 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9437 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009438}
9439
9440static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9441{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009442 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009443
Takashi Iwai47fd8302007-08-10 17:11:07 +02009444 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9445 HDA_AMP_MUTE, bits);
9446 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9447 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009448}
9449
9450static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9451 unsigned int res)
9452{
9453 if ((res >> 26) == ALC880_HP_EVENT)
9454 alc883_lenovo_101e_all_automute(codec);
9455 if ((res >> 26) == ALC880_FRONT_EVENT)
9456 alc883_lenovo_101e_ispeaker_automute(codec);
9457}
9458
Takashi Iwai676a9b52007-08-16 15:23:35 +02009459/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009460static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009461{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009462 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009463
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009464 spec->autocfg.hp_pins[0] = 0x14;
9465 spec->autocfg.speaker_pins[0] = 0x15;
9466 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009467}
9468
Kailang Yangd1a991a2007-08-15 16:21:59 +02009469static struct hda_verb alc883_acer_eapd_verbs[] = {
9470 /* HP Pin: output 0 (0x0c) */
9471 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9472 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9473 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9474 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009475 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9476 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009477 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009478 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9479 /* eanable EAPD on medion laptop */
9480 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9481 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009482 /* enable unsolicited event */
9483 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009484 { }
9485};
9486
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009487static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9489 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9490 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9491 { } /* end */
9492};
9493
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009494static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009495{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009496 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009497
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009498 spec->autocfg.hp_pins[0] = 0x1b;
9499 spec->autocfg.speaker_pins[0] = 0x14;
9500 spec->autocfg.speaker_pins[1] = 0x15;
9501 spec->autocfg.speaker_pins[2] = 0x16;
9502 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009503}
9504
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009505static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009506{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009507 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009508
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009509 spec->autocfg.hp_pins[0] = 0x1b;
9510 spec->autocfg.speaker_pins[0] = 0x14;
9511 spec->autocfg.speaker_pins[1] = 0x15;
9512 spec->autocfg.speaker_pins[2] = 0x16;
9513 spec->autocfg.speaker_pins[3] = 0x17;
9514 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009515}
9516
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009517static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009518{
9519 struct alc_spec *spec = codec->spec;
9520
9521 spec->autocfg.hp_pins[0] = 0x15;
9522 spec->autocfg.speaker_pins[0] = 0x14;
9523 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009524}
9525
Kailang Yange2757d52008-08-26 13:17:46 +02009526static struct hda_verb alc888_asus_m90v_verbs[] = {
9527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9528 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9529 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9530 /* enable unsolicited event */
9531 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9532 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9533 { } /* end */
9534};
9535
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009536static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009537{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009538 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009539
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009540 spec->autocfg.hp_pins[0] = 0x1b;
9541 spec->autocfg.speaker_pins[0] = 0x14;
9542 spec->autocfg.speaker_pins[1] = 0x15;
9543 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009544 spec->ext_mic.pin = 0x18;
9545 spec->int_mic.pin = 0x19;
9546 spec->ext_mic.mux_idx = 0;
9547 spec->int_mic.mux_idx = 1;
9548 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009549}
9550
9551static struct hda_verb alc888_asus_eee1601_verbs[] = {
9552 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9553 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9555 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9556 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9557 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9558 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9559 /* enable unsolicited event */
9560 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9561 { } /* end */
9562};
9563
Kailang Yange2757d52008-08-26 13:17:46 +02009564static void alc883_eee1601_inithook(struct hda_codec *codec)
9565{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009566 struct alc_spec *spec = codec->spec;
9567
9568 spec->autocfg.hp_pins[0] = 0x14;
9569 spec->autocfg.speaker_pins[0] = 0x1b;
9570 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009571}
9572
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009573static struct hda_verb alc889A_mb31_verbs[] = {
9574 /* Init rear pin (used as headphone output) */
9575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9576 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9577 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9578 /* Init line pin (used as output in 4ch and 6ch mode) */
9579 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9580 /* Init line 2 pin (used as headphone out by default) */
9581 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9582 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9583 { } /* end */
9584};
9585
9586/* Mute speakers according to the headphone jack state */
9587static void alc889A_mb31_automute(struct hda_codec *codec)
9588{
9589 unsigned int present;
9590
9591 /* Mute only in 2ch or 4ch mode */
9592 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9593 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009594 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009595 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9596 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9597 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9598 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9599 }
9600}
9601
9602static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9603{
9604 if ((res >> 26) == ALC880_HP_EVENT)
9605 alc889A_mb31_automute(codec);
9606}
9607
Takashi Iwai4953550a2009-06-30 15:28:30 +02009608
Takashi Iwaicb53c622007-08-10 17:21:45 +02009609#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009610#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009611#endif
9612
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009613/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009614#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9615#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9616#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9617#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9618
9619static hda_nid_t alc883_slave_dig_outs[] = {
9620 ALC1200_DIGOUT_NID, 0,
9621};
9622
9623static hda_nid_t alc1200_slave_dig_outs[] = {
9624 ALC883_DIGOUT_NID, 0,
9625};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009626
9627/*
9628 * configuration and preset
9629 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009630static const char *alc882_models[ALC882_MODEL_LAST] = {
9631 [ALC882_3ST_DIG] = "3stack-dig",
9632 [ALC882_6ST_DIG] = "6stack-dig",
9633 [ALC882_ARIMA] = "arima",
9634 [ALC882_W2JC] = "w2jc",
9635 [ALC882_TARGA] = "targa",
9636 [ALC882_ASUS_A7J] = "asus-a7j",
9637 [ALC882_ASUS_A7M] = "asus-a7m",
9638 [ALC885_MACPRO] = "macpro",
9639 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009640 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009641 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009642 [ALC885_MBP3] = "mbp3",
9643 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009644 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009645 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009646 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9647 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009648 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009649 [ALC883_TARGA_DIG] = "targa-dig",
9650 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009651 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009652 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009653 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009654 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009655 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009656 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009657 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009658 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009659 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009660 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009661 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009662 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009663 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9664 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009665 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009666 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009667 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009668 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009669 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309670 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009671 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009672 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009673 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009674 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009675 [ALC889A_INTEL] = "intel-alc889a",
9676 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009677 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009678 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009679 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009680 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009681};
9682
Takashi Iwai4953550a2009-06-30 15:28:30 +02009683static struct snd_pci_quirk alc882_cfg_tbl[] = {
9684 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9685
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009686 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009687 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009688 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009689 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9690 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009691 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009692 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9693 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009694 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009695 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009696 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9697 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009698 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9699 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009700 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9701 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009702 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009703 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009704 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009705 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009706 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9707 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009708 /* default Acer -- disabled as it causes more problems.
9709 * model=auto should work fine now
9710 */
9711 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009712
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009713 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009714
Tobin Davisfebe3372007-06-12 11:27:46 +02009715 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009716 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9717 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009718 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009719 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009720 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009721
9722 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9723 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9724 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009725 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009726 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9727 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9728 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009729 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009730 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009731 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009732 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009733
9734 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009735 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009736 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009737 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009738 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9739 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009740 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009741 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009742 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9743
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009744 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9745 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9746 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009747 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009748 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009749 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009750 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009751 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009752 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9753 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9754 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9755 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9756 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9757 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009758 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009759 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9760 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9761 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009762 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009763 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009764 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9765 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009766 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009767 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009768 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009769 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009770 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009771 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009772 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009773 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009774 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009775
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009776 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009777 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009778 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9779 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309780 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009781 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009782 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009783 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009784 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009785 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009786 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009787 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009788 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009789 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009790 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009791 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9792 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009793 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009794 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009795 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009796 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009797 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009798
Jiang zhe17bba1b2008-06-04 12:11:07 +02009799 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9800 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009801 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009802 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9803 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9804 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009805 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009806
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009807 {}
9808};
9809
Takashi Iwai4953550a2009-06-30 15:28:30 +02009810/* codec SSID table for Intel Mac */
9811static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9812 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9813 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9814 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9815 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9816 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9817 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9818 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009819 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009820 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009821 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009822 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009823 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9824 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9825 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009826 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009827 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009828 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009829 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9830 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009831 */
9832 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009833 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009834 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009835 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009836};
9837
Takashi Iwai4953550a2009-06-30 15:28:30 +02009838static struct alc_config_preset alc882_presets[] = {
9839 [ALC882_3ST_DIG] = {
9840 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009841 .init_verbs = { alc882_base_init_verbs,
9842 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009843 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9844 .dac_nids = alc882_dac_nids,
9845 .dig_out_nid = ALC882_DIGOUT_NID,
9846 .dig_in_nid = ALC882_DIGIN_NID,
9847 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9848 .channel_mode = alc882_ch_modes,
9849 .need_dac_fix = 1,
9850 .input_mux = &alc882_capture_source,
9851 },
9852 [ALC882_6ST_DIG] = {
9853 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009854 .init_verbs = { alc882_base_init_verbs,
9855 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009856 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9857 .dac_nids = alc882_dac_nids,
9858 .dig_out_nid = ALC882_DIGOUT_NID,
9859 .dig_in_nid = ALC882_DIGIN_NID,
9860 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9861 .channel_mode = alc882_sixstack_modes,
9862 .input_mux = &alc882_capture_source,
9863 },
9864 [ALC882_ARIMA] = {
9865 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009866 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9867 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009868 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9869 .dac_nids = alc882_dac_nids,
9870 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9871 .channel_mode = alc882_sixstack_modes,
9872 .input_mux = &alc882_capture_source,
9873 },
9874 [ALC882_W2JC] = {
9875 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009876 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9877 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009878 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9879 .dac_nids = alc882_dac_nids,
9880 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9881 .channel_mode = alc880_threestack_modes,
9882 .need_dac_fix = 1,
9883 .input_mux = &alc882_capture_source,
9884 .dig_out_nid = ALC882_DIGOUT_NID,
9885 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009886 [ALC885_MBA21] = {
9887 .mixers = { alc885_mba21_mixer },
9888 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9889 .num_dacs = 2,
9890 .dac_nids = alc882_dac_nids,
9891 .channel_mode = alc885_mba21_ch_modes,
9892 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9893 .input_mux = &alc882_capture_source,
9894 .unsol_event = alc_automute_amp_unsol_event,
9895 .setup = alc885_mba21_setup,
9896 .init_hook = alc_automute_amp,
9897 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009898 [ALC885_MBP3] = {
9899 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9900 .init_verbs = { alc885_mbp3_init_verbs,
9901 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009902 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009903 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009904 .hp_nid = 0x04,
9905 .channel_mode = alc885_mbp_4ch_modes,
9906 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009907 .input_mux = &alc882_capture_source,
9908 .dig_out_nid = ALC882_DIGOUT_NID,
9909 .dig_in_nid = ALC882_DIGIN_NID,
9910 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009911 .setup = alc885_mbp3_setup,
9912 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009913 },
9914 [ALC885_MB5] = {
9915 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9916 .init_verbs = { alc885_mb5_init_verbs,
9917 alc880_gpio1_init_verbs },
9918 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9919 .dac_nids = alc882_dac_nids,
9920 .channel_mode = alc885_mb5_6ch_modes,
9921 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9922 .input_mux = &mb5_capture_source,
9923 .dig_out_nid = ALC882_DIGOUT_NID,
9924 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009925 .unsol_event = alc_automute_amp_unsol_event,
9926 .setup = alc885_mb5_setup,
9927 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009928 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009929 [ALC885_MACMINI3] = {
9930 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9931 .init_verbs = { alc885_macmini3_init_verbs,
9932 alc880_gpio1_init_verbs },
9933 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9934 .dac_nids = alc882_dac_nids,
9935 .channel_mode = alc885_macmini3_6ch_modes,
9936 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9937 .input_mux = &macmini3_capture_source,
9938 .dig_out_nid = ALC882_DIGOUT_NID,
9939 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009940 .unsol_event = alc_automute_amp_unsol_event,
9941 .setup = alc885_macmini3_setup,
9942 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009943 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009944 [ALC885_MACPRO] = {
9945 .mixers = { alc882_macpro_mixer },
9946 .init_verbs = { alc882_macpro_init_verbs },
9947 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9948 .dac_nids = alc882_dac_nids,
9949 .dig_out_nid = ALC882_DIGOUT_NID,
9950 .dig_in_nid = ALC882_DIGIN_NID,
9951 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9952 .channel_mode = alc882_ch_modes,
9953 .input_mux = &alc882_capture_source,
9954 .init_hook = alc885_macpro_init_hook,
9955 },
9956 [ALC885_IMAC24] = {
9957 .mixers = { alc885_imac24_mixer },
9958 .init_verbs = { alc885_imac24_init_verbs },
9959 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9960 .dac_nids = alc882_dac_nids,
9961 .dig_out_nid = ALC882_DIGOUT_NID,
9962 .dig_in_nid = ALC882_DIGIN_NID,
9963 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9964 .channel_mode = alc882_ch_modes,
9965 .input_mux = &alc882_capture_source,
9966 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009967 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009968 .init_hook = alc885_imac24_init_hook,
9969 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009970 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009971 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009972 .init_verbs = { alc885_imac91_init_verbs,
9973 alc880_gpio1_init_verbs },
9974 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9975 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009976 .channel_mode = alc885_mba21_ch_modes,
9977 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9978 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009979 .dig_out_nid = ALC882_DIGOUT_NID,
9980 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009981 .unsol_event = alc_automute_amp_unsol_event,
9982 .setup = alc885_imac91_setup,
9983 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009984 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009985 [ALC882_TARGA] = {
9986 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009987 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009988 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009989 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9990 .dac_nids = alc882_dac_nids,
9991 .dig_out_nid = ALC882_DIGOUT_NID,
9992 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9993 .adc_nids = alc882_adc_nids,
9994 .capsrc_nids = alc882_capsrc_nids,
9995 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9996 .channel_mode = alc882_3ST_6ch_modes,
9997 .need_dac_fix = 1,
9998 .input_mux = &alc882_capture_source,
9999 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010000 .setup = alc882_targa_setup,
10001 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010002 },
10003 [ALC882_ASUS_A7J] = {
10004 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010005 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10006 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010007 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10008 .dac_nids = alc882_dac_nids,
10009 .dig_out_nid = ALC882_DIGOUT_NID,
10010 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10011 .adc_nids = alc882_adc_nids,
10012 .capsrc_nids = alc882_capsrc_nids,
10013 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10014 .channel_mode = alc882_3ST_6ch_modes,
10015 .need_dac_fix = 1,
10016 .input_mux = &alc882_capture_source,
10017 },
10018 [ALC882_ASUS_A7M] = {
10019 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010020 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10021 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010022 alc882_asus_a7m_verbs },
10023 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10024 .dac_nids = alc882_dac_nids,
10025 .dig_out_nid = ALC882_DIGOUT_NID,
10026 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10027 .channel_mode = alc880_threestack_modes,
10028 .need_dac_fix = 1,
10029 .input_mux = &alc882_capture_source,
10030 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010031 [ALC883_3ST_2ch_DIG] = {
10032 .mixers = { alc883_3ST_2ch_mixer },
10033 .init_verbs = { alc883_init_verbs },
10034 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10035 .dac_nids = alc883_dac_nids,
10036 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010037 .dig_in_nid = ALC883_DIGIN_NID,
10038 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10039 .channel_mode = alc883_3ST_2ch_modes,
10040 .input_mux = &alc883_capture_source,
10041 },
10042 [ALC883_3ST_6ch_DIG] = {
10043 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10044 .init_verbs = { alc883_init_verbs },
10045 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10046 .dac_nids = alc883_dac_nids,
10047 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010048 .dig_in_nid = ALC883_DIGIN_NID,
10049 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10050 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010051 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010052 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010053 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010054 [ALC883_3ST_6ch] = {
10055 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10056 .init_verbs = { alc883_init_verbs },
10057 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10058 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010059 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10060 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010061 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010062 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010063 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010064 [ALC883_3ST_6ch_INTEL] = {
10065 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10066 .init_verbs = { alc883_init_verbs },
10067 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10068 .dac_nids = alc883_dac_nids,
10069 .dig_out_nid = ALC883_DIGOUT_NID,
10070 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010071 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010072 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10073 .channel_mode = alc883_3ST_6ch_intel_modes,
10074 .need_dac_fix = 1,
10075 .input_mux = &alc883_3stack_6ch_intel,
10076 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010077 [ALC889A_INTEL] = {
10078 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010079 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10080 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010081 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10082 .dac_nids = alc883_dac_nids,
10083 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10084 .adc_nids = alc889_adc_nids,
10085 .dig_out_nid = ALC883_DIGOUT_NID,
10086 .dig_in_nid = ALC883_DIGIN_NID,
10087 .slave_dig_outs = alc883_slave_dig_outs,
10088 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10089 .channel_mode = alc889_8ch_intel_modes,
10090 .capsrc_nids = alc889_capsrc_nids,
10091 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010092 .setup = alc889_automute_setup,
10093 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010094 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010095 .need_dac_fix = 1,
10096 },
10097 [ALC889_INTEL] = {
10098 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10099 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010100 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010101 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10102 .dac_nids = alc883_dac_nids,
10103 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10104 .adc_nids = alc889_adc_nids,
10105 .dig_out_nid = ALC883_DIGOUT_NID,
10106 .dig_in_nid = ALC883_DIGIN_NID,
10107 .slave_dig_outs = alc883_slave_dig_outs,
10108 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10109 .channel_mode = alc889_8ch_intel_modes,
10110 .capsrc_nids = alc889_capsrc_nids,
10111 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010112 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010113 .init_hook = alc889_intel_init_hook,
10114 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010115 .need_dac_fix = 1,
10116 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010117 [ALC883_6ST_DIG] = {
10118 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10119 .init_verbs = { alc883_init_verbs },
10120 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10121 .dac_nids = alc883_dac_nids,
10122 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010123 .dig_in_nid = ALC883_DIGIN_NID,
10124 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10125 .channel_mode = alc883_sixstack_modes,
10126 .input_mux = &alc883_capture_source,
10127 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010128 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010129 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010130 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10131 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010132 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10133 .dac_nids = alc883_dac_nids,
10134 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010135 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10136 .channel_mode = alc883_3ST_6ch_modes,
10137 .need_dac_fix = 1,
10138 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010139 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010140 .setup = alc882_targa_setup,
10141 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010142 },
10143 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010144 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010145 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10146 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010147 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10148 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010149 .adc_nids = alc883_adc_nids_alt,
10150 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010151 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010152 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010153 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10154 .channel_mode = alc883_3ST_2ch_modes,
10155 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010156 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010157 .setup = alc882_targa_setup,
10158 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010159 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010160 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010161 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10162 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010163 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010164 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010165 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10166 .dac_nids = alc883_dac_nids,
10167 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10168 .adc_nids = alc883_adc_nids_rev,
10169 .capsrc_nids = alc883_capsrc_nids_rev,
10170 .dig_out_nid = ALC883_DIGOUT_NID,
10171 .dig_in_nid = ALC883_DIGIN_NID,
10172 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10173 .channel_mode = alc883_4ST_8ch_modes,
10174 .need_dac_fix = 1,
10175 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010176 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010177 .setup = alc882_targa_setup,
10178 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010179 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010180 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010181 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010182 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10183 * and the headphone jack. Turn this on and rely on the
10184 * standard mute methods whenever the user wants to turn
10185 * these outputs off.
10186 */
10187 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10188 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10189 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010190 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10191 .channel_mode = alc883_3ST_2ch_modes,
10192 .input_mux = &alc883_capture_source,
10193 },
Tobin Davis2880a862007-08-07 11:50:26 +020010194 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010195 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010196 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010197 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10198 .dac_nids = alc883_dac_nids,
10199 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010200 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10201 .channel_mode = alc883_3ST_2ch_modes,
10202 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010203 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010204 .setup = alc883_acer_aspire_setup,
10205 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010206 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010207 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010208 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010209 alc883_chmode_mixer },
10210 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10211 alc888_acer_aspire_4930g_verbs },
10212 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10213 .dac_nids = alc883_dac_nids,
10214 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10215 .adc_nids = alc883_adc_nids_rev,
10216 .capsrc_nids = alc883_capsrc_nids_rev,
10217 .dig_out_nid = ALC883_DIGOUT_NID,
10218 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10219 .channel_mode = alc883_3ST_6ch_modes,
10220 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010221 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010222 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010223 ARRAY_SIZE(alc888_2_capture_sources),
10224 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010225 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010226 .setup = alc888_acer_aspire_4930g_setup,
10227 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010228 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010229 [ALC888_ACER_ASPIRE_6530G] = {
10230 .mixers = { alc888_acer_aspire_6530_mixer },
10231 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10232 alc888_acer_aspire_6530g_verbs },
10233 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10234 .dac_nids = alc883_dac_nids,
10235 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10236 .adc_nids = alc883_adc_nids_rev,
10237 .capsrc_nids = alc883_capsrc_nids_rev,
10238 .dig_out_nid = ALC883_DIGOUT_NID,
10239 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10240 .channel_mode = alc883_3ST_2ch_modes,
10241 .num_mux_defs =
10242 ARRAY_SIZE(alc888_2_capture_sources),
10243 .input_mux = alc888_acer_aspire_6530_sources,
10244 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010245 .setup = alc888_acer_aspire_6530g_setup,
10246 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010247 },
Hector Martin3b315d72009-06-02 10:54:19 +020010248 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010249 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010250 alc883_chmode_mixer },
10251 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010252 alc889_acer_aspire_8930g_verbs,
10253 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010254 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10255 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010256 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10257 .adc_nids = alc889_adc_nids,
10258 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010259 .dig_out_nid = ALC883_DIGOUT_NID,
10260 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10261 .channel_mode = alc883_3ST_6ch_modes,
10262 .need_dac_fix = 1,
10263 .const_channel_count = 6,
10264 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010265 ARRAY_SIZE(alc889_capture_sources),
10266 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010267 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010268 .setup = alc889_acer_aspire_8930g_setup,
10269 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010270#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010271 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010272#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010273 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010274 [ALC888_ACER_ASPIRE_7730G] = {
10275 .mixers = { alc883_3ST_6ch_mixer,
10276 alc883_chmode_mixer },
10277 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10278 alc888_acer_aspire_7730G_verbs },
10279 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10280 .dac_nids = alc883_dac_nids,
10281 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10282 .adc_nids = alc883_adc_nids_rev,
10283 .capsrc_nids = alc883_capsrc_nids_rev,
10284 .dig_out_nid = ALC883_DIGOUT_NID,
10285 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10286 .channel_mode = alc883_3ST_6ch_modes,
10287 .need_dac_fix = 1,
10288 .const_channel_count = 6,
10289 .input_mux = &alc883_capture_source,
10290 .unsol_event = alc_automute_amp_unsol_event,
10291 .setup = alc888_acer_aspire_6530g_setup,
10292 .init_hook = alc_automute_amp,
10293 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010294 [ALC883_MEDION] = {
10295 .mixers = { alc883_fivestack_mixer,
10296 alc883_chmode_mixer },
10297 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010298 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010299 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10300 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010301 .adc_nids = alc883_adc_nids_alt,
10302 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010303 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010304 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10305 .channel_mode = alc883_sixstack_modes,
10306 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010307 },
Kailang Yang272a5272007-05-14 11:00:38 +020010308 [ALC883_MEDION_MD2] = {
10309 .mixers = { alc883_medion_md2_mixer},
10310 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
10311 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10312 .dac_nids = alc883_dac_nids,
10313 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010314 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10315 .channel_mode = alc883_3ST_2ch_modes,
10316 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010317 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010318 .setup = alc883_medion_md2_setup,
10319 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020010320 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010321 [ALC883_MEDION_WIM2160] = {
10322 .mixers = { alc883_medion_wim2160_mixer },
10323 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10324 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10325 .dac_nids = alc883_dac_nids,
10326 .dig_out_nid = ALC883_DIGOUT_NID,
10327 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10328 .adc_nids = alc883_adc_nids,
10329 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10330 .channel_mode = alc883_3ST_2ch_modes,
10331 .input_mux = &alc883_capture_source,
10332 .unsol_event = alc_automute_amp_unsol_event,
10333 .setup = alc883_medion_wim2160_setup,
10334 .init_hook = alc_automute_amp,
10335 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010336 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010337 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010338 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10339 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10340 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010341 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10342 .channel_mode = alc883_3ST_2ch_modes,
10343 .input_mux = &alc883_capture_source,
10344 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010345 [ALC883_CLEVO_M540R] = {
10346 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10347 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10348 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10349 .dac_nids = alc883_dac_nids,
10350 .dig_out_nid = ALC883_DIGOUT_NID,
10351 .dig_in_nid = ALC883_DIGIN_NID,
10352 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10353 .channel_mode = alc883_3ST_6ch_clevo_modes,
10354 .need_dac_fix = 1,
10355 .input_mux = &alc883_capture_source,
10356 /* This machine has the hardware HP auto-muting, thus
10357 * we need no software mute via unsol event
10358 */
10359 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010360 [ALC883_CLEVO_M720] = {
10361 .mixers = { alc883_clevo_m720_mixer },
10362 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010363 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10364 .dac_nids = alc883_dac_nids,
10365 .dig_out_nid = ALC883_DIGOUT_NID,
10366 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10367 .channel_mode = alc883_3ST_2ch_modes,
10368 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010369 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010370 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010371 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010372 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010373 [ALC883_LENOVO_101E_2ch] = {
10374 .mixers = { alc883_lenovo_101e_2ch_mixer},
10375 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10376 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10377 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010378 .adc_nids = alc883_adc_nids_alt,
10379 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010380 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010381 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10382 .channel_mode = alc883_3ST_2ch_modes,
10383 .input_mux = &alc883_lenovo_101e_capture_source,
10384 .unsol_event = alc883_lenovo_101e_unsol_event,
10385 .init_hook = alc883_lenovo_101e_all_automute,
10386 },
Kailang Yang272a5272007-05-14 11:00:38 +020010387 [ALC883_LENOVO_NB0763] = {
10388 .mixers = { alc883_lenovo_nb0763_mixer },
10389 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10390 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10391 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010392 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10393 .channel_mode = alc883_3ST_2ch_modes,
10394 .need_dac_fix = 1,
10395 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010396 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010397 .setup = alc883_medion_md2_setup,
10398 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010399 },
10400 [ALC888_LENOVO_MS7195_DIG] = {
10401 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10402 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10403 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10404 .dac_nids = alc883_dac_nids,
10405 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010406 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10407 .channel_mode = alc883_3ST_6ch_modes,
10408 .need_dac_fix = 1,
10409 .input_mux = &alc883_capture_source,
10410 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10411 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010412 },
10413 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010414 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010415 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10416 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10417 .dac_nids = alc883_dac_nids,
10418 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010419 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10420 .channel_mode = alc883_3ST_2ch_modes,
10421 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010422 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010423 .setup = alc883_haier_w66_setup,
10424 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010425 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010426 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010427 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010428 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010429 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10430 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010431 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10432 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010433 .need_dac_fix = 1,
10434 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010435 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010436 .setup = alc888_3st_hp_setup,
10437 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010438 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010439 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010440 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010441 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10442 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10443 .dac_nids = alc883_dac_nids,
10444 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010445 .dig_in_nid = ALC883_DIGIN_NID,
10446 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10447 .channel_mode = alc883_sixstack_modes,
10448 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010449 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010450 .setup = alc888_6st_dell_setup,
10451 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010452 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010453 [ALC883_MITAC] = {
10454 .mixers = { alc883_mitac_mixer },
10455 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10456 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10457 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010458 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10459 .channel_mode = alc883_3ST_2ch_modes,
10460 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010461 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010462 .setup = alc883_mitac_setup,
10463 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010464 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010465 [ALC883_FUJITSU_PI2515] = {
10466 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10467 .init_verbs = { alc883_init_verbs,
10468 alc883_2ch_fujitsu_pi2515_verbs},
10469 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10470 .dac_nids = alc883_dac_nids,
10471 .dig_out_nid = ALC883_DIGOUT_NID,
10472 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10473 .channel_mode = alc883_3ST_2ch_modes,
10474 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010475 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010476 .setup = alc883_2ch_fujitsu_pi2515_setup,
10477 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010478 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010479 [ALC888_FUJITSU_XA3530] = {
10480 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10481 .init_verbs = { alc883_init_verbs,
10482 alc888_fujitsu_xa3530_verbs },
10483 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10484 .dac_nids = alc883_dac_nids,
10485 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10486 .adc_nids = alc883_adc_nids_rev,
10487 .capsrc_nids = alc883_capsrc_nids_rev,
10488 .dig_out_nid = ALC883_DIGOUT_NID,
10489 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10490 .channel_mode = alc888_4ST_8ch_intel_modes,
10491 .num_mux_defs =
10492 ARRAY_SIZE(alc888_2_capture_sources),
10493 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010494 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010495 .setup = alc888_fujitsu_xa3530_setup,
10496 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010497 },
Kailang Yange2757d52008-08-26 13:17:46 +020010498 [ALC888_LENOVO_SKY] = {
10499 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10500 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10501 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10502 .dac_nids = alc883_dac_nids,
10503 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010504 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10505 .channel_mode = alc883_sixstack_modes,
10506 .need_dac_fix = 1,
10507 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010508 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010509 .setup = alc888_lenovo_sky_setup,
10510 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010511 },
10512 [ALC888_ASUS_M90V] = {
10513 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10514 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10515 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10516 .dac_nids = alc883_dac_nids,
10517 .dig_out_nid = ALC883_DIGOUT_NID,
10518 .dig_in_nid = ALC883_DIGIN_NID,
10519 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10520 .channel_mode = alc883_3ST_6ch_modes,
10521 .need_dac_fix = 1,
10522 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010523 .unsol_event = alc_sku_unsol_event,
10524 .setup = alc883_mode2_setup,
10525 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010526 },
10527 [ALC888_ASUS_EEE1601] = {
10528 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010529 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010530 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10531 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10532 .dac_nids = alc883_dac_nids,
10533 .dig_out_nid = ALC883_DIGOUT_NID,
10534 .dig_in_nid = ALC883_DIGIN_NID,
10535 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10536 .channel_mode = alc883_3ST_2ch_modes,
10537 .need_dac_fix = 1,
10538 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010539 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010540 .init_hook = alc883_eee1601_inithook,
10541 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010542 [ALC1200_ASUS_P5Q] = {
10543 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10544 .init_verbs = { alc883_init_verbs },
10545 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10546 .dac_nids = alc883_dac_nids,
10547 .dig_out_nid = ALC1200_DIGOUT_NID,
10548 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010549 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010550 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10551 .channel_mode = alc883_sixstack_modes,
10552 .input_mux = &alc883_capture_source,
10553 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010554 [ALC889A_MB31] = {
10555 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10556 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10557 alc880_gpio1_init_verbs },
10558 .adc_nids = alc883_adc_nids,
10559 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010560 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010561 .dac_nids = alc883_dac_nids,
10562 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10563 .channel_mode = alc889A_mb31_6ch_modes,
10564 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10565 .input_mux = &alc889A_mb31_capture_source,
10566 .dig_out_nid = ALC883_DIGOUT_NID,
10567 .unsol_event = alc889A_mb31_unsol_event,
10568 .init_hook = alc889A_mb31_automute,
10569 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010570 [ALC883_SONY_VAIO_TT] = {
10571 .mixers = { alc883_vaiott_mixer },
10572 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10573 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10574 .dac_nids = alc883_dac_nids,
10575 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10576 .channel_mode = alc883_3ST_2ch_modes,
10577 .input_mux = &alc883_capture_source,
10578 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010579 .setup = alc883_vaiott_setup,
10580 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010581 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010582};
10583
10584
10585/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010586 * Pin config fixes
10587 */
10588enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010589 PINFIX_ABIT_AW9D_MAX,
10590 PINFIX_PB_M5210,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010591};
10592
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010593static const struct alc_fixup alc882_fixups[] = {
10594 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010595 .pins = (const struct alc_pincfg[]) {
10596 { 0x15, 0x01080104 }, /* side */
10597 { 0x16, 0x01011012 }, /* rear */
10598 { 0x17, 0x01016011 }, /* clfe */
10599 { }
10600 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010601 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010602 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010603 .verbs = (const struct hda_verb[]) {
10604 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10605 {}
10606 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010607 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010608};
10609
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010610static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010611 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010612 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10613 {}
10614};
10615
10616/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010617 * BIOS auto configuration
10618 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010619static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10620 const struct auto_pin_cfg *cfg)
10621{
10622 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10623}
10624
Takashi Iwai4953550a2009-06-30 15:28:30 +020010625static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010626 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010627 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010628{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010629 int idx;
10630
Takashi Iwai489008c2010-04-07 09:06:00 +020010631 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010632 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010633
Takashi Iwai489008c2010-04-07 09:06:00 +020010634 if (dac == 0x25)
10635 idx = 4;
10636 else if (dac >= 0x02 && dac <= 0x05)
10637 idx = dac - 2;
10638 else
10639 return;
10640 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010641}
10642
Takashi Iwai4953550a2009-06-30 15:28:30 +020010643static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010644{
10645 struct alc_spec *spec = codec->spec;
10646 int i;
10647
10648 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010649 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010650 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010651 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010652 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010653 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010654 }
10655}
10656
Takashi Iwai4953550a2009-06-30 15:28:30 +020010657static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010658{
10659 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010660 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010661 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010662
Takashi Iwai5855fb82010-09-16 18:24:02 +020010663 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10664 pin = spec->autocfg.hp_pins[i];
10665 if (!pin)
10666 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010667 dac = spec->multiout.hp_nid;
10668 if (!dac)
10669 dac = spec->multiout.dac_nids[0]; /* to front */
10670 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10671 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010672 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10673 pin = spec->autocfg.speaker_pins[i];
10674 if (!pin)
10675 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010676 dac = spec->multiout.extra_out_nid[0];
10677 if (!dac)
10678 dac = spec->multiout.dac_nids[0]; /* to front */
10679 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10680 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010681}
10682
Takashi Iwai4953550a2009-06-30 15:28:30 +020010683static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010684{
10685 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010686 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010687 int i;
10688
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010689 for (i = 0; i < cfg->num_inputs; i++) {
10690 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010691 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010692 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10693 snd_hda_codec_write(codec, nid, 0,
10694 AC_VERB_SET_AMP_GAIN_MUTE,
10695 AMP_OUT_MUTE);
10696 }
10697}
10698
10699static void alc882_auto_init_input_src(struct hda_codec *codec)
10700{
10701 struct alc_spec *spec = codec->spec;
10702 int c;
10703
10704 for (c = 0; c < spec->num_adc_nids; c++) {
10705 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10706 hda_nid_t nid = spec->capsrc_nids[c];
10707 unsigned int mux_idx;
10708 const struct hda_input_mux *imux;
10709 int conns, mute, idx, item;
10710
10711 conns = snd_hda_get_connections(codec, nid, conn_list,
10712 ARRAY_SIZE(conn_list));
10713 if (conns < 0)
10714 continue;
10715 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10716 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010717 if (!imux->num_items && mux_idx > 0)
10718 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010719 for (idx = 0; idx < conns; idx++) {
10720 /* if the current connection is the selected one,
10721 * unmute it as default - otherwise mute it
10722 */
10723 mute = AMP_IN_MUTE(idx);
10724 for (item = 0; item < imux->num_items; item++) {
10725 if (imux->items[item].index == idx) {
10726 if (spec->cur_mux[c] == item)
10727 mute = AMP_IN_UNMUTE(idx);
10728 break;
10729 }
10730 }
10731 /* check if we have a selector or mixer
10732 * we could check for the widget type instead, but
10733 * just check for Amp-In presence (in case of mixer
10734 * without amp-in there is something wrong, this
10735 * function shouldn't be used or capsrc nid is wrong)
10736 */
10737 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010738 snd_hda_codec_write(codec, nid, 0,
10739 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010740 mute);
10741 else if (mute != AMP_IN_MUTE(idx))
10742 snd_hda_codec_write(codec, nid, 0,
10743 AC_VERB_SET_CONNECT_SEL,
10744 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010745 }
10746 }
10747}
10748
Takashi Iwai4953550a2009-06-30 15:28:30 +020010749/* add mic boosts if needed */
10750static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010751{
10752 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010753 struct auto_pin_cfg *cfg = &spec->autocfg;
10754 int i, err;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010755 hda_nid_t nid;
10756
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010757 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010758 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010759 break;
10760 nid = cfg->inputs[i].pin;
10761 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +020010762 char label[32];
10763 snprintf(label, sizeof(label), "%s Boost",
10764 hda_get_autocfg_input_label(codec, cfg, i));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010765 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010766 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010767 if (err < 0)
10768 return err;
10769 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010770 }
10771 return 0;
10772}
10773
10774/* almost identical with ALC880 parser... */
10775static int alc882_parse_auto_config(struct hda_codec *codec)
10776{
10777 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010778 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010779 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010780
Takashi Iwai05f5f472009-08-25 13:10:18 +020010781 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10782 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010783 if (err < 0)
10784 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010785 if (!spec->autocfg.line_outs)
10786 return 0; /* can't find valid BIOS pin config */
10787
10788 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10789 if (err < 0)
10790 return err;
10791 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10792 if (err < 0)
10793 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010794 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10795 "Headphone");
10796 if (err < 0)
10797 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010798 err = alc880_auto_create_extra_out(spec,
10799 spec->autocfg.speaker_pins[0],
10800 "Speaker");
10801 if (err < 0)
10802 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010803 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10804 if (err < 0)
10805 return err;
10806
10807 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10808
Takashi Iwai757899a2010-07-30 10:48:14 +020010809 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010810
10811 if (spec->kctls.list)
10812 add_mixer(spec, spec->kctls.list);
10813
10814 add_verb(spec, alc883_auto_init_verbs);
10815 /* if ADC 0x07 is available, initialize it, too */
10816 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10817 add_verb(spec, alc882_adc1_init_verbs);
10818
10819 spec->num_mux_defs = 1;
10820 spec->input_mux = &spec->private_imux[0];
10821
Kailang Yang6227cdc2010-02-25 08:36:52 +010010822 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010823
10824 err = alc_auto_add_mic_boost(codec);
10825 if (err < 0)
10826 return err;
10827
Takashi Iwai776e1842007-08-29 15:07:11 +020010828 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010829}
10830
10831/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010832static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010833{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010834 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010835 alc882_auto_init_multi_out(codec);
10836 alc882_auto_init_hp_out(codec);
10837 alc882_auto_init_analog_input(codec);
10838 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010839 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010840 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010841 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010842}
10843
Takashi Iwai4953550a2009-06-30 15:28:30 +020010844static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010845{
10846 struct alc_spec *spec;
10847 int err, board_config;
10848
10849 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10850 if (spec == NULL)
10851 return -ENOMEM;
10852
10853 codec->spec = spec;
10854
Kailang Yangda00c242010-03-19 11:23:45 +010010855 alc_auto_parse_customize_define(codec);
10856
Takashi Iwai4953550a2009-06-30 15:28:30 +020010857 switch (codec->vendor_id) {
10858 case 0x10ec0882:
10859 case 0x10ec0885:
10860 break;
10861 default:
10862 /* ALC883 and variants */
10863 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10864 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010865 }
10866
Takashi Iwai4953550a2009-06-30 15:28:30 +020010867 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10868 alc882_models,
10869 alc882_cfg_tbl);
10870
10871 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10872 board_config = snd_hda_check_board_codec_sid_config(codec,
10873 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10874
10875 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010876 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010877 codec->chip_name);
10878 board_config = ALC882_AUTO;
10879 }
10880
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010881 if (board_config == ALC882_AUTO)
10882 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010883
10884 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010885 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010886 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010887 if (err < 0) {
10888 alc_free(codec);
10889 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010890 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010891 printk(KERN_INFO
10892 "hda_codec: Cannot set up configuration "
10893 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010894 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010895 }
10896 }
10897
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010898 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010899 err = snd_hda_attach_beep_device(codec, 0x1);
10900 if (err < 0) {
10901 alc_free(codec);
10902 return err;
10903 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010904 }
10905
Takashi Iwai4953550a2009-06-30 15:28:30 +020010906 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010907 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010908
Takashi Iwai4953550a2009-06-30 15:28:30 +020010909 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10910 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10911 /* FIXME: setup DAC5 */
10912 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10913 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10914
10915 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10916 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10917
Takashi Iwai4953550a2009-06-30 15:28:30 +020010918 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010919 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010920 spec->num_adc_nids = 0;
10921 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010922 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010923 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010924 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010925 hda_nid_t nid = alc882_adc_nids[i];
10926 unsigned int wcap = get_wcaps(codec, nid);
10927 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010928 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010929 if (wcap != AC_WID_AUD_IN)
10930 continue;
10931 spec->private_adc_nids[spec->num_adc_nids] = nid;
10932 err = snd_hda_get_connections(codec, nid, &cap, 1);
10933 if (err < 0)
10934 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010935 err = snd_hda_get_connections(codec, cap, items,
10936 ARRAY_SIZE(items));
10937 if (err < 0)
10938 continue;
10939 for (j = 0; j < imux->num_items; j++)
10940 if (imux->items[j].index >= err)
10941 break;
10942 if (j < imux->num_items)
10943 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010944 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10945 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010946 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010947 spec->adc_nids = spec->private_adc_nids;
10948 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010949 }
10950
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010951 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010952
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010953 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010010954 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010955
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010956 if (board_config == ALC882_AUTO)
10957 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10958
Takashi Iwai2134ea42008-01-10 16:53:55 +010010959 spec->vmaster_nid = 0x0c;
10960
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010961 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010962 if (board_config == ALC882_AUTO)
10963 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010964#ifdef CONFIG_SND_HDA_POWER_SAVE
10965 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010966 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010967#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010968
10969 return 0;
10970}
10971
Takashi Iwai4953550a2009-06-30 15:28:30 +020010972
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010973/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010974 * ALC262 support
10975 */
10976
10977#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10978#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10979
10980#define alc262_dac_nids alc260_dac_nids
10981#define alc262_adc_nids alc882_adc_nids
10982#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010983#define alc262_capsrc_nids alc882_capsrc_nids
10984#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010985
10986#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010987#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010988
Kailang Yang4e555fe2008-08-26 13:05:55 +020010989static hda_nid_t alc262_dmic_adc_nids[1] = {
10990 /* ADC0 */
10991 0x09
10992};
10993
10994static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10995
Kailang Yangdf694da2005-12-05 19:42:22 +010010996static struct snd_kcontrol_new alc262_base_mixer[] = {
10997 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10998 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10999 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11000 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11001 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11002 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11004 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011005 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011006 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11007 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011008 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011009 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11010 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11011 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11012 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011013 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011014};
11015
Takashi Iwaice875f02008-01-28 18:17:43 +010011016/* update HP, line and mono-out pins according to the master switch */
11017static void alc262_hp_master_update(struct hda_codec *codec)
11018{
11019 struct alc_spec *spec = codec->spec;
11020 int val = spec->master_sw;
11021
11022 /* HP & line-out */
11023 snd_hda_codec_write_cache(codec, 0x1b, 0,
11024 AC_VERB_SET_PIN_WIDGET_CONTROL,
11025 val ? PIN_HP : 0);
11026 snd_hda_codec_write_cache(codec, 0x15, 0,
11027 AC_VERB_SET_PIN_WIDGET_CONTROL,
11028 val ? PIN_HP : 0);
11029 /* mono (speaker) depending on the HP jack sense */
11030 val = val && !spec->jack_present;
11031 snd_hda_codec_write_cache(codec, 0x16, 0,
11032 AC_VERB_SET_PIN_WIDGET_CONTROL,
11033 val ? PIN_OUT : 0);
11034}
11035
11036static void alc262_hp_bpc_automute(struct hda_codec *codec)
11037{
11038 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011039
11040 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011041 alc262_hp_master_update(codec);
11042}
11043
11044static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11045{
11046 if ((res >> 26) != ALC880_HP_EVENT)
11047 return;
11048 alc262_hp_bpc_automute(codec);
11049}
11050
11051static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11052{
11053 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011054
11055 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011056 alc262_hp_master_update(codec);
11057}
11058
11059static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11060 unsigned int res)
11061{
11062 if ((res >> 26) != ALC880_HP_EVENT)
11063 return;
11064 alc262_hp_wildwest_automute(codec);
11065}
11066
Takashi Iwaib72519b2009-05-08 14:31:55 +020011067#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011068
11069static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11070 struct snd_ctl_elem_value *ucontrol)
11071{
11072 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11073 struct alc_spec *spec = codec->spec;
11074 int val = !!*ucontrol->value.integer.value;
11075
11076 if (val == spec->master_sw)
11077 return 0;
11078 spec->master_sw = val;
11079 alc262_hp_master_update(codec);
11080 return 1;
11081}
11082
Takashi Iwaib72519b2009-05-08 14:31:55 +020011083#define ALC262_HP_MASTER_SWITCH \
11084 { \
11085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11086 .name = "Master Playback Switch", \
11087 .info = snd_ctl_boolean_mono_info, \
11088 .get = alc262_hp_master_sw_get, \
11089 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011090 }, \
11091 { \
11092 .iface = NID_MAPPING, \
11093 .name = "Master Playback Switch", \
11094 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011095 }
11096
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011097
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011098static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011099 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011100 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11101 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11102 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011103 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11104 HDA_OUTPUT),
11105 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11106 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011109 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011110 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11111 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011112 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011113 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11114 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11115 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11116 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011117 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11118 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11119 { } /* end */
11120};
11121
Kailang Yangcd7509a2007-01-26 18:33:17 +010011122static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011123 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11125 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11126 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11127 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011128 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11129 HDA_OUTPUT),
11130 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11131 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011132 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11133 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011134 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011135 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11136 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11137 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11138 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011139 { } /* end */
11140};
11141
11142static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11143 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11144 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011145 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011146 { } /* end */
11147};
11148
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011149/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011150static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011151{
11152 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011153
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011154 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011155 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011156}
11157
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011158static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011159 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11160 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011161 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11162 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11165 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11166 { } /* end */
11167};
11168
11169static struct hda_verb alc262_hp_t5735_verbs[] = {
11170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11171 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11172
11173 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11174 { }
11175};
11176
Kailang Yang8c427222008-01-10 13:03:59 +010011177static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011178 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11179 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011180 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11181 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011182 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11183 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11184 { } /* end */
11185};
11186
11187static struct hda_verb alc262_hp_rp5700_verbs[] = {
11188 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11189 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11190 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11191 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11192 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11193 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11194 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11196 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11198 {}
11199};
11200
11201static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11202 .num_items = 1,
11203 .items = {
11204 { "Line", 0x1 },
11205 },
11206};
11207
Takashi Iwai42171c12009-05-08 14:11:43 +020011208/* bind hp and internal speaker mute (with plug check) as master switch */
11209static void alc262_hippo_master_update(struct hda_codec *codec)
11210{
11211 struct alc_spec *spec = codec->spec;
11212 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11213 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11214 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11215 unsigned int mute;
11216
11217 /* HP */
11218 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11219 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11220 HDA_AMP_MUTE, mute);
11221 /* mute internal speaker per jack sense */
11222 if (spec->jack_present)
11223 mute = HDA_AMP_MUTE;
11224 if (line_nid)
11225 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11226 HDA_AMP_MUTE, mute);
11227 if (speaker_nid && speaker_nid != line_nid)
11228 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11229 HDA_AMP_MUTE, mute);
11230}
11231
11232#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11233
11234static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11235 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011236{
11237 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011238 struct alc_spec *spec = codec->spec;
11239 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011240
Takashi Iwai42171c12009-05-08 14:11:43 +020011241 if (val == spec->master_sw)
11242 return 0;
11243 spec->master_sw = val;
11244 alc262_hippo_master_update(codec);
11245 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011246}
Takashi Iwai5b319542007-07-26 11:49:22 +020011247
Takashi Iwai42171c12009-05-08 14:11:43 +020011248#define ALC262_HIPPO_MASTER_SWITCH \
11249 { \
11250 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11251 .name = "Master Playback Switch", \
11252 .info = snd_ctl_boolean_mono_info, \
11253 .get = alc262_hippo_master_sw_get, \
11254 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011255 }, \
11256 { \
11257 .iface = NID_MAPPING, \
11258 .name = "Master Playback Switch", \
11259 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11260 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011261 }
11262
11263static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11264 ALC262_HIPPO_MASTER_SWITCH,
11265 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11266 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11267 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11268 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11269 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11271 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11272 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11273 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11274 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11275 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11276 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11277 { } /* end */
11278};
11279
11280static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11281 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11282 ALC262_HIPPO_MASTER_SWITCH,
11283 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11284 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11285 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11286 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11288 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11289 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11290 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11291 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11292 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11293 { } /* end */
11294};
11295
11296/* mute/unmute internal speaker according to the hp jack and mute state */
11297static void alc262_hippo_automute(struct hda_codec *codec)
11298{
11299 struct alc_spec *spec = codec->spec;
11300 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011301
Wu Fengguang864f92b2009-11-18 12:38:02 +080011302 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011303 alc262_hippo_master_update(codec);
11304}
11305
11306static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11307{
11308 if ((res >> 26) != ALC880_HP_EVENT)
11309 return;
11310 alc262_hippo_automute(codec);
11311}
11312
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011313static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011314{
11315 struct alc_spec *spec = codec->spec;
11316
11317 spec->autocfg.hp_pins[0] = 0x15;
11318 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011319}
11320
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011321static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011322{
11323 struct alc_spec *spec = codec->spec;
11324
11325 spec->autocfg.hp_pins[0] = 0x1b;
11326 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011327}
11328
11329
Kailang Yang272a5272007-05-14 11:00:38 +020011330static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011331 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011332 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011333 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11334 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11335 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11336 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11337 { } /* end */
11338};
11339
Kailang Yang83c34212007-07-05 11:43:05 +020011340static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011341 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11342 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011343 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11344 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11345 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11346 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11347 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11348 { } /* end */
11349};
Kailang Yang272a5272007-05-14 11:00:38 +020011350
Tony Vroonba340e82009-02-02 19:01:30 +000011351static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11352 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11353 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11354 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11355 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11356 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11357 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11358 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11360 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11361 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11362 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11363 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11364 { } /* end */
11365};
11366
11367static struct hda_verb alc262_tyan_verbs[] = {
11368 /* Headphone automute */
11369 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11370 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11371 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11372
11373 /* P11 AUX_IN, white 4-pin connector */
11374 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11375 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11376 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11377 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11378
11379 {}
11380};
11381
11382/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011383static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011384{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011385 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011386
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011387 spec->autocfg.hp_pins[0] = 0x1b;
11388 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011389}
11390
Tony Vroonba340e82009-02-02 19:01:30 +000011391
Kailang Yangdf694da2005-12-05 19:42:22 +010011392#define alc262_capture_mixer alc882_capture_mixer
11393#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11394
11395/*
11396 * generic initialization of ADC, input mixers and output mixers
11397 */
11398static struct hda_verb alc262_init_verbs[] = {
11399 /*
11400 * Unmute ADC0-2 and set the default input to mic-in
11401 */
11402 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11404 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11405 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11406 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11407 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11408
Takashi Iwaicb53c622007-08-10 17:21:45 +020011409 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011410 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011411 * Note: PASD motherboards uses the Line In 2 as the input for
11412 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011413 */
11414 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011415 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11416 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11417 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11418 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11419 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011420
11421 /*
11422 * Set up output mixers (0x0c - 0x0e)
11423 */
11424 /* set vol=0 to output mixers */
11425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11426 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11427 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11428 /* set up input amps for analog loopback */
11429 /* Amp Indices: DAC = 0, mixer = 1 */
11430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11432 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11433 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11435 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11436
11437 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11439 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11440 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11441 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11442 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11443
11444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11445 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11446 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11447 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11448 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011449
Kailang Yangdf694da2005-12-05 19:42:22 +010011450 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11451 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011452
Kailang Yangdf694da2005-12-05 19:42:22 +010011453 /* FIXME: use matrix-type input source selection */
11454 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11455 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11460 /* Input mixer2 */
11461 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11462 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11463 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11465 /* Input mixer3 */
11466 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11467 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11468 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011470
11471 { }
11472};
11473
Kailang Yang4e555fe2008-08-26 13:05:55 +020011474static struct hda_verb alc262_eapd_verbs[] = {
11475 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11476 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11477 { }
11478};
11479
Kailang Yangccc656c2006-10-17 12:32:26 +020011480static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11482 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11483 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11484
11485 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11486 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11487 {}
11488};
11489
Kailang Yang272a5272007-05-14 11:00:38 +020011490static struct hda_verb alc262_sony_unsol_verbs[] = {
11491 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11492 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11493 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11494
11495 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011497 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011498};
11499
Kailang Yang4e555fe2008-08-26 13:05:55 +020011500static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11501 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11502 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11503 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11504 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11505 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011506 { } /* end */
11507};
11508
11509static struct hda_verb alc262_toshiba_s06_verbs[] = {
11510 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11513 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11514 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11515 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11516 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11517 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11518 {}
11519};
11520
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011521static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011522{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011523 struct alc_spec *spec = codec->spec;
11524
11525 spec->autocfg.hp_pins[0] = 0x15;
11526 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011527 spec->ext_mic.pin = 0x18;
11528 spec->ext_mic.mux_idx = 0;
11529 spec->int_mic.pin = 0x12;
11530 spec->int_mic.mux_idx = 9;
11531 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011532}
11533
Takashi Iwai834be882006-03-01 14:16:17 +010011534/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011535 * nec model
11536 * 0x15 = headphone
11537 * 0x16 = internal speaker
11538 * 0x18 = external mic
11539 */
11540
11541static struct snd_kcontrol_new alc262_nec_mixer[] = {
11542 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11543 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11544
11545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11547 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11548
11549 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11550 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11551 { } /* end */
11552};
11553
11554static struct hda_verb alc262_nec_verbs[] = {
11555 /* Unmute Speaker */
11556 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11557
11558 /* Headphone */
11559 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11560 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11561
11562 /* External mic to headphone */
11563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11564 /* External mic to speaker */
11565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11566 {}
11567};
11568
11569/*
Takashi Iwai834be882006-03-01 14:16:17 +010011570 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011571 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11572 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011573 */
11574
11575#define ALC_HP_EVENT 0x37
11576
11577static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11578 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11579 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011580 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11581 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011582 {}
11583};
11584
Jiang zhe0e31daf2008-03-20 12:12:39 +010011585static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11586 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11587 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11588 {}
11589};
11590
Daniel T Chene2595322009-12-19 18:19:02 -050011591static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11592 /* Front Mic pin: input vref at 50% */
11593 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11594 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11595 {}
11596};
11597
Takashi Iwai834be882006-03-01 14:16:17 +010011598static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011599 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011600 .items = {
11601 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011602 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011603 { "CD", 0x4 },
11604 },
11605};
11606
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011607static struct hda_input_mux alc262_HP_capture_source = {
11608 .num_items = 5,
11609 .items = {
11610 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011611 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011612 { "Line", 0x2 },
11613 { "CD", 0x4 },
11614 { "AUX IN", 0x6 },
11615 },
11616};
11617
zhejiangaccbe492007-08-31 12:36:05 +020011618static struct hda_input_mux alc262_HP_D7000_capture_source = {
11619 .num_items = 4,
11620 .items = {
11621 { "Mic", 0x0 },
11622 { "Front Mic", 0x2 },
11623 { "Line", 0x1 },
11624 { "CD", 0x4 },
11625 },
11626};
11627
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011628/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011629static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11630{
11631 struct alc_spec *spec = codec->spec;
11632 unsigned int mute;
11633
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011634 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011635 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11636 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011637 spec->sense_updated = 1;
11638 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011639 /* unmute internal speaker only if both HPs are unplugged and
11640 * master switch is on
11641 */
11642 if (spec->jack_present)
11643 mute = HDA_AMP_MUTE;
11644 else
Takashi Iwai834be882006-03-01 14:16:17 +010011645 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011646 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11647 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011648}
11649
11650/* unsolicited event for HP jack sensing */
11651static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11652 unsigned int res)
11653{
11654 if ((res >> 26) != ALC_HP_EVENT)
11655 return;
11656 alc262_fujitsu_automute(codec, 1);
11657}
11658
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011659static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11660{
11661 alc262_fujitsu_automute(codec, 1);
11662}
11663
Takashi Iwai834be882006-03-01 14:16:17 +010011664/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011665static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11666 .ops = &snd_hda_bind_vol,
11667 .values = {
11668 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11669 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11670 0
11671 },
11672};
Takashi Iwai834be882006-03-01 14:16:17 +010011673
Jiang zhe0e31daf2008-03-20 12:12:39 +010011674/* mute/unmute internal speaker according to the hp jack and mute state */
11675static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11676{
11677 struct alc_spec *spec = codec->spec;
11678 unsigned int mute;
11679
11680 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011681 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011682 spec->sense_updated = 1;
11683 }
11684 if (spec->jack_present) {
11685 /* mute internal speaker */
11686 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11687 HDA_AMP_MUTE, HDA_AMP_MUTE);
11688 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11689 HDA_AMP_MUTE, HDA_AMP_MUTE);
11690 } else {
11691 /* unmute internal speaker if necessary */
11692 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11693 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11694 HDA_AMP_MUTE, mute);
11695 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11696 HDA_AMP_MUTE, mute);
11697 }
11698}
11699
11700/* unsolicited event for HP jack sensing */
11701static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11702 unsigned int res)
11703{
11704 if ((res >> 26) != ALC_HP_EVENT)
11705 return;
11706 alc262_lenovo_3000_automute(codec, 1);
11707}
11708
Takashi Iwai8de56b72009-07-24 16:51:47 +020011709static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11710 int dir, int idx, long *valp)
11711{
11712 int i, change = 0;
11713
11714 for (i = 0; i < 2; i++, valp++)
11715 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11716 HDA_AMP_MUTE,
11717 *valp ? 0 : HDA_AMP_MUTE);
11718 return change;
11719}
11720
Takashi Iwai834be882006-03-01 14:16:17 +010011721/* bind hp and internal speaker mute (with plug check) */
11722static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11723 struct snd_ctl_elem_value *ucontrol)
11724{
11725 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11726 long *valp = ucontrol->value.integer.value;
11727 int change;
11728
Takashi Iwai8de56b72009-07-24 16:51:47 +020011729 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11730 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011731 if (change)
11732 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011733 return change;
11734}
11735
11736static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011737 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011738 {
11739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11740 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011741 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011742 .info = snd_hda_mixer_amp_switch_info,
11743 .get = snd_hda_mixer_amp_switch_get,
11744 .put = alc262_fujitsu_master_sw_put,
11745 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11746 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011747 {
11748 .iface = NID_MAPPING,
11749 .name = "Master Playback Switch",
11750 .private_value = 0x1b,
11751 },
Takashi Iwai834be882006-03-01 14:16:17 +010011752 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11753 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11754 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11756 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011757 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11758 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11759 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011760 { } /* end */
11761};
11762
Jiang zhe0e31daf2008-03-20 12:12:39 +010011763/* bind hp and internal speaker mute (with plug check) */
11764static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11765 struct snd_ctl_elem_value *ucontrol)
11766{
11767 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11768 long *valp = ucontrol->value.integer.value;
11769 int change;
11770
Takashi Iwai8de56b72009-07-24 16:51:47 +020011771 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011772 if (change)
11773 alc262_lenovo_3000_automute(codec, 0);
11774 return change;
11775}
11776
11777static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11778 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11779 {
11780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11781 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011782 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011783 .info = snd_hda_mixer_amp_switch_info,
11784 .get = snd_hda_mixer_amp_switch_get,
11785 .put = alc262_lenovo_3000_master_sw_put,
11786 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11787 },
11788 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11789 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11790 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11792 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11793 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11794 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11795 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11796 { } /* end */
11797};
11798
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011799static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11800 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011801 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11804 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11805 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11806 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11807 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11808 { } /* end */
11809};
11810
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011811/* additional init verbs for Benq laptops */
11812static struct hda_verb alc262_EAPD_verbs[] = {
11813 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11814 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11815 {}
11816};
11817
Kailang Yang83c34212007-07-05 11:43:05 +020011818static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11819 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11820 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11821
11822 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11823 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11824 {}
11825};
11826
Tobin Davisf651b502007-10-26 12:40:47 +020011827/* Samsung Q1 Ultra Vista model setup */
11828static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011829 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11830 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11833 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011834 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011835 { } /* end */
11836};
11837
11838static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011839 /* output mixer */
11840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11842 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11843 /* speaker */
11844 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11845 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11846 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11847 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11848 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011849 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011850 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11852 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11853 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11854 /* internal mic */
11855 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11857 /* ADC, choose mic */
11858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11866 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11867 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011868 {}
11869};
11870
Tobin Davisf651b502007-10-26 12:40:47 +020011871/* mute/unmute internal speaker according to the hp jack and mute state */
11872static void alc262_ultra_automute(struct hda_codec *codec)
11873{
11874 struct alc_spec *spec = codec->spec;
11875 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011876
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011877 mute = 0;
11878 /* auto-mute only when HP is used as HP */
11879 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011880 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011881 if (spec->jack_present)
11882 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011883 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011884 /* mute/unmute internal speaker */
11885 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11886 HDA_AMP_MUTE, mute);
11887 /* mute/unmute HP */
11888 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11889 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011890}
11891
11892/* unsolicited event for HP jack sensing */
11893static void alc262_ultra_unsol_event(struct hda_codec *codec,
11894 unsigned int res)
11895{
11896 if ((res >> 26) != ALC880_HP_EVENT)
11897 return;
11898 alc262_ultra_automute(codec);
11899}
11900
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011901static struct hda_input_mux alc262_ultra_capture_source = {
11902 .num_items = 2,
11903 .items = {
11904 { "Mic", 0x1 },
11905 { "Headphone", 0x7 },
11906 },
11907};
11908
11909static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11910 struct snd_ctl_elem_value *ucontrol)
11911{
11912 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11913 struct alc_spec *spec = codec->spec;
11914 int ret;
11915
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011916 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011917 if (!ret)
11918 return 0;
11919 /* reprogram the HP pin as mic or HP according to the input source */
11920 snd_hda_codec_write_cache(codec, 0x15, 0,
11921 AC_VERB_SET_PIN_WIDGET_CONTROL,
11922 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11923 alc262_ultra_automute(codec); /* mute/unmute HP */
11924 return ret;
11925}
11926
11927static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11928 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11929 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11930 {
11931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11932 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011933 .info = alc_mux_enum_info,
11934 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011935 .put = alc262_ultra_mux_enum_put,
11936 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011937 {
11938 .iface = NID_MAPPING,
11939 .name = "Capture Source",
11940 .private_value = 0x15,
11941 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011942 { } /* end */
11943};
11944
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011945/* We use two mixers depending on the output pin; 0x16 is a mono output
11946 * and thus it's bound with a different mixer.
11947 * This function returns which mixer amp should be used.
11948 */
11949static int alc262_check_volbit(hda_nid_t nid)
11950{
11951 if (!nid)
11952 return 0;
11953 else if (nid == 0x16)
11954 return 2;
11955 else
11956 return 1;
11957}
11958
11959static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011960 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011961{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011962 unsigned long val;
11963 int vbit;
11964
11965 vbit = alc262_check_volbit(nid);
11966 if (!vbit)
11967 return 0;
11968 if (*vbits & vbit) /* a volume control for this mixer already there */
11969 return 0;
11970 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011971 if (vbit == 2)
11972 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11973 else
11974 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011975 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011976}
11977
11978static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011979 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011980{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011981 unsigned long val;
11982
11983 if (!nid)
11984 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011985 if (nid == 0x16)
11986 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11987 else
11988 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011989 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011990}
11991
Kailang Yangdf694da2005-12-05 19:42:22 +010011992/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011993static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11994 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011995{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011996 const char *pfx;
11997 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020011998 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011999
12000 spec->multiout.num_dacs = 1; /* only use one dac */
12001 spec->multiout.dac_nids = spec->private_dac_nids;
12002 spec->multiout.dac_nids[0] = 2;
12003
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012004 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
12005 pfx = "Master";
12006 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12007 pfx = "Speaker";
Takashi Iwai033688a2010-09-08 15:47:09 +020012008 else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
12009 pfx = "Headphone";
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012010 else
12011 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012012 for (i = 0; i < 2; i++) {
12013 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12014 if (err < 0)
12015 return err;
12016 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12017 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12018 "Speaker", i);
12019 if (err < 0)
12020 return err;
12021 }
12022 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12023 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12024 "Headphone", i);
12025 if (err < 0)
12026 return err;
12027 }
12028 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012029
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012030 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12031 alc262_check_volbit(cfg->speaker_pins[0]) |
12032 alc262_check_volbit(cfg->hp_pins[0]);
12033 if (vbits == 1 || vbits == 2)
12034 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012035 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012036 for (i = 0; i < 2; i++) {
12037 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12038 &vbits, i);
12039 if (err < 0)
12040 return err;
12041 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12042 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12043 "Speaker", &vbits, i);
12044 if (err < 0)
12045 return err;
12046 }
12047 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12048 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12049 "Headphone", &vbits, i);
12050 if (err < 0)
12051 return err;
12052 }
12053 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012054 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012055}
12056
Takashi Iwai05f5f472009-08-25 13:10:18 +020012057#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012058 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012059
12060/*
12061 * generic initialization of ADC, input mixers and output mixers
12062 */
12063static struct hda_verb alc262_volume_init_verbs[] = {
12064 /*
12065 * Unmute ADC0-2 and set the default input to mic-in
12066 */
12067 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12069 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12070 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12071 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12073
Takashi Iwaicb53c622007-08-10 17:21:45 +020012074 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012075 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012076 * Note: PASD motherboards uses the Line In 2 as the input for
12077 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012078 */
12079 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12081 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012085
12086 /*
12087 * Set up output mixers (0x0c - 0x0f)
12088 */
12089 /* set vol=0 to output mixers */
12090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12091 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12092 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012093
Kailang Yangdf694da2005-12-05 19:42:22 +010012094 /* set up input amps for analog loopback */
12095 /* Amp Indices: DAC = 0, mixer = 1 */
12096 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12097 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12098 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12099 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12100 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12101 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12102
12103 /* FIXME: use matrix-type input source selection */
12104 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12105 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12106 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12107 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12108 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12109 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12110 /* Input mixer2 */
12111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12112 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12113 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12114 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12115 /* Input mixer3 */
12116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12120
12121 { }
12122};
12123
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012124static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12125 /*
12126 * Unmute ADC0-2 and set the default input to mic-in
12127 */
12128 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12130 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12131 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12132 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12133 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12134
Takashi Iwaicb53c622007-08-10 17:21:45 +020012135 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012136 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012137 * Note: PASD motherboards uses the Line In 2 as the input for
12138 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012139 */
12140 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012141 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12142 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12143 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12144 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12145 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012148
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012149 /*
12150 * Set up output mixers (0x0c - 0x0e)
12151 */
12152 /* set vol=0 to output mixers */
12153 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12154 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12155 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12156
12157 /* set up input amps for analog loopback */
12158 /* Amp Indices: DAC = 0, mixer = 1 */
12159 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12160 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12161 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12162 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12163 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12164 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12165
Takashi Iwaice875f02008-01-28 18:17:43 +010012166 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012167 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12168 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12169
12170 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12171 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12172
12173 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12174 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12175
12176 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12177 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12178 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12179 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12180 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12181
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012182 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012183 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12184 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012185 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012186 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12187 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12188
12189
12190 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012191 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12192 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012202 /* Input mixer2 */
12203 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012204 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12205 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12206 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12207 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12208 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12209 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12210 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012212 /* Input mixer3 */
12213 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012214 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012222
Takashi Iwaice875f02008-01-28 18:17:43 +010012223 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12224
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012225 { }
12226};
12227
Kailang Yangcd7509a2007-01-26 18:33:17 +010012228static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12229 /*
12230 * Unmute ADC0-2 and set the default input to mic-in
12231 */
12232 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12234 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12236 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12238
Takashi Iwaicb53c622007-08-10 17:21:45 +020012239 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012240 * mixer widget
12241 * Note: PASD motherboards uses the Line In 2 as the input for front
12242 * panel mic (mic 2)
12243 */
12244 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12247 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12248 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12249 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012253 /*
12254 * Set up output mixers (0x0c - 0x0e)
12255 */
12256 /* set vol=0 to output mixers */
12257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12258 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12259 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12260
12261 /* set up input amps for analog loopback */
12262 /* Amp Indices: DAC = 0, mixer = 1 */
12263 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12265 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12266 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12267 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12268 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12269
12270
12271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12273 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12274 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12275 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12276 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12277 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12278
12279 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12281
12282 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12283 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12284
12285 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12286 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12287 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12288 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12289 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12290 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12291
12292 /* FIXME: use matrix-type input source selection */
12293 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12294 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12296 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12297 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12298 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12300 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12301 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12302 /* Input mixer2 */
12303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12304 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12308 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12310 /* Input mixer3 */
12311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12316 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12318
Takashi Iwaice875f02008-01-28 18:17:43 +010012319 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12320
Kailang Yangcd7509a2007-01-26 18:33:17 +010012321 { }
12322};
12323
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012324static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12325
12326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12327 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12328 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12329
12330 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12331 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12332 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12333 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12334
12335 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12337 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12338 {}
12339};
12340
Takashi Iwai18675e42010-09-08 15:55:44 +020012341/*
12342 * Pin config fixes
12343 */
12344enum {
12345 PINFIX_FSC_H270,
12346};
12347
12348static const struct alc_fixup alc262_fixups[] = {
12349 [PINFIX_FSC_H270] = {
12350 .pins = (const struct alc_pincfg[]) {
12351 { 0x14, 0x99130110 }, /* speaker */
12352 { 0x15, 0x0221142f }, /* front HP */
12353 { 0x1b, 0x0121141f }, /* rear HP */
12354 { }
12355 }
12356 },
12357 [PINFIX_PB_M5210] = {
12358 .verbs = (const struct hda_verb[]) {
12359 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12360 {}
12361 }
12362 },
12363};
12364
12365static struct snd_pci_quirk alc262_fixup_tbl[] = {
12366 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12367 {}
12368};
12369
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012370
Takashi Iwaicb53c622007-08-10 17:21:45 +020012371#ifdef CONFIG_SND_HDA_POWER_SAVE
12372#define alc262_loopbacks alc880_loopbacks
12373#endif
12374
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012375/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012376#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12377#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12378#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12379#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12380
12381/*
12382 * BIOS auto configuration
12383 */
12384static int alc262_parse_auto_config(struct hda_codec *codec)
12385{
12386 struct alc_spec *spec = codec->spec;
12387 int err;
12388 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12389
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012390 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12391 alc262_ignore);
12392 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012393 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012394 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012395 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012396 spec->multiout.max_channels = 2;
12397 spec->no_analog = 1;
12398 goto dig_only;
12399 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012400 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012401 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012402 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12403 if (err < 0)
12404 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012405 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012406 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012407 return err;
12408
12409 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12410
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012411 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012412 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012413
Takashi Iwai603c4012008-07-30 15:01:44 +020012414 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012415 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012416
Takashi Iwaid88897e2008-10-31 15:01:37 +010012417 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012418 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012419 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012420
Takashi Iwai776e1842007-08-29 15:07:11 +020012421 err = alc_auto_add_mic_boost(codec);
12422 if (err < 0)
12423 return err;
12424
Kailang Yang6227cdc2010-02-25 08:36:52 +010012425 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012426
Kailang Yangdf694da2005-12-05 19:42:22 +010012427 return 1;
12428}
12429
12430#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12431#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12432#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012433#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012434
12435
12436/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012437static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012438{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012439 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012440 alc262_auto_init_multi_out(codec);
12441 alc262_auto_init_hp_out(codec);
12442 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012443 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012444 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012445 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012446 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012447}
12448
12449/*
12450 * configuration and preset
12451 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012452static const char *alc262_models[ALC262_MODEL_LAST] = {
12453 [ALC262_BASIC] = "basic",
12454 [ALC262_HIPPO] = "hippo",
12455 [ALC262_HIPPO_1] = "hippo_1",
12456 [ALC262_FUJITSU] = "fujitsu",
12457 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012458 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012459 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012460 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012461 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012462 [ALC262_BENQ_T31] = "benq-t31",
12463 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012464 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012465 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012466 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012467 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012468 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012469 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012470 [ALC262_AUTO] = "auto",
12471};
12472
12473static struct snd_pci_quirk alc262_cfg_tbl[] = {
12474 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012475 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012476 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12477 ALC262_HP_BPC),
12478 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12479 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012480 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12481 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012482 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012483 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012484 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012485 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012486 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012487 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012488 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012489 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012490 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12491 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12492 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012493 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12494 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012495 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012496 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012497 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012498 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012499 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012500 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012501 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012502 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012503#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012504 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12505 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012506#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012507 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012508 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012509 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012510 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012511 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012512 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012513 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12514 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012515 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012516 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012517 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012518 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012519 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012520 {}
12521};
12522
12523static struct alc_config_preset alc262_presets[] = {
12524 [ALC262_BASIC] = {
12525 .mixers = { alc262_base_mixer },
12526 .init_verbs = { alc262_init_verbs },
12527 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12528 .dac_nids = alc262_dac_nids,
12529 .hp_nid = 0x03,
12530 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12531 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012532 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012533 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012534 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012535 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012536 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012537 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12538 .dac_nids = alc262_dac_nids,
12539 .hp_nid = 0x03,
12540 .dig_out_nid = ALC262_DIGOUT_NID,
12541 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12542 .channel_mode = alc262_modes,
12543 .input_mux = &alc262_capture_source,
12544 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012545 .setup = alc262_hippo_setup,
12546 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012547 },
12548 [ALC262_HIPPO_1] = {
12549 .mixers = { alc262_hippo1_mixer },
12550 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12551 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12552 .dac_nids = alc262_dac_nids,
12553 .hp_nid = 0x02,
12554 .dig_out_nid = ALC262_DIGOUT_NID,
12555 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12556 .channel_mode = alc262_modes,
12557 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012558 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012559 .setup = alc262_hippo1_setup,
12560 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012561 },
Takashi Iwai834be882006-03-01 14:16:17 +010012562 [ALC262_FUJITSU] = {
12563 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012564 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12565 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012566 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12567 .dac_nids = alc262_dac_nids,
12568 .hp_nid = 0x03,
12569 .dig_out_nid = ALC262_DIGOUT_NID,
12570 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12571 .channel_mode = alc262_modes,
12572 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012573 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012574 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012575 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012576 [ALC262_HP_BPC] = {
12577 .mixers = { alc262_HP_BPC_mixer },
12578 .init_verbs = { alc262_HP_BPC_init_verbs },
12579 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12580 .dac_nids = alc262_dac_nids,
12581 .hp_nid = 0x03,
12582 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12583 .channel_mode = alc262_modes,
12584 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012585 .unsol_event = alc262_hp_bpc_unsol_event,
12586 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012587 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012588 [ALC262_HP_BPC_D7000_WF] = {
12589 .mixers = { alc262_HP_BPC_WildWest_mixer },
12590 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12591 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12592 .dac_nids = alc262_dac_nids,
12593 .hp_nid = 0x03,
12594 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12595 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012596 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012597 .unsol_event = alc262_hp_wildwest_unsol_event,
12598 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012599 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012600 [ALC262_HP_BPC_D7000_WL] = {
12601 .mixers = { alc262_HP_BPC_WildWest_mixer,
12602 alc262_HP_BPC_WildWest_option_mixer },
12603 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12604 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12605 .dac_nids = alc262_dac_nids,
12606 .hp_nid = 0x03,
12607 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12608 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012609 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012610 .unsol_event = alc262_hp_wildwest_unsol_event,
12611 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012612 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012613 [ALC262_HP_TC_T5735] = {
12614 .mixers = { alc262_hp_t5735_mixer },
12615 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12616 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12617 .dac_nids = alc262_dac_nids,
12618 .hp_nid = 0x03,
12619 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12620 .channel_mode = alc262_modes,
12621 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012622 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012623 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012624 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012625 },
12626 [ALC262_HP_RP5700] = {
12627 .mixers = { alc262_hp_rp5700_mixer },
12628 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12629 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12630 .dac_nids = alc262_dac_nids,
12631 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12632 .channel_mode = alc262_modes,
12633 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012634 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012635 [ALC262_BENQ_ED8] = {
12636 .mixers = { alc262_base_mixer },
12637 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12638 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12639 .dac_nids = alc262_dac_nids,
12640 .hp_nid = 0x03,
12641 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12642 .channel_mode = alc262_modes,
12643 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012644 },
Kailang Yang272a5272007-05-14 11:00:38 +020012645 [ALC262_SONY_ASSAMD] = {
12646 .mixers = { alc262_sony_mixer },
12647 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12648 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12649 .dac_nids = alc262_dac_nids,
12650 .hp_nid = 0x02,
12651 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12652 .channel_mode = alc262_modes,
12653 .input_mux = &alc262_capture_source,
12654 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012655 .setup = alc262_hippo_setup,
12656 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012657 },
12658 [ALC262_BENQ_T31] = {
12659 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012660 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12661 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012662 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12663 .dac_nids = alc262_dac_nids,
12664 .hp_nid = 0x03,
12665 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12666 .channel_mode = alc262_modes,
12667 .input_mux = &alc262_capture_source,
12668 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012669 .setup = alc262_hippo_setup,
12670 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012671 },
Tobin Davisf651b502007-10-26 12:40:47 +020012672 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012673 .mixers = { alc262_ultra_mixer },
12674 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012675 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012676 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12677 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012678 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12679 .channel_mode = alc262_modes,
12680 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012681 .adc_nids = alc262_adc_nids, /* ADC0 */
12682 .capsrc_nids = alc262_capsrc_nids,
12683 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012684 .unsol_event = alc262_ultra_unsol_event,
12685 .init_hook = alc262_ultra_automute,
12686 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012687 [ALC262_LENOVO_3000] = {
12688 .mixers = { alc262_lenovo_3000_mixer },
12689 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012690 alc262_lenovo_3000_unsol_verbs,
12691 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012692 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12693 .dac_nids = alc262_dac_nids,
12694 .hp_nid = 0x03,
12695 .dig_out_nid = ALC262_DIGOUT_NID,
12696 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12697 .channel_mode = alc262_modes,
12698 .input_mux = &alc262_fujitsu_capture_source,
12699 .unsol_event = alc262_lenovo_3000_unsol_event,
12700 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012701 [ALC262_NEC] = {
12702 .mixers = { alc262_nec_mixer },
12703 .init_verbs = { alc262_nec_verbs },
12704 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12705 .dac_nids = alc262_dac_nids,
12706 .hp_nid = 0x03,
12707 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12708 .channel_mode = alc262_modes,
12709 .input_mux = &alc262_capture_source,
12710 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012711 [ALC262_TOSHIBA_S06] = {
12712 .mixers = { alc262_toshiba_s06_mixer },
12713 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12714 alc262_eapd_verbs },
12715 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12716 .capsrc_nids = alc262_dmic_capsrc_nids,
12717 .dac_nids = alc262_dac_nids,
12718 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012719 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012720 .dig_out_nid = ALC262_DIGOUT_NID,
12721 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12722 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012723 .unsol_event = alc_sku_unsol_event,
12724 .setup = alc262_toshiba_s06_setup,
12725 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012726 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012727 [ALC262_TOSHIBA_RX1] = {
12728 .mixers = { alc262_toshiba_rx1_mixer },
12729 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12730 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12731 .dac_nids = alc262_dac_nids,
12732 .hp_nid = 0x03,
12733 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12734 .channel_mode = alc262_modes,
12735 .input_mux = &alc262_capture_source,
12736 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012737 .setup = alc262_hippo_setup,
12738 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012739 },
Tony Vroonba340e82009-02-02 19:01:30 +000012740 [ALC262_TYAN] = {
12741 .mixers = { alc262_tyan_mixer },
12742 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12743 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12744 .dac_nids = alc262_dac_nids,
12745 .hp_nid = 0x02,
12746 .dig_out_nid = ALC262_DIGOUT_NID,
12747 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12748 .channel_mode = alc262_modes,
12749 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012750 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012751 .setup = alc262_tyan_setup,
12752 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012753 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012754};
12755
12756static int patch_alc262(struct hda_codec *codec)
12757{
12758 struct alc_spec *spec;
12759 int board_config;
12760 int err;
12761
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012762 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012763 if (spec == NULL)
12764 return -ENOMEM;
12765
12766 codec->spec = spec;
12767#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012768 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12769 * under-run
12770 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012771 {
12772 int tmp;
12773 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12774 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12775 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12776 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12777 }
12778#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012779 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012780
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012781 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12782
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012783 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12784 alc262_models,
12785 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012786
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012787 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012788 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12789 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012790 board_config = ALC262_AUTO;
12791 }
12792
Takashi Iwai18675e42010-09-08 15:55:44 +020012793 if (board_config == ALC262_AUTO)
12794 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12795
Kailang Yangdf694da2005-12-05 19:42:22 +010012796 if (board_config == ALC262_AUTO) {
12797 /* automatic parse from the BIOS config */
12798 err = alc262_parse_auto_config(codec);
12799 if (err < 0) {
12800 alc_free(codec);
12801 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012802 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012803 printk(KERN_INFO
12804 "hda_codec: Cannot set up configuration "
12805 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012806 board_config = ALC262_BASIC;
12807 }
12808 }
12809
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012810 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012811 err = snd_hda_attach_beep_device(codec, 0x1);
12812 if (err < 0) {
12813 alc_free(codec);
12814 return err;
12815 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012816 }
12817
Kailang Yangdf694da2005-12-05 19:42:22 +010012818 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012819 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012820
Kailang Yangdf694da2005-12-05 19:42:22 +010012821 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12822 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012823
Kailang Yangdf694da2005-12-05 19:42:22 +010012824 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12825 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12826
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012827 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012828 int i;
12829 /* check whether the digital-mic has to be supported */
12830 for (i = 0; i < spec->input_mux->num_items; i++) {
12831 if (spec->input_mux->items[i].index >= 9)
12832 break;
12833 }
12834 if (i < spec->input_mux->num_items) {
12835 /* use only ADC0 */
12836 spec->adc_nids = alc262_dmic_adc_nids;
12837 spec->num_adc_nids = 1;
12838 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012839 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012840 /* all analog inputs */
12841 /* check whether NID 0x07 is valid */
12842 unsigned int wcap = get_wcaps(codec, 0x07);
12843
12844 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012845 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012846 if (wcap != AC_WID_AUD_IN) {
12847 spec->adc_nids = alc262_adc_nids_alt;
12848 spec->num_adc_nids =
12849 ARRAY_SIZE(alc262_adc_nids_alt);
12850 spec->capsrc_nids = alc262_capsrc_nids_alt;
12851 } else {
12852 spec->adc_nids = alc262_adc_nids;
12853 spec->num_adc_nids =
12854 ARRAY_SIZE(alc262_adc_nids);
12855 spec->capsrc_nids = alc262_capsrc_nids;
12856 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012857 }
12858 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012859 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012860 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012861 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012862 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012863
Takashi Iwai18675e42010-09-08 15:55:44 +020012864 if (board_config == ALC262_AUTO)
12865 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12866
Takashi Iwai2134ea42008-01-10 16:53:55 +010012867 spec->vmaster_nid = 0x0c;
12868
Kailang Yangdf694da2005-12-05 19:42:22 +010012869 codec->patch_ops = alc_patch_ops;
12870 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012871 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012872#ifdef CONFIG_SND_HDA_POWER_SAVE
12873 if (!spec->loopback.amplist)
12874 spec->loopback.amplist = alc262_loopbacks;
12875#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012876
Kailang Yangdf694da2005-12-05 19:42:22 +010012877 return 0;
12878}
12879
Kailang Yangdf694da2005-12-05 19:42:22 +010012880/*
Kailang Yanga361d842007-06-05 12:30:55 +020012881 * ALC268 channel source setting (2 channel)
12882 */
12883#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12884#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012885
Kailang Yanga361d842007-06-05 12:30:55 +020012886static hda_nid_t alc268_dac_nids[2] = {
12887 /* front, hp */
12888 0x02, 0x03
12889};
12890
12891static hda_nid_t alc268_adc_nids[2] = {
12892 /* ADC0-1 */
12893 0x08, 0x07
12894};
12895
12896static hda_nid_t alc268_adc_nids_alt[1] = {
12897 /* ADC0 */
12898 0x08
12899};
12900
Takashi Iwaie1406342008-02-11 18:32:32 +010012901static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12902
Kailang Yanga361d842007-06-05 12:30:55 +020012903static struct snd_kcontrol_new alc268_base_mixer[] = {
12904 /* output mixer control */
12905 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12906 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12907 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12908 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012909 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12910 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12911 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012912 { }
12913};
12914
Takashi Iwai42171c12009-05-08 14:11:43 +020012915static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12916 /* output mixer control */
12917 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12918 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12919 ALC262_HIPPO_MASTER_SWITCH,
12920 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12921 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12922 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12923 { }
12924};
12925
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012926/* bind Beep switches of both NID 0x0f and 0x10 */
12927static struct hda_bind_ctls alc268_bind_beep_sw = {
12928 .ops = &snd_hda_bind_sw,
12929 .values = {
12930 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12931 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12932 0
12933 },
12934};
12935
12936static struct snd_kcontrol_new alc268_beep_mixer[] = {
12937 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12938 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12939 { }
12940};
12941
Kailang Yangd1a991a2007-08-15 16:21:59 +020012942static struct hda_verb alc268_eapd_verbs[] = {
12943 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12944 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12945 { }
12946};
12947
Takashi Iwaid2738092007-08-16 14:59:45 +020012948/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012949static struct hda_verb alc268_toshiba_verbs[] = {
12950 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12951 { } /* end */
12952};
12953
12954/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012955/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012956static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12957 .ops = &snd_hda_bind_vol,
12958 .values = {
12959 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12960 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12961 0
12962 },
12963};
12964
Takashi Iwai889c4392007-08-23 18:56:52 +020012965/* mute/unmute internal speaker according to the hp jack and mute state */
12966static void alc268_acer_automute(struct hda_codec *codec, int force)
12967{
12968 struct alc_spec *spec = codec->spec;
12969 unsigned int mute;
12970
12971 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012972 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012973 spec->sense_updated = 1;
12974 }
12975 if (spec->jack_present)
12976 mute = HDA_AMP_MUTE; /* mute internal speaker */
12977 else /* unmute internal speaker if necessary */
12978 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12979 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12980 HDA_AMP_MUTE, mute);
12981}
12982
12983
12984/* bind hp and internal speaker mute (with plug check) */
12985static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12986 struct snd_ctl_elem_value *ucontrol)
12987{
12988 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12989 long *valp = ucontrol->value.integer.value;
12990 int change;
12991
Takashi Iwai8de56b72009-07-24 16:51:47 +020012992 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012993 if (change)
12994 alc268_acer_automute(codec, 0);
12995 return change;
12996}
Takashi Iwaid2738092007-08-16 14:59:45 +020012997
Kailang Yang8ef355d2008-08-26 13:10:22 +020012998static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12999 /* output mixer control */
13000 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13001 {
13002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13003 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013004 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013005 .info = snd_hda_mixer_amp_switch_info,
13006 .get = snd_hda_mixer_amp_switch_get,
13007 .put = alc268_acer_master_sw_put,
13008 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13009 },
13010 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13011 { }
13012};
13013
Takashi Iwaid2738092007-08-16 14:59:45 +020013014static struct snd_kcontrol_new alc268_acer_mixer[] = {
13015 /* output mixer control */
13016 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13017 {
13018 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13019 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013020 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013021 .info = snd_hda_mixer_amp_switch_info,
13022 .get = snd_hda_mixer_amp_switch_get,
13023 .put = alc268_acer_master_sw_put,
13024 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13025 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020013026 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13027 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13028 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013029 { }
13030};
13031
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013032static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13033 /* output mixer control */
13034 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13035 {
13036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13037 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013038 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013039 .info = snd_hda_mixer_amp_switch_info,
13040 .get = snd_hda_mixer_amp_switch_get,
13041 .put = alc268_acer_master_sw_put,
13042 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13043 },
13044 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13045 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13046 { }
13047};
13048
Kailang Yang8ef355d2008-08-26 13:10:22 +020013049static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13050 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13052 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13053 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13054 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13055 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13056 { }
13057};
13058
Takashi Iwaid2738092007-08-16 14:59:45 +020013059static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013060 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13061 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013062 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13063 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13065 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013066 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13067 { }
13068};
13069
13070/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013071#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013072#define alc268_toshiba_setup alc262_hippo_setup
13073#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013074
13075static void alc268_acer_unsol_event(struct hda_codec *codec,
13076 unsigned int res)
13077{
Takashi Iwai889c4392007-08-23 18:56:52 +020013078 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013079 return;
13080 alc268_acer_automute(codec, 1);
13081}
13082
Takashi Iwai889c4392007-08-23 18:56:52 +020013083static void alc268_acer_init_hook(struct hda_codec *codec)
13084{
13085 alc268_acer_automute(codec, 1);
13086}
13087
Kailang Yang8ef355d2008-08-26 13:10:22 +020013088/* toggle speaker-output according to the hp-jack state */
13089static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13090{
13091 unsigned int present;
13092 unsigned char bits;
13093
Wu Fengguang864f92b2009-11-18 12:38:02 +080013094 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013095 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013096 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013097 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013098 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013099 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013100}
13101
Kailang Yang8ef355d2008-08-26 13:10:22 +020013102static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13103 unsigned int res)
13104{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013105 switch (res >> 26) {
13106 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013107 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013108 break;
13109 case ALC880_MIC_EVENT:
13110 alc_mic_automute(codec);
13111 break;
13112 }
13113}
13114
13115static void alc268_acer_lc_setup(struct hda_codec *codec)
13116{
13117 struct alc_spec *spec = codec->spec;
13118 spec->ext_mic.pin = 0x18;
13119 spec->ext_mic.mux_idx = 0;
13120 spec->int_mic.pin = 0x12;
13121 spec->int_mic.mux_idx = 6;
13122 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013123}
13124
13125static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13126{
13127 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013128 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013129}
13130
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013131static struct snd_kcontrol_new alc268_dell_mixer[] = {
13132 /* output mixer control */
13133 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13134 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13135 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13137 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13138 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13139 { }
13140};
13141
13142static struct hda_verb alc268_dell_verbs[] = {
13143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13144 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13145 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013146 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013147 { }
13148};
13149
13150/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013151static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013152{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013153 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013154
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013155 spec->autocfg.hp_pins[0] = 0x15;
13156 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013157 spec->ext_mic.pin = 0x18;
13158 spec->ext_mic.mux_idx = 0;
13159 spec->int_mic.pin = 0x19;
13160 spec->int_mic.mux_idx = 1;
13161 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013162}
13163
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013164static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13165 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13166 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13167 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13168 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13169 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13170 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13171 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13172 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13173 { }
13174};
13175
13176static struct hda_verb alc267_quanta_il1_verbs[] = {
13177 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13178 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13179 { }
13180};
13181
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013182static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013183{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013184 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013185 spec->autocfg.hp_pins[0] = 0x15;
13186 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013187 spec->ext_mic.pin = 0x18;
13188 spec->ext_mic.mux_idx = 0;
13189 spec->int_mic.pin = 0x19;
13190 spec->int_mic.mux_idx = 1;
13191 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013192}
13193
Kailang Yanga361d842007-06-05 12:30:55 +020013194/*
13195 * generic initialization of ADC, input mixers and output mixers
13196 */
13197static struct hda_verb alc268_base_init_verbs[] = {
13198 /* Unmute DAC0-1 and set vol = 0 */
13199 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013200 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013201
13202 /*
13203 * Set up output mixers (0x0c - 0x0e)
13204 */
13205 /* set vol=0 to output mixers */
13206 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013207 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13208
13209 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13210 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13211
13212 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13213 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13214 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13215 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13216 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13217 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13218 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13219 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13220
13221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13223 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13224 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013225 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013226
13227 /* set PCBEEP vol = 0, mute connections */
13228 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13229 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13230 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013231
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013232 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013233
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013234 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13236 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013238
Kailang Yanga361d842007-06-05 12:30:55 +020013239 { }
13240};
13241
13242/*
13243 * generic initialization of ADC, input mixers and output mixers
13244 */
13245static struct hda_verb alc268_volume_init_verbs[] = {
13246 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013247 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13248 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013249
13250 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13251 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13252 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13253 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13254 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13255
Kailang Yanga361d842007-06-05 12:30:55 +020013256 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013257 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13258 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13259
13260 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013261 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013262
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013263 /* set PCBEEP vol = 0, mute connections */
13264 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13266 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013267
13268 { }
13269};
13270
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013271static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13272 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13273 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13274 { } /* end */
13275};
13276
Kailang Yanga361d842007-06-05 12:30:55 +020013277static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13278 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13279 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013280 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013281 { } /* end */
13282};
13283
13284static struct snd_kcontrol_new alc268_capture_mixer[] = {
13285 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13286 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13287 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13288 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013289 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013290 { } /* end */
13291};
13292
13293static struct hda_input_mux alc268_capture_source = {
13294 .num_items = 4,
13295 .items = {
13296 { "Mic", 0x0 },
13297 { "Front Mic", 0x1 },
13298 { "Line", 0x2 },
13299 { "CD", 0x3 },
13300 },
13301};
13302
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013303static struct hda_input_mux alc268_acer_capture_source = {
13304 .num_items = 3,
13305 .items = {
13306 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013307 { "Internal Mic", 0x1 },
13308 { "Line", 0x2 },
13309 },
13310};
13311
13312static struct hda_input_mux alc268_acer_dmic_capture_source = {
13313 .num_items = 3,
13314 .items = {
13315 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013316 { "Internal Mic", 0x6 },
13317 { "Line", 0x2 },
13318 },
13319};
13320
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013321#ifdef CONFIG_SND_DEBUG
13322static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013323 /* Volume widgets */
13324 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13325 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13326 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13327 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13328 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13329 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13330 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13331 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13332 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13333 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13334 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13335 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13336 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013337 /* The below appears problematic on some hardwares */
13338 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013339 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13340 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13341 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13342 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13343
13344 /* Modes for retasking pin widgets */
13345 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13346 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13347 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13348 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13349
13350 /* Controls for GPIO pins, assuming they are configured as outputs */
13351 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13352 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13353 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13354 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13355
13356 /* Switches to allow the digital SPDIF output pin to be enabled.
13357 * The ALC268 does not have an SPDIF input.
13358 */
13359 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13360
13361 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13362 * this output to turn on an external amplifier.
13363 */
13364 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13365 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13366
13367 { } /* end */
13368};
13369#endif
13370
Kailang Yanga361d842007-06-05 12:30:55 +020013371/* create input playback/capture controls for the given pin */
13372static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13373 const char *ctlname, int idx)
13374{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013375 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013376 int err;
13377
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013378 switch (nid) {
13379 case 0x14:
13380 case 0x16:
13381 dac = 0x02;
13382 break;
13383 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013384 case 0x1a: /* ALC259/269 only */
13385 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013386 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013387 dac = 0x03;
13388 break;
13389 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013390 snd_printd(KERN_WARNING "hda_codec: "
13391 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013392 return 0;
13393 }
13394 if (spec->multiout.dac_nids[0] != dac &&
13395 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013396 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013397 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013398 HDA_OUTPUT));
13399 if (err < 0)
13400 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013401 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13402 }
13403
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013404 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013405 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013406 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013407 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013408 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013409 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013410 if (err < 0)
13411 return err;
13412 return 0;
13413}
13414
13415/* add playback controls from the parsed DAC table */
13416static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13417 const struct auto_pin_cfg *cfg)
13418{
13419 hda_nid_t nid;
13420 int err;
13421
Kailang Yanga361d842007-06-05 12:30:55 +020013422 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013423
13424 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013425 if (nid) {
13426 const char *name;
13427 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13428 name = "Speaker";
13429 else
13430 name = "Front";
13431 err = alc268_new_analog_output(spec, nid, name, 0);
13432 if (err < 0)
13433 return err;
13434 }
Kailang Yanga361d842007-06-05 12:30:55 +020013435
13436 nid = cfg->speaker_pins[0];
13437 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013438 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013439 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13440 if (err < 0)
13441 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013442 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013443 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13444 if (err < 0)
13445 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013446 }
13447 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013448 if (nid) {
13449 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13450 if (err < 0)
13451 return err;
13452 }
Kailang Yanga361d842007-06-05 12:30:55 +020013453
13454 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13455 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013456 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013457 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013458 if (err < 0)
13459 return err;
13460 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013461 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013462}
13463
13464/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013465static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013466 const struct auto_pin_cfg *cfg)
13467{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013468 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013469}
13470
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013471static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13472 hda_nid_t nid, int pin_type)
13473{
13474 int idx;
13475
13476 alc_set_pin_output(codec, nid, pin_type);
13477 if (nid == 0x14 || nid == 0x16)
13478 idx = 0;
13479 else
13480 idx = 1;
13481 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13482}
13483
13484static void alc268_auto_init_multi_out(struct hda_codec *codec)
13485{
13486 struct alc_spec *spec = codec->spec;
13487 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13488 if (nid) {
13489 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13490 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13491 }
13492}
13493
13494static void alc268_auto_init_hp_out(struct hda_codec *codec)
13495{
13496 struct alc_spec *spec = codec->spec;
13497 hda_nid_t pin;
13498
13499 pin = spec->autocfg.hp_pins[0];
13500 if (pin)
13501 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13502 pin = spec->autocfg.speaker_pins[0];
13503 if (pin)
13504 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13505}
13506
Kailang Yanga361d842007-06-05 12:30:55 +020013507static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13508{
13509 struct alc_spec *spec = codec->spec;
13510 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13511 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13512 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13513 unsigned int dac_vol1, dac_vol2;
13514
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013515 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013516 snd_hda_codec_write(codec, speaker_nid, 0,
13517 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013518 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013519 snd_hda_codec_write(codec, 0x0f, 0,
13520 AC_VERB_SET_AMP_GAIN_MUTE,
13521 AMP_IN_UNMUTE(1));
13522 snd_hda_codec_write(codec, 0x10, 0,
13523 AC_VERB_SET_AMP_GAIN_MUTE,
13524 AMP_IN_UNMUTE(1));
13525 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013526 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013527 snd_hda_codec_write(codec, 0x0f, 0,
13528 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13529 snd_hda_codec_write(codec, 0x10, 0,
13530 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13531 }
13532
13533 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013534 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013535 dac_vol2 = AMP_OUT_ZERO;
13536 else if (line_nid == 0x15)
13537 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013538 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013539 dac_vol2 = AMP_OUT_ZERO;
13540 else if (hp_nid == 0x15)
13541 dac_vol1 = AMP_OUT_ZERO;
13542 if (line_nid != 0x16 || hp_nid != 0x16 ||
13543 spec->autocfg.line_out_pins[1] != 0x16 ||
13544 spec->autocfg.line_out_pins[2] != 0x16)
13545 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13546
13547 snd_hda_codec_write(codec, 0x02, 0,
13548 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13549 snd_hda_codec_write(codec, 0x03, 0,
13550 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13551}
13552
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013553/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013554#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13555#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013556#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013557#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13558
13559/*
13560 * BIOS auto configuration
13561 */
13562static int alc268_parse_auto_config(struct hda_codec *codec)
13563{
13564 struct alc_spec *spec = codec->spec;
13565 int err;
13566 static hda_nid_t alc268_ignore[] = { 0 };
13567
13568 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13569 alc268_ignore);
13570 if (err < 0)
13571 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013572 if (!spec->autocfg.line_outs) {
13573 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13574 spec->multiout.max_channels = 2;
13575 spec->no_analog = 1;
13576 goto dig_only;
13577 }
Kailang Yanga361d842007-06-05 12:30:55 +020013578 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013579 }
Kailang Yanga361d842007-06-05 12:30:55 +020013580 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13581 if (err < 0)
13582 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013583 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013584 if (err < 0)
13585 return err;
13586
13587 spec->multiout.max_channels = 2;
13588
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013589 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013590 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013591 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013592 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013593 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013594
Takashi Iwai892981f2009-03-02 08:04:35 +010013595 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013596 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013597
Takashi Iwaid88897e2008-10-31 15:01:37 +010013598 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013599 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013600 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013601
Takashi Iwai776e1842007-08-29 15:07:11 +020013602 err = alc_auto_add_mic_boost(codec);
13603 if (err < 0)
13604 return err;
13605
Kailang Yang6227cdc2010-02-25 08:36:52 +010013606 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013607
Kailang Yanga361d842007-06-05 12:30:55 +020013608 return 1;
13609}
13610
Kailang Yanga361d842007-06-05 12:30:55 +020013611#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13612
13613/* init callback for auto-configuration model -- overriding the default init */
13614static void alc268_auto_init(struct hda_codec *codec)
13615{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013616 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013617 alc268_auto_init_multi_out(codec);
13618 alc268_auto_init_hp_out(codec);
13619 alc268_auto_init_mono_speaker_out(codec);
13620 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013621 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013622 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013623 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013624}
13625
13626/*
13627 * configuration and preset
13628 */
13629static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013630 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013631 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013632 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013633 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013634 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013635 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013636 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013637 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013638#ifdef CONFIG_SND_DEBUG
13639 [ALC268_TEST] = "test",
13640#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013641 [ALC268_AUTO] = "auto",
13642};
13643
13644static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013645 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013646 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013647 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013648 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013649 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013650 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13651 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013652 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013653 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13654 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013655 /* almost compatible with toshiba but with optional digital outs;
13656 * auto-probing seems working fine
13657 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013658 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013659 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013660 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013661 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013662 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013663 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013664 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013665 {}
13666};
13667
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013668/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13669static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13670 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13671 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13672 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13673 ALC268_TOSHIBA),
13674 {}
13675};
13676
Kailang Yanga361d842007-06-05 12:30:55 +020013677static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013678 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013679 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13680 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013681 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13682 alc267_quanta_il1_verbs },
13683 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13684 .dac_nids = alc268_dac_nids,
13685 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13686 .adc_nids = alc268_adc_nids_alt,
13687 .hp_nid = 0x03,
13688 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13689 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013690 .unsol_event = alc_sku_unsol_event,
13691 .setup = alc267_quanta_il1_setup,
13692 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013693 },
Kailang Yanga361d842007-06-05 12:30:55 +020013694 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013695 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13696 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013697 .init_verbs = { alc268_base_init_verbs },
13698 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13699 .dac_nids = alc268_dac_nids,
13700 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13701 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013702 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013703 .hp_nid = 0x03,
13704 .dig_out_nid = ALC268_DIGOUT_NID,
13705 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13706 .channel_mode = alc268_modes,
13707 .input_mux = &alc268_capture_source,
13708 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013709 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013710 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013711 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013712 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13713 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013714 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13715 .dac_nids = alc268_dac_nids,
13716 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13717 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013718 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013719 .hp_nid = 0x03,
13720 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13721 .channel_mode = alc268_modes,
13722 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013723 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013724 .setup = alc268_toshiba_setup,
13725 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013726 },
13727 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013728 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013729 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013730 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13731 alc268_acer_verbs },
13732 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13733 .dac_nids = alc268_dac_nids,
13734 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13735 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013736 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013737 .hp_nid = 0x02,
13738 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13739 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013740 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013741 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013742 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013743 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013744 [ALC268_ACER_DMIC] = {
13745 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13746 alc268_beep_mixer },
13747 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13748 alc268_acer_verbs },
13749 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13750 .dac_nids = alc268_dac_nids,
13751 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13752 .adc_nids = alc268_adc_nids_alt,
13753 .capsrc_nids = alc268_capsrc_nids,
13754 .hp_nid = 0x02,
13755 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13756 .channel_mode = alc268_modes,
13757 .input_mux = &alc268_acer_dmic_capture_source,
13758 .unsol_event = alc268_acer_unsol_event,
13759 .init_hook = alc268_acer_init_hook,
13760 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013761 [ALC268_ACER_ASPIRE_ONE] = {
13762 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013763 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013764 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013765 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13766 alc268_acer_aspire_one_verbs },
13767 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13768 .dac_nids = alc268_dac_nids,
13769 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13770 .adc_nids = alc268_adc_nids_alt,
13771 .capsrc_nids = alc268_capsrc_nids,
13772 .hp_nid = 0x03,
13773 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13774 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013775 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013776 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013777 .init_hook = alc268_acer_lc_init_hook,
13778 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013779 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013780 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13781 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013782 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13783 alc268_dell_verbs },
13784 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13785 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013786 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13787 .adc_nids = alc268_adc_nids_alt,
13788 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013789 .hp_nid = 0x02,
13790 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13791 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013792 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013793 .setup = alc268_dell_setup,
13794 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013795 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013796 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013797 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13798 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013799 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13800 alc268_toshiba_verbs },
13801 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13802 .dac_nids = alc268_dac_nids,
13803 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13804 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013805 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013806 .hp_nid = 0x03,
13807 .dig_out_nid = ALC268_DIGOUT_NID,
13808 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13809 .channel_mode = alc268_modes,
13810 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013811 .setup = alc268_toshiba_setup,
13812 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013813 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013814#ifdef CONFIG_SND_DEBUG
13815 [ALC268_TEST] = {
13816 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13817 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13818 alc268_volume_init_verbs },
13819 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13820 .dac_nids = alc268_dac_nids,
13821 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13822 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013823 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013824 .hp_nid = 0x03,
13825 .dig_out_nid = ALC268_DIGOUT_NID,
13826 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13827 .channel_mode = alc268_modes,
13828 .input_mux = &alc268_capture_source,
13829 },
13830#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013831};
13832
13833static int patch_alc268(struct hda_codec *codec)
13834{
13835 struct alc_spec *spec;
13836 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013837 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013838
Julia Lawallef86f582009-12-19 08:18:03 +010013839 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013840 if (spec == NULL)
13841 return -ENOMEM;
13842
13843 codec->spec = spec;
13844
13845 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13846 alc268_models,
13847 alc268_cfg_tbl);
13848
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013849 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13850 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013851 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013852
Kailang Yanga361d842007-06-05 12:30:55 +020013853 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013854 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13855 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013856 board_config = ALC268_AUTO;
13857 }
13858
13859 if (board_config == ALC268_AUTO) {
13860 /* automatic parse from the BIOS config */
13861 err = alc268_parse_auto_config(codec);
13862 if (err < 0) {
13863 alc_free(codec);
13864 return err;
13865 } else if (!err) {
13866 printk(KERN_INFO
13867 "hda_codec: Cannot set up configuration "
13868 "from BIOS. Using base mode...\n");
13869 board_config = ALC268_3ST;
13870 }
13871 }
13872
13873 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013874 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013875
Kailang Yanga361d842007-06-05 12:30:55 +020013876 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13877 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013878 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013879
Kailang Yanga361d842007-06-05 12:30:55 +020013880 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13881
Takashi Iwai22971e32009-02-10 11:56:44 +010013882 has_beep = 0;
13883 for (i = 0; i < spec->num_mixers; i++) {
13884 if (spec->mixers[i] == alc268_beep_mixer) {
13885 has_beep = 1;
13886 break;
13887 }
13888 }
13889
13890 if (has_beep) {
13891 err = snd_hda_attach_beep_device(codec, 0x1);
13892 if (err < 0) {
13893 alc_free(codec);
13894 return err;
13895 }
13896 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13897 /* override the amp caps for beep generator */
13898 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013899 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13900 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13901 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13902 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013903 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013904
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013905 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013906 /* check whether NID 0x07 is valid */
13907 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013908 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013909
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013910 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013911 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013912 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013913 if (spec->auto_mic ||
13914 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013915 spec->adc_nids = alc268_adc_nids_alt;
13916 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013917 if (spec->auto_mic)
13918 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013919 if (spec->auto_mic || spec->input_mux->num_items == 1)
13920 add_mixer(spec, alc268_capture_nosrc_mixer);
13921 else
13922 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013923 } else {
13924 spec->adc_nids = alc268_adc_nids;
13925 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013926 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013927 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013928 /* set default input source */
13929 for (i = 0; i < spec->num_adc_nids; i++)
13930 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13931 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013932 i < spec->num_mux_defs ?
13933 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013934 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013935 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013936
13937 spec->vmaster_nid = 0x02;
13938
Kailang Yanga361d842007-06-05 12:30:55 +020013939 codec->patch_ops = alc_patch_ops;
13940 if (board_config == ALC268_AUTO)
13941 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013942
Kailang Yanga361d842007-06-05 12:30:55 +020013943 return 0;
13944}
13945
13946/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013947 * ALC269 channel source setting (2 channel)
13948 */
13949#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13950
13951#define alc269_dac_nids alc260_dac_nids
13952
13953static hda_nid_t alc269_adc_nids[1] = {
13954 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013955 0x08,
13956};
13957
Takashi Iwaie01bf502008-08-21 16:25:07 +020013958static hda_nid_t alc269_capsrc_nids[1] = {
13959 0x23,
13960};
13961
Kailang Yang84898e82010-02-04 14:16:14 +010013962static hda_nid_t alc269vb_adc_nids[1] = {
13963 /* ADC1 */
13964 0x09,
13965};
13966
13967static hda_nid_t alc269vb_capsrc_nids[1] = {
13968 0x22,
13969};
13970
Takashi Iwai66946352010-03-29 17:21:45 +020013971static hda_nid_t alc269_adc_candidates[] = {
13972 0x08, 0x09, 0x07,
13973};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013974
Kailang Yangf6a92242007-12-13 16:52:54 +010013975#define alc269_modes alc260_modes
13976#define alc269_capture_source alc880_lg_lw_capture_source
13977
13978static struct snd_kcontrol_new alc269_base_mixer[] = {
13979 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13980 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13981 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13982 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13983 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13984 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13985 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13986 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13987 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13988 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13989 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13990 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13991 { } /* end */
13992};
13993
Kailang Yang60db6b52008-08-26 13:13:00 +020013994static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13995 /* output mixer control */
13996 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13997 {
13998 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13999 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014000 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014001 .info = snd_hda_mixer_amp_switch_info,
14002 .get = snd_hda_mixer_amp_switch_get,
14003 .put = alc268_acer_master_sw_put,
14004 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14005 },
14006 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14008 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14009 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14010 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14011 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014012 { }
14013};
14014
Tony Vroon64154832008-11-06 15:08:49 +000014015static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14016 /* output mixer control */
14017 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14018 {
14019 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14020 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014021 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014022 .info = snd_hda_mixer_amp_switch_info,
14023 .get = snd_hda_mixer_amp_switch_get,
14024 .put = alc268_acer_master_sw_put,
14025 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14026 },
14027 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14028 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14029 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14030 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14031 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14032 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
14033 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14034 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
14035 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014036 { }
14037};
14038
Kailang Yang84898e82010-02-04 14:16:14 +010014039static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014040 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014041 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014042 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014043 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014044 { } /* end */
14045};
14046
Kailang Yang84898e82010-02-04 14:16:14 +010014047static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14048 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14049 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14050 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14051 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14052 { } /* end */
14053};
14054
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014055static struct snd_kcontrol_new alc269_asus_mixer[] = {
14056 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14057 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14058 { } /* end */
14059};
14060
Kailang Yangf6a92242007-12-13 16:52:54 +010014061/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014062static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14063 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14064 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14065 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14066 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14067 { } /* end */
14068};
14069
14070static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014071 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14072 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014073 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14074 { } /* end */
14075};
14076
Kailang Yang84898e82010-02-04 14:16:14 +010014077static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14078 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14079 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14080 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14081 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14082 { } /* end */
14083};
14084
14085static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14086 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14087 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14088 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14089 { } /* end */
14090};
14091
Takashi Iwai26f5df22008-11-03 17:39:46 +010014092/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014093#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014094
Kailang Yang60db6b52008-08-26 13:13:00 +020014095static struct hda_verb alc269_quanta_fl1_verbs[] = {
14096 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14097 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14098 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14099 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14100 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14101 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14102 { }
14103};
14104
Tony Vroon64154832008-11-06 15:08:49 +000014105static struct hda_verb alc269_lifebook_verbs[] = {
14106 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14107 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14108 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14110 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14111 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14112 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14113 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14114 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14115 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14116 { }
14117};
14118
Kailang Yang60db6b52008-08-26 13:13:00 +020014119/* toggle speaker-output according to the hp-jack state */
14120static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14121{
14122 unsigned int present;
14123 unsigned char bits;
14124
Wu Fengguang864f92b2009-11-18 12:38:02 +080014125 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014126 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014127 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014128 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014129 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014130 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014131
14132 snd_hda_codec_write(codec, 0x20, 0,
14133 AC_VERB_SET_COEF_INDEX, 0x0c);
14134 snd_hda_codec_write(codec, 0x20, 0,
14135 AC_VERB_SET_PROC_COEF, 0x680);
14136
14137 snd_hda_codec_write(codec, 0x20, 0,
14138 AC_VERB_SET_COEF_INDEX, 0x0c);
14139 snd_hda_codec_write(codec, 0x20, 0,
14140 AC_VERB_SET_PROC_COEF, 0x480);
14141}
14142
Tony Vroon64154832008-11-06 15:08:49 +000014143/* toggle speaker-output according to the hp-jacks state */
14144static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14145{
14146 unsigned int present;
14147 unsigned char bits;
14148
14149 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014150 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014151
14152 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014153 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014154
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014155 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014156 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014157 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014158 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014159 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014160
14161 snd_hda_codec_write(codec, 0x20, 0,
14162 AC_VERB_SET_COEF_INDEX, 0x0c);
14163 snd_hda_codec_write(codec, 0x20, 0,
14164 AC_VERB_SET_PROC_COEF, 0x680);
14165
14166 snd_hda_codec_write(codec, 0x20, 0,
14167 AC_VERB_SET_COEF_INDEX, 0x0c);
14168 snd_hda_codec_write(codec, 0x20, 0,
14169 AC_VERB_SET_PROC_COEF, 0x480);
14170}
14171
Tony Vroon64154832008-11-06 15:08:49 +000014172static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14173{
14174 unsigned int present_laptop;
14175 unsigned int present_dock;
14176
Wu Fengguang864f92b2009-11-18 12:38:02 +080014177 present_laptop = snd_hda_jack_detect(codec, 0x18);
14178 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014179
14180 /* Laptop mic port overrides dock mic port, design decision */
14181 if (present_dock)
14182 snd_hda_codec_write(codec, 0x23, 0,
14183 AC_VERB_SET_CONNECT_SEL, 0x3);
14184 if (present_laptop)
14185 snd_hda_codec_write(codec, 0x23, 0,
14186 AC_VERB_SET_CONNECT_SEL, 0x0);
14187 if (!present_dock && !present_laptop)
14188 snd_hda_codec_write(codec, 0x23, 0,
14189 AC_VERB_SET_CONNECT_SEL, 0x1);
14190}
14191
Kailang Yang60db6b52008-08-26 13:13:00 +020014192static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14193 unsigned int res)
14194{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014195 switch (res >> 26) {
14196 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014197 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014198 break;
14199 case ALC880_MIC_EVENT:
14200 alc_mic_automute(codec);
14201 break;
14202 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014203}
14204
Tony Vroon64154832008-11-06 15:08:49 +000014205static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14206 unsigned int res)
14207{
14208 if ((res >> 26) == ALC880_HP_EVENT)
14209 alc269_lifebook_speaker_automute(codec);
14210 if ((res >> 26) == ALC880_MIC_EVENT)
14211 alc269_lifebook_mic_autoswitch(codec);
14212}
14213
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014214static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14215{
14216 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014217 spec->autocfg.hp_pins[0] = 0x15;
14218 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014219 spec->ext_mic.pin = 0x18;
14220 spec->ext_mic.mux_idx = 0;
14221 spec->int_mic.pin = 0x19;
14222 spec->int_mic.mux_idx = 1;
14223 spec->auto_mic = 1;
14224}
14225
Kailang Yang60db6b52008-08-26 13:13:00 +020014226static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14227{
14228 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014229 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014230}
14231
Tony Vroon64154832008-11-06 15:08:49 +000014232static void alc269_lifebook_init_hook(struct hda_codec *codec)
14233{
14234 alc269_lifebook_speaker_automute(codec);
14235 alc269_lifebook_mic_autoswitch(codec);
14236}
14237
Kailang Yang84898e82010-02-04 14:16:14 +010014238static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014239 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14240 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14241 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14242 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14243 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14244 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14245 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14246 {}
14247};
14248
Kailang Yang84898e82010-02-04 14:16:14 +010014249static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014250 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14251 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14252 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14253 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14254 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14255 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14256 {}
14257};
14258
Kailang Yang84898e82010-02-04 14:16:14 +010014259static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14260 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14261 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14262 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14263 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14264 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14265 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14266 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14267 {}
14268};
14269
14270static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14271 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14272 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14273 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14274 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14275 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14276 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14277 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14278 {}
14279};
14280
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014281static struct hda_verb alc271_acer_dmic_verbs[] = {
14282 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14283 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14284 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14285 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14286 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14287 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14288 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14289 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14290 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14291 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14292 { }
14293};
14294
Kailang Yang60db6b52008-08-26 13:13:00 +020014295/* toggle speaker-output according to the hp-jack state */
14296static void alc269_speaker_automute(struct hda_codec *codec)
14297{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014298 struct alc_spec *spec = codec->spec;
14299 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014300 unsigned int present;
14301 unsigned char bits;
14302
Kailang Yangebb83ee2009-12-17 12:23:00 +010014303 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014304 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014305 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014306 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014307 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014308 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014309}
14310
Kailang Yang60db6b52008-08-26 13:13:00 +020014311/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014312static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014313 unsigned int res)
14314{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014315 switch (res >> 26) {
14316 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014317 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014318 break;
14319 case ALC880_MIC_EVENT:
14320 alc_mic_automute(codec);
14321 break;
14322 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014323}
14324
Kailang Yang226b1ec2010-04-09 11:01:20 +020014325static void alc269_laptop_amic_setup(struct hda_codec *codec)
14326{
14327 struct alc_spec *spec = codec->spec;
14328 spec->autocfg.hp_pins[0] = 0x15;
14329 spec->autocfg.speaker_pins[0] = 0x14;
14330 spec->ext_mic.pin = 0x18;
14331 spec->ext_mic.mux_idx = 0;
14332 spec->int_mic.pin = 0x19;
14333 spec->int_mic.mux_idx = 1;
14334 spec->auto_mic = 1;
14335}
14336
Kailang Yang84898e82010-02-04 14:16:14 +010014337static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014338{
14339 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014340 spec->autocfg.hp_pins[0] = 0x15;
14341 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014342 spec->ext_mic.pin = 0x18;
14343 spec->ext_mic.mux_idx = 0;
14344 spec->int_mic.pin = 0x12;
14345 spec->int_mic.mux_idx = 5;
14346 spec->auto_mic = 1;
14347}
14348
Kailang Yang226b1ec2010-04-09 11:01:20 +020014349static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014350{
14351 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014352 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014353 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014354 spec->ext_mic.pin = 0x18;
14355 spec->ext_mic.mux_idx = 0;
14356 spec->int_mic.pin = 0x19;
14357 spec->int_mic.mux_idx = 1;
14358 spec->auto_mic = 1;
14359}
14360
Kailang Yang226b1ec2010-04-09 11:01:20 +020014361static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14362{
14363 struct alc_spec *spec = codec->spec;
14364 spec->autocfg.hp_pins[0] = 0x21;
14365 spec->autocfg.speaker_pins[0] = 0x14;
14366 spec->ext_mic.pin = 0x18;
14367 spec->ext_mic.mux_idx = 0;
14368 spec->int_mic.pin = 0x12;
14369 spec->int_mic.mux_idx = 6;
14370 spec->auto_mic = 1;
14371}
14372
Kailang Yang84898e82010-02-04 14:16:14 +010014373static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014374{
14375 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014376 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014377}
14378
Kailang Yangf6a92242007-12-13 16:52:54 +010014379/*
14380 * generic initialization of ADC, input mixers and output mixers
14381 */
14382static struct hda_verb alc269_init_verbs[] = {
14383 /*
14384 * Unmute ADC0 and set the default input to mic-in
14385 */
Kailang Yang84898e82010-02-04 14:16:14 +010014386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014387
14388 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014389 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014390 */
14391 /* set vol=0 to output mixers */
14392 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14393 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14394
14395 /* set up input amps for analog loopback */
14396 /* Amp Indices: DAC = 0, mixer = 1 */
14397 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14398 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14399 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14400 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14401 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14402 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14403
14404 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14405 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14406 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14407 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14408 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14409 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14410 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14411
14412 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14413 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014414
Kailang Yang84898e82010-02-04 14:16:14 +010014415 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014416 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14417 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014418 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014419
14420 /* set EAPD */
14421 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014422 { }
14423};
14424
14425static struct hda_verb alc269vb_init_verbs[] = {
14426 /*
14427 * Unmute ADC0 and set the default input to mic-in
14428 */
14429 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14430
14431 /*
14432 * Set up output mixers (0x02 - 0x03)
14433 */
14434 /* set vol=0 to output mixers */
14435 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14436 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14437
14438 /* set up input amps for analog loopback */
14439 /* Amp Indices: DAC = 0, mixer = 1 */
14440 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14441 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14442 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14443 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14444 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14445 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14446
14447 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14448 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14449 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14450 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14451 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14452 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14453 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14454
14455 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14456 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14457
14458 /* FIXME: use Mux-type input source selection */
14459 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14460 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14461 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14462
14463 /* set EAPD */
14464 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014465 { }
14466};
14467
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014468#define alc269_auto_create_multi_out_ctls \
14469 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014470#define alc269_auto_create_input_ctls \
14471 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014472
14473#ifdef CONFIG_SND_HDA_POWER_SAVE
14474#define alc269_loopbacks alc880_loopbacks
14475#endif
14476
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014477/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014478#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14479#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14480#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14481#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14482
Takashi Iwaif03d3112009-03-05 14:18:16 +010014483static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14484 .substreams = 1,
14485 .channels_min = 2,
14486 .channels_max = 8,
14487 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14488 /* NID is set in alc_build_pcms */
14489 .ops = {
14490 .open = alc880_playback_pcm_open,
14491 .prepare = alc880_playback_pcm_prepare,
14492 .cleanup = alc880_playback_pcm_cleanup
14493 },
14494};
14495
14496static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14497 .substreams = 1,
14498 .channels_min = 2,
14499 .channels_max = 2,
14500 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14501 /* NID is set in alc_build_pcms */
14502};
14503
Takashi Iwaiad358792010-03-30 18:00:59 +020014504#ifdef CONFIG_SND_HDA_POWER_SAVE
14505static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14506{
14507 switch (codec->subsystem_id) {
14508 case 0x103c1586:
14509 return 1;
14510 }
14511 return 0;
14512}
14513
14514static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14515{
14516 /* update mute-LED according to the speaker mute state */
14517 if (nid == 0x01 || nid == 0x14) {
14518 int pinval;
14519 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14520 HDA_AMP_MUTE)
14521 pinval = 0x24;
14522 else
14523 pinval = 0x20;
14524 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014525 snd_hda_codec_update_cache(codec, 0x19, 0,
14526 AC_VERB_SET_PIN_WIDGET_CONTROL,
14527 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014528 }
14529 return alc_check_power_status(codec, nid);
14530}
14531#endif /* CONFIG_SND_HDA_POWER_SAVE */
14532
Takashi Iwai840b64c2010-07-13 22:49:01 +020014533static int alc275_setup_dual_adc(struct hda_codec *codec)
14534{
14535 struct alc_spec *spec = codec->spec;
14536
14537 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14538 return 0;
14539 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14540 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14541 if (spec->ext_mic.pin <= 0x12) {
14542 spec->private_adc_nids[0] = 0x08;
14543 spec->private_adc_nids[1] = 0x11;
14544 spec->private_capsrc_nids[0] = 0x23;
14545 spec->private_capsrc_nids[1] = 0x22;
14546 } else {
14547 spec->private_adc_nids[0] = 0x11;
14548 spec->private_adc_nids[1] = 0x08;
14549 spec->private_capsrc_nids[0] = 0x22;
14550 spec->private_capsrc_nids[1] = 0x23;
14551 }
14552 spec->adc_nids = spec->private_adc_nids;
14553 spec->capsrc_nids = spec->private_capsrc_nids;
14554 spec->num_adc_nids = 2;
14555 spec->dual_adc_switch = 1;
14556 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14557 spec->adc_nids[0], spec->adc_nids[1]);
14558 return 1;
14559 }
14560 return 0;
14561}
14562
Kailang Yangf6a92242007-12-13 16:52:54 +010014563/*
14564 * BIOS auto configuration
14565 */
14566static int alc269_parse_auto_config(struct hda_codec *codec)
14567{
14568 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014569 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014570 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14571
14572 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14573 alc269_ignore);
14574 if (err < 0)
14575 return err;
14576
14577 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14578 if (err < 0)
14579 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014580 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014581 if (err < 0)
14582 return err;
14583
14584 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14585
Takashi Iwai757899a2010-07-30 10:48:14 +020014586 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014587
Takashi Iwai603c4012008-07-30 15:01:44 +020014588 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014589 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014590
Kailang Yang84898e82010-02-04 14:16:14 +010014591 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14592 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014593 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014594 } else {
14595 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014596 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014597 }
14598
Kailang Yangf6a92242007-12-13 16:52:54 +010014599 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014600 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014601
14602 if (!alc275_setup_dual_adc(codec))
14603 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14604 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014605
Takashi Iwaie01bf502008-08-21 16:25:07 +020014606 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014607 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014608 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14609 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014610
14611 err = alc_auto_add_mic_boost(codec);
14612 if (err < 0)
14613 return err;
14614
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014615 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014616 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014617
Kailang Yangf6a92242007-12-13 16:52:54 +010014618 return 1;
14619}
14620
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014621#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14622#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014623#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14624
14625
14626/* init callback for auto-configuration model -- overriding the default init */
14627static void alc269_auto_init(struct hda_codec *codec)
14628{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014629 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014630 alc269_auto_init_multi_out(codec);
14631 alc269_auto_init_hp_out(codec);
14632 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014633 alc_auto_init_digital(codec);
Kailang Yang9ad0e492010-09-14 23:22:00 +020014634 alc_init_jacks(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014635 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014636 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014637}
14638
Kailang Yang977ddd62010-09-15 10:02:29 +020014639#ifdef CONFIG_SND_HDA_POWER_SAVE
14640static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14641{
14642 struct alc_spec *spec = codec->spec;
14643 int val;
14644
14645 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14646 val = alc_read_coef_idx(codec, 0x04);
14647 /* Power down output pin */
14648 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14649 }
14650
14651 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14652 val = alc_read_coef_idx(codec, 0x04);
14653 /* Power down output pin */
14654 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14655 msleep(150);
14656 }
14657
14658 alc_shutup(codec);
14659 if (spec && spec->power_hook)
14660 spec->power_hook(codec);
14661 return 0;
14662}
14663#endif
14664#ifdef SND_HDA_NEEDS_RESUME
14665static int alc269_resume(struct hda_codec *codec)
14666{
14667 int val;
14668
14669 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14670 val = alc_read_coef_idx(codec, 0x04);
14671 /* Power down output pin */
14672 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14673 msleep(150);
14674 }
14675
14676 codec->patch_ops.init(codec);
14677
14678 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14679 val = alc_read_coef_idx(codec, 0x04);
14680 /* Power up output pin */
14681 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14682 msleep(200);
14683 }
14684
14685 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14686 val = alc_read_coef_idx(codec, 0x04);
14687 /* Power up output pin */
14688 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14689 }
14690
14691 snd_hda_codec_resume_amp(codec);
14692 snd_hda_codec_resume_cache(codec);
14693#ifdef CONFIG_SND_HDA_POWER_SAVE
14694 if (codec->patch_ops.check_power_status)
14695 codec->patch_ops.check_power_status(codec, 0x01);
14696#endif
14697 return 0;
14698}
14699#endif
14700
Takashi Iwaiff818c22010-04-12 08:59:25 +020014701enum {
14702 ALC269_FIXUP_SONY_VAIO,
14703};
14704
Takashi Iwaiff818c22010-04-12 08:59:25 +020014705static const struct alc_fixup alc269_fixups[] = {
14706 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014707 .verbs = (const struct hda_verb[]) {
14708 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14709 {}
14710 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014711 },
14712};
14713
14714static struct snd_pci_quirk alc269_fixup_tbl[] = {
14715 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningssondbbcbc02010-08-23 08:14:35 +020014716 SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014717 {}
14718};
14719
14720
Kailang Yangf6a92242007-12-13 16:52:54 +010014721/*
14722 * configuration and preset
14723 */
14724static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014725 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014726 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014727 [ALC269_AMIC] = "laptop-amic",
14728 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014729 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014730 [ALC269_LIFEBOOK] = "lifebook",
14731 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014732};
14733
14734static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014735 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014736 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014737 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014738 ALC269_AMIC),
14739 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14740 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14741 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14742 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14743 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14744 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14745 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14746 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14747 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14748 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14749 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14750 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14751 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14752 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14753 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14754 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14755 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14756 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14757 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14758 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14759 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14760 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14761 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14762 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14763 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14764 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14765 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14766 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14767 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14768 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14769 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14770 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14771 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14772 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14773 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14774 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014775 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014776 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014777 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014778 ALC269_DMIC),
14779 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14780 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014781 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014782 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014783 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14784 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14785 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14786 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14787 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14788 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014789 {}
14790};
14791
14792static struct alc_config_preset alc269_presets[] = {
14793 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014794 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014795 .init_verbs = { alc269_init_verbs },
14796 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14797 .dac_nids = alc269_dac_nids,
14798 .hp_nid = 0x03,
14799 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14800 .channel_mode = alc269_modes,
14801 .input_mux = &alc269_capture_source,
14802 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014803 [ALC269_QUANTA_FL1] = {
14804 .mixers = { alc269_quanta_fl1_mixer },
14805 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14806 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14807 .dac_nids = alc269_dac_nids,
14808 .hp_nid = 0x03,
14809 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14810 .channel_mode = alc269_modes,
14811 .input_mux = &alc269_capture_source,
14812 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014813 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014814 .init_hook = alc269_quanta_fl1_init_hook,
14815 },
Kailang Yang84898e82010-02-04 14:16:14 +010014816 [ALC269_AMIC] = {
14817 .mixers = { alc269_laptop_mixer },
14818 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014819 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014820 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014821 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14822 .dac_nids = alc269_dac_nids,
14823 .hp_nid = 0x03,
14824 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14825 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014826 .unsol_event = alc269_laptop_unsol_event,
14827 .setup = alc269_laptop_amic_setup,
14828 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014829 },
Kailang Yang84898e82010-02-04 14:16:14 +010014830 [ALC269_DMIC] = {
14831 .mixers = { alc269_laptop_mixer },
14832 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014833 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014834 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014835 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14836 .dac_nids = alc269_dac_nids,
14837 .hp_nid = 0x03,
14838 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14839 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014840 .unsol_event = alc269_laptop_unsol_event,
14841 .setup = alc269_laptop_dmic_setup,
14842 .init_hook = alc269_laptop_inithook,
14843 },
14844 [ALC269VB_AMIC] = {
14845 .mixers = { alc269vb_laptop_mixer },
14846 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14847 .init_verbs = { alc269vb_init_verbs,
14848 alc269vb_laptop_amic_init_verbs },
14849 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14850 .dac_nids = alc269_dac_nids,
14851 .hp_nid = 0x03,
14852 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14853 .channel_mode = alc269_modes,
14854 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014855 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014856 .init_hook = alc269_laptop_inithook,
14857 },
14858 [ALC269VB_DMIC] = {
14859 .mixers = { alc269vb_laptop_mixer },
14860 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14861 .init_verbs = { alc269vb_init_verbs,
14862 alc269vb_laptop_dmic_init_verbs },
14863 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14864 .dac_nids = alc269_dac_nids,
14865 .hp_nid = 0x03,
14866 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14867 .channel_mode = alc269_modes,
14868 .unsol_event = alc269_laptop_unsol_event,
14869 .setup = alc269vb_laptop_dmic_setup,
14870 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014871 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014872 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014873 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014874 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014875 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014876 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014877 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14878 .dac_nids = alc269_dac_nids,
14879 .hp_nid = 0x03,
14880 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14881 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014882 .unsol_event = alc269_laptop_unsol_event,
14883 .setup = alc269_laptop_dmic_setup,
14884 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014885 },
Tony Vroon64154832008-11-06 15:08:49 +000014886 [ALC269_LIFEBOOK] = {
14887 .mixers = { alc269_lifebook_mixer },
14888 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14889 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14890 .dac_nids = alc269_dac_nids,
14891 .hp_nid = 0x03,
14892 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14893 .channel_mode = alc269_modes,
14894 .input_mux = &alc269_capture_source,
14895 .unsol_event = alc269_lifebook_unsol_event,
14896 .init_hook = alc269_lifebook_init_hook,
14897 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014898 [ALC271_ACER] = {
14899 .mixers = { alc269_asus_mixer },
14900 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14901 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14902 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14903 .dac_nids = alc269_dac_nids,
14904 .adc_nids = alc262_dmic_adc_nids,
14905 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14906 .capsrc_nids = alc262_dmic_capsrc_nids,
14907 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14908 .channel_mode = alc269_modes,
14909 .input_mux = &alc269_capture_source,
14910 .dig_out_nid = ALC880_DIGOUT_NID,
14911 .unsol_event = alc_sku_unsol_event,
14912 .setup = alc269vb_laptop_dmic_setup,
14913 .init_hook = alc_inithook,
14914 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014915};
14916
Kailang Yang977ddd62010-09-15 10:02:29 +020014917static int alc269_fill_coef(struct hda_codec *codec)
14918{
14919 int val;
14920
14921 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
14922 alc_write_coef_idx(codec, 0xf, 0x960b);
14923 alc_write_coef_idx(codec, 0xe, 0x8817);
14924 }
14925
14926 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
14927 alc_write_coef_idx(codec, 0xf, 0x960b);
14928 alc_write_coef_idx(codec, 0xe, 0x8814);
14929 }
14930
14931 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14932 val = alc_read_coef_idx(codec, 0x04);
14933 /* Power up output pin */
14934 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14935 }
14936
14937 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14938 val = alc_read_coef_idx(codec, 0xd);
14939 if ((val & 0x0c00) >> 10 != 0x1) {
14940 /* Capless ramp up clock control */
14941 alc_write_coef_idx(codec, 0xd, val | 1<<10);
14942 }
14943 val = alc_read_coef_idx(codec, 0x17);
14944 if ((val & 0x01c0) >> 6 != 0x4) {
14945 /* Class D power on reset */
14946 alc_write_coef_idx(codec, 0x17, val | 1<<7);
14947 }
14948 }
14949 return 0;
14950}
14951
Kailang Yangf6a92242007-12-13 16:52:54 +010014952static int patch_alc269(struct hda_codec *codec)
14953{
14954 struct alc_spec *spec;
14955 int board_config;
14956 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014957 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014958
14959 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14960 if (spec == NULL)
14961 return -ENOMEM;
14962
14963 codec->spec = spec;
14964
Kailang Yangda00c242010-03-19 11:23:45 +010014965 alc_auto_parse_customize_define(codec);
14966
Kailang Yang274693f2009-12-03 10:07:50 +010014967 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014968 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14969 spec->cdefine.platform_type == 1)
14970 alc_codec_rename(codec, "ALC271X");
14971 else
14972 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014973 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014974 } else
14975 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014976
Kailang Yang977ddd62010-09-15 10:02:29 +020014977 alc269_fill_coef(codec);
14978
Kailang Yangf6a92242007-12-13 16:52:54 +010014979 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14980 alc269_models,
14981 alc269_cfg_tbl);
14982
14983 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014984 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14985 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014986 board_config = ALC269_AUTO;
14987 }
14988
Takashi Iwaiff818c22010-04-12 08:59:25 +020014989 if (board_config == ALC269_AUTO)
14990 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14991
Kailang Yangf6a92242007-12-13 16:52:54 +010014992 if (board_config == ALC269_AUTO) {
14993 /* automatic parse from the BIOS config */
14994 err = alc269_parse_auto_config(codec);
14995 if (err < 0) {
14996 alc_free(codec);
14997 return err;
14998 } else if (!err) {
14999 printk(KERN_INFO
15000 "hda_codec: Cannot set up configuration "
15001 "from BIOS. Using base mode...\n");
15002 board_config = ALC269_BASIC;
15003 }
15004 }
15005
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015006 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015007 err = snd_hda_attach_beep_device(codec, 0x1);
15008 if (err < 0) {
15009 alc_free(codec);
15010 return err;
15011 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015012 }
15013
Kailang Yangf6a92242007-12-13 16:52:54 +010015014 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015015 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015016
Kailang Yang84898e82010-02-04 14:16:14 +010015017 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015018 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15019 * fix the sample rate of analog I/O to 44.1kHz
15020 */
15021 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15022 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015023 } else if (spec->dual_adc_switch) {
15024 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15025 /* switch ADC dynamically */
15026 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015027 } else {
15028 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15029 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15030 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015031 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15032 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15033
Takashi Iwai66946352010-03-29 17:21:45 +020015034 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
15035 if (!is_alc269vb) {
15036 spec->adc_nids = alc269_adc_nids;
15037 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15038 spec->capsrc_nids = alc269_capsrc_nids;
15039 } else {
15040 spec->adc_nids = alc269vb_adc_nids;
15041 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15042 spec->capsrc_nids = alc269vb_capsrc_nids;
15043 }
Kailang Yang84898e82010-02-04 14:16:14 +010015044 }
15045
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015046 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015047 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015048 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015049 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015050
Takashi Iwaiff818c22010-04-12 08:59:25 +020015051 if (board_config == ALC269_AUTO)
15052 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
15053
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015054 spec->vmaster_nid = 0x02;
15055
Kailang Yangf6a92242007-12-13 16:52:54 +010015056 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015057#ifdef CONFIG_SND_HDA_POWER_SAVE
15058 codec->patch_ops.suspend = alc269_suspend;
15059#endif
15060#ifdef SND_HDA_NEEDS_RESUME
15061 codec->patch_ops.resume = alc269_resume;
15062#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015063 if (board_config == ALC269_AUTO)
15064 spec->init_hook = alc269_auto_init;
15065#ifdef CONFIG_SND_HDA_POWER_SAVE
15066 if (!spec->loopback.amplist)
15067 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015068 if (alc269_mic2_for_mute_led(codec))
15069 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015070#endif
15071
15072 return 0;
15073}
15074
15075/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015076 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15077 */
15078
15079/*
15080 * set the path ways for 2 channel output
15081 * need to set the codec line out and mic 1 pin widgets to inputs
15082 */
15083static struct hda_verb alc861_threestack_ch2_init[] = {
15084 /* set pin widget 1Ah (line in) for input */
15085 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015086 /* set pin widget 18h (mic1/2) for input, for mic also enable
15087 * the vref
15088 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015089 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15090
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015091 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15092#if 0
15093 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15094 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15095#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015096 { } /* end */
15097};
15098/*
15099 * 6ch mode
15100 * need to set the codec line out and mic 1 pin widgets to outputs
15101 */
15102static struct hda_verb alc861_threestack_ch6_init[] = {
15103 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15104 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15105 /* set pin widget 18h (mic1) for output (CLFE)*/
15106 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15107
15108 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015109 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015110
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015111 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15112#if 0
15113 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15114 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15115#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015116 { } /* end */
15117};
15118
15119static struct hda_channel_mode alc861_threestack_modes[2] = {
15120 { 2, alc861_threestack_ch2_init },
15121 { 6, alc861_threestack_ch6_init },
15122};
Takashi Iwai22309c32006-08-09 16:57:28 +020015123/* Set mic1 as input and unmute the mixer */
15124static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15125 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15126 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15127 { } /* end */
15128};
15129/* Set mic1 as output and mute mixer */
15130static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15131 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15132 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15133 { } /* end */
15134};
15135
15136static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15137 { 2, alc861_uniwill_m31_ch2_init },
15138 { 4, alc861_uniwill_m31_ch4_init },
15139};
Kailang Yangdf694da2005-12-05 19:42:22 +010015140
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015141/* Set mic1 and line-in as input and unmute the mixer */
15142static struct hda_verb alc861_asus_ch2_init[] = {
15143 /* set pin widget 1Ah (line in) for input */
15144 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015145 /* set pin widget 18h (mic1/2) for input, for mic also enable
15146 * the vref
15147 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015148 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15149
15150 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15151#if 0
15152 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15153 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15154#endif
15155 { } /* end */
15156};
15157/* Set mic1 nad line-in as output and mute mixer */
15158static struct hda_verb alc861_asus_ch6_init[] = {
15159 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15160 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15161 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15162 /* set pin widget 18h (mic1) for output (CLFE)*/
15163 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15164 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15165 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15166 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15167
15168 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15169#if 0
15170 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15171 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15172#endif
15173 { } /* end */
15174};
15175
15176static struct hda_channel_mode alc861_asus_modes[2] = {
15177 { 2, alc861_asus_ch2_init },
15178 { 6, alc861_asus_ch6_init },
15179};
15180
Kailang Yangdf694da2005-12-05 19:42:22 +010015181/* patch-ALC861 */
15182
15183static struct snd_kcontrol_new alc861_base_mixer[] = {
15184 /* output mixer control */
15185 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15186 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15187 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15188 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15189 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15190
15191 /*Input mixer control */
15192 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15193 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15194 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15195 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15196 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15197 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15198 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15199 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15200 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15201 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015202
Kailang Yangdf694da2005-12-05 19:42:22 +010015203 { } /* end */
15204};
15205
15206static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15207 /* output mixer control */
15208 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15209 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15210 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15211 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15212 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15213
15214 /* Input mixer control */
15215 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15216 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15217 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15218 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15219 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15220 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15221 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15222 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15223 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15224 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015225
Kailang Yangdf694da2005-12-05 19:42:22 +010015226 {
15227 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15228 .name = "Channel Mode",
15229 .info = alc_ch_mode_info,
15230 .get = alc_ch_mode_get,
15231 .put = alc_ch_mode_put,
15232 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15233 },
15234 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015235};
15236
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015237static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015238 /* output mixer control */
15239 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15240 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15241 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015242
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015243 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015244};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015245
Takashi Iwai22309c32006-08-09 16:57:28 +020015246static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15247 /* output mixer control */
15248 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15249 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15250 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15251 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15252 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15253
15254 /* Input mixer control */
15255 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15256 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15257 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15258 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15259 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15260 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15261 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15262 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15263 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15264 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015265
Takashi Iwai22309c32006-08-09 16:57:28 +020015266 {
15267 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15268 .name = "Channel Mode",
15269 .info = alc_ch_mode_info,
15270 .get = alc_ch_mode_get,
15271 .put = alc_ch_mode_put,
15272 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15273 },
15274 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015275};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015276
15277static struct snd_kcontrol_new alc861_asus_mixer[] = {
15278 /* output mixer control */
15279 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15280 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15281 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15282 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15283 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15284
15285 /* Input mixer control */
15286 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15287 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15288 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15289 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15290 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15291 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15292 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15293 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15294 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015295 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15296
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015297 {
15298 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15299 .name = "Channel Mode",
15300 .info = alc_ch_mode_info,
15301 .get = alc_ch_mode_get,
15302 .put = alc_ch_mode_put,
15303 .private_value = ARRAY_SIZE(alc861_asus_modes),
15304 },
15305 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015306};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015307
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015308/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015309static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015310 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15311 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015312 { }
15313};
15314
Kailang Yangdf694da2005-12-05 19:42:22 +010015315/*
15316 * generic initialization of ADC, input mixers and output mixers
15317 */
15318static struct hda_verb alc861_base_init_verbs[] = {
15319 /*
15320 * Unmute ADC0 and set the default input to mic-in
15321 */
15322 /* port-A for surround (rear panel) */
15323 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15324 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15325 /* port-B for mic-in (rear panel) with vref */
15326 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15327 /* port-C for line-in (rear panel) */
15328 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15329 /* port-D for Front */
15330 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15331 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15332 /* port-E for HP out (front panel) */
15333 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15334 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015335 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015336 /* port-F for mic-in (front panel) with vref */
15337 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15338 /* port-G for CLFE (rear panel) */
15339 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15340 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15341 /* port-H for side (rear panel) */
15342 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15343 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15344 /* CD-in */
15345 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15346 /* route front mic to ADC1*/
15347 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15348 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015349
Kailang Yangdf694da2005-12-05 19:42:22 +010015350 /* Unmute DAC0~3 & spdif out*/
15351 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15352 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15353 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15354 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15355 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015356
Kailang Yangdf694da2005-12-05 19:42:22 +010015357 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15358 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15359 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15360 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15361 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015362
Kailang Yangdf694da2005-12-05 19:42:22 +010015363 /* Unmute Stereo Mixer 15 */
15364 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15365 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15366 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015367 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015368
15369 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15370 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15371 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15372 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15373 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15374 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15375 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15376 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015377 /* hp used DAC 3 (Front) */
15378 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015379 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15380
15381 { }
15382};
15383
15384static struct hda_verb alc861_threestack_init_verbs[] = {
15385 /*
15386 * Unmute ADC0 and set the default input to mic-in
15387 */
15388 /* port-A for surround (rear panel) */
15389 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15390 /* port-B for mic-in (rear panel) with vref */
15391 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15392 /* port-C for line-in (rear panel) */
15393 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15394 /* port-D for Front */
15395 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15396 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15397 /* port-E for HP out (front panel) */
15398 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15399 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015400 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015401 /* port-F for mic-in (front panel) with vref */
15402 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15403 /* port-G for CLFE (rear panel) */
15404 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15405 /* port-H for side (rear panel) */
15406 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15407 /* CD-in */
15408 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15409 /* route front mic to ADC1*/
15410 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15411 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15412 /* Unmute DAC0~3 & spdif out*/
15413 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15414 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15415 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15416 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015418
Kailang Yangdf694da2005-12-05 19:42:22 +010015419 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15420 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15421 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15422 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15423 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015424
Kailang Yangdf694da2005-12-05 19:42:22 +010015425 /* Unmute Stereo Mixer 15 */
15426 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15427 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15428 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015429 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015430
15431 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15432 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15433 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15434 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15435 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15436 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15437 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15438 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015439 /* hp used DAC 3 (Front) */
15440 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015441 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15442 { }
15443};
Takashi Iwai22309c32006-08-09 16:57:28 +020015444
15445static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15446 /*
15447 * Unmute ADC0 and set the default input to mic-in
15448 */
15449 /* port-A for surround (rear panel) */
15450 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15451 /* port-B for mic-in (rear panel) with vref */
15452 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15453 /* port-C for line-in (rear panel) */
15454 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15455 /* port-D for Front */
15456 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15457 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15458 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015459 /* this has to be set to VREF80 */
15460 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015461 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015462 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015463 /* port-F for mic-in (front panel) with vref */
15464 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15465 /* port-G for CLFE (rear panel) */
15466 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15467 /* port-H for side (rear panel) */
15468 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15469 /* CD-in */
15470 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15471 /* route front mic to ADC1*/
15472 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15473 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15474 /* Unmute DAC0~3 & spdif out*/
15475 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15476 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15477 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15478 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15479 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015480
Takashi Iwai22309c32006-08-09 16:57:28 +020015481 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15482 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15483 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15484 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15485 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015486
Takashi Iwai22309c32006-08-09 16:57:28 +020015487 /* Unmute Stereo Mixer 15 */
15488 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15489 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15490 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015491 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015492
15493 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15494 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15495 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15496 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15497 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15498 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15499 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15500 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015501 /* hp used DAC 3 (Front) */
15502 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015503 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15504 { }
15505};
15506
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015507static struct hda_verb alc861_asus_init_verbs[] = {
15508 /*
15509 * Unmute ADC0 and set the default input to mic-in
15510 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015511 /* port-A for surround (rear panel)
15512 * according to codec#0 this is the HP jack
15513 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015514 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15515 /* route front PCM to HP */
15516 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15517 /* port-B for mic-in (rear panel) with vref */
15518 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15519 /* port-C for line-in (rear panel) */
15520 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15521 /* port-D for Front */
15522 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15523 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15524 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015525 /* this has to be set to VREF80 */
15526 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015527 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015528 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015529 /* port-F for mic-in (front panel) with vref */
15530 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15531 /* port-G for CLFE (rear panel) */
15532 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15533 /* port-H for side (rear panel) */
15534 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15535 /* CD-in */
15536 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15537 /* route front mic to ADC1*/
15538 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15539 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15540 /* Unmute DAC0~3 & spdif out*/
15541 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15542 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15543 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15544 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15546 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15547 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15548 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15549 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15550 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015551
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015552 /* Unmute Stereo Mixer 15 */
15553 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15554 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15555 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015556 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015557
15558 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15559 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15560 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15561 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15562 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15563 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15564 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15565 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015566 /* hp used DAC 3 (Front) */
15567 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015568 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15569 { }
15570};
15571
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015572/* additional init verbs for ASUS laptops */
15573static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15574 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15575 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15576 { }
15577};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015578
Kailang Yangdf694da2005-12-05 19:42:22 +010015579/*
15580 * generic initialization of ADC, input mixers and output mixers
15581 */
15582static struct hda_verb alc861_auto_init_verbs[] = {
15583 /*
15584 * Unmute ADC0 and set the default input to mic-in
15585 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015586 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015587 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015588
Kailang Yangdf694da2005-12-05 19:42:22 +010015589 /* Unmute DAC0~3 & spdif out*/
15590 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15591 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15592 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15593 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015595
Kailang Yangdf694da2005-12-05 19:42:22 +010015596 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15597 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15598 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15599 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15600 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015601
Kailang Yangdf694da2005-12-05 19:42:22 +010015602 /* Unmute Stereo Mixer 15 */
15603 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15605 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15606 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15607
Takashi Iwai1c209302009-07-22 15:17:45 +020015608 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15609 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15610 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15611 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15612 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15613 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15614 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15615 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015616
15617 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15618 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015619 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15620 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015621 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15622 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015623 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15624 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015625
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015626 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015627
15628 { }
15629};
15630
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015631static struct hda_verb alc861_toshiba_init_verbs[] = {
15632 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015633
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015634 { }
15635};
15636
15637/* toggle speaker-output according to the hp-jack state */
15638static void alc861_toshiba_automute(struct hda_codec *codec)
15639{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015640 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015641
Takashi Iwai47fd8302007-08-10 17:11:07 +020015642 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15643 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15644 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15645 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015646}
15647
15648static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15649 unsigned int res)
15650{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015651 if ((res >> 26) == ALC880_HP_EVENT)
15652 alc861_toshiba_automute(codec);
15653}
15654
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015655/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015656#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15657#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15658#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15659#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15660
15661
15662#define ALC861_DIGOUT_NID 0x07
15663
15664static struct hda_channel_mode alc861_8ch_modes[1] = {
15665 { 8, NULL }
15666};
15667
15668static hda_nid_t alc861_dac_nids[4] = {
15669 /* front, surround, clfe, side */
15670 0x03, 0x06, 0x05, 0x04
15671};
15672
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015673static hda_nid_t alc660_dac_nids[3] = {
15674 /* front, clfe, surround */
15675 0x03, 0x05, 0x06
15676};
15677
Kailang Yangdf694da2005-12-05 19:42:22 +010015678static hda_nid_t alc861_adc_nids[1] = {
15679 /* ADC0-2 */
15680 0x08,
15681};
15682
15683static struct hda_input_mux alc861_capture_source = {
15684 .num_items = 5,
15685 .items = {
15686 { "Mic", 0x0 },
15687 { "Front Mic", 0x3 },
15688 { "Line", 0x1 },
15689 { "CD", 0x4 },
15690 { "Mixer", 0x5 },
15691 },
15692};
15693
Takashi Iwai1c209302009-07-22 15:17:45 +020015694static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15695{
15696 struct alc_spec *spec = codec->spec;
15697 hda_nid_t mix, srcs[5];
15698 int i, j, num;
15699
15700 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15701 return 0;
15702 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15703 if (num < 0)
15704 return 0;
15705 for (i = 0; i < num; i++) {
15706 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015707 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015708 if (type != AC_WID_AUD_OUT)
15709 continue;
15710 for (j = 0; j < spec->multiout.num_dacs; j++)
15711 if (spec->multiout.dac_nids[j] == srcs[i])
15712 break;
15713 if (j >= spec->multiout.num_dacs)
15714 return srcs[i];
15715 }
15716 return 0;
15717}
15718
Kailang Yangdf694da2005-12-05 19:42:22 +010015719/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015720static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015721 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015722{
Takashi Iwai1c209302009-07-22 15:17:45 +020015723 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015724 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015725 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015726
15727 spec->multiout.dac_nids = spec->private_dac_nids;
15728 for (i = 0; i < cfg->line_outs; i++) {
15729 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015730 dac = alc861_look_for_dac(codec, nid);
15731 if (!dac)
15732 continue;
15733 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015734 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015735 return 0;
15736}
15737
Takashi Iwai1c209302009-07-22 15:17:45 +020015738static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15739 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015740{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015741 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015742 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15743}
15744
15745/* add playback controls from the parsed DAC table */
15746static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15747 const struct auto_pin_cfg *cfg)
15748{
15749 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015750 static const char *chname[4] = {
15751 "Front", "Surround", NULL /*CLFE*/, "Side"
15752 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015753 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015754 int i, err;
15755
15756 if (cfg->line_outs == 1) {
15757 const char *pfx = NULL;
15758 if (!cfg->hp_outs)
15759 pfx = "Master";
15760 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15761 pfx = "Speaker";
15762 if (pfx) {
15763 nid = spec->multiout.dac_nids[0];
15764 return alc861_create_out_sw(codec, pfx, nid, 3);
15765 }
15766 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015767
15768 for (i = 0; i < cfg->line_outs; i++) {
15769 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015770 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015771 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015772 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015773 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015774 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015775 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015776 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015777 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015778 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015779 return err;
15780 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015781 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015782 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015783 return err;
15784 }
15785 }
15786 return 0;
15787}
15788
Takashi Iwai1c209302009-07-22 15:17:45 +020015789static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015790{
Takashi Iwai1c209302009-07-22 15:17:45 +020015791 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015792 int err;
15793 hda_nid_t nid;
15794
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015795 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015796 return 0;
15797
15798 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015799 nid = alc861_look_for_dac(codec, pin);
15800 if (nid) {
15801 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15802 if (err < 0)
15803 return err;
15804 spec->multiout.hp_nid = nid;
15805 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015806 }
15807 return 0;
15808}
15809
15810/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015811static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015812 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015813{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015814 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015815}
15816
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015817static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15818 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015819 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015820{
Takashi Iwai1c209302009-07-22 15:17:45 +020015821 hda_nid_t mix, srcs[5];
15822 int i, num;
15823
Jacek Luczak564c5be2008-05-03 18:41:23 +020015824 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15825 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015826 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015827 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015828 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15829 return;
15830 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15831 if (num < 0)
15832 return;
15833 for (i = 0; i < num; i++) {
15834 unsigned int mute;
15835 if (srcs[i] == dac || srcs[i] == 0x15)
15836 mute = AMP_IN_UNMUTE(i);
15837 else
15838 mute = AMP_IN_MUTE(i);
15839 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15840 mute);
15841 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015842}
15843
15844static void alc861_auto_init_multi_out(struct hda_codec *codec)
15845{
15846 struct alc_spec *spec = codec->spec;
15847 int i;
15848
15849 for (i = 0; i < spec->autocfg.line_outs; i++) {
15850 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015851 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015852 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015853 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015854 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015855 }
15856}
15857
15858static void alc861_auto_init_hp_out(struct hda_codec *codec)
15859{
15860 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015861
Takashi Iwai15870f02009-10-05 08:25:13 +020015862 if (spec->autocfg.hp_outs)
15863 alc861_auto_set_output_and_unmute(codec,
15864 spec->autocfg.hp_pins[0],
15865 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015866 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015867 if (spec->autocfg.speaker_outs)
15868 alc861_auto_set_output_and_unmute(codec,
15869 spec->autocfg.speaker_pins[0],
15870 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015871 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015872}
15873
15874static void alc861_auto_init_analog_input(struct hda_codec *codec)
15875{
15876 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015877 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010015878 int i;
15879
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015880 for (i = 0; i < cfg->num_inputs; i++) {
15881 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010015882 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020015883 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015884 }
15885}
15886
15887/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015888/* return 1 if successful, 0 if the proper config is not found,
15889 * or a negative error code
15890 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015891static int alc861_parse_auto_config(struct hda_codec *codec)
15892{
15893 struct alc_spec *spec = codec->spec;
15894 int err;
15895 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15896
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015897 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15898 alc861_ignore);
15899 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015900 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015901 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015902 return 0; /* can't find valid BIOS pin config */
15903
Takashi Iwai1c209302009-07-22 15:17:45 +020015904 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015905 if (err < 0)
15906 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015907 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015908 if (err < 0)
15909 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015910 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015911 if (err < 0)
15912 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015913 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015914 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015915 return err;
15916
15917 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15918
Takashi Iwai757899a2010-07-30 10:48:14 +020015919 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015920
Takashi Iwai603c4012008-07-30 15:01:44 +020015921 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015922 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015923
Takashi Iwaid88897e2008-10-31 15:01:37 +010015924 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015925
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015926 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015927 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015928
15929 spec->adc_nids = alc861_adc_nids;
15930 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015931 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015932
Kailang Yang6227cdc2010-02-25 08:36:52 +010015933 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015934
Kailang Yangdf694da2005-12-05 19:42:22 +010015935 return 1;
15936}
15937
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015938/* additional initialization for auto-configuration model */
15939static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015940{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015941 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015942 alc861_auto_init_multi_out(codec);
15943 alc861_auto_init_hp_out(codec);
15944 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020015945 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015946 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015947 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015948}
15949
Takashi Iwaicb53c622007-08-10 17:21:45 +020015950#ifdef CONFIG_SND_HDA_POWER_SAVE
15951static struct hda_amp_list alc861_loopbacks[] = {
15952 { 0x15, HDA_INPUT, 0 },
15953 { 0x15, HDA_INPUT, 1 },
15954 { 0x15, HDA_INPUT, 2 },
15955 { 0x15, HDA_INPUT, 3 },
15956 { } /* end */
15957};
15958#endif
15959
Kailang Yangdf694da2005-12-05 19:42:22 +010015960
15961/*
15962 * configuration and preset
15963 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015964static const char *alc861_models[ALC861_MODEL_LAST] = {
15965 [ALC861_3ST] = "3stack",
15966 [ALC660_3ST] = "3stack-660",
15967 [ALC861_3ST_DIG] = "3stack-dig",
15968 [ALC861_6ST_DIG] = "6stack-dig",
15969 [ALC861_UNIWILL_M31] = "uniwill-m31",
15970 [ALC861_TOSHIBA] = "toshiba",
15971 [ALC861_ASUS] = "asus",
15972 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15973 [ALC861_AUTO] = "auto",
15974};
15975
15976static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015977 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015978 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15979 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15980 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015981 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015982 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015983 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015984 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15985 * Any other models that need this preset?
15986 */
15987 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015988 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15989 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015990 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15991 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15992 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15993 /* FIXME: the below seems conflict */
15994 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15995 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15996 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015997 {}
15998};
15999
16000static struct alc_config_preset alc861_presets[] = {
16001 [ALC861_3ST] = {
16002 .mixers = { alc861_3ST_mixer },
16003 .init_verbs = { alc861_threestack_init_verbs },
16004 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16005 .dac_nids = alc861_dac_nids,
16006 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16007 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016008 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016009 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16010 .adc_nids = alc861_adc_nids,
16011 .input_mux = &alc861_capture_source,
16012 },
16013 [ALC861_3ST_DIG] = {
16014 .mixers = { alc861_base_mixer },
16015 .init_verbs = { alc861_threestack_init_verbs },
16016 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16017 .dac_nids = alc861_dac_nids,
16018 .dig_out_nid = ALC861_DIGOUT_NID,
16019 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16020 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016021 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016022 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16023 .adc_nids = alc861_adc_nids,
16024 .input_mux = &alc861_capture_source,
16025 },
16026 [ALC861_6ST_DIG] = {
16027 .mixers = { alc861_base_mixer },
16028 .init_verbs = { alc861_base_init_verbs },
16029 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16030 .dac_nids = alc861_dac_nids,
16031 .dig_out_nid = ALC861_DIGOUT_NID,
16032 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16033 .channel_mode = alc861_8ch_modes,
16034 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16035 .adc_nids = alc861_adc_nids,
16036 .input_mux = &alc861_capture_source,
16037 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016038 [ALC660_3ST] = {
16039 .mixers = { alc861_3ST_mixer },
16040 .init_verbs = { alc861_threestack_init_verbs },
16041 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16042 .dac_nids = alc660_dac_nids,
16043 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16044 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016045 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016046 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16047 .adc_nids = alc861_adc_nids,
16048 .input_mux = &alc861_capture_source,
16049 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016050 [ALC861_UNIWILL_M31] = {
16051 .mixers = { alc861_uniwill_m31_mixer },
16052 .init_verbs = { alc861_uniwill_m31_init_verbs },
16053 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16054 .dac_nids = alc861_dac_nids,
16055 .dig_out_nid = ALC861_DIGOUT_NID,
16056 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16057 .channel_mode = alc861_uniwill_m31_modes,
16058 .need_dac_fix = 1,
16059 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16060 .adc_nids = alc861_adc_nids,
16061 .input_mux = &alc861_capture_source,
16062 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016063 [ALC861_TOSHIBA] = {
16064 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016065 .init_verbs = { alc861_base_init_verbs,
16066 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016067 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16068 .dac_nids = alc861_dac_nids,
16069 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16070 .channel_mode = alc883_3ST_2ch_modes,
16071 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16072 .adc_nids = alc861_adc_nids,
16073 .input_mux = &alc861_capture_source,
16074 .unsol_event = alc861_toshiba_unsol_event,
16075 .init_hook = alc861_toshiba_automute,
16076 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016077 [ALC861_ASUS] = {
16078 .mixers = { alc861_asus_mixer },
16079 .init_verbs = { alc861_asus_init_verbs },
16080 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16081 .dac_nids = alc861_dac_nids,
16082 .dig_out_nid = ALC861_DIGOUT_NID,
16083 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16084 .channel_mode = alc861_asus_modes,
16085 .need_dac_fix = 1,
16086 .hp_nid = 0x06,
16087 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16088 .adc_nids = alc861_adc_nids,
16089 .input_mux = &alc861_capture_source,
16090 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016091 [ALC861_ASUS_LAPTOP] = {
16092 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16093 .init_verbs = { alc861_asus_init_verbs,
16094 alc861_asus_laptop_init_verbs },
16095 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16096 .dac_nids = alc861_dac_nids,
16097 .dig_out_nid = ALC861_DIGOUT_NID,
16098 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16099 .channel_mode = alc883_3ST_2ch_modes,
16100 .need_dac_fix = 1,
16101 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16102 .adc_nids = alc861_adc_nids,
16103 .input_mux = &alc861_capture_source,
16104 },
16105};
Kailang Yangdf694da2005-12-05 19:42:22 +010016106
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016107/* Pin config fixes */
16108enum {
16109 PINFIX_FSC_AMILO_PI1505,
16110};
16111
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016112static const struct alc_fixup alc861_fixups[] = {
16113 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016114 .pins = (const struct alc_pincfg[]) {
16115 { 0x0b, 0x0221101f }, /* HP */
16116 { 0x0f, 0x90170310 }, /* speaker */
16117 { }
16118 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016119 },
16120};
16121
16122static struct snd_pci_quirk alc861_fixup_tbl[] = {
16123 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16124 {}
16125};
Kailang Yangdf694da2005-12-05 19:42:22 +010016126
16127static int patch_alc861(struct hda_codec *codec)
16128{
16129 struct alc_spec *spec;
16130 int board_config;
16131 int err;
16132
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016133 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016134 if (spec == NULL)
16135 return -ENOMEM;
16136
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016137 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016138
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016139 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16140 alc861_models,
16141 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016142
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016143 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016144 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16145 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016146 board_config = ALC861_AUTO;
16147 }
16148
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016149 if (board_config == ALC861_AUTO)
16150 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016151
Kailang Yangdf694da2005-12-05 19:42:22 +010016152 if (board_config == ALC861_AUTO) {
16153 /* automatic parse from the BIOS config */
16154 err = alc861_parse_auto_config(codec);
16155 if (err < 0) {
16156 alc_free(codec);
16157 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016158 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016159 printk(KERN_INFO
16160 "hda_codec: Cannot set up configuration "
16161 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016162 board_config = ALC861_3ST_DIG;
16163 }
16164 }
16165
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016166 err = snd_hda_attach_beep_device(codec, 0x23);
16167 if (err < 0) {
16168 alc_free(codec);
16169 return err;
16170 }
16171
Kailang Yangdf694da2005-12-05 19:42:22 +010016172 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016173 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016174
Kailang Yangdf694da2005-12-05 19:42:22 +010016175 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16176 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16177
Kailang Yangdf694da2005-12-05 19:42:22 +010016178 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16179 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16180
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016181 if (!spec->cap_mixer)
16182 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016183 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16184
Takashi Iwai2134ea42008-01-10 16:53:55 +010016185 spec->vmaster_nid = 0x03;
16186
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016187 if (board_config == ALC861_AUTO)
16188 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
16189
Kailang Yangdf694da2005-12-05 19:42:22 +010016190 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016191 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016192 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016193#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016194 spec->power_hook = alc_power_eapd;
16195#endif
16196 }
16197#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016198 if (!spec->loopback.amplist)
16199 spec->loopback.amplist = alc861_loopbacks;
16200#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016201
Kailang Yangdf694da2005-12-05 19:42:22 +010016202 return 0;
16203}
16204
16205/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016206 * ALC861-VD support
16207 *
16208 * Based on ALC882
16209 *
16210 * In addition, an independent DAC
16211 */
16212#define ALC861VD_DIGOUT_NID 0x06
16213
16214static hda_nid_t alc861vd_dac_nids[4] = {
16215 /* front, surr, clfe, side surr */
16216 0x02, 0x03, 0x04, 0x05
16217};
16218
16219/* dac_nids for ALC660vd are in a different order - according to
16220 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016221 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016222 * of ALC660vd codecs, but for now there is only 3stack mixer
16223 * - and it is the same as in 861vd.
16224 * adc_nids in ALC660vd are (is) the same as in 861vd
16225 */
16226static hda_nid_t alc660vd_dac_nids[3] = {
16227 /* front, rear, clfe, rear_surr */
16228 0x02, 0x04, 0x03
16229};
16230
16231static hda_nid_t alc861vd_adc_nids[1] = {
16232 /* ADC0 */
16233 0x09,
16234};
16235
Takashi Iwaie1406342008-02-11 18:32:32 +010016236static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16237
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016238/* input MUX */
16239/* FIXME: should be a matrix-type input source selection */
16240static struct hda_input_mux alc861vd_capture_source = {
16241 .num_items = 4,
16242 .items = {
16243 { "Mic", 0x0 },
16244 { "Front Mic", 0x1 },
16245 { "Line", 0x2 },
16246 { "CD", 0x4 },
16247 },
16248};
16249
Kailang Yang272a5272007-05-14 11:00:38 +020016250static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016251 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016252 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010016253 { "Ext Mic", 0x0 },
16254 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016255 },
16256};
16257
Kailang Yangd1a991a2007-08-15 16:21:59 +020016258static struct hda_input_mux alc861vd_hp_capture_source = {
16259 .num_items = 2,
16260 .items = {
16261 { "Front Mic", 0x0 },
16262 { "ATAPI Mic", 0x1 },
16263 },
16264};
16265
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016266/*
16267 * 2ch mode
16268 */
16269static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16270 { 2, NULL }
16271};
16272
16273/*
16274 * 6ch mode
16275 */
16276static struct hda_verb alc861vd_6stack_ch6_init[] = {
16277 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16278 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16279 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16280 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16281 { } /* end */
16282};
16283
16284/*
16285 * 8ch mode
16286 */
16287static struct hda_verb alc861vd_6stack_ch8_init[] = {
16288 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16289 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16290 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16291 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16292 { } /* end */
16293};
16294
16295static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16296 { 6, alc861vd_6stack_ch6_init },
16297 { 8, alc861vd_6stack_ch8_init },
16298};
16299
16300static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16301 {
16302 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16303 .name = "Channel Mode",
16304 .info = alc_ch_mode_info,
16305 .get = alc_ch_mode_get,
16306 .put = alc_ch_mode_put,
16307 },
16308 { } /* end */
16309};
16310
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016311/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16312 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16313 */
16314static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16315 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16316 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16317
16318 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16319 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16320
16321 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16322 HDA_OUTPUT),
16323 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16324 HDA_OUTPUT),
16325 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16326 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16327
16328 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16329 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16330
16331 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16332
16333 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16336
16337 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16338 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16339 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16340
16341 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16342 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16343
16344 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16345 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16346
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016347 { } /* end */
16348};
16349
16350static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16351 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16352 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16353
16354 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16355
16356 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16357 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16358 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16359
16360 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16361 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16362 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16363
16364 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16365 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16366
16367 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16368 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16369
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016370 { } /* end */
16371};
16372
Kailang Yangbdd148a2007-05-08 15:19:08 +020016373static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16374 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16375 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16376 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16377
16378 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16379
16380 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16382 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16383
16384 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16385 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16386 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16387
16388 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16389 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16390
16391 { } /* end */
16392};
16393
Tobin Davisb419f342008-03-07 11:57:51 +010016394/* Pin assignment: Speaker=0x14, HP = 0x15,
16395 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016396 */
16397static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016398 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16399 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016400 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16401 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016402 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16403 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16404 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16405 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16406 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16407 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016408 { } /* end */
16409};
16410
Kailang Yangd1a991a2007-08-15 16:21:59 +020016411/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16412 * Front Mic=0x18, ATAPI Mic = 0x19,
16413 */
16414static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16415 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16416 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16417 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16418 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16419 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16420 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16421 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16422 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016423
Kailang Yangd1a991a2007-08-15 16:21:59 +020016424 { } /* end */
16425};
16426
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016427/*
16428 * generic initialization of ADC, input mixers and output mixers
16429 */
16430static struct hda_verb alc861vd_volume_init_verbs[] = {
16431 /*
16432 * Unmute ADC0 and set the default input to mic-in
16433 */
16434 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16435 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16436
16437 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16438 * the analog-loopback mixer widget
16439 */
16440 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016441 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16442 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16443 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16444 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16445 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016446
16447 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016448 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16449 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16450 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016451 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016452
16453 /*
16454 * Set up output mixers (0x02 - 0x05)
16455 */
16456 /* set vol=0 to output mixers */
16457 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16458 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16459 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16460 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16461
16462 /* set up input amps for analog loopback */
16463 /* Amp Indices: DAC = 0, mixer = 1 */
16464 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16465 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16466 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16467 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16468 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16469 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16470 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16471 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16472
16473 { }
16474};
16475
16476/*
16477 * 3-stack pin configuration:
16478 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16479 */
16480static struct hda_verb alc861vd_3stack_init_verbs[] = {
16481 /*
16482 * Set pin mode and muting
16483 */
16484 /* set front pin widgets 0x14 for output */
16485 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16486 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16487 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16488
16489 /* Mic (rear) pin: input vref at 80% */
16490 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16491 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16492 /* Front Mic pin: input vref at 80% */
16493 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16494 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16495 /* Line In pin: input */
16496 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16497 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16498 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16499 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16500 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16501 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16502 /* CD pin widget for input */
16503 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16504
16505 { }
16506};
16507
16508/*
16509 * 6-stack pin configuration:
16510 */
16511static struct hda_verb alc861vd_6stack_init_verbs[] = {
16512 /*
16513 * Set pin mode and muting
16514 */
16515 /* set front pin widgets 0x14 for output */
16516 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16517 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16518 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16519
16520 /* Rear Pin: output 1 (0x0d) */
16521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16522 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16523 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16524 /* CLFE Pin: output 2 (0x0e) */
16525 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16526 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16527 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16528 /* Side Pin: output 3 (0x0f) */
16529 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16530 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16531 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16532
16533 /* Mic (rear) pin: input vref at 80% */
16534 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16535 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16536 /* Front Mic pin: input vref at 80% */
16537 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16538 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16539 /* Line In pin: input */
16540 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16541 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16542 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16543 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16544 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16545 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16546 /* CD pin widget for input */
16547 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16548
16549 { }
16550};
16551
Kailang Yangbdd148a2007-05-08 15:19:08 +020016552static struct hda_verb alc861vd_eapd_verbs[] = {
16553 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16554 { }
16555};
16556
Kailang Yangf9423e72008-05-27 12:32:25 +020016557static struct hda_verb alc660vd_eapd_verbs[] = {
16558 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16559 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16560 { }
16561};
16562
Kailang Yangbdd148a2007-05-08 15:19:08 +020016563static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16564 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16565 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16566 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16567 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016568 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016569 {}
16570};
16571
Kailang Yangbdd148a2007-05-08 15:19:08 +020016572static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16573{
16574 unsigned int present;
16575 unsigned char bits;
16576
Wu Fengguang864f92b2009-11-18 12:38:02 +080016577 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016578 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016579
Takashi Iwai47fd8302007-08-10 17:11:07 +020016580 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16581 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016582}
16583
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016584static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016585{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016586 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016587 spec->autocfg.hp_pins[0] = 0x1b;
16588 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016589}
16590
16591static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16592{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016593 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016594 alc861vd_lenovo_mic_automute(codec);
16595}
16596
16597static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16598 unsigned int res)
16599{
16600 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016601 case ALC880_MIC_EVENT:
16602 alc861vd_lenovo_mic_automute(codec);
16603 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016604 default:
16605 alc_automute_amp_unsol_event(codec, res);
16606 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016607 }
16608}
16609
Kailang Yang272a5272007-05-14 11:00:38 +020016610static struct hda_verb alc861vd_dallas_verbs[] = {
16611 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16612 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16613 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16614 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16615
16616 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16617 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16618 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16619 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16620 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16621 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16622 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16623 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016624
Kailang Yang272a5272007-05-14 11:00:38 +020016625 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16626 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16627 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16628 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16629 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16630 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16631 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16632 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16633
16634 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16635 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16636 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16637 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16638 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16639 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16640 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16641 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16642
16643 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16644 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16645 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16646 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16647
16648 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016649 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016650 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16651
16652 { } /* end */
16653};
16654
16655/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016656static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016657{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016658 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016659
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016660 spec->autocfg.hp_pins[0] = 0x15;
16661 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016662}
16663
Takashi Iwaicb53c622007-08-10 17:21:45 +020016664#ifdef CONFIG_SND_HDA_POWER_SAVE
16665#define alc861vd_loopbacks alc880_loopbacks
16666#endif
16667
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016668/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016669#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16670#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16671#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16672#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16673
16674/*
16675 * configuration and preset
16676 */
16677static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16678 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016679 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016680 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016681 [ALC861VD_3ST] = "3stack",
16682 [ALC861VD_3ST_DIG] = "3stack-digout",
16683 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016684 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016685 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016686 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016687 [ALC861VD_AUTO] = "auto",
16688};
16689
16690static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016691 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16692 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016693 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016694 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016695 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016696 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016697 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016698 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016699 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016700 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016701 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016702 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016703 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016704 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016705 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016706 {}
16707};
16708
16709static struct alc_config_preset alc861vd_presets[] = {
16710 [ALC660VD_3ST] = {
16711 .mixers = { alc861vd_3st_mixer },
16712 .init_verbs = { alc861vd_volume_init_verbs,
16713 alc861vd_3stack_init_verbs },
16714 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16715 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016716 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16717 .channel_mode = alc861vd_3stack_2ch_modes,
16718 .input_mux = &alc861vd_capture_source,
16719 },
Mike Crash6963f842007-06-25 12:12:51 +020016720 [ALC660VD_3ST_DIG] = {
16721 .mixers = { alc861vd_3st_mixer },
16722 .init_verbs = { alc861vd_volume_init_verbs,
16723 alc861vd_3stack_init_verbs },
16724 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16725 .dac_nids = alc660vd_dac_nids,
16726 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016727 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16728 .channel_mode = alc861vd_3stack_2ch_modes,
16729 .input_mux = &alc861vd_capture_source,
16730 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016731 [ALC861VD_3ST] = {
16732 .mixers = { alc861vd_3st_mixer },
16733 .init_verbs = { alc861vd_volume_init_verbs,
16734 alc861vd_3stack_init_verbs },
16735 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16736 .dac_nids = alc861vd_dac_nids,
16737 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16738 .channel_mode = alc861vd_3stack_2ch_modes,
16739 .input_mux = &alc861vd_capture_source,
16740 },
16741 [ALC861VD_3ST_DIG] = {
16742 .mixers = { alc861vd_3st_mixer },
16743 .init_verbs = { alc861vd_volume_init_verbs,
16744 alc861vd_3stack_init_verbs },
16745 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16746 .dac_nids = alc861vd_dac_nids,
16747 .dig_out_nid = ALC861VD_DIGOUT_NID,
16748 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16749 .channel_mode = alc861vd_3stack_2ch_modes,
16750 .input_mux = &alc861vd_capture_source,
16751 },
16752 [ALC861VD_6ST_DIG] = {
16753 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16754 .init_verbs = { alc861vd_volume_init_verbs,
16755 alc861vd_6stack_init_verbs },
16756 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16757 .dac_nids = alc861vd_dac_nids,
16758 .dig_out_nid = ALC861VD_DIGOUT_NID,
16759 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16760 .channel_mode = alc861vd_6stack_modes,
16761 .input_mux = &alc861vd_capture_source,
16762 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016763 [ALC861VD_LENOVO] = {
16764 .mixers = { alc861vd_lenovo_mixer },
16765 .init_verbs = { alc861vd_volume_init_verbs,
16766 alc861vd_3stack_init_verbs,
16767 alc861vd_eapd_verbs,
16768 alc861vd_lenovo_unsol_verbs },
16769 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16770 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016771 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16772 .channel_mode = alc861vd_3stack_2ch_modes,
16773 .input_mux = &alc861vd_capture_source,
16774 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016775 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016776 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016777 },
Kailang Yang272a5272007-05-14 11:00:38 +020016778 [ALC861VD_DALLAS] = {
16779 .mixers = { alc861vd_dallas_mixer },
16780 .init_verbs = { alc861vd_dallas_verbs },
16781 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16782 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016783 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16784 .channel_mode = alc861vd_3stack_2ch_modes,
16785 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016786 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016787 .setup = alc861vd_dallas_setup,
16788 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016789 },
16790 [ALC861VD_HP] = {
16791 .mixers = { alc861vd_hp_mixer },
16792 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16793 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16794 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016795 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016796 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16797 .channel_mode = alc861vd_3stack_2ch_modes,
16798 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016799 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016800 .setup = alc861vd_dallas_setup,
16801 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016802 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016803 [ALC660VD_ASUS_V1S] = {
16804 .mixers = { alc861vd_lenovo_mixer },
16805 .init_verbs = { alc861vd_volume_init_verbs,
16806 alc861vd_3stack_init_verbs,
16807 alc861vd_eapd_verbs,
16808 alc861vd_lenovo_unsol_verbs },
16809 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16810 .dac_nids = alc660vd_dac_nids,
16811 .dig_out_nid = ALC861VD_DIGOUT_NID,
16812 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16813 .channel_mode = alc861vd_3stack_2ch_modes,
16814 .input_mux = &alc861vd_capture_source,
16815 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016816 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016817 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016818 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016819};
16820
16821/*
16822 * BIOS auto configuration
16823 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016824static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16825 const struct auto_pin_cfg *cfg)
16826{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016827 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016828}
16829
16830
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016831static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16832 hda_nid_t nid, int pin_type, int dac_idx)
16833{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016834 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016835}
16836
16837static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16838{
16839 struct alc_spec *spec = codec->spec;
16840 int i;
16841
16842 for (i = 0; i <= HDA_SIDE; i++) {
16843 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016844 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016845 if (nid)
16846 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016847 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016848 }
16849}
16850
16851
16852static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16853{
16854 struct alc_spec *spec = codec->spec;
16855 hda_nid_t pin;
16856
16857 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016858 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016859 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016860 pin = spec->autocfg.speaker_pins[0];
16861 if (pin)
16862 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016863}
16864
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016865#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16866
16867static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16868{
16869 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016870 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016871 int i;
16872
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016873 for (i = 0; i < cfg->num_inputs; i++) {
16874 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016875 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020016876 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016877 if (nid != ALC861VD_PIN_CD_NID &&
16878 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016879 snd_hda_codec_write(codec, nid, 0,
16880 AC_VERB_SET_AMP_GAIN_MUTE,
16881 AMP_OUT_MUTE);
16882 }
16883 }
16884}
16885
Takashi Iwaif511b012008-08-15 16:46:42 +020016886#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16887
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016888#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16889#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16890
16891/* add playback controls from the parsed DAC table */
16892/* Based on ALC880 version. But ALC861VD has separate,
16893 * different NIDs for mute/unmute switch and volume control */
16894static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16895 const struct auto_pin_cfg *cfg)
16896{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016897 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16898 hda_nid_t nid_v, nid_s;
16899 int i, err;
16900
16901 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016902 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016903 continue;
16904 nid_v = alc861vd_idx_to_mixer_vol(
16905 alc880_dac_to_idx(
16906 spec->multiout.dac_nids[i]));
16907 nid_s = alc861vd_idx_to_mixer_switch(
16908 alc880_dac_to_idx(
16909 spec->multiout.dac_nids[i]));
16910
16911 if (i == 2) {
16912 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016913 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16914 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016915 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16916 HDA_OUTPUT));
16917 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016918 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016919 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16920 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016921 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16922 HDA_OUTPUT));
16923 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016924 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016925 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16926 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016927 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16928 HDA_INPUT));
16929 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016930 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016931 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16932 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016933 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16934 HDA_INPUT));
16935 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016936 return err;
16937 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016938 const char *pfx;
16939 if (cfg->line_outs == 1 &&
16940 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16941 if (!cfg->hp_pins)
16942 pfx = "Speaker";
16943 else
16944 pfx = "PCM";
16945 } else
16946 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016947 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016948 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16949 HDA_OUTPUT));
16950 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016951 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016952 if (cfg->line_outs == 1 &&
16953 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16954 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016955 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016956 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016957 HDA_INPUT));
16958 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016959 return err;
16960 }
16961 }
16962 return 0;
16963}
16964
16965/* add playback controls for speaker and HP outputs */
16966/* Based on ALC880 version. But ALC861VD has separate,
16967 * different NIDs for mute/unmute switch and volume control */
16968static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16969 hda_nid_t pin, const char *pfx)
16970{
16971 hda_nid_t nid_v, nid_s;
16972 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016973
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016974 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016975 return 0;
16976
16977 if (alc880_is_fixed_pin(pin)) {
16978 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16979 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016980 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016981 spec->multiout.hp_nid = nid_v;
16982 else
16983 spec->multiout.extra_out_nid[0] = nid_v;
16984 /* control HP volume/switch on the output mixer amp */
16985 nid_v = alc861vd_idx_to_mixer_vol(
16986 alc880_fixed_pin_idx(pin));
16987 nid_s = alc861vd_idx_to_mixer_switch(
16988 alc880_fixed_pin_idx(pin));
16989
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016990 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016991 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16992 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016993 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016994 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016995 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16996 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016997 return err;
16998 } else if (alc880_is_multi_pin(pin)) {
16999 /* set manual connection */
17000 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017001 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017002 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17003 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017004 return err;
17005 }
17006 return 0;
17007}
17008
17009/* parse the BIOS configuration and set up the alc_spec
17010 * return 1 if successful, 0 if the proper config is not found,
17011 * or a negative error code
17012 * Based on ALC880 version - had to change it to override
17013 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17014static int alc861vd_parse_auto_config(struct hda_codec *codec)
17015{
17016 struct alc_spec *spec = codec->spec;
17017 int err;
17018 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17019
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017020 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17021 alc861vd_ignore);
17022 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017023 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017024 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017025 return 0; /* can't find valid BIOS pin config */
17026
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017027 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17028 if (err < 0)
17029 return err;
17030 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17031 if (err < 0)
17032 return err;
17033 err = alc861vd_auto_create_extra_out(spec,
17034 spec->autocfg.speaker_pins[0],
17035 "Speaker");
17036 if (err < 0)
17037 return err;
17038 err = alc861vd_auto_create_extra_out(spec,
17039 spec->autocfg.hp_pins[0],
17040 "Headphone");
17041 if (err < 0)
17042 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017043 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017044 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017045 return err;
17046
17047 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17048
Takashi Iwai757899a2010-07-30 10:48:14 +020017049 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017050
Takashi Iwai603c4012008-07-30 15:01:44 +020017051 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017052 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017053
Takashi Iwaid88897e2008-10-31 15:01:37 +010017054 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017055
17056 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017057 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017058
Takashi Iwai776e1842007-08-29 15:07:11 +020017059 err = alc_auto_add_mic_boost(codec);
17060 if (err < 0)
17061 return err;
17062
Kailang Yang6227cdc2010-02-25 08:36:52 +010017063 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017064
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017065 return 1;
17066}
17067
17068/* additional initialization for auto-configuration model */
17069static void alc861vd_auto_init(struct hda_codec *codec)
17070{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017071 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017072 alc861vd_auto_init_multi_out(codec);
17073 alc861vd_auto_init_hp_out(codec);
17074 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017075 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017076 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017077 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017078 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017079}
17080
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017081enum {
17082 ALC660VD_FIX_ASUS_GPIO1
17083};
17084
17085/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017086static const struct alc_fixup alc861vd_fixups[] = {
17087 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020017088 .verbs = (const struct hda_verb[]) {
17089 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17090 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17091 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17092 { }
17093 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017094 },
17095};
17096
17097static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17098 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17099 {}
17100};
17101
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017102static int patch_alc861vd(struct hda_codec *codec)
17103{
17104 struct alc_spec *spec;
17105 int err, board_config;
17106
17107 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17108 if (spec == NULL)
17109 return -ENOMEM;
17110
17111 codec->spec = spec;
17112
17113 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17114 alc861vd_models,
17115 alc861vd_cfg_tbl);
17116
17117 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017118 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17119 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017120 board_config = ALC861VD_AUTO;
17121 }
17122
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017123 if (board_config == ALC861VD_AUTO)
17124 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017125
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017126 if (board_config == ALC861VD_AUTO) {
17127 /* automatic parse from the BIOS config */
17128 err = alc861vd_parse_auto_config(codec);
17129 if (err < 0) {
17130 alc_free(codec);
17131 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017132 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017133 printk(KERN_INFO
17134 "hda_codec: Cannot set up configuration "
17135 "from BIOS. Using base mode...\n");
17136 board_config = ALC861VD_3ST;
17137 }
17138 }
17139
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017140 err = snd_hda_attach_beep_device(codec, 0x23);
17141 if (err < 0) {
17142 alc_free(codec);
17143 return err;
17144 }
17145
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017146 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017147 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017148
Kailang Yang2f893282008-05-27 12:14:47 +020017149 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017150 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017151 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017152 }
17153
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017154 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17155 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17156
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017157 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17158 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17159
Takashi Iwaidd704692009-08-11 08:45:11 +020017160 if (!spec->adc_nids) {
17161 spec->adc_nids = alc861vd_adc_nids;
17162 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17163 }
17164 if (!spec->capsrc_nids)
17165 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017166
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017167 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017168 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017169
Takashi Iwai2134ea42008-01-10 16:53:55 +010017170 spec->vmaster_nid = 0x02;
17171
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017172 if (board_config == ALC861VD_AUTO)
17173 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
17174
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017175 codec->patch_ops = alc_patch_ops;
17176
17177 if (board_config == ALC861VD_AUTO)
17178 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017179#ifdef CONFIG_SND_HDA_POWER_SAVE
17180 if (!spec->loopback.amplist)
17181 spec->loopback.amplist = alc861vd_loopbacks;
17182#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017183
17184 return 0;
17185}
17186
17187/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017188 * ALC662 support
17189 *
17190 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17191 * configuration. Each pin widget can choose any input DACs and a mixer.
17192 * Each ADC is connected from a mixer of all inputs. This makes possible
17193 * 6-channel independent captures.
17194 *
17195 * In addition, an independent DAC for the multi-playback (not used in this
17196 * driver yet).
17197 */
17198#define ALC662_DIGOUT_NID 0x06
17199#define ALC662_DIGIN_NID 0x0a
17200
17201static hda_nid_t alc662_dac_nids[4] = {
17202 /* front, rear, clfe, rear_surr */
17203 0x02, 0x03, 0x04
17204};
17205
Kailang Yang622e84c2009-04-21 07:39:04 +020017206static hda_nid_t alc272_dac_nids[2] = {
17207 0x02, 0x03
17208};
17209
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017210static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017211 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017212 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017213};
Takashi Iwaie1406342008-02-11 18:32:32 +010017214
Kailang Yang622e84c2009-04-21 07:39:04 +020017215static hda_nid_t alc272_adc_nids[1] = {
17216 /* ADC1-2 */
17217 0x08,
17218};
17219
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017220static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017221static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17222
Takashi Iwaie1406342008-02-11 18:32:32 +010017223
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017224/* input MUX */
17225/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017226static struct hda_input_mux alc662_capture_source = {
17227 .num_items = 4,
17228 .items = {
17229 { "Mic", 0x0 },
17230 { "Front Mic", 0x1 },
17231 { "Line", 0x2 },
17232 { "CD", 0x4 },
17233 },
17234};
17235
17236static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17237 .num_items = 2,
17238 .items = {
17239 { "Mic", 0x1 },
17240 { "Line", 0x2 },
17241 },
17242};
Kailang Yang291702f2007-10-16 14:28:03 +020017243
Kailang Yang6dda9f42008-05-27 12:05:31 +020017244static struct hda_input_mux alc663_capture_source = {
17245 .num_items = 3,
17246 .items = {
17247 { "Mic", 0x0 },
17248 { "Front Mic", 0x1 },
17249 { "Line", 0x2 },
17250 },
17251};
17252
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017253#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017254static struct hda_input_mux alc272_nc10_capture_source = {
17255 .num_items = 16,
17256 .items = {
17257 { "Autoselect Mic", 0x0 },
17258 { "Internal Mic", 0x1 },
17259 { "In-0x02", 0x2 },
17260 { "In-0x03", 0x3 },
17261 { "In-0x04", 0x4 },
17262 { "In-0x05", 0x5 },
17263 { "In-0x06", 0x6 },
17264 { "In-0x07", 0x7 },
17265 { "In-0x08", 0x8 },
17266 { "In-0x09", 0x9 },
17267 { "In-0x0a", 0x0a },
17268 { "In-0x0b", 0x0b },
17269 { "In-0x0c", 0x0c },
17270 { "In-0x0d", 0x0d },
17271 { "In-0x0e", 0x0e },
17272 { "In-0x0f", 0x0f },
17273 },
17274};
17275#endif
17276
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017277/*
17278 * 2ch mode
17279 */
17280static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17281 { 2, NULL }
17282};
17283
17284/*
17285 * 2ch mode
17286 */
17287static struct hda_verb alc662_3ST_ch2_init[] = {
17288 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17289 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17290 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17291 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17292 { } /* end */
17293};
17294
17295/*
17296 * 6ch mode
17297 */
17298static struct hda_verb alc662_3ST_ch6_init[] = {
17299 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17300 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17301 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17302 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17303 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17304 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17305 { } /* end */
17306};
17307
17308static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17309 { 2, alc662_3ST_ch2_init },
17310 { 6, alc662_3ST_ch6_init },
17311};
17312
17313/*
17314 * 2ch mode
17315 */
17316static struct hda_verb alc662_sixstack_ch6_init[] = {
17317 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17318 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17319 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17320 { } /* end */
17321};
17322
17323/*
17324 * 6ch mode
17325 */
17326static struct hda_verb alc662_sixstack_ch8_init[] = {
17327 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17328 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17329 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17330 { } /* end */
17331};
17332
17333static struct hda_channel_mode alc662_5stack_modes[2] = {
17334 { 2, alc662_sixstack_ch6_init },
17335 { 6, alc662_sixstack_ch8_init },
17336};
17337
17338/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17339 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17340 */
17341
17342static struct snd_kcontrol_new alc662_base_mixer[] = {
17343 /* output mixer control */
17344 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017345 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017346 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017347 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017348 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17349 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017350 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17351 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017352 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17353
17354 /*Input mixer control */
17355 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17356 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17357 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17358 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17359 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17360 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17361 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17362 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017363 { } /* end */
17364};
17365
17366static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17367 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017368 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017369 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17370 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17371 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17372 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17373 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17374 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17375 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17376 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17377 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017378 { } /* end */
17379};
17380
17381static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17382 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017383 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017384 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017385 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017386 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17387 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017388 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17389 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017390 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17391 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17392 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17393 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17394 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17395 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17396 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17397 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17398 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017399 { } /* end */
17400};
17401
17402static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17403 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17404 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017405 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17406 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017407 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17408 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17409 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17410 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17411 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017412 { } /* end */
17413};
17414
Kailang Yang291702f2007-10-16 14:28:03 +020017415static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017416 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17417 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017418
17419 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17420 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17421 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17422
17423 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17424 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17425 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17426 { } /* end */
17427};
17428
Kailang Yang8c427222008-01-10 13:03:59 +010017429static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017430 ALC262_HIPPO_MASTER_SWITCH,
17431 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017432 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017433 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17434 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017435 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17436 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17437 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17438 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17439 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17440 { } /* end */
17441};
17442
Kailang Yangf1d4e282008-08-26 14:03:29 +020017443static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17444 .ops = &snd_hda_bind_vol,
17445 .values = {
17446 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17447 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17448 0
17449 },
17450};
17451
17452static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17453 .ops = &snd_hda_bind_sw,
17454 .values = {
17455 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17456 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17457 0
17458 },
17459};
17460
Kailang Yang6dda9f42008-05-27 12:05:31 +020017461static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017462 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17463 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17464 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17465 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17466 { } /* end */
17467};
17468
17469static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17470 .ops = &snd_hda_bind_sw,
17471 .values = {
17472 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17473 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17474 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17475 0
17476 },
17477};
17478
17479static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17480 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17481 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17482 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17483 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17484 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17485 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17486
17487 { } /* end */
17488};
17489
17490static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17491 .ops = &snd_hda_bind_sw,
17492 .values = {
17493 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17494 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17495 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17496 0
17497 },
17498};
17499
17500static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17501 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17502 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17503 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17504 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17505 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17506 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17507 { } /* end */
17508};
17509
17510static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017511 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17512 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017513 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17514 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17515 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17516 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17517 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17518 { } /* end */
17519};
17520
17521static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17522 .ops = &snd_hda_bind_vol,
17523 .values = {
17524 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17525 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17526 0
17527 },
17528};
17529
17530static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17531 .ops = &snd_hda_bind_sw,
17532 .values = {
17533 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17534 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17535 0
17536 },
17537};
17538
17539static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17540 HDA_BIND_VOL("Master Playback Volume",
17541 &alc663_asus_two_bind_master_vol),
17542 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17543 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017544 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017547 { } /* end */
17548};
17549
17550static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17551 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17552 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17553 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17554 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17555 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17556 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017557 { } /* end */
17558};
17559
17560static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17561 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17562 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17563 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17564 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17565 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17566
17567 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17568 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17569 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17570 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17571 { } /* end */
17572};
17573
17574static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17575 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17576 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17577 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17578
17579 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17580 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17581 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17582 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17583 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17584 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17585 { } /* end */
17586};
17587
Kailang Yangebb83ee2009-12-17 12:23:00 +010017588static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17589 .ops = &snd_hda_bind_sw,
17590 .values = {
17591 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17592 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17593 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17594 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17595 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17596 0
17597 },
17598};
17599
17600static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17601 .ops = &snd_hda_bind_sw,
17602 .values = {
17603 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17604 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17605 0
17606 },
17607};
17608
17609static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17610 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17611 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17612 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17613 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17614 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17615 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17616 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17619 { } /* end */
17620};
17621
17622static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17623 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17624 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17625 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17626 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17627 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17628 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17630 { } /* end */
17631};
17632
17633
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017634static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17635 {
17636 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17637 .name = "Channel Mode",
17638 .info = alc_ch_mode_info,
17639 .get = alc_ch_mode_get,
17640 .put = alc_ch_mode_put,
17641 },
17642 { } /* end */
17643};
17644
17645static struct hda_verb alc662_init_verbs[] = {
17646 /* ADC: mute amp left and right */
17647 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17648 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017649
Kailang Yangb60dd392007-09-20 12:50:29 +020017650 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17651 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17652 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17653 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17654 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17655 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017656
17657 /* Front Pin: output 0 (0x0c) */
17658 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17659 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17660
17661 /* Rear Pin: output 1 (0x0d) */
17662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17663 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17664
17665 /* CLFE Pin: output 2 (0x0e) */
17666 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17667 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17668
17669 /* Mic (rear) pin: input vref at 80% */
17670 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17671 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17672 /* Front Mic pin: input vref at 80% */
17673 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17674 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17675 /* Line In pin: input */
17676 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17677 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17678 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17679 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17680 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17681 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17682 /* CD pin widget for input */
17683 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17684
17685 /* FIXME: use matrix-type input source selection */
17686 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17687 /* Input mixer */
17688 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017689 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017690
17691 /* always trun on EAPD */
17692 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17693 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17694
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017695 { }
17696};
17697
Kailang Yangcec27c82010-02-04 14:18:18 +010017698static struct hda_verb alc663_init_verbs[] = {
17699 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17700 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17701 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17702 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17703 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17704 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17705 { }
17706};
17707
17708static struct hda_verb alc272_init_verbs[] = {
17709 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17710 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17711 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17712 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17713 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17714 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17715 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17716 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17717 { }
17718};
17719
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017720static struct hda_verb alc662_sue_init_verbs[] = {
17721 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17722 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017723 {}
17724};
17725
17726static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17727 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17728 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17729 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017730};
17731
Kailang Yang8c427222008-01-10 13:03:59 +010017732/* Set Unsolicited Event*/
17733static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17734 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17735 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17736 {}
17737};
17738
Kailang Yang6dda9f42008-05-27 12:05:31 +020017739static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017740 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17741 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017742 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17743 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017744 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017747 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17748 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17749 {}
17750};
17751
Kailang Yangf1d4e282008-08-26 14:03:29 +020017752static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17753 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17754 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17755 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17756 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17757 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17758 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17759 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17760 {}
17761};
17762
17763static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17764 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17765 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17766 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17767 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17768 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17769 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17770 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17771 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17772 {}
17773};
17774
17775static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17776 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17777 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17778 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17779 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17780 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17781 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17782 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17783 {}
17784};
17785
17786static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17787 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17788 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17789 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17790 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17791 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17792 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17793 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17794 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17795 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17796 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17797 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17798 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17799 {}
17800};
17801
17802static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17803 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17804 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17805 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17806 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17807 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17808 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17809 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17810 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17811 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17812 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17813 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17814 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17815 {}
17816};
17817
Kailang Yang6dda9f42008-05-27 12:05:31 +020017818static struct hda_verb alc663_g71v_init_verbs[] = {
17819 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17820 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17821 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17822
17823 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17824 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17825 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17826
17827 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17828 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17829 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17830 {}
17831};
17832
17833static struct hda_verb alc663_g50v_init_verbs[] = {
17834 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17835 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17836 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17837
17838 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17839 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17840 {}
17841};
17842
Kailang Yangf1d4e282008-08-26 14:03:29 +020017843static struct hda_verb alc662_ecs_init_verbs[] = {
17844 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17845 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17846 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17847 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17848 {}
17849};
17850
Kailang Yang622e84c2009-04-21 07:39:04 +020017851static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17852 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17853 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17854 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17855 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17856 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17857 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17858 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17859 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17860 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17861 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17862 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17863 {}
17864};
17865
17866static struct hda_verb alc272_dell_init_verbs[] = {
17867 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17868 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17869 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17870 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17871 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17872 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17873 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17874 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17875 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17876 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17877 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17878 {}
17879};
17880
Kailang Yangebb83ee2009-12-17 12:23:00 +010017881static struct hda_verb alc663_mode7_init_verbs[] = {
17882 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17883 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17884 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17885 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17886 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17887 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17888 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17889 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17890 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17891 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17892 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17893 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17894 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17895 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17896 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17897 {}
17898};
17899
17900static struct hda_verb alc663_mode8_init_verbs[] = {
17901 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17902 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17903 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17904 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17905 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17906 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17907 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17908 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17909 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17910 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17911 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17912 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17913 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17914 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17915 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17916 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17917 {}
17918};
17919
Kailang Yangf1d4e282008-08-26 14:03:29 +020017920static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17921 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17922 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17923 { } /* end */
17924};
17925
Kailang Yang622e84c2009-04-21 07:39:04 +020017926static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17927 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17928 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17929 { } /* end */
17930};
17931
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017932static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17933{
17934 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017935 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017936
Wu Fengguang864f92b2009-11-18 12:38:02 +080017937 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017938 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017939
Takashi Iwai47fd8302007-08-10 17:11:07 +020017940 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17941 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017942}
17943
17944static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17945{
17946 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017947 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017948
Wu Fengguang864f92b2009-11-18 12:38:02 +080017949 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017950 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017951
Takashi Iwai47fd8302007-08-10 17:11:07 +020017952 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17953 HDA_AMP_MUTE, bits);
17954 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17955 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017956}
17957
17958static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17959 unsigned int res)
17960{
17961 if ((res >> 26) == ALC880_HP_EVENT)
17962 alc662_lenovo_101e_all_automute(codec);
17963 if ((res >> 26) == ALC880_FRONT_EVENT)
17964 alc662_lenovo_101e_ispeaker_automute(codec);
17965}
17966
Kailang Yang291702f2007-10-16 14:28:03 +020017967/* unsolicited event for HP jack sensing */
17968static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17969 unsigned int res)
17970{
Kailang Yang291702f2007-10-16 14:28:03 +020017971 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017972 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017973 else
17974 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017975}
17976
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017977static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017978{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017979 struct alc_spec *spec = codec->spec;
17980
17981 alc262_hippo1_setup(codec);
17982 spec->ext_mic.pin = 0x18;
17983 spec->ext_mic.mux_idx = 0;
17984 spec->int_mic.pin = 0x19;
17985 spec->int_mic.mux_idx = 1;
17986 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017987}
17988
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017989static void alc662_eeepc_inithook(struct hda_codec *codec)
17990{
17991 alc262_hippo_automute(codec);
17992 alc_mic_automute(codec);
17993}
17994
17995static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017996{
Takashi Iwai42171c12009-05-08 14:11:43 +020017997 struct alc_spec *spec = codec->spec;
17998
17999 spec->autocfg.hp_pins[0] = 0x14;
18000 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018001}
18002
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018003#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18004
Kailang Yang6dda9f42008-05-27 12:05:31 +020018005static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18006{
18007 unsigned int present;
18008 unsigned char bits;
18009
Wu Fengguang864f92b2009-11-18 12:38:02 +080018010 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018011 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018012 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018013 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018014 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018015 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018016}
18017
18018static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18019{
18020 unsigned int present;
18021 unsigned char bits;
18022
Wu Fengguang864f92b2009-11-18 12:38:02 +080018023 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018024 bits = present ? HDA_AMP_MUTE : 0;
18025 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018026 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018027 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018028 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018029 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018030 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018031 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018032 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018033}
18034
18035static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18036{
18037 unsigned int present;
18038 unsigned char bits;
18039
Wu Fengguang864f92b2009-11-18 12:38:02 +080018040 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018041 bits = present ? HDA_AMP_MUTE : 0;
18042 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018043 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018044 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018045 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018046 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018047 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018048 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018049 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018050}
18051
18052static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18053{
18054 unsigned int present;
18055 unsigned char bits;
18056
Wu Fengguang864f92b2009-11-18 12:38:02 +080018057 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018058 bits = present ? 0 : PIN_OUT;
18059 snd_hda_codec_write(codec, 0x14, 0,
18060 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18061}
18062
18063static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18064{
18065 unsigned int present1, present2;
18066
Wu Fengguang864f92b2009-11-18 12:38:02 +080018067 present1 = snd_hda_jack_detect(codec, 0x21);
18068 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018069
18070 if (present1 || present2) {
18071 snd_hda_codec_write_cache(codec, 0x14, 0,
18072 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18073 } else {
18074 snd_hda_codec_write_cache(codec, 0x14, 0,
18075 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18076 }
18077}
18078
18079static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18080{
18081 unsigned int present1, present2;
18082
Wu Fengguang864f92b2009-11-18 12:38:02 +080018083 present1 = snd_hda_jack_detect(codec, 0x1b);
18084 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018085
18086 if (present1 || present2) {
18087 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018088 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018089 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018090 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018091 } else {
18092 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018093 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018094 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018095 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018096 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018097}
18098
Kailang Yangebb83ee2009-12-17 12:23:00 +010018099static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18100{
18101 unsigned int present1, present2;
18102
18103 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18104 AC_VERB_GET_PIN_SENSE, 0)
18105 & AC_PINSENSE_PRESENCE;
18106 present2 = snd_hda_codec_read(codec, 0x21, 0,
18107 AC_VERB_GET_PIN_SENSE, 0)
18108 & AC_PINSENSE_PRESENCE;
18109
18110 if (present1 || present2) {
18111 snd_hda_codec_write_cache(codec, 0x14, 0,
18112 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18113 snd_hda_codec_write_cache(codec, 0x17, 0,
18114 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18115 } else {
18116 snd_hda_codec_write_cache(codec, 0x14, 0,
18117 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18118 snd_hda_codec_write_cache(codec, 0x17, 0,
18119 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18120 }
18121}
18122
18123static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18124{
18125 unsigned int present1, present2;
18126
18127 present1 = snd_hda_codec_read(codec, 0x21, 0,
18128 AC_VERB_GET_PIN_SENSE, 0)
18129 & AC_PINSENSE_PRESENCE;
18130 present2 = snd_hda_codec_read(codec, 0x15, 0,
18131 AC_VERB_GET_PIN_SENSE, 0)
18132 & AC_PINSENSE_PRESENCE;
18133
18134 if (present1 || present2) {
18135 snd_hda_codec_write_cache(codec, 0x14, 0,
18136 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18137 snd_hda_codec_write_cache(codec, 0x17, 0,
18138 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18139 } else {
18140 snd_hda_codec_write_cache(codec, 0x14, 0,
18141 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18142 snd_hda_codec_write_cache(codec, 0x17, 0,
18143 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18144 }
18145}
18146
Kailang Yang6dda9f42008-05-27 12:05:31 +020018147static void alc663_m51va_unsol_event(struct hda_codec *codec,
18148 unsigned int res)
18149{
18150 switch (res >> 26) {
18151 case ALC880_HP_EVENT:
18152 alc663_m51va_speaker_automute(codec);
18153 break;
18154 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018155 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018156 break;
18157 }
18158}
18159
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018160static void alc663_m51va_setup(struct hda_codec *codec)
18161{
18162 struct alc_spec *spec = codec->spec;
18163 spec->ext_mic.pin = 0x18;
18164 spec->ext_mic.mux_idx = 0;
18165 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018166 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018167 spec->auto_mic = 1;
18168}
18169
Kailang Yang6dda9f42008-05-27 12:05:31 +020018170static void alc663_m51va_inithook(struct hda_codec *codec)
18171{
18172 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018173 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018174}
18175
Kailang Yangf1d4e282008-08-26 14:03:29 +020018176/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018177#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018178
18179static void alc663_mode1_setup(struct hda_codec *codec)
18180{
18181 struct alc_spec *spec = codec->spec;
18182 spec->ext_mic.pin = 0x18;
18183 spec->ext_mic.mux_idx = 0;
18184 spec->int_mic.pin = 0x19;
18185 spec->int_mic.mux_idx = 1;
18186 spec->auto_mic = 1;
18187}
18188
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018189#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018190
Kailang Yangf1d4e282008-08-26 14:03:29 +020018191/* ***************** Mode2 ******************************/
18192static void alc662_mode2_unsol_event(struct hda_codec *codec,
18193 unsigned int res)
18194{
18195 switch (res >> 26) {
18196 case ALC880_HP_EVENT:
18197 alc662_f5z_speaker_automute(codec);
18198 break;
18199 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018200 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018201 break;
18202 }
18203}
18204
Kailang Yangebb83ee2009-12-17 12:23:00 +010018205#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018206
Kailang Yangf1d4e282008-08-26 14:03:29 +020018207static void alc662_mode2_inithook(struct hda_codec *codec)
18208{
18209 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018210 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018211}
18212/* ***************** Mode3 ******************************/
18213static void alc663_mode3_unsol_event(struct hda_codec *codec,
18214 unsigned int res)
18215{
18216 switch (res >> 26) {
18217 case ALC880_HP_EVENT:
18218 alc663_two_hp_m1_speaker_automute(codec);
18219 break;
18220 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018221 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018222 break;
18223 }
18224}
18225
Kailang Yangebb83ee2009-12-17 12:23:00 +010018226#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018227
Kailang Yangf1d4e282008-08-26 14:03:29 +020018228static void alc663_mode3_inithook(struct hda_codec *codec)
18229{
18230 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018231 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018232}
18233/* ***************** Mode4 ******************************/
18234static void alc663_mode4_unsol_event(struct hda_codec *codec,
18235 unsigned int res)
18236{
18237 switch (res >> 26) {
18238 case ALC880_HP_EVENT:
18239 alc663_21jd_two_speaker_automute(codec);
18240 break;
18241 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018242 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018243 break;
18244 }
18245}
18246
Kailang Yangebb83ee2009-12-17 12:23:00 +010018247#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018248
Kailang Yangf1d4e282008-08-26 14:03:29 +020018249static void alc663_mode4_inithook(struct hda_codec *codec)
18250{
18251 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018252 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018253}
18254/* ***************** Mode5 ******************************/
18255static void alc663_mode5_unsol_event(struct hda_codec *codec,
18256 unsigned int res)
18257{
18258 switch (res >> 26) {
18259 case ALC880_HP_EVENT:
18260 alc663_15jd_two_speaker_automute(codec);
18261 break;
18262 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018263 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018264 break;
18265 }
18266}
18267
Kailang Yangebb83ee2009-12-17 12:23:00 +010018268#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018269
Kailang Yangf1d4e282008-08-26 14:03:29 +020018270static void alc663_mode5_inithook(struct hda_codec *codec)
18271{
18272 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018273 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018274}
18275/* ***************** Mode6 ******************************/
18276static void alc663_mode6_unsol_event(struct hda_codec *codec,
18277 unsigned int res)
18278{
18279 switch (res >> 26) {
18280 case ALC880_HP_EVENT:
18281 alc663_two_hp_m2_speaker_automute(codec);
18282 break;
18283 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018284 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018285 break;
18286 }
18287}
18288
Kailang Yangebb83ee2009-12-17 12:23:00 +010018289#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018290
Kailang Yangf1d4e282008-08-26 14:03:29 +020018291static void alc663_mode6_inithook(struct hda_codec *codec)
18292{
18293 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018294 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018295}
18296
Kailang Yangebb83ee2009-12-17 12:23:00 +010018297/* ***************** Mode7 ******************************/
18298static void alc663_mode7_unsol_event(struct hda_codec *codec,
18299 unsigned int res)
18300{
18301 switch (res >> 26) {
18302 case ALC880_HP_EVENT:
18303 alc663_two_hp_m7_speaker_automute(codec);
18304 break;
18305 case ALC880_MIC_EVENT:
18306 alc_mic_automute(codec);
18307 break;
18308 }
18309}
18310
18311#define alc663_mode7_setup alc663_mode1_setup
18312
18313static void alc663_mode7_inithook(struct hda_codec *codec)
18314{
18315 alc663_two_hp_m7_speaker_automute(codec);
18316 alc_mic_automute(codec);
18317}
18318
18319/* ***************** Mode8 ******************************/
18320static void alc663_mode8_unsol_event(struct hda_codec *codec,
18321 unsigned int res)
18322{
18323 switch (res >> 26) {
18324 case ALC880_HP_EVENT:
18325 alc663_two_hp_m8_speaker_automute(codec);
18326 break;
18327 case ALC880_MIC_EVENT:
18328 alc_mic_automute(codec);
18329 break;
18330 }
18331}
18332
18333#define alc663_mode8_setup alc663_m51va_setup
18334
18335static void alc663_mode8_inithook(struct hda_codec *codec)
18336{
18337 alc663_two_hp_m8_speaker_automute(codec);
18338 alc_mic_automute(codec);
18339}
18340
Kailang Yang6dda9f42008-05-27 12:05:31 +020018341static void alc663_g71v_hp_automute(struct hda_codec *codec)
18342{
18343 unsigned int present;
18344 unsigned char bits;
18345
Wu Fengguang864f92b2009-11-18 12:38:02 +080018346 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018347 bits = present ? HDA_AMP_MUTE : 0;
18348 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18349 HDA_AMP_MUTE, bits);
18350 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18351 HDA_AMP_MUTE, bits);
18352}
18353
18354static void alc663_g71v_front_automute(struct hda_codec *codec)
18355{
18356 unsigned int present;
18357 unsigned char bits;
18358
Wu Fengguang864f92b2009-11-18 12:38:02 +080018359 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018360 bits = present ? HDA_AMP_MUTE : 0;
18361 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18362 HDA_AMP_MUTE, bits);
18363}
18364
18365static void alc663_g71v_unsol_event(struct hda_codec *codec,
18366 unsigned int res)
18367{
18368 switch (res >> 26) {
18369 case ALC880_HP_EVENT:
18370 alc663_g71v_hp_automute(codec);
18371 break;
18372 case ALC880_FRONT_EVENT:
18373 alc663_g71v_front_automute(codec);
18374 break;
18375 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018376 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018377 break;
18378 }
18379}
18380
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018381#define alc663_g71v_setup alc663_m51va_setup
18382
Kailang Yang6dda9f42008-05-27 12:05:31 +020018383static void alc663_g71v_inithook(struct hda_codec *codec)
18384{
18385 alc663_g71v_front_automute(codec);
18386 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018387 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018388}
18389
18390static void alc663_g50v_unsol_event(struct hda_codec *codec,
18391 unsigned int res)
18392{
18393 switch (res >> 26) {
18394 case ALC880_HP_EVENT:
18395 alc663_m51va_speaker_automute(codec);
18396 break;
18397 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018398 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018399 break;
18400 }
18401}
18402
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018403#define alc663_g50v_setup alc663_m51va_setup
18404
Kailang Yang6dda9f42008-05-27 12:05:31 +020018405static void alc663_g50v_inithook(struct hda_codec *codec)
18406{
18407 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018408 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018409}
18410
Kailang Yangf1d4e282008-08-26 14:03:29 +020018411static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18412 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018413 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018414
18415 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18416 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18417 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18418
18419 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18420 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18421 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18422 { } /* end */
18423};
18424
Chris Pockelé9541ba12009-05-12 08:08:53 +020018425static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18426 /* Master Playback automatically created from Speaker and Headphone */
18427 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18428 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18429 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18430 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18431
18432 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18433 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18434 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18435
18436 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18437 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18438 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18439 { } /* end */
18440};
18441
Takashi Iwaicb53c622007-08-10 17:21:45 +020018442#ifdef CONFIG_SND_HDA_POWER_SAVE
18443#define alc662_loopbacks alc880_loopbacks
18444#endif
18445
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018446
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018447/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018448#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18449#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18450#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18451#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18452
18453/*
18454 * configuration and preset
18455 */
18456static const char *alc662_models[ALC662_MODEL_LAST] = {
18457 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18458 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18459 [ALC662_3ST_6ch] = "3stack-6ch",
18460 [ALC662_5ST_DIG] = "6stack-dig",
18461 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018462 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018463 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018464 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018465 [ALC663_ASUS_M51VA] = "m51va",
18466 [ALC663_ASUS_G71V] = "g71v",
18467 [ALC663_ASUS_H13] = "h13",
18468 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018469 [ALC663_ASUS_MODE1] = "asus-mode1",
18470 [ALC662_ASUS_MODE2] = "asus-mode2",
18471 [ALC663_ASUS_MODE3] = "asus-mode3",
18472 [ALC663_ASUS_MODE4] = "asus-mode4",
18473 [ALC663_ASUS_MODE5] = "asus-mode5",
18474 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018475 [ALC663_ASUS_MODE7] = "asus-mode7",
18476 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018477 [ALC272_DELL] = "dell",
18478 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018479 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018480 [ALC662_AUTO] = "auto",
18481};
18482
18483static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018484 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018485 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18486 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018487 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18488 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018489 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018490 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18491 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18492 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18493 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018494 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18495 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018496 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018497 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18498 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18499 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18500 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18501 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018502 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018503 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18504 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018505 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18506 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18507 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18508 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018509 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018510 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18511 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18512 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018513 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18514 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18515 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18516 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018517 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018518 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18519 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018520 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018521 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18522 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18523 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018524 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018525 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018526 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18527 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018528 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18529 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18530 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018531 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018532 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18533 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018534 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018535 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018536 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018537 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18538 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18539 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018540 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018541 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18542 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018543 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018544 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018545 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018546 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018547 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18548 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018549 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018550 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018551 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18552 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018553 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018554 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018555 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018556 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018557 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018558 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018559 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18560 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018561 {}
18562};
18563
18564static struct alc_config_preset alc662_presets[] = {
18565 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018566 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018567 .init_verbs = { alc662_init_verbs },
18568 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18569 .dac_nids = alc662_dac_nids,
18570 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018571 .dig_in_nid = ALC662_DIGIN_NID,
18572 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18573 .channel_mode = alc662_3ST_2ch_modes,
18574 .input_mux = &alc662_capture_source,
18575 },
18576 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018577 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018578 .init_verbs = { alc662_init_verbs },
18579 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18580 .dac_nids = alc662_dac_nids,
18581 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018582 .dig_in_nid = ALC662_DIGIN_NID,
18583 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18584 .channel_mode = alc662_3ST_6ch_modes,
18585 .need_dac_fix = 1,
18586 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018587 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018588 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018589 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018590 .init_verbs = { alc662_init_verbs },
18591 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18592 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018593 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18594 .channel_mode = alc662_3ST_6ch_modes,
18595 .need_dac_fix = 1,
18596 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018597 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018598 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018599 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018600 .init_verbs = { alc662_init_verbs },
18601 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18602 .dac_nids = alc662_dac_nids,
18603 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018604 .dig_in_nid = ALC662_DIGIN_NID,
18605 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18606 .channel_mode = alc662_5stack_modes,
18607 .input_mux = &alc662_capture_source,
18608 },
18609 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018610 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018611 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18612 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18613 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018614 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18615 .channel_mode = alc662_3ST_2ch_modes,
18616 .input_mux = &alc662_lenovo_101e_capture_source,
18617 .unsol_event = alc662_lenovo_101e_unsol_event,
18618 .init_hook = alc662_lenovo_101e_all_automute,
18619 },
Kailang Yang291702f2007-10-16 14:28:03 +020018620 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018621 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018622 .init_verbs = { alc662_init_verbs,
18623 alc662_eeepc_sue_init_verbs },
18624 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18625 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018626 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18627 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018628 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018629 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018630 .init_hook = alc662_eeepc_inithook,
18631 },
Kailang Yang8c427222008-01-10 13:03:59 +010018632 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018633 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018634 alc662_chmode_mixer },
18635 .init_verbs = { alc662_init_verbs,
18636 alc662_eeepc_ep20_sue_init_verbs },
18637 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18638 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018639 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18640 .channel_mode = alc662_3ST_6ch_modes,
18641 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018642 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018643 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018644 .init_hook = alc662_eeepc_ep20_inithook,
18645 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018646 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018647 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018648 .init_verbs = { alc662_init_verbs,
18649 alc662_ecs_init_verbs },
18650 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18651 .dac_nids = alc662_dac_nids,
18652 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18653 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018654 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018655 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018656 .init_hook = alc662_eeepc_inithook,
18657 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018658 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018659 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018660 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18661 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18662 .dac_nids = alc662_dac_nids,
18663 .dig_out_nid = ALC662_DIGOUT_NID,
18664 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18665 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018666 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018667 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018668 .init_hook = alc663_m51va_inithook,
18669 },
18670 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018671 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018672 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18673 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18674 .dac_nids = alc662_dac_nids,
18675 .dig_out_nid = ALC662_DIGOUT_NID,
18676 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18677 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018678 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018679 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018680 .init_hook = alc663_g71v_inithook,
18681 },
18682 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018683 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018684 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18685 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18686 .dac_nids = alc662_dac_nids,
18687 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18688 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018689 .unsol_event = alc663_m51va_unsol_event,
18690 .init_hook = alc663_m51va_inithook,
18691 },
18692 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018693 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018694 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18695 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18696 .dac_nids = alc662_dac_nids,
18697 .dig_out_nid = ALC662_DIGOUT_NID,
18698 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18699 .channel_mode = alc662_3ST_6ch_modes,
18700 .input_mux = &alc663_capture_source,
18701 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018702 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018703 .init_hook = alc663_g50v_inithook,
18704 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018705 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018706 .mixers = { alc663_m51va_mixer },
18707 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018708 .init_verbs = { alc662_init_verbs,
18709 alc663_21jd_amic_init_verbs },
18710 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18711 .hp_nid = 0x03,
18712 .dac_nids = alc662_dac_nids,
18713 .dig_out_nid = ALC662_DIGOUT_NID,
18714 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18715 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018716 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018717 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018718 .init_hook = alc663_mode1_inithook,
18719 },
18720 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018721 .mixers = { alc662_1bjd_mixer },
18722 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018723 .init_verbs = { alc662_init_verbs,
18724 alc662_1bjd_amic_init_verbs },
18725 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18726 .dac_nids = alc662_dac_nids,
18727 .dig_out_nid = ALC662_DIGOUT_NID,
18728 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18729 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018730 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018731 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018732 .init_hook = alc662_mode2_inithook,
18733 },
18734 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018735 .mixers = { alc663_two_hp_m1_mixer },
18736 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018737 .init_verbs = { alc662_init_verbs,
18738 alc663_two_hp_amic_m1_init_verbs },
18739 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18740 .hp_nid = 0x03,
18741 .dac_nids = alc662_dac_nids,
18742 .dig_out_nid = ALC662_DIGOUT_NID,
18743 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18744 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018745 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018746 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018747 .init_hook = alc663_mode3_inithook,
18748 },
18749 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018750 .mixers = { alc663_asus_21jd_clfe_mixer },
18751 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018752 .init_verbs = { alc662_init_verbs,
18753 alc663_21jd_amic_init_verbs},
18754 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18755 .hp_nid = 0x03,
18756 .dac_nids = alc662_dac_nids,
18757 .dig_out_nid = ALC662_DIGOUT_NID,
18758 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18759 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018760 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018761 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018762 .init_hook = alc663_mode4_inithook,
18763 },
18764 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018765 .mixers = { alc663_asus_15jd_clfe_mixer },
18766 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018767 .init_verbs = { alc662_init_verbs,
18768 alc663_15jd_amic_init_verbs },
18769 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18770 .hp_nid = 0x03,
18771 .dac_nids = alc662_dac_nids,
18772 .dig_out_nid = ALC662_DIGOUT_NID,
18773 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18774 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018775 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018776 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018777 .init_hook = alc663_mode5_inithook,
18778 },
18779 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018780 .mixers = { alc663_two_hp_m2_mixer },
18781 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018782 .init_verbs = { alc662_init_verbs,
18783 alc663_two_hp_amic_m2_init_verbs },
18784 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18785 .hp_nid = 0x03,
18786 .dac_nids = alc662_dac_nids,
18787 .dig_out_nid = ALC662_DIGOUT_NID,
18788 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18789 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018790 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018791 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018792 .init_hook = alc663_mode6_inithook,
18793 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018794 [ALC663_ASUS_MODE7] = {
18795 .mixers = { alc663_mode7_mixer },
18796 .cap_mixer = alc662_auto_capture_mixer,
18797 .init_verbs = { alc662_init_verbs,
18798 alc663_mode7_init_verbs },
18799 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18800 .hp_nid = 0x03,
18801 .dac_nids = alc662_dac_nids,
18802 .dig_out_nid = ALC662_DIGOUT_NID,
18803 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18804 .channel_mode = alc662_3ST_2ch_modes,
18805 .unsol_event = alc663_mode7_unsol_event,
18806 .setup = alc663_mode7_setup,
18807 .init_hook = alc663_mode7_inithook,
18808 },
18809 [ALC663_ASUS_MODE8] = {
18810 .mixers = { alc663_mode8_mixer },
18811 .cap_mixer = alc662_auto_capture_mixer,
18812 .init_verbs = { alc662_init_verbs,
18813 alc663_mode8_init_verbs },
18814 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18815 .hp_nid = 0x03,
18816 .dac_nids = alc662_dac_nids,
18817 .dig_out_nid = ALC662_DIGOUT_NID,
18818 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18819 .channel_mode = alc662_3ST_2ch_modes,
18820 .unsol_event = alc663_mode8_unsol_event,
18821 .setup = alc663_mode8_setup,
18822 .init_hook = alc663_mode8_inithook,
18823 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018824 [ALC272_DELL] = {
18825 .mixers = { alc663_m51va_mixer },
18826 .cap_mixer = alc272_auto_capture_mixer,
18827 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18828 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18829 .dac_nids = alc662_dac_nids,
18830 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18831 .adc_nids = alc272_adc_nids,
18832 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18833 .capsrc_nids = alc272_capsrc_nids,
18834 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018835 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018836 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018837 .init_hook = alc663_m51va_inithook,
18838 },
18839 [ALC272_DELL_ZM1] = {
18840 .mixers = { alc663_m51va_mixer },
18841 .cap_mixer = alc662_auto_capture_mixer,
18842 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18843 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18844 .dac_nids = alc662_dac_nids,
18845 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18846 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018847 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018848 .capsrc_nids = alc662_capsrc_nids,
18849 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018850 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018851 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018852 .init_hook = alc663_m51va_inithook,
18853 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018854 [ALC272_SAMSUNG_NC10] = {
18855 .mixers = { alc272_nc10_mixer },
18856 .init_verbs = { alc662_init_verbs,
18857 alc663_21jd_amic_init_verbs },
18858 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18859 .dac_nids = alc272_dac_nids,
18860 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18861 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018862 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018863 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018864 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018865 .init_hook = alc663_mode4_inithook,
18866 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018867};
18868
18869
18870/*
18871 * BIOS auto configuration
18872 */
18873
Takashi Iwai7085ec12009-10-02 09:03:58 +020018874/* convert from MIX nid to DAC */
18875static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18876{
18877 if (nid == 0x0f)
18878 return 0x02;
18879 else if (nid >= 0x0c && nid <= 0x0e)
18880 return nid - 0x0c + 0x02;
18881 else
18882 return 0;
18883}
18884
18885/* get MIX nid connected to the given pin targeted to DAC */
18886static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18887 hda_nid_t dac)
18888{
18889 hda_nid_t mix[4];
18890 int i, num;
18891
18892 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18893 for (i = 0; i < num; i++) {
18894 if (alc662_mix_to_dac(mix[i]) == dac)
18895 return mix[i];
18896 }
18897 return 0;
18898}
18899
18900/* look for an empty DAC slot */
18901static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18902{
18903 struct alc_spec *spec = codec->spec;
18904 hda_nid_t srcs[5];
18905 int i, j, num;
18906
18907 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18908 if (num < 0)
18909 return 0;
18910 for (i = 0; i < num; i++) {
18911 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18912 if (!nid)
18913 continue;
18914 for (j = 0; j < spec->multiout.num_dacs; j++)
18915 if (spec->multiout.dac_nids[j] == nid)
18916 break;
18917 if (j >= spec->multiout.num_dacs)
18918 return nid;
18919 }
18920 return 0;
18921}
18922
18923/* fill in the dac_nids table from the parsed pin configuration */
18924static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18925 const struct auto_pin_cfg *cfg)
18926{
18927 struct alc_spec *spec = codec->spec;
18928 int i;
18929 hda_nid_t dac;
18930
18931 spec->multiout.dac_nids = spec->private_dac_nids;
18932 for (i = 0; i < cfg->line_outs; i++) {
18933 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18934 if (!dac)
18935 continue;
18936 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18937 }
18938 return 0;
18939}
18940
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018941static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018942 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018943{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018944 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018945 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18946}
18947
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018948static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018949 hda_nid_t nid, unsigned int chs)
18950{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018951 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018952 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18953}
18954
18955#define alc662_add_stereo_vol(spec, pfx, nid) \
18956 alc662_add_vol_ctl(spec, pfx, nid, 3)
18957#define alc662_add_stereo_sw(spec, pfx, nid) \
18958 alc662_add_sw_ctl(spec, pfx, nid, 3)
18959
18960/* add playback controls from the parsed DAC table */
18961static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18962 const struct auto_pin_cfg *cfg)
18963{
18964 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018965 static const char *chname[4] = {
18966 "Front", "Surround", NULL /*CLFE*/, "Side"
18967 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018968 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018969 int i, err;
18970
18971 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018972 nid = spec->multiout.dac_nids[i];
18973 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018974 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018975 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18976 if (!mix)
18977 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018978 if (i == 2) {
18979 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018980 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018981 if (err < 0)
18982 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018983 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018984 if (err < 0)
18985 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018986 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018987 if (err < 0)
18988 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018989 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018990 if (err < 0)
18991 return err;
18992 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018993 const char *pfx;
18994 if (cfg->line_outs == 1 &&
18995 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018996 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018997 pfx = "Speaker";
18998 else
18999 pfx = "PCM";
19000 } else
19001 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019002 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019003 if (err < 0)
19004 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019005 if (cfg->line_outs == 1 &&
19006 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19007 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020019008 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019009 if (err < 0)
19010 return err;
19011 }
19012 }
19013 return 0;
19014}
19015
19016/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019017/* return DAC nid if any new DAC is assigned */
19018static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019019 const char *pfx)
19020{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019021 struct alc_spec *spec = codec->spec;
19022 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019023 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019024
19025 if (!pin)
19026 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019027 nid = alc662_look_for_dac(codec, pin);
19028 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019029 /* the corresponding DAC is already occupied */
19030 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19031 return 0; /* no way */
19032 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019033 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019034 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19035 }
19036
19037 mix = alc662_dac_to_mix(codec, pin, nid);
19038 if (!mix)
19039 return 0;
19040 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19041 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019042 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019043 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19044 if (err < 0)
19045 return err;
19046 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019047}
19048
19049/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019050#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019051 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019052
19053static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19054 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019055 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019056{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019057 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019058 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019059
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019060 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019061 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019062 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19063 if (num <= 1)
19064 return;
19065 for (i = 0; i < num; i++) {
19066 if (alc662_mix_to_dac(srcs[i]) != dac)
19067 continue;
19068 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19069 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019070 }
19071}
19072
19073static void alc662_auto_init_multi_out(struct hda_codec *codec)
19074{
19075 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019076 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019077 int i;
19078
19079 for (i = 0; i <= HDA_SIDE; i++) {
19080 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19081 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019082 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019083 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019084 }
19085}
19086
19087static void alc662_auto_init_hp_out(struct hda_codec *codec)
19088{
19089 struct alc_spec *spec = codec->spec;
19090 hda_nid_t pin;
19091
19092 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019093 if (pin)
19094 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19095 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019096 pin = spec->autocfg.speaker_pins[0];
19097 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019098 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19099 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019100}
19101
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019102#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19103
19104static void alc662_auto_init_analog_input(struct hda_codec *codec)
19105{
19106 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019107 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019108 int i;
19109
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019110 for (i = 0; i < cfg->num_inputs; i++) {
19111 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019112 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019113 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019114 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019115 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019116 snd_hda_codec_write(codec, nid, 0,
19117 AC_VERB_SET_AMP_GAIN_MUTE,
19118 AMP_OUT_MUTE);
19119 }
19120 }
19121}
19122
Takashi Iwaif511b012008-08-15 16:46:42 +020019123#define alc662_auto_init_input_src alc882_auto_init_input_src
19124
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019125static int alc662_parse_auto_config(struct hda_codec *codec)
19126{
19127 struct alc_spec *spec = codec->spec;
19128 int err;
19129 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19130
19131 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19132 alc662_ignore);
19133 if (err < 0)
19134 return err;
19135 if (!spec->autocfg.line_outs)
19136 return 0; /* can't find valid BIOS pin config */
19137
Takashi Iwai7085ec12009-10-02 09:03:58 +020019138 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019139 if (err < 0)
19140 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019141 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019142 if (err < 0)
19143 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019144 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019145 spec->autocfg.speaker_pins[0],
19146 "Speaker");
19147 if (err < 0)
19148 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019149 if (err)
19150 spec->multiout.extra_out_nid[0] = err;
19151 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019152 "Headphone");
19153 if (err < 0)
19154 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019155 if (err)
19156 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019157 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019158 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019159 return err;
19160
19161 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19162
Takashi Iwai757899a2010-07-30 10:48:14 +020019163 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019164
Takashi Iwai603c4012008-07-30 15:01:44 +020019165 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019166 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019167
19168 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019169 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019170
Kailang Yangcec27c82010-02-04 14:18:18 +010019171 add_verb(spec, alc662_init_verbs);
19172 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019173 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019174 add_verb(spec, alc663_init_verbs);
19175
19176 if (codec->vendor_id == 0x10ec0272)
19177 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019178
19179 err = alc_auto_add_mic_boost(codec);
19180 if (err < 0)
19181 return err;
19182
Kailang Yang6227cdc2010-02-25 08:36:52 +010019183 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19184 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19185 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19186 else
19187 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019188
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019189 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019190}
19191
19192/* additional initialization for auto-configuration model */
19193static void alc662_auto_init(struct hda_codec *codec)
19194{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019195 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019196 alc662_auto_init_multi_out(codec);
19197 alc662_auto_init_hp_out(codec);
19198 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019199 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019200 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019201 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019202 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019203}
19204
David Henningsson6cb3b702010-09-09 08:51:44 +020019205enum {
19206 ALC662_FIXUP_IDEAPAD,
19207};
19208
19209static const struct alc_fixup alc662_fixups[] = {
19210 [ALC662_FIXUP_IDEAPAD] = {
19211 .pins = (const struct alc_pincfg[]) {
19212 { 0x17, 0x99130112 }, /* subwoofer */
19213 { }
19214 }
19215 },
19216};
19217
19218static struct snd_pci_quirk alc662_fixup_tbl[] = {
19219 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19220 {}
19221};
19222
19223
19224
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019225static int patch_alc662(struct hda_codec *codec)
19226{
19227 struct alc_spec *spec;
19228 int err, board_config;
19229
19230 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19231 if (!spec)
19232 return -ENOMEM;
19233
19234 codec->spec = spec;
19235
Kailang Yangda00c242010-03-19 11:23:45 +010019236 alc_auto_parse_customize_define(codec);
19237
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019238 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19239
Kailang Yangc027ddc2010-03-19 11:33:06 +010019240 if (alc_read_coef_idx(codec, 0) == 0x8020)
19241 alc_codec_rename(codec, "ALC661");
19242 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
19243 codec->bus->pci->subsystem_vendor == 0x1025 &&
19244 spec->cdefine.platform_type == 1)
19245 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010019246
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019247 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19248 alc662_models,
19249 alc662_cfg_tbl);
19250 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019251 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19252 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019253 board_config = ALC662_AUTO;
19254 }
19255
19256 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019257 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019258 /* automatic parse from the BIOS config */
19259 err = alc662_parse_auto_config(codec);
19260 if (err < 0) {
19261 alc_free(codec);
19262 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019263 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019264 printk(KERN_INFO
19265 "hda_codec: Cannot set up configuration "
19266 "from BIOS. Using base mode...\n");
19267 board_config = ALC662_3ST_2ch_DIG;
19268 }
19269 }
19270
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019271 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019272 err = snd_hda_attach_beep_device(codec, 0x1);
19273 if (err < 0) {
19274 alc_free(codec);
19275 return err;
19276 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019277 }
19278
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019279 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019280 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019281
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019282 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19283 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19284
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019285 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19286 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19287
Takashi Iwaidd704692009-08-11 08:45:11 +020019288 if (!spec->adc_nids) {
19289 spec->adc_nids = alc662_adc_nids;
19290 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19291 }
19292 if (!spec->capsrc_nids)
19293 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019294
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019295 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019296 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019297
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019298 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019299 switch (codec->vendor_id) {
19300 case 0x10ec0662:
19301 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19302 break;
19303 case 0x10ec0272:
19304 case 0x10ec0663:
19305 case 0x10ec0665:
19306 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19307 break;
19308 case 0x10ec0273:
19309 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19310 break;
19311 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019312 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019313 spec->vmaster_nid = 0x02;
19314
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019315 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019316 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019317 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019318 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0);
19319 }
19320
Takashi Iwaicb53c622007-08-10 17:21:45 +020019321#ifdef CONFIG_SND_HDA_POWER_SAVE
19322 if (!spec->loopback.amplist)
19323 spec->loopback.amplist = alc662_loopbacks;
19324#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019325
19326 return 0;
19327}
19328
Kailang Yang274693f2009-12-03 10:07:50 +010019329static int patch_alc888(struct hda_codec *codec)
19330{
19331 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19332 kfree(codec->chip_name);
19333 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019334 if (!codec->chip_name) {
19335 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019336 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019337 }
19338 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019339 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019340 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019341}
19342
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019343/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019344 * ALC680 support
19345 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019346#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019347#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19348#define alc680_modes alc260_modes
19349
19350static hda_nid_t alc680_dac_nids[3] = {
19351 /* Lout1, Lout2, hp */
19352 0x02, 0x03, 0x04
19353};
19354
19355static hda_nid_t alc680_adc_nids[3] = {
19356 /* ADC0-2 */
19357 /* DMIC, MIC, Line-in*/
19358 0x07, 0x08, 0x09
19359};
19360
Kailang Yangc69aefa2010-08-17 10:39:22 +020019361/*
19362 * Analog capture ADC cgange
19363 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019364static void alc680_rec_autoswitch(struct hda_codec *codec)
19365{
19366 struct alc_spec *spec = codec->spec;
19367 struct auto_pin_cfg *cfg = &spec->autocfg;
19368 int pin_found = 0;
19369 int type_found = AUTO_PIN_LAST;
19370 hda_nid_t nid;
19371 int i;
19372
19373 for (i = 0; i < cfg->num_inputs; i++) {
19374 nid = cfg->inputs[i].pin;
19375 if (!(snd_hda_query_pin_caps(codec, nid) &
19376 AC_PINCAP_PRES_DETECT))
19377 continue;
19378 if (snd_hda_jack_detect(codec, nid)) {
19379 if (cfg->inputs[i].type < type_found) {
19380 type_found = cfg->inputs[i].type;
19381 pin_found = nid;
19382 }
19383 }
19384 }
19385
19386 nid = 0x07;
19387 if (pin_found)
19388 snd_hda_get_connections(codec, pin_found, &nid, 1);
19389
19390 if (nid != spec->cur_adc)
19391 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19392 spec->cur_adc = nid;
19393 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19394 spec->cur_adc_format);
19395}
19396
Kailang Yangc69aefa2010-08-17 10:39:22 +020019397static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19398 struct hda_codec *codec,
19399 unsigned int stream_tag,
19400 unsigned int format,
19401 struct snd_pcm_substream *substream)
19402{
19403 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019404
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019405 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019406 spec->cur_adc_stream_tag = stream_tag;
19407 spec->cur_adc_format = format;
19408
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019409 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019410 return 0;
19411}
19412
19413static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19414 struct hda_codec *codec,
19415 struct snd_pcm_substream *substream)
19416{
19417 snd_hda_codec_cleanup_stream(codec, 0x07);
19418 snd_hda_codec_cleanup_stream(codec, 0x08);
19419 snd_hda_codec_cleanup_stream(codec, 0x09);
19420 return 0;
19421}
19422
19423static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19424 .substreams = 1, /* can be overridden */
19425 .channels_min = 2,
19426 .channels_max = 2,
19427 /* NID is set in alc_build_pcms */
19428 .ops = {
19429 .prepare = alc680_capture_pcm_prepare,
19430 .cleanup = alc680_capture_pcm_cleanup
19431 },
19432};
19433
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019434static struct snd_kcontrol_new alc680_base_mixer[] = {
19435 /* output mixer control */
19436 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19437 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19438 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19439 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019440 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019441 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019442 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019443 { }
19444};
19445
Kailang Yangc69aefa2010-08-17 10:39:22 +020019446static struct hda_bind_ctls alc680_bind_cap_vol = {
19447 .ops = &snd_hda_bind_vol,
19448 .values = {
19449 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19450 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19451 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19452 0
19453 },
19454};
19455
19456static struct hda_bind_ctls alc680_bind_cap_switch = {
19457 .ops = &snd_hda_bind_sw,
19458 .values = {
19459 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19460 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19461 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19462 0
19463 },
19464};
19465
19466static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19467 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19468 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019469 { } /* end */
19470};
19471
19472/*
19473 * generic initialization of ADC, input mixers and output mixers
19474 */
19475static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019476 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19477 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19478 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019479
Kailang Yangc69aefa2010-08-17 10:39:22 +020019480 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19481 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19482 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19483 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19484 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19485 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019486
19487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19488 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19489 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19490 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19491 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019492
19493 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19494 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019495 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019496
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019497 { }
19498};
19499
Kailang Yangc69aefa2010-08-17 10:39:22 +020019500/* toggle speaker-output according to the hp-jack state */
19501static void alc680_base_setup(struct hda_codec *codec)
19502{
19503 struct alc_spec *spec = codec->spec;
19504
19505 spec->autocfg.hp_pins[0] = 0x16;
19506 spec->autocfg.speaker_pins[0] = 0x14;
19507 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019508 spec->autocfg.num_inputs = 2;
19509 spec->autocfg.inputs[0].pin = 0x18;
19510 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19511 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019512 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019513}
19514
19515static void alc680_unsol_event(struct hda_codec *codec,
19516 unsigned int res)
19517{
19518 if ((res >> 26) == ALC880_HP_EVENT)
19519 alc_automute_amp(codec);
19520 if ((res >> 26) == ALC880_MIC_EVENT)
19521 alc680_rec_autoswitch(codec);
19522}
19523
19524static void alc680_inithook(struct hda_codec *codec)
19525{
19526 alc_automute_amp(codec);
19527 alc680_rec_autoswitch(codec);
19528}
19529
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019530/* create input playback/capture controls for the given pin */
19531static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19532 const char *ctlname, int idx)
19533{
19534 hda_nid_t dac;
19535 int err;
19536
19537 switch (nid) {
19538 case 0x14:
19539 dac = 0x02;
19540 break;
19541 case 0x15:
19542 dac = 0x03;
19543 break;
19544 case 0x16:
19545 dac = 0x04;
19546 break;
19547 default:
19548 return 0;
19549 }
19550 if (spec->multiout.dac_nids[0] != dac &&
19551 spec->multiout.dac_nids[1] != dac) {
19552 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19553 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19554 HDA_OUTPUT));
19555 if (err < 0)
19556 return err;
19557
19558 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19559 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19560
19561 if (err < 0)
19562 return err;
19563 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19564 }
19565
19566 return 0;
19567}
19568
19569/* add playback controls from the parsed DAC table */
19570static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19571 const struct auto_pin_cfg *cfg)
19572{
19573 hda_nid_t nid;
19574 int err;
19575
19576 spec->multiout.dac_nids = spec->private_dac_nids;
19577
19578 nid = cfg->line_out_pins[0];
19579 if (nid) {
19580 const char *name;
19581 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19582 name = "Speaker";
19583 else
19584 name = "Front";
19585 err = alc680_new_analog_output(spec, nid, name, 0);
19586 if (err < 0)
19587 return err;
19588 }
19589
19590 nid = cfg->speaker_pins[0];
19591 if (nid) {
19592 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19593 if (err < 0)
19594 return err;
19595 }
19596 nid = cfg->hp_pins[0];
19597 if (nid) {
19598 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19599 if (err < 0)
19600 return err;
19601 }
19602
19603 return 0;
19604}
19605
19606static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19607 hda_nid_t nid, int pin_type)
19608{
19609 alc_set_pin_output(codec, nid, pin_type);
19610}
19611
19612static void alc680_auto_init_multi_out(struct hda_codec *codec)
19613{
19614 struct alc_spec *spec = codec->spec;
19615 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19616 if (nid) {
19617 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19618 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19619 }
19620}
19621
19622static void alc680_auto_init_hp_out(struct hda_codec *codec)
19623{
19624 struct alc_spec *spec = codec->spec;
19625 hda_nid_t pin;
19626
19627 pin = spec->autocfg.hp_pins[0];
19628 if (pin)
19629 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19630 pin = spec->autocfg.speaker_pins[0];
19631 if (pin)
19632 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19633}
19634
19635/* pcm configuration: identical with ALC880 */
19636#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19637#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19638#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19639#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019640#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019641
19642/*
19643 * BIOS auto configuration
19644 */
19645static int alc680_parse_auto_config(struct hda_codec *codec)
19646{
19647 struct alc_spec *spec = codec->spec;
19648 int err;
19649 static hda_nid_t alc680_ignore[] = { 0 };
19650
19651 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19652 alc680_ignore);
19653 if (err < 0)
19654 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019655
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019656 if (!spec->autocfg.line_outs) {
19657 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19658 spec->multiout.max_channels = 2;
19659 spec->no_analog = 1;
19660 goto dig_only;
19661 }
19662 return 0; /* can't find valid BIOS pin config */
19663 }
19664 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19665 if (err < 0)
19666 return err;
19667
19668 spec->multiout.max_channels = 2;
19669
19670 dig_only:
19671 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019672 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019673 if (spec->kctls.list)
19674 add_mixer(spec, spec->kctls.list);
19675
19676 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019677
19678 err = alc_auto_add_mic_boost(codec);
19679 if (err < 0)
19680 return err;
19681
19682 return 1;
19683}
19684
19685#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19686
19687/* init callback for auto-configuration model -- overriding the default init */
19688static void alc680_auto_init(struct hda_codec *codec)
19689{
19690 struct alc_spec *spec = codec->spec;
19691 alc680_auto_init_multi_out(codec);
19692 alc680_auto_init_hp_out(codec);
19693 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019694 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019695 if (spec->unsol_event)
19696 alc_inithook(codec);
19697}
19698
19699/*
19700 * configuration and preset
19701 */
19702static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019703 [ALC680_BASE] = "base",
19704 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019705};
19706
19707static struct snd_pci_quirk alc680_cfg_tbl[] = {
19708 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19709 {}
19710};
19711
19712static struct alc_config_preset alc680_presets[] = {
19713 [ALC680_BASE] = {
19714 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019715 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019716 .init_verbs = { alc680_init_verbs },
19717 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19718 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019719 .dig_out_nid = ALC680_DIGOUT_NID,
19720 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19721 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019722 .unsol_event = alc680_unsol_event,
19723 .setup = alc680_base_setup,
19724 .init_hook = alc680_inithook,
19725
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019726 },
19727};
19728
19729static int patch_alc680(struct hda_codec *codec)
19730{
19731 struct alc_spec *spec;
19732 int board_config;
19733 int err;
19734
19735 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19736 if (spec == NULL)
19737 return -ENOMEM;
19738
19739 codec->spec = spec;
19740
19741 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19742 alc680_models,
19743 alc680_cfg_tbl);
19744
19745 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19746 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19747 codec->chip_name);
19748 board_config = ALC680_AUTO;
19749 }
19750
19751 if (board_config == ALC680_AUTO) {
19752 /* automatic parse from the BIOS config */
19753 err = alc680_parse_auto_config(codec);
19754 if (err < 0) {
19755 alc_free(codec);
19756 return err;
19757 } else if (!err) {
19758 printk(KERN_INFO
19759 "hda_codec: Cannot set up configuration "
19760 "from BIOS. Using base mode...\n");
19761 board_config = ALC680_BASE;
19762 }
19763 }
19764
19765 if (board_config != ALC680_AUTO)
19766 setup_preset(codec, &alc680_presets[board_config]);
19767
19768 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019769 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019770 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019771 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019772
19773 if (!spec->adc_nids) {
19774 spec->adc_nids = alc680_adc_nids;
19775 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19776 }
19777
19778 if (!spec->cap_mixer)
19779 set_capture_mixer(codec);
19780
19781 spec->vmaster_nid = 0x02;
19782
19783 codec->patch_ops = alc_patch_ops;
19784 if (board_config == ALC680_AUTO)
19785 spec->init_hook = alc680_auto_init;
19786
19787 return 0;
19788}
19789
19790/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019791 * patch entries
19792 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019793static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019794 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019795 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019796 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019797 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019798 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019799 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019800 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019801 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019802 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019803 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019804 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19805 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19806 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019807 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019808 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019809 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19810 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019811 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019812 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019813 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019814 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019815 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019816 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019817 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019818 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019819 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019820 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019821 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019822 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019823 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020019824 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019825 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019826 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019827 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019828 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019829 {} /* terminator */
19830};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019831
19832MODULE_ALIAS("snd-hda-codec-id:10ec*");
19833
19834MODULE_LICENSE("GPL");
19835MODULE_DESCRIPTION("Realtek HD-audio codec");
19836
19837static struct hda_codec_preset_list realtek_list = {
19838 .preset = snd_hda_preset_realtek,
19839 .owner = THIS_MODULE,
19840};
19841
19842static int __init patch_realtek_init(void)
19843{
19844 return snd_hda_add_codec_preset(&realtek_list);
19845}
19846
19847static void __exit patch_realtek_exit(void)
19848{
19849 snd_hda_delete_codec_preset(&realtek_list);
19850}
19851
19852module_init(patch_realtek_init)
19853module_exit(patch_realtek_exit)