blob: 5df88798895b1007896ce715da136880b861b716 [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ünther3e1647c52009-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
879/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100880 */
881static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
882{
883 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
884 return;
885 spec->mixers[spec->num_mixers++] = mix;
886}
887
888static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
889{
890 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
891 return;
892 spec->init_verbs[spec->num_init_verbs++] = verb;
893}
894
895/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100896 * set up from the preset table
897 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200898static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200899 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100900{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200901 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100902 int i;
903
904 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100905 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100906 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200907 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
908 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100909 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200910
Kailang Yangdf694da2005-12-05 19:42:22 +0100911 spec->channel_mode = preset->channel_mode;
912 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200913 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200914 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100915
Hector Martin3b315d72009-06-02 10:54:19 +0200916 if (preset->const_channel_count)
917 spec->multiout.max_channels = preset->const_channel_count;
918 else
919 spec->multiout.max_channels = spec->channel_mode[0].channels;
920 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100921
922 spec->multiout.num_dacs = preset->num_dacs;
923 spec->multiout.dac_nids = preset->dac_nids;
924 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800925 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100926 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200927
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200928 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200929 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200930 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100931 spec->input_mux = preset->input_mux;
932
933 spec->num_adc_nids = preset->num_adc_nids;
934 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100935 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100936 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100937
938 spec->unsol_event = preset->unsol_event;
939 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200940#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100941 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200942 spec->loopback.amplist = preset->loopbacks;
943#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200944
945 if (preset->setup)
946 preset->setup(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100947}
948
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200949/* Enable GPIO mask and set output */
950static struct hda_verb alc_gpio1_init_verbs[] = {
951 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
952 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
953 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
954 { }
955};
956
957static struct hda_verb alc_gpio2_init_verbs[] = {
958 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
959 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
960 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
961 { }
962};
963
Kailang Yangbdd148a2007-05-08 15:19:08 +0200964static struct hda_verb alc_gpio3_init_verbs[] = {
965 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
966 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
967 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
968 { }
969};
970
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200971/*
972 * Fix hardware PLL issue
973 * On some codecs, the analog PLL gating control must be off while
974 * the default value is 1.
975 */
976static void alc_fix_pll(struct hda_codec *codec)
977{
978 struct alc_spec *spec = codec->spec;
979 unsigned int val;
980
981 if (!spec->pll_nid)
982 return;
983 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
984 spec->pll_coef_idx);
985 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
986 AC_VERB_GET_PROC_COEF, 0);
987 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
988 spec->pll_coef_idx);
989 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
990 val & ~(1 << spec->pll_coef_bit));
991}
992
993static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
994 unsigned int coef_idx, unsigned int coef_bit)
995{
996 struct alc_spec *spec = codec->spec;
997 spec->pll_nid = nid;
998 spec->pll_coef_idx = coef_idx;
999 spec->pll_coef_bit = coef_bit;
1000 alc_fix_pll(codec);
1001}
1002
Kailang Yang9ad0e492010-09-14 23:22:00 +02001003#ifdef CONFIG_SND_HDA_INPUT_JACK
1004static void alc_free_jack_priv(struct snd_jack *jack)
1005{
1006 struct alc_jack *jacks = jack->private_data;
1007 jacks->nid = 0;
1008 jacks->jack = NULL;
1009}
1010
1011static int alc_add_jack(struct hda_codec *codec,
1012 hda_nid_t nid, int type)
1013{
1014 struct alc_spec *spec;
1015 struct alc_jack *jack;
1016 const char *name;
1017 int err;
1018
1019 spec = codec->spec;
1020 snd_array_init(&spec->jacks, sizeof(*jack), 32);
1021 jack = snd_array_new(&spec->jacks);
1022 if (!jack)
1023 return -ENOMEM;
1024
1025 jack->nid = nid;
1026 jack->type = type;
1027 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
1028
1029 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
1030 if (err < 0)
1031 return err;
1032 jack->jack->private_data = jack;
1033 jack->jack->private_free = alc_free_jack_priv;
1034 return 0;
1035}
1036
1037static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1038{
1039 struct alc_spec *spec = codec->spec;
1040 struct alc_jack *jacks = spec->jacks.list;
1041
1042 if (jacks) {
1043 int i;
1044 for (i = 0; i < spec->jacks.used; i++) {
1045 if (jacks->nid == nid) {
1046 unsigned int present;
1047 present = snd_hda_jack_detect(codec, nid);
1048
1049 present = (present) ? jacks->type : 0;
1050
1051 snd_jack_report(jacks->jack, present);
1052 }
1053 jacks++;
1054 }
1055 }
1056}
1057
1058static int alc_init_jacks(struct hda_codec *codec)
1059{
1060 struct alc_spec *spec = codec->spec;
1061 int err;
1062 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1063 unsigned int mic_nid = spec->ext_mic.pin;
1064
1065 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1066 if (err < 0)
1067 return err;
1068 alc_report_jack(codec, hp_nid);
1069
1070 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1071 if (err < 0)
1072 return err;
1073 alc_report_jack(codec, mic_nid);
1074
1075 return 0;
1076}
1077#else
1078static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1079{
1080}
1081
1082static inline int alc_init_jacks(struct hda_codec *codec)
1083{
1084 return 0;
1085}
1086#endif
1087
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001088static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001089{
1090 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001091 unsigned int mute;
1092 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001093 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001094
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001095 spec->jack_present = 0;
1096 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1097 nid = spec->autocfg.hp_pins[i];
1098 if (!nid)
1099 break;
1100 if (snd_hda_jack_detect(codec, nid)) {
1101 spec->jack_present = 1;
1102 break;
1103 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001104 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001105 }
1106
1107 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1108 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001109 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1110 nid = spec->autocfg.speaker_pins[i];
1111 if (!nid)
1112 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001113 if (pinctl) {
1114 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001115 AC_VERB_SET_PIN_WIDGET_CONTROL,
1116 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001117 } else {
1118 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1119 HDA_AMP_MUTE, mute);
1120 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001121 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001122}
1123
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001124static void alc_automute_pin(struct hda_codec *codec)
1125{
1126 alc_automute_speaker(codec, 1);
1127}
1128
Takashi Iwai6c819492009-08-10 18:47:44 +02001129static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1130 hda_nid_t nid)
1131{
1132 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1133 int i, nums;
1134
1135 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1136 for (i = 0; i < nums; i++)
1137 if (conn[i] == nid)
1138 return i;
1139 return -1;
1140}
1141
Takashi Iwai840b64c2010-07-13 22:49:01 +02001142/* switch the current ADC according to the jack state */
1143static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1144{
1145 struct alc_spec *spec = codec->spec;
1146 unsigned int present;
1147 hda_nid_t new_adc;
1148
1149 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1150 if (present)
1151 spec->cur_adc_idx = 1;
1152 else
1153 spec->cur_adc_idx = 0;
1154 new_adc = spec->adc_nids[spec->cur_adc_idx];
1155 if (spec->cur_adc && spec->cur_adc != new_adc) {
1156 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001157 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001158 spec->cur_adc = new_adc;
1159 snd_hda_codec_setup_stream(codec, new_adc,
1160 spec->cur_adc_stream_tag, 0,
1161 spec->cur_adc_format);
1162 }
1163}
1164
Kailang Yang7fb0d782008-10-15 11:12:35 +02001165static void alc_mic_automute(struct hda_codec *codec)
1166{
1167 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001168 struct alc_mic_route *dead, *alive;
1169 unsigned int present, type;
1170 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001171
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001172 if (!spec->auto_mic)
1173 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001174 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1175 return;
1176 if (snd_BUG_ON(!spec->adc_nids))
1177 return;
1178
Takashi Iwai840b64c2010-07-13 22:49:01 +02001179 if (spec->dual_adc_switch) {
1180 alc_dual_mic_adc_auto_switch(codec);
1181 return;
1182 }
1183
Takashi Iwai6c819492009-08-10 18:47:44 +02001184 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1185
Wu Fengguang864f92b2009-11-18 12:38:02 +08001186 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001187 if (present) {
1188 alive = &spec->ext_mic;
1189 dead = &spec->int_mic;
1190 } else {
1191 alive = &spec->int_mic;
1192 dead = &spec->ext_mic;
1193 }
1194
Takashi Iwai6c819492009-08-10 18:47:44 +02001195 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1196 if (type == AC_WID_AUD_MIX) {
1197 /* Matrix-mixer style (e.g. ALC882) */
1198 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1199 alive->mux_idx,
1200 HDA_AMP_MUTE, 0);
1201 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1202 dead->mux_idx,
1203 HDA_AMP_MUTE, HDA_AMP_MUTE);
1204 } else {
1205 /* MUX style (e.g. ALC880) */
1206 snd_hda_codec_write_cache(codec, cap_nid, 0,
1207 AC_VERB_SET_CONNECT_SEL,
1208 alive->mux_idx);
1209 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001210 alc_report_jack(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001211
1212 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001213}
1214
Kailang Yangc9b58002007-10-16 14:30:01 +02001215/* unsolicited event for HP jack sensing */
1216static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1217{
1218 if (codec->vendor_id == 0x10ec0880)
1219 res >>= 28;
1220 else
1221 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001222 switch (res) {
1223 case ALC880_HP_EVENT:
1224 alc_automute_pin(codec);
1225 break;
1226 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001227 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001228 break;
1229 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001230}
1231
1232static void alc_inithook(struct hda_codec *codec)
1233{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001234 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001235 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001236}
1237
Kailang Yangf9423e72008-05-27 12:32:25 +02001238/* additional initialization for ALC888 variants */
1239static void alc888_coef_init(struct hda_codec *codec)
1240{
1241 unsigned int tmp;
1242
1243 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1244 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1245 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001246 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001247 /* alc888S-VC */
1248 snd_hda_codec_read(codec, 0x20, 0,
1249 AC_VERB_SET_PROC_COEF, 0x830);
1250 else
1251 /* alc888-VB */
1252 snd_hda_codec_read(codec, 0x20, 0,
1253 AC_VERB_SET_PROC_COEF, 0x3030);
1254}
1255
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001256static void alc889_coef_init(struct hda_codec *codec)
1257{
1258 unsigned int tmp;
1259
1260 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1261 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1262 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1263 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1264}
1265
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001266/* turn on/off EAPD control (only if available) */
1267static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1268{
1269 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1270 return;
1271 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1272 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1273 on ? 2 : 0);
1274}
1275
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001276static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001277{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001278 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001279
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001280 switch (type) {
1281 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001282 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1283 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001284 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001285 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1286 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001287 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001288 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1289 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001290 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001291 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001292 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001293 set_eapd(codec, 0x0f, 1);
1294 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001295 break;
1296 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001297 case 0x10ec0267:
1298 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001299 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001300 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001301 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001302 case 0x10ec0660:
1303 case 0x10ec0662:
1304 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001305 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001306 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001307 set_eapd(codec, 0x14, 1);
1308 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001309 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001310 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001311 switch (codec->vendor_id) {
1312 case 0x10ec0260:
1313 snd_hda_codec_write(codec, 0x1a, 0,
1314 AC_VERB_SET_COEF_INDEX, 7);
1315 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1316 AC_VERB_GET_PROC_COEF, 0);
1317 snd_hda_codec_write(codec, 0x1a, 0,
1318 AC_VERB_SET_COEF_INDEX, 7);
1319 snd_hda_codec_write(codec, 0x1a, 0,
1320 AC_VERB_SET_PROC_COEF,
1321 tmp | 0x2010);
1322 break;
1323 case 0x10ec0262:
1324 case 0x10ec0880:
1325 case 0x10ec0882:
1326 case 0x10ec0883:
1327 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001328 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001329 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001330 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001331 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001332 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001333 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001334 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001335#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001336 case 0x10ec0267:
1337 case 0x10ec0268:
1338 snd_hda_codec_write(codec, 0x20, 0,
1339 AC_VERB_SET_COEF_INDEX, 7);
1340 tmp = snd_hda_codec_read(codec, 0x20, 0,
1341 AC_VERB_GET_PROC_COEF, 0);
1342 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001343 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001344 snd_hda_codec_write(codec, 0x20, 0,
1345 AC_VERB_SET_PROC_COEF,
1346 tmp | 0x3000);
1347 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001348#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001349 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001350 break;
1351 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001352}
Kailang Yangea1fb292008-08-26 12:58:38 +02001353
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001354static void alc_init_auto_hp(struct hda_codec *codec)
1355{
1356 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001357 struct auto_pin_cfg *cfg = &spec->autocfg;
1358 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001359
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001360 if (!cfg->hp_pins[0]) {
1361 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001362 return;
1363 }
1364
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001365 if (!cfg->speaker_pins[0]) {
1366 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1367 return;
1368 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1369 sizeof(cfg->speaker_pins));
1370 cfg->speaker_outs = cfg->line_outs;
1371 }
1372
1373 if (!cfg->hp_pins[0]) {
1374 memcpy(cfg->hp_pins, cfg->line_out_pins,
1375 sizeof(cfg->hp_pins));
1376 cfg->hp_outs = cfg->line_outs;
1377 }
1378
1379 for (i = 0; i < cfg->hp_outs; i++) {
1380 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1381 cfg->hp_pins[i]);
1382 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001383 AC_VERB_SET_UNSOLICITED_ENABLE,
1384 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001385 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001386 spec->unsol_event = alc_sku_unsol_event;
1387}
1388
Takashi Iwai6c819492009-08-10 18:47:44 +02001389static void alc_init_auto_mic(struct hda_codec *codec)
1390{
1391 struct alc_spec *spec = codec->spec;
1392 struct auto_pin_cfg *cfg = &spec->autocfg;
1393 hda_nid_t fixed, ext;
1394 int i;
1395
1396 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001397 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001398 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001399 return;
1400
1401 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001402 for (i = 0; i < cfg->num_inputs; i++) {
1403 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001404 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001405 defcfg = snd_hda_codec_get_pincfg(codec, nid);
1406 switch (get_defcfg_connect(defcfg)) {
1407 case AC_JACK_PORT_FIXED:
1408 if (fixed)
1409 return; /* already occupied */
1410 fixed = nid;
1411 break;
1412 case AC_JACK_PORT_COMPLEX:
1413 if (ext)
1414 return; /* already occupied */
1415 ext = nid;
1416 break;
1417 default:
1418 return; /* invalid entry */
1419 }
1420 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001421 if (!ext || !fixed)
1422 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001423 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1424 return; /* no unsol support */
1425 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1426 ext, fixed);
1427 spec->ext_mic.pin = ext;
1428 spec->int_mic.pin = fixed;
1429 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1430 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1431 spec->auto_mic = 1;
1432 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1433 AC_VERB_SET_UNSOLICITED_ENABLE,
1434 AC_USRSP_EN | ALC880_MIC_EVENT);
1435 spec->unsol_event = alc_sku_unsol_event;
1436}
1437
Kailang Yangda00c242010-03-19 11:23:45 +01001438static int alc_auto_parse_customize_define(struct hda_codec *codec)
1439{
1440 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001441 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001442 struct alc_spec *spec = codec->spec;
1443
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001444 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1445
Kailang Yangda00c242010-03-19 11:23:45 +01001446 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001447 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001448 goto do_sku;
1449
1450 nid = 0x1d;
1451 if (codec->vendor_id == 0x10ec0260)
1452 nid = 0x17;
1453 ass = snd_hda_codec_get_pincfg(codec, nid);
1454
1455 if (!(ass & 1)) {
1456 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1457 codec->chip_name, ass);
1458 return -1;
1459 }
1460
1461 /* check sum */
1462 tmp = 0;
1463 for (i = 1; i < 16; i++) {
1464 if ((ass >> i) & 1)
1465 tmp++;
1466 }
1467 if (((ass >> 16) & 0xf) != tmp)
1468 return -1;
1469
1470 spec->cdefine.port_connectivity = ass >> 30;
1471 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1472 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1473 spec->cdefine.customization = ass >> 8;
1474do_sku:
1475 spec->cdefine.sku_cfg = ass;
1476 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1477 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1478 spec->cdefine.swap = (ass & 0x2) >> 1;
1479 spec->cdefine.override = ass & 0x1;
1480
1481 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1482 nid, spec->cdefine.sku_cfg);
1483 snd_printd("SKU: port_connectivity=0x%x\n",
1484 spec->cdefine.port_connectivity);
1485 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1486 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1487 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1488 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1489 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1490 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1491 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1492
1493 return 0;
1494}
1495
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001496/* check subsystem ID and set up device-specific initialization;
1497 * return 1 if initialized, 0 if invalid SSID
1498 */
1499/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1500 * 31 ~ 16 : Manufacture ID
1501 * 15 ~ 8 : SKU ID
1502 * 7 ~ 0 : Assembly ID
1503 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1504 */
1505static int alc_subsystem_id(struct hda_codec *codec,
1506 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001507 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001508{
1509 unsigned int ass, tmp, i;
1510 unsigned nid;
1511 struct alc_spec *spec = codec->spec;
1512
1513 ass = codec->subsystem_id & 0xffff;
1514 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1515 goto do_sku;
1516
1517 /* invalid SSID, check the special NID pin defcfg instead */
1518 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001519 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001520 * 29~21 : reserve
1521 * 20 : PCBEEP input
1522 * 19~16 : Check sum (15:1)
1523 * 15~1 : Custom
1524 * 0 : override
1525 */
1526 nid = 0x1d;
1527 if (codec->vendor_id == 0x10ec0260)
1528 nid = 0x17;
1529 ass = snd_hda_codec_get_pincfg(codec, nid);
1530 snd_printd("realtek: No valid SSID, "
1531 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001532 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001533 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001534 return 0;
1535 if ((ass >> 30) != 1) /* no physical connection */
1536 return 0;
1537
1538 /* check sum */
1539 tmp = 0;
1540 for (i = 1; i < 16; i++) {
1541 if ((ass >> i) & 1)
1542 tmp++;
1543 }
1544 if (((ass >> 16) & 0xf) != tmp)
1545 return 0;
1546do_sku:
1547 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1548 ass & 0xffff, codec->vendor_id);
1549 /*
1550 * 0 : override
1551 * 1 : Swap Jack
1552 * 2 : 0 --> Desktop, 1 --> Laptop
1553 * 3~5 : External Amplifier control
1554 * 7~6 : Reserved
1555 */
1556 tmp = (ass & 0x38) >> 3; /* external Amp control */
1557 switch (tmp) {
1558 case 1:
1559 spec->init_amp = ALC_INIT_GPIO1;
1560 break;
1561 case 3:
1562 spec->init_amp = ALC_INIT_GPIO2;
1563 break;
1564 case 7:
1565 spec->init_amp = ALC_INIT_GPIO3;
1566 break;
1567 case 5:
1568 spec->init_amp = ALC_INIT_DEFAULT;
1569 break;
1570 }
1571
1572 /* is laptop or Desktop and enable the function "Mute internal speaker
1573 * when the external headphone out jack is plugged"
1574 */
1575 if (!(ass & 0x8000))
1576 return 1;
1577 /*
1578 * 10~8 : Jack location
1579 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1580 * 14~13: Resvered
1581 * 15 : 1 --> enable the function "Mute internal speaker
1582 * when the external headphone out jack is plugged"
1583 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001584 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001585 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001586 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1587 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001588 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001589 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001590 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001591 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001592 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001593 else if (tmp == 3)
1594 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001595 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001596 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001597 for (i = 0; i < spec->autocfg.line_outs; i++)
1598 if (spec->autocfg.line_out_pins[i] == nid)
1599 return 1;
1600 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001601 }
1602
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001603 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001604 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001605 return 1;
1606}
Kailang Yangea1fb292008-08-26 12:58:38 +02001607
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001608static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001609 hda_nid_t porta, hda_nid_t porte,
1610 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001611{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001612 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001613 struct alc_spec *spec = codec->spec;
1614 snd_printd("realtek: "
1615 "Enable default setup for auto mode as fallback\n");
1616 spec->init_amp = ALC_INIT_DEFAULT;
1617 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001618 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001619 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001620}
1621
Takashi Iwai41e41f12005-06-08 14:48:49 +02001622/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001623 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001624 */
1625
1626struct alc_pincfg {
1627 hda_nid_t nid;
1628 u32 val;
1629};
1630
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001631struct alc_fixup {
1632 const struct alc_pincfg *pins;
1633 const struct hda_verb *verbs;
1634};
1635
1636static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001637 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001638 const struct alc_fixup *fix,
1639 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001640{
1641 const struct alc_pincfg *cfg;
1642
1643 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1644 if (!quirk)
1645 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001646 fix += quirk->value;
1647 cfg = fix->pins;
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001648 if (pre_init && cfg) {
1649#ifdef CONFIG_SND_DEBUG_VERBOSE
1650 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1651 codec->chip_name, quirk->name);
1652#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001653 for (; cfg->nid; cfg++)
1654 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1655 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001656 if (!pre_init && fix->verbs) {
1657#ifdef CONFIG_SND_DEBUG_VERBOSE
1658 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1659 codec->chip_name, quirk->name);
1660#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001661 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001662 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001663}
1664
Kailang Yang274693f2009-12-03 10:07:50 +01001665static int alc_read_coef_idx(struct hda_codec *codec,
1666 unsigned int coef_idx)
1667{
1668 unsigned int val;
1669 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1670 coef_idx);
1671 val = snd_hda_codec_read(codec, 0x20, 0,
1672 AC_VERB_GET_PROC_COEF, 0);
1673 return val;
1674}
1675
Kailang Yang977ddd62010-09-15 10:02:29 +02001676static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1677 unsigned int coef_val)
1678{
1679 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1680 coef_idx);
1681 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1682 coef_val);
1683}
1684
Takashi Iwai757899a2010-07-30 10:48:14 +02001685/* set right pin controls for digital I/O */
1686static void alc_auto_init_digital(struct hda_codec *codec)
1687{
1688 struct alc_spec *spec = codec->spec;
1689 int i;
1690 hda_nid_t pin;
1691
1692 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1693 pin = spec->autocfg.dig_out_pins[i];
1694 if (pin) {
1695 snd_hda_codec_write(codec, pin, 0,
1696 AC_VERB_SET_PIN_WIDGET_CONTROL,
1697 PIN_OUT);
1698 }
1699 }
1700 pin = spec->autocfg.dig_in_pin;
1701 if (pin)
1702 snd_hda_codec_write(codec, pin, 0,
1703 AC_VERB_SET_PIN_WIDGET_CONTROL,
1704 PIN_IN);
1705}
1706
1707/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1708static void alc_auto_parse_digital(struct hda_codec *codec)
1709{
1710 struct alc_spec *spec = codec->spec;
1711 int i, err;
1712 hda_nid_t dig_nid;
1713
1714 /* support multiple SPDIFs; the secondary is set up as a slave */
1715 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1716 err = snd_hda_get_connections(codec,
1717 spec->autocfg.dig_out_pins[i],
1718 &dig_nid, 1);
1719 if (err < 0)
1720 continue;
1721 if (!i) {
1722 spec->multiout.dig_out_nid = dig_nid;
1723 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1724 } else {
1725 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1726 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1727 break;
1728 spec->slave_dig_outs[i - 1] = dig_nid;
1729 }
1730 }
1731
1732 if (spec->autocfg.dig_in_pin) {
1733 hda_nid_t dig_nid;
1734 err = snd_hda_get_connections(codec,
1735 spec->autocfg.dig_in_pin,
1736 &dig_nid, 1);
1737 if (err > 0)
1738 spec->dig_in_nid = dig_nid;
1739 }
1740}
1741
Takashi Iwaif95474e2007-07-10 00:47:43 +02001742/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001743 * ALC888
1744 */
1745
1746/*
1747 * 2ch mode
1748 */
1749static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1750/* Mic-in jack as mic in */
1751 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1752 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1753/* Line-in jack as Line in */
1754 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1755 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1756/* Line-Out as Front */
1757 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1758 { } /* end */
1759};
1760
1761/*
1762 * 4ch mode
1763 */
1764static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1765/* Mic-in jack as mic in */
1766 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1767 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1768/* Line-in jack as Surround */
1769 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1770 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1771/* Line-Out as Front */
1772 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1773 { } /* end */
1774};
1775
1776/*
1777 * 6ch mode
1778 */
1779static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1780/* Mic-in jack as CLFE */
1781 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1782 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1783/* Line-in jack as Surround */
1784 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1785 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1786/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1787 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1788 { } /* end */
1789};
1790
1791/*
1792 * 8ch mode
1793 */
1794static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1795/* Mic-in jack as CLFE */
1796 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1797 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1798/* Line-in jack as Surround */
1799 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1800 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1801/* Line-Out as Side */
1802 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1803 { } /* end */
1804};
1805
1806static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1807 { 2, alc888_4ST_ch2_intel_init },
1808 { 4, alc888_4ST_ch4_intel_init },
1809 { 6, alc888_4ST_ch6_intel_init },
1810 { 8, alc888_4ST_ch8_intel_init },
1811};
1812
1813/*
1814 * ALC888 Fujitsu Siemens Amillo xa3530
1815 */
1816
1817static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1818/* Front Mic: set to PIN_IN (empty by default) */
1819 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1820/* Connect Internal HP to Front */
1821 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1822 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1823 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1824/* Connect Bass HP to Front */
1825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1827 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1828/* Connect Line-Out side jack (SPDIF) to Side */
1829 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1830 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1831 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1832/* Connect Mic jack to CLFE */
1833 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1834 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1835 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1836/* Connect Line-in jack to Surround */
1837 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1838 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1839 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1840/* Connect HP out jack to Front */
1841 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1842 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1843 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1844/* Enable unsolicited event for HP jack and Line-out jack */
1845 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1846 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1847 {}
1848};
1849
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001850static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001851{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001852 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001853}
1854
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001855static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1856 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001857{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001858 if (codec->vendor_id == 0x10ec0880)
1859 res >>= 28;
1860 else
1861 res >>= 26;
1862 if (res == ALC880_HP_EVENT)
1863 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001864}
1865
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001866static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001867{
1868 struct alc_spec *spec = codec->spec;
1869
1870 spec->autocfg.hp_pins[0] = 0x15;
1871 spec->autocfg.speaker_pins[0] = 0x14;
1872 spec->autocfg.speaker_pins[1] = 0x16;
1873 spec->autocfg.speaker_pins[2] = 0x17;
1874 spec->autocfg.speaker_pins[3] = 0x19;
1875 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001876}
1877
1878static void alc889_intel_init_hook(struct hda_codec *codec)
1879{
1880 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001881 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001882}
1883
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001884static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001885{
1886 struct alc_spec *spec = codec->spec;
1887
1888 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1889 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1890 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1891 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001892}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001893
1894/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001895 * ALC888 Acer Aspire 4930G model
1896 */
1897
1898static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1899/* Front Mic: set to PIN_IN (empty by default) */
1900 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1901/* Unselect Front Mic by default in input mixer 3 */
1902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001903/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001904 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1905/* Connect Internal HP to front */
1906 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1907 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1908 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1909/* Connect HP out to front */
1910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1912 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1913 { }
1914};
1915
Hector Martin3b315d72009-06-02 10:54:19 +02001916/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001917 * ALC888 Acer Aspire 6530G model
1918 */
1919
1920static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001921/* Route to built-in subwoofer as well as speakers */
1922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1923 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1924 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1925 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001926/* Bias voltage on for external mic port */
1927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001928/* Front Mic: set to PIN_IN (empty by default) */
1929 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1930/* Unselect Front Mic by default in input mixer 3 */
1931 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001932/* Enable unsolicited event for HP jack */
1933 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1934/* Enable speaker output */
1935 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1936 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01001937 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001938/* Enable headphone output */
1939 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1940 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1941 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01001942 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001943 { }
1944};
1945
1946/*
Hector Martin018df412009-06-04 00:13:40 +02001947 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001948 */
1949
Hector Martin018df412009-06-04 00:13:40 +02001950static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001951/* Front Mic: set to PIN_IN (empty by default) */
1952 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1953/* Unselect Front Mic by default in input mixer 3 */
1954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1955/* Enable unsolicited event for HP jack */
1956 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1957/* Connect Internal Front to Front */
1958 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1959 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1960 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1961/* Connect Internal Rear to Rear */
1962 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1963 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1964 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1965/* Connect Internal CLFE to CLFE */
1966 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1967 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1968 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1969/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001970 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001971 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1972 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1973/* Enable all DACs */
1974/* DAC DISABLE/MUTE 1? */
1975/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
1976 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
1977 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
1978/* DAC DISABLE/MUTE 2? */
1979/* some bit here disables the other DACs. Init=0x4900 */
1980 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
1981 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02001982/* DMIC fix
1983 * This laptop has a stereo digital microphone. The mics are only 1cm apart
1984 * which makes the stereo useless. However, either the mic or the ALC889
1985 * makes the signal become a difference/sum signal instead of standard
1986 * stereo, which is annoying. So instead we flip this bit which makes the
1987 * codec replicate the sum signal to both channels, turning it into a
1988 * normal mono mic.
1989 */
1990/* DMIC_CONTROL? Init value = 0x0001 */
1991 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
1992 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02001993 { }
1994};
1995
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001996static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001997 /* Front mic only available on one ADC */
1998 {
1999 .num_items = 4,
2000 .items = {
2001 { "Mic", 0x0 },
2002 { "Line", 0x2 },
2003 { "CD", 0x4 },
2004 { "Front Mic", 0xb },
2005 },
2006 },
2007 {
2008 .num_items = 3,
2009 .items = {
2010 { "Mic", 0x0 },
2011 { "Line", 0x2 },
2012 { "CD", 0x4 },
2013 },
2014 }
2015};
2016
Tony Vroond2fd4b02009-06-21 00:40:10 +01002017static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2018 /* Interal mic only available on one ADC */
2019 {
Tony Vroon684a8842009-06-26 09:27:50 +01002020 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002021 .items = {
2022 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002023 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002024 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002025 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002026 { "Int Mic", 0xb },
2027 },
2028 },
2029 {
Tony Vroon684a8842009-06-26 09:27:50 +01002030 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002031 .items = {
2032 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002033 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002034 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002035 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002036 },
2037 }
2038};
2039
Hector Martin018df412009-06-04 00:13:40 +02002040static struct hda_input_mux alc889_capture_sources[3] = {
2041 /* Digital mic only available on first "ADC" */
2042 {
2043 .num_items = 5,
2044 .items = {
2045 { "Mic", 0x0 },
2046 { "Line", 0x2 },
2047 { "CD", 0x4 },
2048 { "Front Mic", 0xb },
2049 { "Input Mix", 0xa },
2050 },
2051 },
2052 {
2053 .num_items = 4,
2054 .items = {
2055 { "Mic", 0x0 },
2056 { "Line", 0x2 },
2057 { "CD", 0x4 },
2058 { "Input Mix", 0xa },
2059 },
2060 },
2061 {
2062 .num_items = 4,
2063 .items = {
2064 { "Mic", 0x0 },
2065 { "Line", 0x2 },
2066 { "CD", 0x4 },
2067 { "Input Mix", 0xa },
2068 },
2069 }
2070};
2071
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002072static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002073 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2074 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2075 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2076 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2077 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2078 HDA_OUTPUT),
2079 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2080 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2081 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2082 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2083 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2084 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2085 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2086 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2087 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2088 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2089 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2090 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002091 { } /* end */
2092};
2093
Hector Martin556eea92009-12-20 22:51:23 +01002094static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2095 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2096 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2097 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2098 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2099 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2100 HDA_OUTPUT),
2101 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2102 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2103 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2104 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2105 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2106 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2107 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2109 { } /* end */
2110};
2111
2112
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002113static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002114{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002115 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002116
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002117 spec->autocfg.hp_pins[0] = 0x15;
2118 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002119 spec->autocfg.speaker_pins[1] = 0x16;
2120 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002121}
2122
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002123static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002124{
2125 struct alc_spec *spec = codec->spec;
2126
2127 spec->autocfg.hp_pins[0] = 0x15;
2128 spec->autocfg.speaker_pins[0] = 0x14;
2129 spec->autocfg.speaker_pins[1] = 0x16;
2130 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002131}
2132
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002133static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002134{
2135 struct alc_spec *spec = codec->spec;
2136
2137 spec->autocfg.hp_pins[0] = 0x15;
2138 spec->autocfg.speaker_pins[0] = 0x14;
2139 spec->autocfg.speaker_pins[1] = 0x16;
2140 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002141}
2142
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002143/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002144 * ALC880 3-stack model
2145 *
2146 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002147 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2148 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149 */
2150
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002151static hda_nid_t alc880_dac_nids[4] = {
2152 /* front, rear, clfe, rear_surr */
2153 0x02, 0x05, 0x04, 0x03
2154};
2155
2156static hda_nid_t alc880_adc_nids[3] = {
2157 /* ADC0-2 */
2158 0x07, 0x08, 0x09,
2159};
2160
2161/* The datasheet says the node 0x07 is connected from inputs,
2162 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002163 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002164 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002165static hda_nid_t alc880_adc_nids_alt[2] = {
2166 /* ADC1-2 */
2167 0x08, 0x09,
2168};
2169
2170#define ALC880_DIGOUT_NID 0x06
2171#define ALC880_DIGIN_NID 0x0a
2172
2173static struct hda_input_mux alc880_capture_source = {
2174 .num_items = 4,
2175 .items = {
2176 { "Mic", 0x0 },
2177 { "Front Mic", 0x3 },
2178 { "Line", 0x2 },
2179 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002180 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002181};
2182
2183/* channel source setting (2/6 channel selection for 3-stack) */
2184/* 2ch mode */
2185static struct hda_verb alc880_threestack_ch2_init[] = {
2186 /* set line-in to input, mute it */
2187 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2188 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2189 /* set mic-in to input vref 80%, mute it */
2190 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2191 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002192 { } /* end */
2193};
2194
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002195/* 6ch mode */
2196static struct hda_verb alc880_threestack_ch6_init[] = {
2197 /* set line-in to output, unmute it */
2198 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2199 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2200 /* set mic-in to output, unmute it */
2201 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2202 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2203 { } /* end */
2204};
2205
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002206static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002207 { 2, alc880_threestack_ch2_init },
2208 { 6, alc880_threestack_ch6_init },
2209};
2210
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002211static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002212 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002213 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002214 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002215 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002216 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2217 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002218 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2219 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002220 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2221 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2222 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2223 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2224 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2225 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2226 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2227 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002228 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002229 {
2230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2231 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002232 .info = alc_ch_mode_info,
2233 .get = alc_ch_mode_get,
2234 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002235 },
2236 { } /* end */
2237};
2238
2239/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002240static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2241 struct snd_ctl_elem_info *uinfo)
2242{
2243 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2244 struct alc_spec *spec = codec->spec;
2245 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002246
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002247 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002248 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2249 HDA_INPUT);
2250 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002251 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002252 return err;
2253}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002254
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002255static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2256 unsigned int size, unsigned int __user *tlv)
2257{
2258 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2259 struct alc_spec *spec = codec->spec;
2260 int err;
2261
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002262 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002263 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2264 HDA_INPUT);
2265 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002266 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002267 return err;
2268}
2269
2270typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2271 struct snd_ctl_elem_value *ucontrol);
2272
2273static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2274 struct snd_ctl_elem_value *ucontrol,
2275 getput_call_t func)
2276{
2277 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2278 struct alc_spec *spec = codec->spec;
2279 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2280 int err;
2281
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002282 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002283 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2284 3, 0, HDA_INPUT);
2285 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002286 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002287 return err;
2288}
2289
2290static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2291 struct snd_ctl_elem_value *ucontrol)
2292{
2293 return alc_cap_getput_caller(kcontrol, ucontrol,
2294 snd_hda_mixer_amp_volume_get);
2295}
2296
2297static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2298 struct snd_ctl_elem_value *ucontrol)
2299{
2300 return alc_cap_getput_caller(kcontrol, ucontrol,
2301 snd_hda_mixer_amp_volume_put);
2302}
2303
2304/* capture mixer elements */
2305#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2306
2307static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2308 struct snd_ctl_elem_value *ucontrol)
2309{
2310 return alc_cap_getput_caller(kcontrol, ucontrol,
2311 snd_hda_mixer_amp_switch_get);
2312}
2313
2314static int alc_cap_sw_put(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_switch_put);
2319}
2320
Takashi Iwaia23b6882009-03-23 15:21:36 +01002321#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002322 { \
2323 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2324 .name = "Capture Switch", \
2325 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2326 .count = num, \
2327 .info = alc_cap_sw_info, \
2328 .get = alc_cap_sw_get, \
2329 .put = alc_cap_sw_put, \
2330 }, \
2331 { \
2332 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2333 .name = "Capture Volume", \
2334 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2335 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2336 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2337 .count = num, \
2338 .info = alc_cap_vol_info, \
2339 .get = alc_cap_vol_get, \
2340 .put = alc_cap_vol_put, \
2341 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002342 }
2343
2344#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002345 { \
2346 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2347 /* .name = "Capture Source", */ \
2348 .name = "Input Source", \
2349 .count = num, \
2350 .info = alc_mux_enum_info, \
2351 .get = alc_mux_enum_get, \
2352 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002353 }
2354
2355#define DEFINE_CAPMIX(num) \
2356static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2357 _DEFINE_CAPMIX(num), \
2358 _DEFINE_CAPSRC(num), \
2359 { } /* end */ \
2360}
2361
2362#define DEFINE_CAPMIX_NOSRC(num) \
2363static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2364 _DEFINE_CAPMIX(num), \
2365 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002366}
2367
2368/* up to three ADCs */
2369DEFINE_CAPMIX(1);
2370DEFINE_CAPMIX(2);
2371DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002372DEFINE_CAPMIX_NOSRC(1);
2373DEFINE_CAPMIX_NOSRC(2);
2374DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002375
2376/*
2377 * ALC880 5-stack model
2378 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002379 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2380 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002381 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2382 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2383 */
2384
2385/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002386static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002387 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002388 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002389 { } /* end */
2390};
2391
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002392/* channel source setting (6/8 channel selection for 5-stack) */
2393/* 6ch mode */
2394static struct hda_verb alc880_fivestack_ch6_init[] = {
2395 /* set line-in to input, mute it */
2396 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2397 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002398 { } /* end */
2399};
2400
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002401/* 8ch mode */
2402static struct hda_verb alc880_fivestack_ch8_init[] = {
2403 /* set line-in to output, unmute it */
2404 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2405 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2406 { } /* end */
2407};
2408
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002409static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002410 { 6, alc880_fivestack_ch6_init },
2411 { 8, alc880_fivestack_ch8_init },
2412};
2413
2414
2415/*
2416 * ALC880 6-stack model
2417 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002418 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2419 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002420 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2421 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2422 */
2423
2424static hda_nid_t alc880_6st_dac_nids[4] = {
2425 /* front, rear, clfe, rear_surr */
2426 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002427};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002428
2429static struct hda_input_mux alc880_6stack_capture_source = {
2430 .num_items = 4,
2431 .items = {
2432 { "Mic", 0x0 },
2433 { "Front Mic", 0x1 },
2434 { "Line", 0x2 },
2435 { "CD", 0x4 },
2436 },
2437};
2438
2439/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002440static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002441 { 8, NULL },
2442};
2443
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002444static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002445 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002446 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002447 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002448 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002449 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2450 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002451 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2452 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002453 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002454 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002455 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2456 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2457 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2458 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2459 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2460 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2461 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2462 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002463 {
2464 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2465 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002466 .info = alc_ch_mode_info,
2467 .get = alc_ch_mode_get,
2468 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002469 },
2470 { } /* end */
2471};
2472
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002473
2474/*
2475 * ALC880 W810 model
2476 *
2477 * W810 has rear IO for:
2478 * Front (DAC 02)
2479 * Surround (DAC 03)
2480 * Center/LFE (DAC 04)
2481 * Digital out (06)
2482 *
2483 * The system also has a pair of internal speakers, and a headphone jack.
2484 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002485 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002486 * There is a variable resistor to control the speaker or headphone
2487 * volume. This is a hardware-only device without a software API.
2488 *
2489 * Plugging headphones in will disable the internal speakers. This is
2490 * implemented in hardware, not via the driver using jack sense. In
2491 * a similar fashion, plugging into the rear socket marked "front" will
2492 * disable both the speakers and headphones.
2493 *
2494 * For input, there's a microphone jack, and an "audio in" jack.
2495 * These may not do anything useful with this driver yet, because I
2496 * haven't setup any initialization verbs for these yet...
2497 */
2498
2499static hda_nid_t alc880_w810_dac_nids[3] = {
2500 /* front, rear/surround, clfe */
2501 0x02, 0x03, 0x04
2502};
2503
2504/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002505static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002506 { 6, NULL }
2507};
2508
2509/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002510static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002511 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002512 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002513 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002514 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002515 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2516 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002517 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2518 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002519 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2520 { } /* end */
2521};
2522
2523
2524/*
2525 * Z710V model
2526 *
2527 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002528 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2529 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002530 */
2531
2532static hda_nid_t alc880_z71v_dac_nids[1] = {
2533 0x02
2534};
2535#define ALC880_Z71V_HP_DAC 0x03
2536
2537/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002538static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002539 { 2, NULL }
2540};
2541
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002542static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002543 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002544 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002545 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002546 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002547 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2548 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2549 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2550 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2551 { } /* end */
2552};
2553
2554
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002555/*
2556 * ALC880 F1734 model
2557 *
2558 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2559 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2560 */
2561
2562static hda_nid_t alc880_f1734_dac_nids[1] = {
2563 0x03
2564};
2565#define ALC880_F1734_HP_DAC 0x02
2566
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002567static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002568 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002569 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002570 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2571 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002572 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2573 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2575 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002576 { } /* end */
2577};
2578
Takashi Iwai937b4162008-02-11 14:52:36 +01002579static struct hda_input_mux alc880_f1734_capture_source = {
2580 .num_items = 2,
2581 .items = {
2582 { "Mic", 0x1 },
2583 { "CD", 0x4 },
2584 },
2585};
2586
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002587
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002588/*
2589 * ALC880 ASUS model
2590 *
2591 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2592 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2593 * Mic = 0x18, Line = 0x1a
2594 */
2595
2596#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2597#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2598
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002599static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002600 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002601 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002602 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002603 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002604 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2605 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002606 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2607 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002608 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2609 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2610 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2611 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2612 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2613 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002614 {
2615 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2616 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002617 .info = alc_ch_mode_info,
2618 .get = alc_ch_mode_get,
2619 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002620 },
2621 { } /* end */
2622};
2623
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002624/*
2625 * ALC880 ASUS W1V model
2626 *
2627 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2628 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2629 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2630 */
2631
2632/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002633static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002634 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2635 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002636 { } /* end */
2637};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002638
Kailang Yangdf694da2005-12-05 19:42:22 +01002639/* TCL S700 */
2640static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2641 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2642 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2643 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2644 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2645 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2647 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2648 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2649 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002650 { } /* end */
2651};
2652
Kailang Yangccc656c2006-10-17 12:32:26 +02002653/* Uniwill */
2654static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002655 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2656 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2657 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2658 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002659 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2660 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2661 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2662 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2663 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2664 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2665 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2666 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2667 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2668 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2669 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2670 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002671 {
2672 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2673 .name = "Channel Mode",
2674 .info = alc_ch_mode_info,
2675 .get = alc_ch_mode_get,
2676 .put = alc_ch_mode_put,
2677 },
2678 { } /* end */
2679};
2680
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002681static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2682 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2683 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2684 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2685 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2686 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2687 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2688 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2689 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2690 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2691 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2692 { } /* end */
2693};
2694
Kailang Yangccc656c2006-10-17 12:32:26 +02002695static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002696 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2697 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2698 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2699 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002700 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2701 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2702 { } /* end */
2703};
2704
Linus Torvalds1da177e2005-04-16 15:20:36 -07002705/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002706 * virtual master controls
2707 */
2708
2709/*
2710 * slave controls for virtual master
2711 */
2712static const char *alc_slave_vols[] = {
2713 "Front Playback Volume",
2714 "Surround Playback Volume",
2715 "Center Playback Volume",
2716 "LFE Playback Volume",
2717 "Side Playback Volume",
2718 "Headphone Playback Volume",
2719 "Speaker Playback Volume",
2720 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002721 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002722 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002723 NULL,
2724};
2725
2726static const char *alc_slave_sws[] = {
2727 "Front Playback Switch",
2728 "Surround Playback Switch",
2729 "Center Playback Switch",
2730 "LFE Playback Switch",
2731 "Side Playback Switch",
2732 "Headphone Playback Switch",
2733 "Speaker Playback Switch",
2734 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002735 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002736 "Line-Out Playback Switch",
2737 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002738 NULL,
2739};
2740
2741/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002742 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002743 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002744
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002745#define NID_MAPPING (-1)
2746
2747#define SUBDEV_SPEAKER_ (0 << 6)
2748#define SUBDEV_HP_ (1 << 6)
2749#define SUBDEV_LINE_ (2 << 6)
2750#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2751#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2752#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2753
Takashi Iwai603c4012008-07-30 15:01:44 +02002754static void alc_free_kctls(struct hda_codec *codec);
2755
Takashi Iwai67d634c2009-11-16 15:35:59 +01002756#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002757/* additional beep mixers; the actual parameters are overwritten at build */
2758static struct snd_kcontrol_new alc_beep_mixer[] = {
2759 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002760 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002761 { } /* end */
2762};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002763#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002764
Linus Torvalds1da177e2005-04-16 15:20:36 -07002765static int alc_build_controls(struct hda_codec *codec)
2766{
2767 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002768 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002769 struct snd_kcontrol_new *knew;
2770 int i, j, err;
2771 unsigned int u;
2772 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002773
2774 for (i = 0; i < spec->num_mixers; i++) {
2775 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2776 if (err < 0)
2777 return err;
2778 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002779 if (spec->cap_mixer) {
2780 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2781 if (err < 0)
2782 return err;
2783 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002784 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002785 err = snd_hda_create_spdif_out_ctls(codec,
2786 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002787 if (err < 0)
2788 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002789 if (!spec->no_analog) {
2790 err = snd_hda_create_spdif_share_sw(codec,
2791 &spec->multiout);
2792 if (err < 0)
2793 return err;
2794 spec->multiout.share_spdif = 1;
2795 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002796 }
2797 if (spec->dig_in_nid) {
2798 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2799 if (err < 0)
2800 return err;
2801 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002802
Takashi Iwai67d634c2009-11-16 15:35:59 +01002803#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002804 /* create beep controls if needed */
2805 if (spec->beep_amp) {
2806 struct snd_kcontrol_new *knew;
2807 for (knew = alc_beep_mixer; knew->name; knew++) {
2808 struct snd_kcontrol *kctl;
2809 kctl = snd_ctl_new1(knew, codec);
2810 if (!kctl)
2811 return -ENOMEM;
2812 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002813 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002814 if (err < 0)
2815 return err;
2816 }
2817 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002818#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002819
Takashi Iwai2134ea42008-01-10 16:53:55 +01002820 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002821 if (!spec->no_analog &&
2822 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002823 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002824 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002825 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002826 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002827 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002828 if (err < 0)
2829 return err;
2830 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002831 if (!spec->no_analog &&
2832 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002833 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2834 NULL, alc_slave_sws);
2835 if (err < 0)
2836 return err;
2837 }
2838
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002839 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002840 if (spec->capsrc_nids || spec->adc_nids) {
2841 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2842 if (!kctl)
2843 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2844 for (i = 0; kctl && i < kctl->count; i++) {
2845 hda_nid_t *nids = spec->capsrc_nids;
2846 if (!nids)
2847 nids = spec->adc_nids;
2848 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2849 if (err < 0)
2850 return err;
2851 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002852 }
2853 if (spec->cap_mixer) {
2854 const char *kname = kctl ? kctl->id.name : NULL;
2855 for (knew = spec->cap_mixer; knew->name; knew++) {
2856 if (kname && strcmp(knew->name, kname) == 0)
2857 continue;
2858 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2859 for (i = 0; kctl && i < kctl->count; i++) {
2860 err = snd_hda_add_nid(codec, kctl, i,
2861 spec->adc_nids[i]);
2862 if (err < 0)
2863 return err;
2864 }
2865 }
2866 }
2867
2868 /* other nid->control mapping */
2869 for (i = 0; i < spec->num_mixers; i++) {
2870 for (knew = spec->mixers[i]; knew->name; knew++) {
2871 if (knew->iface != NID_MAPPING)
2872 continue;
2873 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2874 if (kctl == NULL)
2875 continue;
2876 u = knew->subdevice;
2877 for (j = 0; j < 4; j++, u >>= 8) {
2878 nid = u & 0x3f;
2879 if (nid == 0)
2880 continue;
2881 switch (u & 0xc0) {
2882 case SUBDEV_SPEAKER_:
2883 nid = spec->autocfg.speaker_pins[nid];
2884 break;
2885 case SUBDEV_LINE_:
2886 nid = spec->autocfg.line_out_pins[nid];
2887 break;
2888 case SUBDEV_HP_:
2889 nid = spec->autocfg.hp_pins[nid];
2890 break;
2891 default:
2892 continue;
2893 }
2894 err = snd_hda_add_nid(codec, kctl, 0, nid);
2895 if (err < 0)
2896 return err;
2897 }
2898 u = knew->private_value;
2899 for (j = 0; j < 4; j++, u >>= 8) {
2900 nid = u & 0xff;
2901 if (nid == 0)
2902 continue;
2903 err = snd_hda_add_nid(codec, kctl, 0, nid);
2904 if (err < 0)
2905 return err;
2906 }
2907 }
2908 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002909
2910 alc_free_kctls(codec); /* no longer needed */
2911
Linus Torvalds1da177e2005-04-16 15:20:36 -07002912 return 0;
2913}
2914
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002915
Linus Torvalds1da177e2005-04-16 15:20:36 -07002916/*
2917 * initialize the codec volumes, etc
2918 */
2919
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002920/*
2921 * generic initialization of ADC, input mixers and output mixers
2922 */
2923static struct hda_verb alc880_volume_init_verbs[] = {
2924 /*
2925 * Unmute ADC0-2 and set the default input to mic-in
2926 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002927 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002928 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002929 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002930 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002931 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002932 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002933
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002934 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2935 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002936 * Note: PASD motherboards uses the Line In 2 as the input for front
2937 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002938 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002939 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002940 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2941 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2942 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2943 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2944 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2945 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2946 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002947
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002948 /*
2949 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002950 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002951 /* set vol=0 to output mixers */
2952 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2953 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2954 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2955 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2956 /* set up input amps for analog loopback */
2957 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002958 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2959 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002960 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2961 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002962 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2963 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002964 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2965 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002966
2967 { }
2968};
2969
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002970/*
2971 * 3-stack pin configuration:
2972 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2973 */
2974static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2975 /*
2976 * preset connection lists of input pins
2977 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
2978 */
2979 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
2980 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
2981 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
2982
2983 /*
2984 * Set pin mode and muting
2985 */
2986 /* set front pin widgets 0x14 for output */
2987 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2988 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2989 /* Mic1 (rear panel) pin widget for input and vref at 80% */
2990 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
2991 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2992 /* Mic2 (as headphone out) for HP output */
2993 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
2994 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2995 /* Line In pin widget for input */
2996 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2997 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
2998 /* Line2 (as front mic) pin widget for input and vref at 80% */
2999 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3000 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3001 /* CD pin widget for input */
3002 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3003
3004 { }
3005};
3006
3007/*
3008 * 5-stack pin configuration:
3009 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3010 * line-in/side = 0x1a, f-mic = 0x1b
3011 */
3012static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3013 /*
3014 * preset connection lists of input pins
3015 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3016 */
3017 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3018 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3019
3020 /*
3021 * Set pin mode and muting
3022 */
3023 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003024 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3025 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3026 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3027 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003028 /* unmute pins for output (no gain on this amp) */
3029 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3030 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3031 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3032 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3033
Linus Torvalds1da177e2005-04-16 15:20:36 -07003034 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003035 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003036 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3037 /* Mic2 (as headphone out) for HP output */
3038 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003039 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003040 /* Line In pin widget for input */
3041 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3042 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3043 /* Line2 (as front mic) pin widget for input and vref at 80% */
3044 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3045 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3046 /* CD pin widget for input */
3047 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003048
3049 { }
3050};
3051
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003052/*
3053 * W810 pin configuration:
3054 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3055 */
3056static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003057 /* hphone/speaker input selector: front DAC */
3058 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3059
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003060 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3061 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3063 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3064 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3065 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3066
3067 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003068 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003069
Linus Torvalds1da177e2005-04-16 15:20:36 -07003070 { }
3071};
3072
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003073/*
3074 * Z71V pin configuration:
3075 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3076 */
3077static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003078 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003079 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003081 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003082
Takashi Iwai16ded522005-06-10 19:58:24 +02003083 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003084 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003085 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003086 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003087
3088 { }
3089};
3090
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003091/*
3092 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003093 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3094 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003095 */
3096static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3097 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3098
Takashi Iwai16ded522005-06-10 19:58:24 +02003099 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003100 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003101 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003102 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003103 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003104 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003105 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003106 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3107
Takashi Iwai16ded522005-06-10 19:58:24 +02003108 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003109 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003110 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003111 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003112 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003113 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003114 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003115 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003116 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003117
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003118 { }
3119};
Takashi Iwai16ded522005-06-10 19:58:24 +02003120
Kailang Yangccc656c2006-10-17 12:32:26 +02003121/*
3122 * Uniwill pin configuration:
3123 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3124 * line = 0x1a
3125 */
3126static struct hda_verb alc880_uniwill_init_verbs[] = {
3127 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3128
3129 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3130 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3131 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3132 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3133 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3134 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3135 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3136 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3137 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3138 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3139 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3140 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3141 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3142 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3143
3144 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3145 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3146 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3147 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3148 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3149 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3150 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3151 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3152 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3153
3154 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3155 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3156
3157 { }
3158};
3159
3160/*
3161* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003162* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003163 */
3164static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3165 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3166
3167 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3168 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3169 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3170 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3171 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3172 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3174 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3175 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3176 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3177 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3178 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3179
3180 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3181 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3182 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3183 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3184 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3185 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3186
3187 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3188 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3189
3190 { }
3191};
3192
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003193static struct hda_verb alc880_beep_init_verbs[] = {
3194 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3195 { }
3196};
3197
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003198/* auto-toggle front mic */
3199static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3200{
3201 unsigned int present;
3202 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003203
Wu Fengguang864f92b2009-11-18 12:38:02 +08003204 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003205 bits = present ? HDA_AMP_MUTE : 0;
3206 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003207}
3208
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003209static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003210{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003211 struct alc_spec *spec = codec->spec;
3212
3213 spec->autocfg.hp_pins[0] = 0x14;
3214 spec->autocfg.speaker_pins[0] = 0x15;
3215 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003216}
3217
3218static void alc880_uniwill_init_hook(struct hda_codec *codec)
3219{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003220 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003221 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003222}
3223
3224static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3225 unsigned int res)
3226{
3227 /* Looks like the unsol event is incompatible with the standard
3228 * definition. 4bit tag is placed at 28 bit!
3229 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003230 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003231 case ALC880_MIC_EVENT:
3232 alc880_uniwill_mic_automute(codec);
3233 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003234 default:
3235 alc_automute_amp_unsol_event(codec, res);
3236 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003237 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003238}
3239
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003240static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003241{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003242 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003243
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003244 spec->autocfg.hp_pins[0] = 0x14;
3245 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003246}
3247
3248static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3249{
3250 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003251
Kailang Yangccc656c2006-10-17 12:32:26 +02003252 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003253 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3254 present &= HDA_AMP_VOLMASK;
3255 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3256 HDA_AMP_VOLMASK, present);
3257 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3258 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003259}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003260
Kailang Yangccc656c2006-10-17 12:32:26 +02003261static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3262 unsigned int res)
3263{
3264 /* Looks like the unsol event is incompatible with the standard
3265 * definition. 4bit tag is placed at 28 bit!
3266 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003267 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003268 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003269 else
3270 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003271}
3272
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003273/*
3274 * F1734 pin configuration:
3275 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3276 */
3277static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003278 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003279 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3280 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3281 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3282 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3283
3284 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3285 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3286 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3287 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3288
3289 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3290 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003291 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003292 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3293 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3294 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3295 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3296 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3297 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003298
Takashi Iwai937b4162008-02-11 14:52:36 +01003299 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3300 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3301
Takashi Iwai16ded522005-06-10 19:58:24 +02003302 { }
3303};
3304
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003305/*
3306 * ASUS pin configuration:
3307 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3308 */
3309static struct hda_verb alc880_pin_asus_init_verbs[] = {
3310 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3311 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3312 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3313 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3314
3315 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3316 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3317 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3318 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3319 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3320 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3321 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3322 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3323
3324 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3325 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3326 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3327 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3328 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3329 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3330 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3331 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3332 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003333
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003334 { }
3335};
3336
3337/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003338#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3339#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003340#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003341
Kailang Yangdf694da2005-12-05 19:42:22 +01003342/* Clevo m520g init */
3343static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3344 /* headphone output */
3345 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3346 /* line-out */
3347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3348 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3349 /* Line-in */
3350 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3351 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3352 /* CD */
3353 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3354 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3355 /* Mic1 (rear panel) */
3356 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3357 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3358 /* Mic2 (front panel) */
3359 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3360 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3361 /* headphone */
3362 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3363 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3364 /* change to EAPD mode */
3365 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3366 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3367
3368 { }
3369};
3370
3371static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003372 /* change to EAPD mode */
3373 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3374 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3375
Kailang Yangdf694da2005-12-05 19:42:22 +01003376 /* Headphone output */
3377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3378 /* Front output*/
3379 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3380 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3381
3382 /* Line In pin widget for input */
3383 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3384 /* CD pin widget for input */
3385 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3386 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3387 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3388
3389 /* change to EAPD mode */
3390 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3391 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3392
3393 { }
3394};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003395
3396/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003397 * LG m1 express dual
3398 *
3399 * Pin assignment:
3400 * Rear Line-In/Out (blue): 0x14
3401 * Build-in Mic-In: 0x15
3402 * Speaker-out: 0x17
3403 * HP-Out (green): 0x1b
3404 * Mic-In/Out (red): 0x19
3405 * SPDIF-Out: 0x1e
3406 */
3407
3408/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3409static hda_nid_t alc880_lg_dac_nids[3] = {
3410 0x05, 0x02, 0x03
3411};
3412
3413/* seems analog CD is not working */
3414static struct hda_input_mux alc880_lg_capture_source = {
3415 .num_items = 3,
3416 .items = {
3417 { "Mic", 0x1 },
3418 { "Line", 0x5 },
3419 { "Internal Mic", 0x6 },
3420 },
3421};
3422
3423/* 2,4,6 channel modes */
3424static struct hda_verb alc880_lg_ch2_init[] = {
3425 /* set line-in and mic-in to input */
3426 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3427 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3428 { }
3429};
3430
3431static struct hda_verb alc880_lg_ch4_init[] = {
3432 /* set line-in to out and mic-in to input */
3433 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3434 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3435 { }
3436};
3437
3438static struct hda_verb alc880_lg_ch6_init[] = {
3439 /* set line-in and mic-in to output */
3440 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3441 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3442 { }
3443};
3444
3445static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3446 { 2, alc880_lg_ch2_init },
3447 { 4, alc880_lg_ch4_init },
3448 { 6, alc880_lg_ch6_init },
3449};
3450
3451static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003452 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3453 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003454 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3455 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3456 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3457 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3458 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3459 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3460 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3461 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3462 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3463 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3464 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3465 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3466 {
3467 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3468 .name = "Channel Mode",
3469 .info = alc_ch_mode_info,
3470 .get = alc_ch_mode_get,
3471 .put = alc_ch_mode_put,
3472 },
3473 { } /* end */
3474};
3475
3476static struct hda_verb alc880_lg_init_verbs[] = {
3477 /* set capture source to mic-in */
3478 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3479 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3480 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3481 /* mute all amp mixer inputs */
3482 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003483 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3484 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003485 /* line-in to input */
3486 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3488 /* built-in mic */
3489 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3490 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3491 /* speaker-out */
3492 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3493 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3494 /* mic-in to input */
3495 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3496 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3497 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3498 /* HP-out */
3499 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3500 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3501 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3502 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003503 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003504 { }
3505};
3506
3507/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003508static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003509{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003510 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003511
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003512 spec->autocfg.hp_pins[0] = 0x1b;
3513 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003514}
3515
3516/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003517 * LG LW20
3518 *
3519 * Pin assignment:
3520 * Speaker-out: 0x14
3521 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003522 * Built-in Mic-In: 0x19
3523 * Line-In: 0x1b
3524 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003525 * SPDIF-Out: 0x1e
3526 */
3527
Takashi Iwaid6815182006-03-23 16:06:23 +01003528static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003529 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003530 .items = {
3531 { "Mic", 0x0 },
3532 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003533 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003534 },
3535};
3536
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003537#define alc880_lg_lw_modes alc880_threestack_modes
3538
Takashi Iwaid6815182006-03-23 16:06:23 +01003539static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003540 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3541 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3542 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3543 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3544 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3545 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3546 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3547 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3548 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3549 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3552 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3553 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003554 {
3555 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3556 .name = "Channel Mode",
3557 .info = alc_ch_mode_info,
3558 .get = alc_ch_mode_get,
3559 .put = alc_ch_mode_put,
3560 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003561 { } /* end */
3562};
3563
3564static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003565 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3566 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3567 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3568
Takashi Iwaid6815182006-03-23 16:06:23 +01003569 /* set capture source to mic-in */
3570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3571 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3572 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003573 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003574 /* speaker-out */
3575 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3576 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3577 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003578 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3579 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3580 /* mic-in to input */
3581 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3582 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3583 /* built-in mic */
3584 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3585 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3586 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003587 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003588 { }
3589};
3590
3591/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003592static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003593{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003594 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003595
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003596 spec->autocfg.hp_pins[0] = 0x1b;
3597 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003598}
3599
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003600static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3601 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3602 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3605 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3606 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3607 { } /* end */
3608};
3609
3610static struct hda_input_mux alc880_medion_rim_capture_source = {
3611 .num_items = 2,
3612 .items = {
3613 { "Mic", 0x0 },
3614 { "Internal Mic", 0x1 },
3615 },
3616};
3617
3618static struct hda_verb alc880_medion_rim_init_verbs[] = {
3619 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3620
3621 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3622 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3623
3624 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3625 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3626 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3627 /* Mic2 (as headphone out) for HP output */
3628 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3629 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3630 /* Internal Speaker */
3631 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3632 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3633
3634 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3635 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3636
3637 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3638 { }
3639};
3640
3641/* toggle speaker-output according to the hp-jack state */
3642static void alc880_medion_rim_automute(struct hda_codec *codec)
3643{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003644 struct alc_spec *spec = codec->spec;
3645 alc_automute_amp(codec);
3646 /* toggle EAPD */
3647 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003648 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3649 else
3650 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3651}
3652
3653static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3654 unsigned int res)
3655{
3656 /* Looks like the unsol event is incompatible with the standard
3657 * definition. 4bit tag is placed at 28 bit!
3658 */
3659 if ((res >> 28) == ALC880_HP_EVENT)
3660 alc880_medion_rim_automute(codec);
3661}
3662
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003663static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003664{
3665 struct alc_spec *spec = codec->spec;
3666
3667 spec->autocfg.hp_pins[0] = 0x14;
3668 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003669}
3670
Takashi Iwaicb53c622007-08-10 17:21:45 +02003671#ifdef CONFIG_SND_HDA_POWER_SAVE
3672static struct hda_amp_list alc880_loopbacks[] = {
3673 { 0x0b, HDA_INPUT, 0 },
3674 { 0x0b, HDA_INPUT, 1 },
3675 { 0x0b, HDA_INPUT, 2 },
3676 { 0x0b, HDA_INPUT, 3 },
3677 { 0x0b, HDA_INPUT, 4 },
3678 { } /* end */
3679};
3680
3681static struct hda_amp_list alc880_lg_loopbacks[] = {
3682 { 0x0b, HDA_INPUT, 1 },
3683 { 0x0b, HDA_INPUT, 6 },
3684 { 0x0b, HDA_INPUT, 7 },
3685 { } /* end */
3686};
3687#endif
3688
Takashi Iwaid6815182006-03-23 16:06:23 +01003689/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003690 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003691 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003692
Linus Torvalds1da177e2005-04-16 15:20:36 -07003693static int alc_init(struct hda_codec *codec)
3694{
3695 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003696 unsigned int i;
3697
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003698 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003699 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003700
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003701 for (i = 0; i < spec->num_init_verbs; i++)
3702 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003703
3704 if (spec->init_hook)
3705 spec->init_hook(codec);
3706
Takashi Iwaiad358792010-03-30 18:00:59 +02003707#ifdef CONFIG_SND_HDA_POWER_SAVE
3708 if (codec->patch_ops.check_power_status)
3709 codec->patch_ops.check_power_status(codec, 0x01);
3710#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003711 return 0;
3712}
3713
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003714static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3715{
3716 struct alc_spec *spec = codec->spec;
3717
3718 if (spec->unsol_event)
3719 spec->unsol_event(codec, res);
3720}
3721
Takashi Iwaicb53c622007-08-10 17:21:45 +02003722#ifdef CONFIG_SND_HDA_POWER_SAVE
3723static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3724{
3725 struct alc_spec *spec = codec->spec;
3726 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3727}
3728#endif
3729
Linus Torvalds1da177e2005-04-16 15:20:36 -07003730/*
3731 * Analog playback callbacks
3732 */
3733static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3734 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003735 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003736{
3737 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003738 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3739 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003740}
3741
3742static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3743 struct hda_codec *codec,
3744 unsigned int stream_tag,
3745 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003746 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003747{
3748 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003749 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3750 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003751}
3752
3753static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3754 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003755 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003756{
3757 struct alc_spec *spec = codec->spec;
3758 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3759}
3760
3761/*
3762 * Digital out
3763 */
3764static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3765 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003766 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003767{
3768 struct alc_spec *spec = codec->spec;
3769 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3770}
3771
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003772static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3773 struct hda_codec *codec,
3774 unsigned int stream_tag,
3775 unsigned int format,
3776 struct snd_pcm_substream *substream)
3777{
3778 struct alc_spec *spec = codec->spec;
3779 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3780 stream_tag, format, substream);
3781}
3782
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003783static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3784 struct hda_codec *codec,
3785 struct snd_pcm_substream *substream)
3786{
3787 struct alc_spec *spec = codec->spec;
3788 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3789}
3790
Linus Torvalds1da177e2005-04-16 15:20:36 -07003791static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3792 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003793 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003794{
3795 struct alc_spec *spec = codec->spec;
3796 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3797}
3798
3799/*
3800 * Analog capture
3801 */
Takashi Iwai63300792008-01-24 15:31:36 +01003802static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003803 struct hda_codec *codec,
3804 unsigned int stream_tag,
3805 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003806 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003807{
3808 struct alc_spec *spec = codec->spec;
3809
Takashi Iwai63300792008-01-24 15:31:36 +01003810 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003811 stream_tag, 0, format);
3812 return 0;
3813}
3814
Takashi Iwai63300792008-01-24 15:31:36 +01003815static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003816 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
Takashi Iwai888afa12008-03-18 09:57:50 +01003821 snd_hda_codec_cleanup_stream(codec,
3822 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003823 return 0;
3824}
3825
Takashi Iwai840b64c2010-07-13 22:49:01 +02003826/* analog capture with dynamic dual-adc changes */
3827static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3828 struct hda_codec *codec,
3829 unsigned int stream_tag,
3830 unsigned int format,
3831 struct snd_pcm_substream *substream)
3832{
3833 struct alc_spec *spec = codec->spec;
3834 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3835 spec->cur_adc_stream_tag = stream_tag;
3836 spec->cur_adc_format = format;
3837 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3838 return 0;
3839}
3840
3841static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3842 struct hda_codec *codec,
3843 struct snd_pcm_substream *substream)
3844{
3845 struct alc_spec *spec = codec->spec;
3846 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
3847 spec->cur_adc = 0;
3848 return 0;
3849}
3850
3851static struct hda_pcm_stream dualmic_pcm_analog_capture = {
3852 .substreams = 1,
3853 .channels_min = 2,
3854 .channels_max = 2,
3855 .nid = 0, /* fill later */
3856 .ops = {
3857 .prepare = dualmic_capture_pcm_prepare,
3858 .cleanup = dualmic_capture_pcm_cleanup
3859 },
3860};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003861
3862/*
3863 */
3864static struct hda_pcm_stream alc880_pcm_analog_playback = {
3865 .substreams = 1,
3866 .channels_min = 2,
3867 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003868 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003869 .ops = {
3870 .open = alc880_playback_pcm_open,
3871 .prepare = alc880_playback_pcm_prepare,
3872 .cleanup = alc880_playback_pcm_cleanup
3873 },
3874};
3875
3876static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003877 .substreams = 1,
3878 .channels_min = 2,
3879 .channels_max = 2,
3880 /* NID is set in alc_build_pcms */
3881};
3882
3883static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3884 .substreams = 1,
3885 .channels_min = 2,
3886 .channels_max = 2,
3887 /* NID is set in alc_build_pcms */
3888};
3889
3890static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3891 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003892 .channels_min = 2,
3893 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003894 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003895 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003896 .prepare = alc880_alt_capture_pcm_prepare,
3897 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003898 },
3899};
3900
3901static struct hda_pcm_stream alc880_pcm_digital_playback = {
3902 .substreams = 1,
3903 .channels_min = 2,
3904 .channels_max = 2,
3905 /* NID is set in alc_build_pcms */
3906 .ops = {
3907 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003908 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003909 .prepare = alc880_dig_playback_pcm_prepare,
3910 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003911 },
3912};
3913
3914static struct hda_pcm_stream alc880_pcm_digital_capture = {
3915 .substreams = 1,
3916 .channels_min = 2,
3917 .channels_max = 2,
3918 /* NID is set in alc_build_pcms */
3919};
3920
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003921/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003922static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003923 .substreams = 0,
3924 .channels_min = 0,
3925 .channels_max = 0,
3926};
3927
Linus Torvalds1da177e2005-04-16 15:20:36 -07003928static int alc_build_pcms(struct hda_codec *codec)
3929{
3930 struct alc_spec *spec = codec->spec;
3931 struct hda_pcm *info = spec->pcm_rec;
3932 int i;
3933
3934 codec->num_pcms = 1;
3935 codec->pcm_info = info;
3936
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003937 if (spec->no_analog)
3938 goto skip_analog;
3939
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003940 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3941 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003942 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003943
Takashi Iwai4a471b72005-12-07 13:56:29 +01003944 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003945 if (snd_BUG_ON(!spec->multiout.dac_nids))
3946 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003947 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3948 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3949 }
3950 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003951 if (snd_BUG_ON(!spec->adc_nids))
3952 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003953 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3954 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3955 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003956
Takashi Iwai4a471b72005-12-07 13:56:29 +01003957 if (spec->channel_mode) {
3958 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3959 for (i = 0; i < spec->num_channel_mode; i++) {
3960 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3961 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3962 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003963 }
3964 }
3965
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003966 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003967 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003968 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003969 snprintf(spec->stream_name_digital,
3970 sizeof(spec->stream_name_digital),
3971 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003972 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003973 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003974 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003975 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01003976 if (spec->dig_out_type)
3977 info->pcm_type = spec->dig_out_type;
3978 else
3979 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003980 if (spec->multiout.dig_out_nid &&
3981 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003982 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
3983 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
3984 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01003985 if (spec->dig_in_nid &&
3986 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003987 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
3988 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
3989 }
Takashi Iwai963f8032008-08-11 10:04:40 +02003990 /* FIXME: do we need this for all Realtek codec models? */
3991 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003992 }
3993
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003994 if (spec->no_analog)
3995 return 0;
3996
Takashi Iwaie08a0072006-09-07 17:52:14 +02003997 /* If the use of more than one ADC is requested for the current
3998 * model, configure a second analog capture-only PCM.
3999 */
4000 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004001 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4002 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004003 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004004 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004005 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004006 if (spec->alt_dac_nid) {
4007 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4008 *spec->stream_analog_alt_playback;
4009 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4010 spec->alt_dac_nid;
4011 } else {
4012 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4013 alc_pcm_null_stream;
4014 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4015 }
4016 if (spec->num_adc_nids > 1) {
4017 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4018 *spec->stream_analog_alt_capture;
4019 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4020 spec->adc_nids[1];
4021 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4022 spec->num_adc_nids - 1;
4023 } else {
4024 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4025 alc_pcm_null_stream;
4026 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004027 }
4028 }
4029
Linus Torvalds1da177e2005-04-16 15:20:36 -07004030 return 0;
4031}
4032
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004033static inline void alc_shutup(struct hda_codec *codec)
4034{
4035 snd_hda_shutup_pins(codec);
4036}
4037
Takashi Iwai603c4012008-07-30 15:01:44 +02004038static void alc_free_kctls(struct hda_codec *codec)
4039{
4040 struct alc_spec *spec = codec->spec;
4041
4042 if (spec->kctls.list) {
4043 struct snd_kcontrol_new *kctl = spec->kctls.list;
4044 int i;
4045 for (i = 0; i < spec->kctls.used; i++)
4046 kfree(kctl[i].name);
4047 }
4048 snd_array_free(&spec->kctls);
4049}
4050
Linus Torvalds1da177e2005-04-16 15:20:36 -07004051static void alc_free(struct hda_codec *codec)
4052{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004053 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004054
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004055 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004056 return;
4057
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004058 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004059 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004060 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004061 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004062}
4063
Hector Martinf5de24b2009-12-20 22:51:31 +01004064#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004065static void alc_power_eapd(struct hda_codec *codec)
4066{
4067 /* We currently only handle front, HP */
4068 switch (codec->vendor_id) {
4069 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004070 set_eapd(codec, 0x0f, 0);
4071 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004072 break;
4073 case 0x10ec0262:
4074 case 0x10ec0267:
4075 case 0x10ec0268:
4076 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004077 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004078 case 0x10ec0272:
4079 case 0x10ec0660:
4080 case 0x10ec0662:
4081 case 0x10ec0663:
4082 case 0x10ec0862:
4083 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004084 set_eapd(codec, 0x14, 0);
4085 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004086 break;
4087 }
4088}
4089
Hector Martinf5de24b2009-12-20 22:51:31 +01004090static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4091{
4092 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004093 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004094 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004095 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004096 return 0;
4097}
4098#endif
4099
Takashi Iwaie044c392008-10-27 16:56:24 +01004100#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004101static int alc_resume(struct hda_codec *codec)
4102{
Takashi Iwaie044c392008-10-27 16:56:24 +01004103 codec->patch_ops.init(codec);
4104 snd_hda_codec_resume_amp(codec);
4105 snd_hda_codec_resume_cache(codec);
Takashi Iwaiad358792010-03-30 18:00:59 +02004106#ifdef CONFIG_SND_HDA_POWER_SAVE
4107 if (codec->patch_ops.check_power_status)
4108 codec->patch_ops.check_power_status(codec, 0x01);
4109#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01004110 return 0;
4111}
Takashi Iwaie044c392008-10-27 16:56:24 +01004112#endif
4113
Linus Torvalds1da177e2005-04-16 15:20:36 -07004114/*
4115 */
4116static struct hda_codec_ops alc_patch_ops = {
4117 .build_controls = alc_build_controls,
4118 .build_pcms = alc_build_pcms,
4119 .init = alc_init,
4120 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004121 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004122#ifdef SND_HDA_NEEDS_RESUME
4123 .resume = alc_resume,
4124#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004125#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004126 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004127 .check_power_status = alc_check_power_status,
4128#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004129 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004130};
4131
Kailang Yangc027ddc2010-03-19 11:33:06 +01004132/* replace the codec chip_name with the given string */
4133static int alc_codec_rename(struct hda_codec *codec, const char *name)
4134{
4135 kfree(codec->chip_name);
4136 codec->chip_name = kstrdup(name, GFP_KERNEL);
4137 if (!codec->chip_name) {
4138 alc_free(codec);
4139 return -ENOMEM;
4140 }
4141 return 0;
4142}
4143
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004144/*
4145 * Test configuration for debugging
4146 *
4147 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4148 * enum controls.
4149 */
4150#ifdef CONFIG_SND_DEBUG
4151static hda_nid_t alc880_test_dac_nids[4] = {
4152 0x02, 0x03, 0x04, 0x05
4153};
4154
4155static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004156 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004157 .items = {
4158 { "In-1", 0x0 },
4159 { "In-2", 0x1 },
4160 { "In-3", 0x2 },
4161 { "In-4", 0x3 },
4162 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004163 { "Front", 0x5 },
4164 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004165 },
4166};
4167
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004168static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004169 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004170 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004171 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004172 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004173};
4174
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004175static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4176 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004177{
4178 static char *texts[] = {
4179 "N/A", "Line Out", "HP Out",
4180 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4181 };
4182 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4183 uinfo->count = 1;
4184 uinfo->value.enumerated.items = 8;
4185 if (uinfo->value.enumerated.item >= 8)
4186 uinfo->value.enumerated.item = 7;
4187 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4188 return 0;
4189}
4190
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004191static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4192 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004193{
4194 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4195 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4196 unsigned int pin_ctl, item = 0;
4197
4198 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4199 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4200 if (pin_ctl & AC_PINCTL_OUT_EN) {
4201 if (pin_ctl & AC_PINCTL_HP_EN)
4202 item = 2;
4203 else
4204 item = 1;
4205 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4206 switch (pin_ctl & AC_PINCTL_VREFEN) {
4207 case AC_PINCTL_VREF_HIZ: item = 3; break;
4208 case AC_PINCTL_VREF_50: item = 4; break;
4209 case AC_PINCTL_VREF_GRD: item = 5; break;
4210 case AC_PINCTL_VREF_80: item = 6; break;
4211 case AC_PINCTL_VREF_100: item = 7; break;
4212 }
4213 }
4214 ucontrol->value.enumerated.item[0] = item;
4215 return 0;
4216}
4217
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004218static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4219 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004220{
4221 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4222 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4223 static unsigned int ctls[] = {
4224 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4225 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4226 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4227 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4228 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4229 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4230 };
4231 unsigned int old_ctl, new_ctl;
4232
4233 old_ctl = snd_hda_codec_read(codec, nid, 0,
4234 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4235 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4236 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004237 int val;
4238 snd_hda_codec_write_cache(codec, nid, 0,
4239 AC_VERB_SET_PIN_WIDGET_CONTROL,
4240 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004241 val = ucontrol->value.enumerated.item[0] >= 3 ?
4242 HDA_AMP_MUTE : 0;
4243 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4244 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004245 return 1;
4246 }
4247 return 0;
4248}
4249
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004250static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4251 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004252{
4253 static char *texts[] = {
4254 "Front", "Surround", "CLFE", "Side"
4255 };
4256 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4257 uinfo->count = 1;
4258 uinfo->value.enumerated.items = 4;
4259 if (uinfo->value.enumerated.item >= 4)
4260 uinfo->value.enumerated.item = 3;
4261 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4262 return 0;
4263}
4264
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004265static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4266 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004267{
4268 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4269 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4270 unsigned int sel;
4271
4272 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4273 ucontrol->value.enumerated.item[0] = sel & 3;
4274 return 0;
4275}
4276
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004277static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4278 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004279{
4280 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4281 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4282 unsigned int sel;
4283
4284 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4285 if (ucontrol->value.enumerated.item[0] != sel) {
4286 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004287 snd_hda_codec_write_cache(codec, nid, 0,
4288 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004289 return 1;
4290 }
4291 return 0;
4292}
4293
4294#define PIN_CTL_TEST(xname,nid) { \
4295 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4296 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004297 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004298 .info = alc_test_pin_ctl_info, \
4299 .get = alc_test_pin_ctl_get, \
4300 .put = alc_test_pin_ctl_put, \
4301 .private_value = nid \
4302 }
4303
4304#define PIN_SRC_TEST(xname,nid) { \
4305 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4306 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004307 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004308 .info = alc_test_pin_src_info, \
4309 .get = alc_test_pin_src_get, \
4310 .put = alc_test_pin_src_put, \
4311 .private_value = nid \
4312 }
4313
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004314static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004315 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4316 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4317 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4318 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004319 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4320 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4321 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4322 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004323 PIN_CTL_TEST("Front Pin Mode", 0x14),
4324 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4325 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4326 PIN_CTL_TEST("Side Pin Mode", 0x17),
4327 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4328 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4329 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4330 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4331 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4332 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4333 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4334 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4335 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4336 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4337 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4338 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4339 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4340 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4341 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4342 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4343 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4344 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004345 {
4346 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4347 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004348 .info = alc_ch_mode_info,
4349 .get = alc_ch_mode_get,
4350 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004351 },
4352 { } /* end */
4353};
4354
4355static struct hda_verb alc880_test_init_verbs[] = {
4356 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004357 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4359 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4361 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4362 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4363 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4364 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004365 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004366 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4367 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4368 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4369 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004370 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004371 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4372 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4373 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4374 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004375 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004376 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4377 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4378 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4379 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004380 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004381 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4382 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004383 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4384 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4385 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004386 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004387 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4388 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4389 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4390 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004391 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004392 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004393 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004394 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004395 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004396 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004397 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004398 /* Analog input/passthru */
4399 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4400 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4401 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4402 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4403 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004404 { }
4405};
4406#endif
4407
Linus Torvalds1da177e2005-04-16 15:20:36 -07004408/*
4409 */
4410
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004411static const char *alc880_models[ALC880_MODEL_LAST] = {
4412 [ALC880_3ST] = "3stack",
4413 [ALC880_TCL_S700] = "tcl",
4414 [ALC880_3ST_DIG] = "3stack-digout",
4415 [ALC880_CLEVO] = "clevo",
4416 [ALC880_5ST] = "5stack",
4417 [ALC880_5ST_DIG] = "5stack-digout",
4418 [ALC880_W810] = "w810",
4419 [ALC880_Z71V] = "z71v",
4420 [ALC880_6ST] = "6stack",
4421 [ALC880_6ST_DIG] = "6stack-digout",
4422 [ALC880_ASUS] = "asus",
4423 [ALC880_ASUS_W1V] = "asus-w1v",
4424 [ALC880_ASUS_DIG] = "asus-dig",
4425 [ALC880_ASUS_DIG2] = "asus-dig2",
4426 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004427 [ALC880_UNIWILL_P53] = "uniwill-p53",
4428 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004429 [ALC880_F1734] = "F1734",
4430 [ALC880_LG] = "lg",
4431 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004432 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004433#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004434 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004435#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004436 [ALC880_AUTO] = "auto",
4437};
4438
4439static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004440 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004441 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4442 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4443 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4444 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4445 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4446 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4447 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4448 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004449 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4450 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004451 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4452 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4453 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4454 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4455 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4456 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4457 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4458 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4459 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4460 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004461 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004462 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4463 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4464 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004465 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004466 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004467 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4468 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004469 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4470 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004471 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4472 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4473 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4474 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004475 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4476 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004477 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004478 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004479 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004480 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004481 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4482 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004483 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004484 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004485 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004486 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004487 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004488 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004489 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004490 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004491 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004492 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4493 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004494 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004495 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4496 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4497 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4498 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004499 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4500 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004501 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004502 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004503 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4504 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004505 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4506 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4507 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004508 /* default Intel */
4509 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004510 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4511 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004512 {}
4513};
4514
Takashi Iwai16ded522005-06-10 19:58:24 +02004515/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004516 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004517 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004518static struct alc_config_preset alc880_presets[] = {
4519 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004520 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004521 .init_verbs = { alc880_volume_init_verbs,
4522 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004523 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004524 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004525 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4526 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004527 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004528 .input_mux = &alc880_capture_source,
4529 },
4530 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004531 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004532 .init_verbs = { alc880_volume_init_verbs,
4533 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004534 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004535 .dac_nids = alc880_dac_nids,
4536 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004537 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4538 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004539 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004540 .input_mux = &alc880_capture_source,
4541 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004542 [ALC880_TCL_S700] = {
4543 .mixers = { alc880_tcl_s700_mixer },
4544 .init_verbs = { alc880_volume_init_verbs,
4545 alc880_pin_tcl_S700_init_verbs,
4546 alc880_gpio2_init_verbs },
4547 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4548 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004549 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4550 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004551 .hp_nid = 0x03,
4552 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4553 .channel_mode = alc880_2_jack_modes,
4554 .input_mux = &alc880_capture_source,
4555 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004556 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004557 .mixers = { alc880_three_stack_mixer,
4558 alc880_five_stack_mixer},
4559 .init_verbs = { alc880_volume_init_verbs,
4560 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004561 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4562 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004563 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4564 .channel_mode = alc880_fivestack_modes,
4565 .input_mux = &alc880_capture_source,
4566 },
4567 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004568 .mixers = { alc880_three_stack_mixer,
4569 alc880_five_stack_mixer },
4570 .init_verbs = { alc880_volume_init_verbs,
4571 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004572 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4573 .dac_nids = alc880_dac_nids,
4574 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004575 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4576 .channel_mode = alc880_fivestack_modes,
4577 .input_mux = &alc880_capture_source,
4578 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004579 [ALC880_6ST] = {
4580 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004581 .init_verbs = { alc880_volume_init_verbs,
4582 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004583 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4584 .dac_nids = alc880_6st_dac_nids,
4585 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4586 .channel_mode = alc880_sixstack_modes,
4587 .input_mux = &alc880_6stack_capture_source,
4588 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004589 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004590 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004591 .init_verbs = { alc880_volume_init_verbs,
4592 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004593 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4594 .dac_nids = alc880_6st_dac_nids,
4595 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004596 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4597 .channel_mode = alc880_sixstack_modes,
4598 .input_mux = &alc880_6stack_capture_source,
4599 },
4600 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004601 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004602 .init_verbs = { alc880_volume_init_verbs,
4603 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004604 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004605 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4606 .dac_nids = alc880_w810_dac_nids,
4607 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004608 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4609 .channel_mode = alc880_w810_modes,
4610 .input_mux = &alc880_capture_source,
4611 },
4612 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004613 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004614 .init_verbs = { alc880_volume_init_verbs,
4615 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004616 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4617 .dac_nids = alc880_z71v_dac_nids,
4618 .dig_out_nid = ALC880_DIGOUT_NID,
4619 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004620 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4621 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004622 .input_mux = &alc880_capture_source,
4623 },
4624 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004625 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004626 .init_verbs = { alc880_volume_init_verbs,
4627 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004628 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4629 .dac_nids = alc880_f1734_dac_nids,
4630 .hp_nid = 0x02,
4631 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4632 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004633 .input_mux = &alc880_f1734_capture_source,
4634 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004635 .setup = alc880_uniwill_p53_setup,
4636 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004637 },
4638 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004639 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004640 .init_verbs = { alc880_volume_init_verbs,
4641 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004642 alc880_gpio1_init_verbs },
4643 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4644 .dac_nids = alc880_asus_dac_nids,
4645 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4646 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004647 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004648 .input_mux = &alc880_capture_source,
4649 },
4650 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004651 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004652 .init_verbs = { alc880_volume_init_verbs,
4653 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004654 alc880_gpio1_init_verbs },
4655 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4656 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004657 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004658 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4659 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004660 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004661 .input_mux = &alc880_capture_source,
4662 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004663 [ALC880_ASUS_DIG2] = {
4664 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004665 .init_verbs = { alc880_volume_init_verbs,
4666 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004667 alc880_gpio2_init_verbs }, /* use GPIO2 */
4668 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4669 .dac_nids = alc880_asus_dac_nids,
4670 .dig_out_nid = ALC880_DIGOUT_NID,
4671 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4672 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004673 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004674 .input_mux = &alc880_capture_source,
4675 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004676 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004677 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004678 .init_verbs = { alc880_volume_init_verbs,
4679 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004680 alc880_gpio1_init_verbs },
4681 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4682 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004683 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004684 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4685 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004686 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004687 .input_mux = &alc880_capture_source,
4688 },
4689 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004690 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004691 .init_verbs = { alc880_volume_init_verbs,
4692 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004693 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4694 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004695 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004696 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4697 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004698 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004699 .input_mux = &alc880_capture_source,
4700 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004701 [ALC880_UNIWILL] = {
4702 .mixers = { alc880_uniwill_mixer },
4703 .init_verbs = { alc880_volume_init_verbs,
4704 alc880_uniwill_init_verbs },
4705 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4706 .dac_nids = alc880_asus_dac_nids,
4707 .dig_out_nid = ALC880_DIGOUT_NID,
4708 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4709 .channel_mode = alc880_threestack_modes,
4710 .need_dac_fix = 1,
4711 .input_mux = &alc880_capture_source,
4712 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004713 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004714 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004715 },
4716 [ALC880_UNIWILL_P53] = {
4717 .mixers = { alc880_uniwill_p53_mixer },
4718 .init_verbs = { alc880_volume_init_verbs,
4719 alc880_uniwill_p53_init_verbs },
4720 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4721 .dac_nids = alc880_asus_dac_nids,
4722 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004723 .channel_mode = alc880_threestack_modes,
4724 .input_mux = &alc880_capture_source,
4725 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004726 .setup = alc880_uniwill_p53_setup,
4727 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004728 },
4729 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004730 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004731 .init_verbs = { alc880_volume_init_verbs,
4732 alc880_uniwill_p53_init_verbs,
4733 alc880_beep_init_verbs },
4734 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4735 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004736 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004737 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4738 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004739 .input_mux = &alc880_capture_source,
4740 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004741 .setup = alc880_uniwill_p53_setup,
4742 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004743 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004744 [ALC880_CLEVO] = {
4745 .mixers = { alc880_three_stack_mixer },
4746 .init_verbs = { alc880_volume_init_verbs,
4747 alc880_pin_clevo_init_verbs },
4748 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4749 .dac_nids = alc880_dac_nids,
4750 .hp_nid = 0x03,
4751 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4752 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004753 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004754 .input_mux = &alc880_capture_source,
4755 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004756 [ALC880_LG] = {
4757 .mixers = { alc880_lg_mixer },
4758 .init_verbs = { alc880_volume_init_verbs,
4759 alc880_lg_init_verbs },
4760 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4761 .dac_nids = alc880_lg_dac_nids,
4762 .dig_out_nid = ALC880_DIGOUT_NID,
4763 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4764 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004765 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004766 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004767 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004768 .setup = alc880_lg_setup,
4769 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004770#ifdef CONFIG_SND_HDA_POWER_SAVE
4771 .loopbacks = alc880_lg_loopbacks,
4772#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004773 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004774 [ALC880_LG_LW] = {
4775 .mixers = { alc880_lg_lw_mixer },
4776 .init_verbs = { alc880_volume_init_verbs,
4777 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004778 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004779 .dac_nids = alc880_dac_nids,
4780 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004781 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4782 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004783 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004784 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004785 .setup = alc880_lg_lw_setup,
4786 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004787 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004788 [ALC880_MEDION_RIM] = {
4789 .mixers = { alc880_medion_rim_mixer },
4790 .init_verbs = { alc880_volume_init_verbs,
4791 alc880_medion_rim_init_verbs,
4792 alc_gpio2_init_verbs },
4793 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4794 .dac_nids = alc880_dac_nids,
4795 .dig_out_nid = ALC880_DIGOUT_NID,
4796 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4797 .channel_mode = alc880_2_jack_modes,
4798 .input_mux = &alc880_medion_rim_capture_source,
4799 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004800 .setup = alc880_medion_rim_setup,
4801 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004802 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004803#ifdef CONFIG_SND_DEBUG
4804 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004805 .mixers = { alc880_test_mixer },
4806 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004807 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4808 .dac_nids = alc880_test_dac_nids,
4809 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004810 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4811 .channel_mode = alc880_test_modes,
4812 .input_mux = &alc880_test_capture_source,
4813 },
4814#endif
4815};
4816
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004817/*
4818 * Automatic parse of I/O pins from the BIOS configuration
4819 */
4820
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004821enum {
4822 ALC_CTL_WIDGET_VOL,
4823 ALC_CTL_WIDGET_MUTE,
4824 ALC_CTL_BIND_MUTE,
4825};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004826static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004827 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4828 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004829 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004830};
4831
4832/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004833static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004834 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004835{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004836 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004837
Takashi Iwai603c4012008-07-30 15:01:44 +02004838 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4839 knew = snd_array_new(&spec->kctls);
4840 if (!knew)
4841 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004842 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004843 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004844 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004845 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004846 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004847 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004848 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004849 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004850 return 0;
4851}
4852
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004853static int add_control_with_pfx(struct alc_spec *spec, int type,
4854 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004855 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004856{
4857 char name[32];
4858 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004859 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004860}
4861
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004862#define add_pb_vol_ctrl(spec, type, pfx, val) \
4863 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
4864#define add_pb_sw_ctrl(spec, type, pfx, val) \
4865 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
4866#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
4867 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
4868#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
4869 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004870
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004871#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4872#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4873#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4874#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004875#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4876#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4877#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4878#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4879#define ALC880_PIN_CD_NID 0x1c
4880
4881/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004882static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4883 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004884{
4885 hda_nid_t nid;
4886 int assigned[4];
4887 int i, j;
4888
4889 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004890 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004891
4892 /* check the pins hardwired to audio widget */
4893 for (i = 0; i < cfg->line_outs; i++) {
4894 nid = cfg->line_out_pins[i];
4895 if (alc880_is_fixed_pin(nid)) {
4896 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004897 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004898 assigned[idx] = 1;
4899 }
4900 }
4901 /* left pins can be connect to any audio widget */
4902 for (i = 0; i < cfg->line_outs; i++) {
4903 nid = cfg->line_out_pins[i];
4904 if (alc880_is_fixed_pin(nid))
4905 continue;
4906 /* search for an empty channel */
4907 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004908 if (!assigned[j]) {
4909 spec->multiout.dac_nids[i] =
4910 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004911 assigned[j] = 1;
4912 break;
4913 }
4914 }
4915 }
4916 spec->multiout.num_dacs = cfg->line_outs;
4917 return 0;
4918}
4919
4920/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004921static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4922 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004923{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004924 static const char *chname[4] = {
4925 "Front", "Surround", NULL /*CLFE*/, "Side"
4926 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004927 hda_nid_t nid;
4928 int i, err;
4929
4930 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004931 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004932 continue;
4933 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4934 if (i == 2) {
4935 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004936 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4937 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004938 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4939 HDA_OUTPUT));
4940 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004941 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004942 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4943 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004944 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4945 HDA_OUTPUT));
4946 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004947 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004948 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4949 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004950 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4951 HDA_INPUT));
4952 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004953 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004954 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4955 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004956 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4957 HDA_INPUT));
4958 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004959 return err;
4960 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004961 const char *pfx;
4962 if (cfg->line_outs == 1 &&
4963 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4964 pfx = "Speaker";
4965 else
4966 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004967 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004968 HDA_COMPOSE_AMP_VAL(nid, 3, 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, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004973 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4974 HDA_INPUT));
4975 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004976 return err;
4977 }
4978 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004979 return 0;
4980}
4981
Takashi Iwai8d88bc32005-11-17 11:09:23 +01004982/* add playback controls for speaker and HP outputs */
4983static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
4984 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004985{
4986 hda_nid_t nid;
4987 int err;
4988
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004989 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004990 return 0;
4991
4992 if (alc880_is_fixed_pin(pin)) {
4993 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01004994 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004995 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004996 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01004997 else
4998 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004999 /* control HP volume/switch on the output mixer amp */
5000 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005001 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005002 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5003 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005004 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005005 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005006 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5007 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005008 return err;
5009 } else if (alc880_is_multi_pin(pin)) {
5010 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005011 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005012 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005013 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5014 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005015 return err;
5016 }
5017 return 0;
5018}
5019
5020/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005021static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005022 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005023 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005024{
Kailang Yangdf694da2005-12-05 19:42:22 +01005025 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005026
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005027 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005028 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5029 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005030 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005031 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005032 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5033 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005034 return err;
5035 return 0;
5036}
5037
Takashi Iwai05f5f472009-08-25 13:10:18 +02005038static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005039{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005040 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5041 return (pincap & AC_PINCAP_IN) != 0;
5042}
5043
5044/* create playback/capture controls for input pins */
5045static int alc_auto_create_input_ctls(struct hda_codec *codec,
5046 const struct auto_pin_cfg *cfg,
5047 hda_nid_t mixer,
5048 hda_nid_t cap1, hda_nid_t cap2)
5049{
5050 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005051 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005052 int i, err, idx, type, type_idx = 0;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005053
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005054 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005055 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005056 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005057
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005058 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005059 if (!alc_is_input_pin(codec, pin))
5060 continue;
5061
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005062 type = cfg->inputs[i].type;
5063 if (i > 0 && type == cfg->inputs[i - 1].type)
5064 type_idx++;
5065 else
5066 type_idx = 0;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005067 label = hda_get_autocfg_input_label(codec, cfg, i);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005068 if (mixer) {
5069 idx = get_connection_index(codec, mixer, pin);
5070 if (idx >= 0) {
5071 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005072 label, type_idx,
5073 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005074 if (err < 0)
5075 return err;
5076 }
5077 }
5078
5079 if (!cap1)
5080 continue;
5081 idx = get_connection_index(codec, cap1, pin);
5082 if (idx < 0 && cap2)
5083 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005084 if (idx >= 0)
5085 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005086 }
5087 return 0;
5088}
5089
Takashi Iwai05f5f472009-08-25 13:10:18 +02005090static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5091 const struct auto_pin_cfg *cfg)
5092{
5093 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5094}
5095
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005096static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5097 unsigned int pin_type)
5098{
5099 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5100 pin_type);
5101 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005102 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5103 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005104}
5105
Kailang Yangdf694da2005-12-05 19:42:22 +01005106static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5107 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005108 int dac_idx)
5109{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005110 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005111 /* need the manual connection? */
5112 if (alc880_is_multi_pin(nid)) {
5113 struct alc_spec *spec = codec->spec;
5114 int idx = alc880_multi_pin_idx(nid);
5115 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5116 AC_VERB_SET_CONNECT_SEL,
5117 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5118 }
5119}
5120
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005121static int get_pin_type(int line_out_type)
5122{
5123 if (line_out_type == AUTO_PIN_HP_OUT)
5124 return PIN_HP;
5125 else
5126 return PIN_OUT;
5127}
5128
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005129static void alc880_auto_init_multi_out(struct hda_codec *codec)
5130{
5131 struct alc_spec *spec = codec->spec;
5132 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005133
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005134 for (i = 0; i < spec->autocfg.line_outs; i++) {
5135 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005136 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5137 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005138 }
5139}
5140
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005141static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005142{
5143 struct alc_spec *spec = codec->spec;
5144 hda_nid_t pin;
5145
Takashi Iwai82bc9552006-03-21 11:24:42 +01005146 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005147 if (pin) /* connect to front */
5148 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005149 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005150 if (pin) /* connect to front */
5151 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5152}
5153
5154static void alc880_auto_init_analog_input(struct hda_codec *codec)
5155{
5156 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005157 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005158 int i;
5159
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005160 for (i = 0; i < cfg->num_inputs; i++) {
5161 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005162 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005163 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005164 if (nid != ALC880_PIN_CD_NID &&
5165 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005166 snd_hda_codec_write(codec, nid, 0,
5167 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005168 AMP_OUT_MUTE);
5169 }
5170 }
5171}
5172
Takashi Iwai7f311a42010-04-09 17:32:23 +02005173static void alc880_auto_init_input_src(struct hda_codec *codec)
5174{
5175 struct alc_spec *spec = codec->spec;
5176 int c;
5177
5178 for (c = 0; c < spec->num_adc_nids; c++) {
5179 unsigned int mux_idx;
5180 const struct hda_input_mux *imux;
5181 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5182 imux = &spec->input_mux[mux_idx];
5183 if (!imux->num_items && mux_idx > 0)
5184 imux = &spec->input_mux[0];
5185 if (imux)
5186 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5187 AC_VERB_SET_CONNECT_SEL,
5188 imux->items[0].index);
5189 }
5190}
5191
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005192/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005193/* return 1 if successful, 0 if the proper config is not found,
5194 * or a negative error code
5195 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005196static int alc880_parse_auto_config(struct hda_codec *codec)
5197{
5198 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005199 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005200 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005201
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005202 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5203 alc880_ignore);
5204 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005205 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005206 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005207 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005208
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005209 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5210 if (err < 0)
5211 return err;
5212 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5213 if (err < 0)
5214 return err;
5215 err = alc880_auto_create_extra_out(spec,
5216 spec->autocfg.speaker_pins[0],
5217 "Speaker");
5218 if (err < 0)
5219 return err;
5220 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5221 "Headphone");
5222 if (err < 0)
5223 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005224 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005225 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005226 return err;
5227
5228 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5229
Takashi Iwai757899a2010-07-30 10:48:14 +02005230 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005231
Takashi Iwai603c4012008-07-30 15:01:44 +02005232 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005233 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005234
Takashi Iwaid88897e2008-10-31 15:01:37 +01005235 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005236
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005237 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005238 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005239
Kailang Yang6227cdc2010-02-25 08:36:52 +01005240 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005241
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005242 return 1;
5243}
5244
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005245/* additional initialization for auto-configuration model */
5246static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005247{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005248 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005249 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005250 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005251 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005252 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005253 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005254 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005255 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005256}
5257
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005258/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5259 * one of two digital mic pins, e.g. on ALC272
5260 */
5261static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005262{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005263 struct alc_spec *spec = codec->spec;
5264 int i;
5265
5266 for (i = 0; i < spec->num_adc_nids; i++) {
5267 hda_nid_t cap = spec->capsrc_nids ?
5268 spec->capsrc_nids[i] : spec->adc_nids[i];
5269 int iidx, eidx;
5270
5271 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5272 if (iidx < 0)
5273 continue;
5274 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5275 if (eidx < 0)
5276 continue;
5277 spec->int_mic.mux_idx = iidx;
5278 spec->ext_mic.mux_idx = eidx;
5279 if (spec->capsrc_nids)
5280 spec->capsrc_nids += i;
5281 spec->adc_nids += i;
5282 spec->num_adc_nids = 1;
5283 return;
5284 }
5285 snd_printd(KERN_INFO "hda_codec: %s: "
5286 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5287 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5288 spec->auto_mic = 0; /* disable auto-mic to be sure */
5289}
5290
Takashi Iwai748cce42010-08-04 07:37:39 +02005291/* select or unmute the given capsrc route */
5292static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5293 int idx)
5294{
5295 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5296 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5297 HDA_AMP_MUTE, 0);
5298 } else {
5299 snd_hda_codec_write_cache(codec, cap, 0,
5300 AC_VERB_SET_CONNECT_SEL, idx);
5301 }
5302}
5303
Takashi Iwai840b64c2010-07-13 22:49:01 +02005304/* set the default connection to that pin */
5305static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5306{
5307 struct alc_spec *spec = codec->spec;
5308 int i;
5309
5310 for (i = 0; i < spec->num_adc_nids; i++) {
5311 hda_nid_t cap = spec->capsrc_nids ?
5312 spec->capsrc_nids[i] : spec->adc_nids[i];
5313 int idx;
5314
5315 idx = get_connection_index(codec, cap, pin);
5316 if (idx < 0)
5317 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005318 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005319 return i; /* return the found index */
5320 }
5321 return -1; /* not found */
5322}
5323
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005324/* choose the ADC/MUX containing the input pin and initialize the setup */
5325static void fixup_single_adc(struct hda_codec *codec)
5326{
5327 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005328 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005329 int i;
5330
5331 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005332 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005333 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005334 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005335 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005336 /* use only this ADC */
5337 if (spec->capsrc_nids)
5338 spec->capsrc_nids += i;
5339 spec->adc_nids += i;
5340 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005341 }
5342}
5343
Takashi Iwai840b64c2010-07-13 22:49:01 +02005344/* initialize dual adcs */
5345static void fixup_dual_adc_switch(struct hda_codec *codec)
5346{
5347 struct alc_spec *spec = codec->spec;
5348 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5349 init_capsrc_for_pin(codec, spec->int_mic.pin);
5350}
5351
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005352static void set_capture_mixer(struct hda_codec *codec)
5353{
5354 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005355 static struct snd_kcontrol_new *caps[2][3] = {
5356 { alc_capture_mixer_nosrc1,
5357 alc_capture_mixer_nosrc2,
5358 alc_capture_mixer_nosrc3 },
5359 { alc_capture_mixer1,
5360 alc_capture_mixer2,
5361 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005362 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005363 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005364 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005365 int num_adcs = spec->num_adc_nids;
5366 if (spec->dual_adc_switch)
5367 fixup_dual_adc_switch(codec);
5368 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005369 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005370 else if (spec->input_mux) {
5371 if (spec->input_mux->num_items > 1)
5372 mux = 1;
5373 else if (spec->input_mux->num_items == 1)
5374 fixup_single_adc(codec);
5375 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005376 if (spec->dual_adc_switch)
5377 num_adcs = 1;
5378 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005379 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005380}
5381
Takashi Iwai66946352010-03-29 17:21:45 +02005382/* fill adc_nids (and capsrc_nids) containing all active input pins */
5383static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5384 int num_nids)
5385{
5386 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005387 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005388 int n;
5389 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5390
5391 for (n = 0; n < num_nids; n++) {
5392 hda_nid_t adc, cap;
5393 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5394 int nconns, i, j;
5395
5396 adc = nids[n];
5397 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5398 continue;
5399 cap = adc;
5400 nconns = snd_hda_get_connections(codec, cap, conn,
5401 ARRAY_SIZE(conn));
5402 if (nconns == 1) {
5403 cap = conn[0];
5404 nconns = snd_hda_get_connections(codec, cap, conn,
5405 ARRAY_SIZE(conn));
5406 }
5407 if (nconns <= 0)
5408 continue;
5409 if (!fallback_adc) {
5410 fallback_adc = adc;
5411 fallback_cap = cap;
5412 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005413 for (i = 0; i < cfg->num_inputs; i++) {
5414 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005415 for (j = 0; j < nconns; j++) {
5416 if (conn[j] == nid)
5417 break;
5418 }
5419 if (j >= nconns)
5420 break;
5421 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005422 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005423 int num_adcs = spec->num_adc_nids;
5424 spec->private_adc_nids[num_adcs] = adc;
5425 spec->private_capsrc_nids[num_adcs] = cap;
5426 spec->num_adc_nids++;
5427 spec->adc_nids = spec->private_adc_nids;
5428 if (adc != cap)
5429 spec->capsrc_nids = spec->private_capsrc_nids;
5430 }
5431 }
5432 if (!spec->num_adc_nids) {
5433 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005434 " using fallback 0x%x\n",
5435 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005436 spec->private_adc_nids[0] = fallback_adc;
5437 spec->adc_nids = spec->private_adc_nids;
5438 if (fallback_adc != fallback_cap) {
5439 spec->private_capsrc_nids[0] = fallback_cap;
5440 spec->capsrc_nids = spec->private_adc_nids;
5441 }
5442 }
5443}
5444
Takashi Iwai67d634c2009-11-16 15:35:59 +01005445#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005446#define set_beep_amp(spec, nid, idx, dir) \
5447 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005448
5449static struct snd_pci_quirk beep_white_list[] = {
5450 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005451 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005452 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005453 {}
5454};
5455
5456static inline int has_cdefine_beep(struct hda_codec *codec)
5457{
5458 struct alc_spec *spec = codec->spec;
5459 const struct snd_pci_quirk *q;
5460 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5461 if (q)
5462 return q->value;
5463 return spec->cdefine.enable_pcbeep;
5464}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005465#else
5466#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005467#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005468#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005469
5470/*
5471 * OK, here we have finally the patch for ALC880
5472 */
5473
Linus Torvalds1da177e2005-04-16 15:20:36 -07005474static int patch_alc880(struct hda_codec *codec)
5475{
5476 struct alc_spec *spec;
5477 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005478 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005479
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005480 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005481 if (spec == NULL)
5482 return -ENOMEM;
5483
5484 codec->spec = spec;
5485
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005486 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5487 alc880_models,
5488 alc880_cfg_tbl);
5489 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005490 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5491 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005492 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005493 }
5494
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005495 if (board_config == ALC880_AUTO) {
5496 /* automatic parse from the BIOS config */
5497 err = alc880_parse_auto_config(codec);
5498 if (err < 0) {
5499 alc_free(codec);
5500 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005501 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005502 printk(KERN_INFO
5503 "hda_codec: Cannot set up configuration "
5504 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005505 board_config = ALC880_3ST;
5506 }
5507 }
5508
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005509 err = snd_hda_attach_beep_device(codec, 0x1);
5510 if (err < 0) {
5511 alc_free(codec);
5512 return err;
5513 }
5514
Kailang Yangdf694da2005-12-05 19:42:22 +01005515 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005516 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005517
Linus Torvalds1da177e2005-04-16 15:20:36 -07005518 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5519 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005520 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005521
Linus Torvalds1da177e2005-04-16 15:20:36 -07005522 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5523 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5524
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005525 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005526 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005527 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005528 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005529 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005530 if (wcap != AC_WID_AUD_IN) {
5531 spec->adc_nids = alc880_adc_nids_alt;
5532 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005533 } else {
5534 spec->adc_nids = alc880_adc_nids;
5535 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005536 }
5537 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005538 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005539 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005540
Takashi Iwai2134ea42008-01-10 16:53:55 +01005541 spec->vmaster_nid = 0x0c;
5542
Linus Torvalds1da177e2005-04-16 15:20:36 -07005543 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005544 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005545 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005546#ifdef CONFIG_SND_HDA_POWER_SAVE
5547 if (!spec->loopback.amplist)
5548 spec->loopback.amplist = alc880_loopbacks;
5549#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005550
5551 return 0;
5552}
5553
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005554
Linus Torvalds1da177e2005-04-16 15:20:36 -07005555/*
5556 * ALC260 support
5557 */
5558
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005559static hda_nid_t alc260_dac_nids[1] = {
5560 /* front */
5561 0x02,
5562};
5563
5564static hda_nid_t alc260_adc_nids[1] = {
5565 /* ADC0 */
5566 0x04,
5567};
5568
Kailang Yangdf694da2005-12-05 19:42:22 +01005569static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005570 /* ADC1 */
5571 0x05,
5572};
5573
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005574/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5575 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5576 */
5577static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005578 /* ADC0, ADC1 */
5579 0x04, 0x05
5580};
5581
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005582#define ALC260_DIGOUT_NID 0x03
5583#define ALC260_DIGIN_NID 0x06
5584
5585static struct hda_input_mux alc260_capture_source = {
5586 .num_items = 4,
5587 .items = {
5588 { "Mic", 0x0 },
5589 { "Front Mic", 0x1 },
5590 { "Line", 0x2 },
5591 { "CD", 0x4 },
5592 },
5593};
5594
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005595/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005596 * headphone jack and the internal CD lines since these are the only pins at
5597 * which audio can appear. For flexibility, also allow the option of
5598 * recording the mixer output on the second ADC (ADC0 doesn't have a
5599 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005600 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005601static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5602 {
5603 .num_items = 3,
5604 .items = {
5605 { "Mic/Line", 0x0 },
5606 { "CD", 0x4 },
5607 { "Headphone", 0x2 },
5608 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005609 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005610 {
5611 .num_items = 4,
5612 .items = {
5613 { "Mic/Line", 0x0 },
5614 { "CD", 0x4 },
5615 { "Headphone", 0x2 },
5616 { "Mixer", 0x5 },
5617 },
5618 },
5619
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005620};
5621
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005622/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5623 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005624 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005625static struct hda_input_mux alc260_acer_capture_sources[2] = {
5626 {
5627 .num_items = 4,
5628 .items = {
5629 { "Mic", 0x0 },
5630 { "Line", 0x2 },
5631 { "CD", 0x4 },
5632 { "Headphone", 0x5 },
5633 },
5634 },
5635 {
5636 .num_items = 5,
5637 .items = {
5638 { "Mic", 0x0 },
5639 { "Line", 0x2 },
5640 { "CD", 0x4 },
5641 { "Headphone", 0x6 },
5642 { "Mixer", 0x5 },
5643 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005644 },
5645};
Michael Schwingencc959482009-02-22 18:58:45 +01005646
5647/* Maxdata Favorit 100XS */
5648static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5649 {
5650 .num_items = 2,
5651 .items = {
5652 { "Line/Mic", 0x0 },
5653 { "CD", 0x4 },
5654 },
5655 },
5656 {
5657 .num_items = 3,
5658 .items = {
5659 { "Line/Mic", 0x0 },
5660 { "CD", 0x4 },
5661 { "Mixer", 0x5 },
5662 },
5663 },
5664};
5665
Linus Torvalds1da177e2005-04-16 15:20:36 -07005666/*
5667 * This is just place-holder, so there's something for alc_build_pcms to look
5668 * at when it calculates the maximum number of channels. ALC260 has no mixer
5669 * element which allows changing the channel mode, so the verb list is
5670 * never used.
5671 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005672static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005673 { 2, NULL },
5674};
5675
Kailang Yangdf694da2005-12-05 19:42:22 +01005676
5677/* Mixer combinations
5678 *
5679 * basic: base_output + input + pc_beep + capture
5680 * HP: base_output + input + capture_alt
5681 * HP_3013: hp_3013 + input + capture
5682 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005683 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005684 */
5685
5686static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005687 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005688 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005689 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5690 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5691 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5692 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5693 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005694};
Kailang Yangdf694da2005-12-05 19:42:22 +01005695
5696static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005697 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5698 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5699 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5700 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5701 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5702 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5703 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5704 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005705 { } /* end */
5706};
5707
Takashi Iwaibec15c32008-01-28 18:16:30 +01005708/* update HP, line and mono out pins according to the master switch */
5709static void alc260_hp_master_update(struct hda_codec *codec,
5710 hda_nid_t hp, hda_nid_t line,
5711 hda_nid_t mono)
5712{
5713 struct alc_spec *spec = codec->spec;
5714 unsigned int val = spec->master_sw ? PIN_HP : 0;
5715 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005716 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005717 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005718 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005719 val);
5720 /* mono (speaker) depending on the HP jack sense */
5721 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005722 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005723 val);
5724}
5725
5726static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5727 struct snd_ctl_elem_value *ucontrol)
5728{
5729 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5730 struct alc_spec *spec = codec->spec;
5731 *ucontrol->value.integer.value = spec->master_sw;
5732 return 0;
5733}
5734
5735static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5736 struct snd_ctl_elem_value *ucontrol)
5737{
5738 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5739 struct alc_spec *spec = codec->spec;
5740 int val = !!*ucontrol->value.integer.value;
5741 hda_nid_t hp, line, mono;
5742
5743 if (val == spec->master_sw)
5744 return 0;
5745 spec->master_sw = val;
5746 hp = (kcontrol->private_value >> 16) & 0xff;
5747 line = (kcontrol->private_value >> 8) & 0xff;
5748 mono = kcontrol->private_value & 0xff;
5749 alc260_hp_master_update(codec, hp, line, mono);
5750 return 1;
5751}
5752
5753static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5754 {
5755 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5756 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005757 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005758 .info = snd_ctl_boolean_mono_info,
5759 .get = alc260_hp_master_sw_get,
5760 .put = alc260_hp_master_sw_put,
5761 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5762 },
5763 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5764 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5765 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5766 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5767 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5768 HDA_OUTPUT),
5769 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5770 { } /* end */
5771};
5772
5773static struct hda_verb alc260_hp_unsol_verbs[] = {
5774 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5775 {},
5776};
5777
5778static void alc260_hp_automute(struct hda_codec *codec)
5779{
5780 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005781
Wu Fengguang864f92b2009-11-18 12:38:02 +08005782 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005783 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5784}
5785
5786static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5787{
5788 if ((res >> 26) == ALC880_HP_EVENT)
5789 alc260_hp_automute(codec);
5790}
5791
Kailang Yangdf694da2005-12-05 19:42:22 +01005792static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005793 {
5794 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5795 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005796 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005797 .info = snd_ctl_boolean_mono_info,
5798 .get = alc260_hp_master_sw_get,
5799 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005800 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005801 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005802 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5803 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5804 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5805 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5806 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5807 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005808 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5809 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005810 { } /* end */
5811};
5812
Kailang Yang3f878302008-08-26 13:02:23 +02005813static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5814 .ops = &snd_hda_bind_vol,
5815 .values = {
5816 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5817 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5818 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5819 0
5820 },
5821};
5822
5823static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5824 .ops = &snd_hda_bind_sw,
5825 .values = {
5826 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5827 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5828 0
5829 },
5830};
5831
5832static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5833 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5834 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5835 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5837 { } /* end */
5838};
5839
Takashi Iwaibec15c32008-01-28 18:16:30 +01005840static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5841 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5842 {},
5843};
5844
5845static void alc260_hp_3013_automute(struct hda_codec *codec)
5846{
5847 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005848
Wu Fengguang864f92b2009-11-18 12:38:02 +08005849 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005850 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005851}
5852
5853static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5854 unsigned int res)
5855{
5856 if ((res >> 26) == ALC880_HP_EVENT)
5857 alc260_hp_3013_automute(codec);
5858}
5859
Kailang Yang3f878302008-08-26 13:02:23 +02005860static void alc260_hp_3012_automute(struct hda_codec *codec)
5861{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005862 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005863
Kailang Yang3f878302008-08-26 13:02:23 +02005864 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5865 bits);
5866 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5867 bits);
5868 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5869 bits);
5870}
5871
5872static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5873 unsigned int res)
5874{
5875 if ((res >> 26) == ALC880_HP_EVENT)
5876 alc260_hp_3012_automute(codec);
5877}
5878
5879/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005880 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5881 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005882static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005883 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005884 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005885 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005886 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5887 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5888 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5889 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005890 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005891 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5892 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005893 { } /* end */
5894};
5895
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005896/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5897 * versions of the ALC260 don't act on requests to enable mic bias from NID
5898 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5899 * datasheet doesn't mention this restriction. At this stage it's not clear
5900 * whether this behaviour is intentional or is a hardware bug in chip
5901 * revisions available in early 2006. Therefore for now allow the
5902 * "Headphone Jack Mode" control to span all choices, but if it turns out
5903 * that the lack of mic bias for this NID is intentional we could change the
5904 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5905 *
5906 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5907 * don't appear to make the mic bias available from the "line" jack, even
5908 * though the NID used for this jack (0x14) can supply it. The theory is
5909 * that perhaps Acer have included blocking capacitors between the ALC260
5910 * and the output jack. If this turns out to be the case for all such
5911 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5912 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005913 *
5914 * The C20x Tablet series have a mono internal speaker which is controlled
5915 * via the chip's Mono sum widget and pin complex, so include the necessary
5916 * controls for such models. On models without a "mono speaker" the control
5917 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005918 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005919static struct snd_kcontrol_new alc260_acer_mixer[] = {
5920 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5921 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005922 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005923 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005924 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005925 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005926 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005927 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5928 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5929 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5930 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5931 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5932 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5933 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5934 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005935 { } /* end */
5936};
5937
Michael Schwingencc959482009-02-22 18:58:45 +01005938/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5939 */
5940static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5941 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5942 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5943 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5944 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5945 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5946 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5947 { } /* end */
5948};
5949
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005950/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5951 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5952 */
5953static struct snd_kcontrol_new alc260_will_mixer[] = {
5954 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5955 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5957 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5958 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5959 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5960 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5961 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5962 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5963 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005964 { } /* end */
5965};
5966
5967/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5968 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5969 */
5970static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5971 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5972 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5974 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5975 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5976 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
5977 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
5978 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5979 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5980 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5981 { } /* end */
5982};
5983
Kailang Yangdf694da2005-12-05 19:42:22 +01005984/*
5985 * initialization verbs
5986 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07005987static struct hda_verb alc260_init_verbs[] = {
5988 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005989 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005990 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02005991 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005992 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005993 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005994 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02005995 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005996 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02005997 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07005998 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01005999 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006000 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006001 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006002 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006003 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006004 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006005 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6006 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006007 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006008 /* set connection select to line in (default select for this ADC) */
6009 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006010 /* mute capture amp left and right */
6011 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6012 /* set connection select to line in (default select for this ADC) */
6013 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006014 /* set vol=0 Line-Out mixer amp left and right */
6015 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6016 /* unmute pin widget amp left and right (no gain on this amp) */
6017 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6018 /* set vol=0 HP mixer amp left and right */
6019 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6020 /* unmute pin widget amp left and right (no gain on this amp) */
6021 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6022 /* set vol=0 Mono mixer amp left and right */
6023 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6024 /* unmute pin widget amp left and right (no gain on this amp) */
6025 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6026 /* unmute LINE-2 out pin */
6027 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006028 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6029 * Line In 2 = 0x03
6030 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006031 /* mute analog inputs */
6032 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6033 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6034 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6035 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6036 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006037 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006038 /* mute Front out path */
6039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6040 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6041 /* mute Headphone out path */
6042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6043 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6044 /* mute Mono out path */
6045 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6046 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006047 { }
6048};
6049
Takashi Iwai474167d2006-05-17 17:17:43 +02006050#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006051static struct hda_verb alc260_hp_init_verbs[] = {
6052 /* Headphone and output */
6053 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6054 /* mono output */
6055 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6056 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6057 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6058 /* Mic2 (front panel) pin widget for input and vref at 80% */
6059 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6060 /* Line In pin widget for input */
6061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6062 /* Line-2 pin widget for output */
6063 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6064 /* CD pin widget for input */
6065 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6066 /* unmute amp left and right */
6067 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6068 /* set connection select to line in (default select for this ADC) */
6069 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6070 /* unmute Line-Out mixer amp left and right (volume = 0) */
6071 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6072 /* mute pin widget amp left and right (no gain on this amp) */
6073 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6074 /* unmute HP mixer amp left and right (volume = 0) */
6075 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6076 /* mute pin widget amp left and right (no gain on this amp) */
6077 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006078 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6079 * Line In 2 = 0x03
6080 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006081 /* mute analog inputs */
6082 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6083 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6086 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006087 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6088 /* Unmute Front out path */
6089 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6090 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6091 /* Unmute Headphone out path */
6092 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6093 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6094 /* Unmute Mono out path */
6095 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6096 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6097 { }
6098};
Takashi Iwai474167d2006-05-17 17:17:43 +02006099#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006100
6101static struct hda_verb alc260_hp_3013_init_verbs[] = {
6102 /* Line out and output */
6103 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6104 /* mono output */
6105 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6106 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6107 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6108 /* Mic2 (front panel) pin widget for input and vref at 80% */
6109 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6110 /* Line In pin widget for input */
6111 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6112 /* Headphone pin widget for output */
6113 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6114 /* CD pin widget for input */
6115 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6116 /* unmute amp left and right */
6117 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6118 /* set connection select to line in (default select for this ADC) */
6119 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6120 /* unmute Line-Out mixer amp left and right (volume = 0) */
6121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6122 /* mute pin widget amp left and right (no gain on this amp) */
6123 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6124 /* unmute HP mixer amp left and right (volume = 0) */
6125 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6126 /* mute pin widget amp left and right (no gain on this amp) */
6127 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006128 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6129 * Line In 2 = 0x03
6130 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006131 /* mute analog inputs */
6132 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6133 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6134 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6135 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6136 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006137 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6138 /* Unmute Front out path */
6139 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6140 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6141 /* Unmute Headphone out path */
6142 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6143 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6144 /* Unmute Mono out path */
6145 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6146 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6147 { }
6148};
6149
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006150/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006151 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6152 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006153 */
6154static struct hda_verb alc260_fujitsu_init_verbs[] = {
6155 /* Disable all GPIOs */
6156 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6157 /* Internal speaker is connected to headphone pin */
6158 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6159 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6160 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006161 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6162 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6163 /* Ensure all other unused pins are disabled and muted. */
6164 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6165 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006166 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006167 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006168 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006169 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6170 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6171 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006172
Jonathan Woithef7ace402006-02-28 11:46:14 +01006173 /* Disable digital (SPDIF) pins */
6174 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6175 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006176
Kailang Yangea1fb292008-08-26 12:58:38 +02006177 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006178 * when acting as an output.
6179 */
6180 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6181
6182 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006183 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6184 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6185 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6186 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6187 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6188 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6189 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6190 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6191 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006192
Jonathan Woithef7ace402006-02-28 11:46:14 +01006193 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6194 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6195 /* Unmute Line1 pin widget output buffer since it starts as an output.
6196 * If the pin mode is changed by the user the pin mode control will
6197 * take care of enabling the pin's input/output buffers as needed.
6198 * Therefore there's no need to enable the input buffer at this
6199 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006200 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006201 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006202 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006203 * mixer ctrl)
6204 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006205 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006206
Jonathan Woithef7ace402006-02-28 11:46:14 +01006207 /* Mute capture amp left and right */
6208 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006209 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006210 * in (on mic1 pin)
6211 */
6212 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006213
Jonathan Woithef7ace402006-02-28 11:46:14 +01006214 /* Do the same for the second ADC: mute capture input amp and
6215 * set ADC connection to line in (on mic1 pin)
6216 */
6217 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6218 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006219
Jonathan Woithef7ace402006-02-28 11:46:14 +01006220 /* Mute all inputs to mixer widget (even unconnected ones) */
6221 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6222 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6223 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6224 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6225 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6226 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6227 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6228 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006229
6230 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006231};
6232
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006233/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6234 * similar laptops (adapted from Fujitsu init verbs).
6235 */
6236static struct hda_verb alc260_acer_init_verbs[] = {
6237 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6238 * the headphone jack. Turn this on and rely on the standard mute
6239 * methods whenever the user wants to turn these outputs off.
6240 */
6241 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6242 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6243 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6244 /* Internal speaker/Headphone jack is connected to Line-out pin */
6245 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6246 /* Internal microphone/Mic jack is connected to Mic1 pin */
6247 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6248 /* Line In jack is connected to Line1 pin */
6249 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006250 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6251 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006252 /* Ensure all other unused pins are disabled and muted. */
6253 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6254 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006255 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6256 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6257 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6258 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6259 /* Disable digital (SPDIF) pins */
6260 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6261 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6262
Kailang Yangea1fb292008-08-26 12:58:38 +02006263 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006264 * bus when acting as outputs.
6265 */
6266 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6267 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6268
6269 /* Start with output sum widgets muted and their output gains at min */
6270 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6271 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6272 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6273 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6274 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6275 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6276 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6277 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6278 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6279
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006280 /* Unmute Line-out pin widget amp left and right
6281 * (no equiv mixer ctrl)
6282 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006283 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006284 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6285 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006286 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6287 * inputs. If the pin mode is changed by the user the pin mode control
6288 * will take care of enabling the pin's input/output buffers as needed.
6289 * Therefore there's no need to enable the input buffer at this
6290 * stage.
6291 */
6292 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6293 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6294
6295 /* Mute capture amp left and right */
6296 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6297 /* Set ADC connection select to match default mixer setting - mic
6298 * (on mic1 pin)
6299 */
6300 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6301
6302 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006303 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006304 */
6305 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006306 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006307
6308 /* Mute all inputs to mixer widget (even unconnected ones) */
6309 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6310 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6311 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6312 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6314 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6315 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6316 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6317
6318 { }
6319};
6320
Michael Schwingencc959482009-02-22 18:58:45 +01006321/* Initialisation sequence for Maxdata Favorit 100XS
6322 * (adapted from Acer init verbs).
6323 */
6324static struct hda_verb alc260_favorit100_init_verbs[] = {
6325 /* GPIO 0 enables the output jack.
6326 * Turn this on and rely on the standard mute
6327 * methods whenever the user wants to turn these outputs off.
6328 */
6329 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6330 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6331 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6332 /* Line/Mic input jack is connected to Mic1 pin */
6333 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6334 /* Ensure all other unused pins are disabled and muted. */
6335 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6336 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6337 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6338 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6339 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6340 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6341 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6342 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6343 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6344 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6345 /* Disable digital (SPDIF) pins */
6346 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6347 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6348
6349 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6350 * bus when acting as outputs.
6351 */
6352 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6353 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6354
6355 /* Start with output sum widgets muted and their output gains at min */
6356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6357 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6358 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6359 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6360 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6361 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6362 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6363 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6364 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6365
6366 /* Unmute Line-out pin widget amp left and right
6367 * (no equiv mixer ctrl)
6368 */
6369 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6370 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6371 * inputs. If the pin mode is changed by the user the pin mode control
6372 * will take care of enabling the pin's input/output buffers as needed.
6373 * Therefore there's no need to enable the input buffer at this
6374 * stage.
6375 */
6376 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6377
6378 /* Mute capture amp left and right */
6379 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6380 /* Set ADC connection select to match default mixer setting - mic
6381 * (on mic1 pin)
6382 */
6383 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6384
6385 /* Do similar with the second ADC: mute capture input amp and
6386 * set ADC connection to mic to match ALSA's default state.
6387 */
6388 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6389 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6390
6391 /* Mute all inputs to mixer widget (even unconnected ones) */
6392 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6393 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6394 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6395 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6396 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6397 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6398 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6399 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6400
6401 { }
6402};
6403
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006404static struct hda_verb alc260_will_verbs[] = {
6405 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6406 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6407 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6408 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6409 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6410 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6411 {}
6412};
6413
6414static struct hda_verb alc260_replacer_672v_verbs[] = {
6415 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6416 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6417 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6418
6419 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6420 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6421 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6422
6423 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6424 {}
6425};
6426
6427/* toggle speaker-output according to the hp-jack state */
6428static void alc260_replacer_672v_automute(struct hda_codec *codec)
6429{
6430 unsigned int present;
6431
6432 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006433 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006434 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006435 snd_hda_codec_write_cache(codec, 0x01, 0,
6436 AC_VERB_SET_GPIO_DATA, 1);
6437 snd_hda_codec_write_cache(codec, 0x0f, 0,
6438 AC_VERB_SET_PIN_WIDGET_CONTROL,
6439 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006440 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006441 snd_hda_codec_write_cache(codec, 0x01, 0,
6442 AC_VERB_SET_GPIO_DATA, 0);
6443 snd_hda_codec_write_cache(codec, 0x0f, 0,
6444 AC_VERB_SET_PIN_WIDGET_CONTROL,
6445 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006446 }
6447}
6448
6449static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6450 unsigned int res)
6451{
6452 if ((res >> 26) == ALC880_HP_EVENT)
6453 alc260_replacer_672v_automute(codec);
6454}
6455
Kailang Yang3f878302008-08-26 13:02:23 +02006456static struct hda_verb alc260_hp_dc7600_verbs[] = {
6457 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6458 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6459 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6460 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6461 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6462 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6463 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6464 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6465 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6466 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6467 {}
6468};
6469
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006470/* Test configuration for debugging, modelled after the ALC880 test
6471 * configuration.
6472 */
6473#ifdef CONFIG_SND_DEBUG
6474static hda_nid_t alc260_test_dac_nids[1] = {
6475 0x02,
6476};
6477static hda_nid_t alc260_test_adc_nids[2] = {
6478 0x04, 0x05,
6479};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006480/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006481 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006482 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006483 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006484static struct hda_input_mux alc260_test_capture_sources[2] = {
6485 {
6486 .num_items = 7,
6487 .items = {
6488 { "MIC1 pin", 0x0 },
6489 { "MIC2 pin", 0x1 },
6490 { "LINE1 pin", 0x2 },
6491 { "LINE2 pin", 0x3 },
6492 { "CD pin", 0x4 },
6493 { "LINE-OUT pin", 0x5 },
6494 { "HP-OUT pin", 0x6 },
6495 },
6496 },
6497 {
6498 .num_items = 8,
6499 .items = {
6500 { "MIC1 pin", 0x0 },
6501 { "MIC2 pin", 0x1 },
6502 { "LINE1 pin", 0x2 },
6503 { "LINE2 pin", 0x3 },
6504 { "CD pin", 0x4 },
6505 { "Mixer", 0x5 },
6506 { "LINE-OUT pin", 0x6 },
6507 { "HP-OUT pin", 0x7 },
6508 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006509 },
6510};
6511static struct snd_kcontrol_new alc260_test_mixer[] = {
6512 /* Output driver widgets */
6513 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6514 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6515 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6516 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6517 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6518 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6519
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006520 /* Modes for retasking pin widgets
6521 * Note: the ALC260 doesn't seem to act on requests to enable mic
6522 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6523 * mention this restriction. At this stage it's not clear whether
6524 * this behaviour is intentional or is a hardware bug in chip
6525 * revisions available at least up until early 2006. Therefore for
6526 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6527 * choices, but if it turns out that the lack of mic bias for these
6528 * NIDs is intentional we could change their modes from
6529 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6530 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006531 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6532 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6533 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6534 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6535 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6536 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6537
6538 /* Loopback mixer controls */
6539 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6540 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6541 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6542 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6543 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6544 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6545 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6546 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6547 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6548 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006549 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6550 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6551 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6552 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006553
6554 /* Controls for GPIO pins, assuming they are configured as outputs */
6555 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6556 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6557 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6558 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6559
Jonathan Woithe92621f12006-02-28 11:47:47 +01006560 /* Switches to allow the digital IO pins to be enabled. The datasheet
6561 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006562 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006563 */
6564 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6565 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6566
Jonathan Woithef8225f62008-01-08 12:16:54 +01006567 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6568 * this output to turn on an external amplifier.
6569 */
6570 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6571 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6572
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006573 { } /* end */
6574};
6575static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006576 /* Enable all GPIOs as outputs with an initial value of 0 */
6577 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6578 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6579 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6580
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006581 /* Enable retasking pins as output, initially without power amp */
6582 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6583 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6584 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6585 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6586 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6587 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6588
Jonathan Woithe92621f12006-02-28 11:47:47 +01006589 /* Disable digital (SPDIF) pins initially, but users can enable
6590 * them via a mixer switch. In the case of SPDIF-out, this initverb
6591 * payload also sets the generation to 0, output to be in "consumer"
6592 * PCM format, copyright asserted, no pre-emphasis and no validity
6593 * control.
6594 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006595 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6596 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6597
Kailang Yangea1fb292008-08-26 12:58:38 +02006598 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006599 * OUT1 sum bus when acting as an output.
6600 */
6601 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6602 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6603 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6604 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6605
6606 /* Start with output sum widgets muted and their output gains at min */
6607 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6608 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6609 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6610 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6611 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6612 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6613 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6614 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6615 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6616
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006617 /* Unmute retasking pin widget output buffers since the default
6618 * state appears to be output. As the pin mode is changed by the
6619 * user the pin mode control will take care of enabling the pin's
6620 * input/output buffers as needed.
6621 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006622 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6623 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6624 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6625 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6626 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6627 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6628 /* Also unmute the mono-out pin widget */
6629 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6630
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006631 /* Mute capture amp left and right */
6632 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006633 /* Set ADC connection select to match default mixer setting (mic1
6634 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006635 */
6636 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6637
6638 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006639 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006640 */
6641 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6642 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6643
6644 /* Mute all inputs to mixer widget (even unconnected ones) */
6645 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6646 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6647 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6648 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6649 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6650 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6651 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6652 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6653
6654 { }
6655};
6656#endif
6657
Takashi Iwai63300792008-01-24 15:31:36 +01006658#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6659#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006660
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006661#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6662#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6663
Kailang Yangdf694da2005-12-05 19:42:22 +01006664/*
6665 * for BIOS auto-configuration
6666 */
6667
6668static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006669 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006670{
6671 hda_nid_t nid_vol;
6672 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006673 int err;
6674
6675 if (nid >= 0x0f && nid < 0x11) {
6676 nid_vol = nid - 0x7;
6677 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6678 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6679 } else if (nid == 0x11) {
6680 nid_vol = nid - 0x7;
6681 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6682 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6683 } else if (nid >= 0x12 && nid <= 0x15) {
6684 nid_vol = 0x08;
6685 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6686 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6687 } else
6688 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006689
Takashi Iwai863b4512008-10-21 17:01:47 +02006690 if (!(*vol_bits & (1 << nid_vol))) {
6691 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006692 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006693 if (err < 0)
6694 return err;
6695 *vol_bits |= (1 << nid_vol);
6696 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006697 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006698 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006699 return err;
6700 return 1;
6701}
6702
6703/* add playback controls from the parsed DAC table */
6704static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6705 const struct auto_pin_cfg *cfg)
6706{
6707 hda_nid_t nid;
6708 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006709 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006710
6711 spec->multiout.num_dacs = 1;
6712 spec->multiout.dac_nids = spec->private_dac_nids;
6713 spec->multiout.dac_nids[0] = 0x02;
6714
6715 nid = cfg->line_out_pins[0];
6716 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006717 const char *pfx;
6718 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6719 pfx = "Master";
6720 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6721 pfx = "Speaker";
6722 else
6723 pfx = "Front";
6724 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006725 if (err < 0)
6726 return err;
6727 }
6728
Takashi Iwai82bc9552006-03-21 11:24:42 +01006729 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006730 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006731 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006732 if (err < 0)
6733 return err;
6734 }
6735
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006736 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006737 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006738 err = alc260_add_playback_controls(spec, nid, "Headphone",
6739 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006740 if (err < 0)
6741 return err;
6742 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006743 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006744}
6745
6746/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006747static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006748 const struct auto_pin_cfg *cfg)
6749{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006750 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006751}
6752
6753static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6754 hda_nid_t nid, int pin_type,
6755 int sel_idx)
6756{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006757 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006758 /* need the manual connection? */
6759 if (nid >= 0x12) {
6760 int idx = nid - 0x12;
6761 snd_hda_codec_write(codec, idx + 0x0b, 0,
6762 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006763 }
6764}
6765
6766static void alc260_auto_init_multi_out(struct hda_codec *codec)
6767{
6768 struct alc_spec *spec = codec->spec;
6769 hda_nid_t nid;
6770
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006771 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006772 if (nid) {
6773 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6774 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6775 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006776
Takashi Iwai82bc9552006-03-21 11:24:42 +01006777 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006778 if (nid)
6779 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6780
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006781 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006782 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006783 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006784}
Kailang Yangdf694da2005-12-05 19:42:22 +01006785
6786#define ALC260_PIN_CD_NID 0x16
6787static void alc260_auto_init_analog_input(struct hda_codec *codec)
6788{
6789 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006790 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006791 int i;
6792
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006793 for (i = 0; i < cfg->num_inputs; i++) {
6794 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006795 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006796 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006797 if (nid != ALC260_PIN_CD_NID &&
6798 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006799 snd_hda_codec_write(codec, nid, 0,
6800 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006801 AMP_OUT_MUTE);
6802 }
6803 }
6804}
6805
Takashi Iwai7f311a42010-04-09 17:32:23 +02006806#define alc260_auto_init_input_src alc880_auto_init_input_src
6807
Kailang Yangdf694da2005-12-05 19:42:22 +01006808/*
6809 * generic initialization of ADC, input mixers and output mixers
6810 */
6811static struct hda_verb alc260_volume_init_verbs[] = {
6812 /*
6813 * Unmute ADC0-1 and set the default input to mic-in
6814 */
6815 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6816 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6817 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6818 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006819
Kailang Yangdf694da2005-12-05 19:42:22 +01006820 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6821 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006822 * Note: PASD motherboards uses the Line In 2 as the input for
6823 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006824 */
6825 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006826 /* mute analog inputs */
6827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6828 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6830 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6831 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006832
6833 /*
6834 * Set up output mixers (0x08 - 0x0a)
6835 */
6836 /* set vol=0 to output mixers */
6837 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6838 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6839 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6840 /* set up input amps for analog loopback */
6841 /* Amp Indices: DAC = 0, mixer = 1 */
6842 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6843 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6844 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6845 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6846 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6847 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006848
Kailang Yangdf694da2005-12-05 19:42:22 +01006849 { }
6850};
6851
6852static int alc260_parse_auto_config(struct hda_codec *codec)
6853{
6854 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006855 int err;
6856 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6857
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006858 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6859 alc260_ignore);
6860 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006861 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006862 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6863 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006864 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006865 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006866 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006867 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006868 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006869 return err;
6870
6871 spec->multiout.max_channels = 2;
6872
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006873 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006874 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006875 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006876 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006877
Takashi Iwaid88897e2008-10-31 15:01:37 +01006878 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006879
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006880 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006881 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006882
Kailang Yang6227cdc2010-02-25 08:36:52 +01006883 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006884
Kailang Yangdf694da2005-12-05 19:42:22 +01006885 return 1;
6886}
6887
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006888/* additional initialization for auto-configuration model */
6889static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006890{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006891 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006892 alc260_auto_init_multi_out(codec);
6893 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006894 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02006895 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006896 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006897 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006898}
6899
Takashi Iwaicb53c622007-08-10 17:21:45 +02006900#ifdef CONFIG_SND_HDA_POWER_SAVE
6901static struct hda_amp_list alc260_loopbacks[] = {
6902 { 0x07, HDA_INPUT, 0 },
6903 { 0x07, HDA_INPUT, 1 },
6904 { 0x07, HDA_INPUT, 2 },
6905 { 0x07, HDA_INPUT, 3 },
6906 { 0x07, HDA_INPUT, 4 },
6907 { } /* end */
6908};
6909#endif
6910
Kailang Yangdf694da2005-12-05 19:42:22 +01006911/*
Takashi Iwaifc091762010-08-04 23:53:36 +02006912 * Pin config fixes
6913 */
6914enum {
6915 PINFIX_HP_DC5750,
6916};
6917
Takashi Iwaifc091762010-08-04 23:53:36 +02006918static const struct alc_fixup alc260_fixups[] = {
6919 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02006920 .pins = (const struct alc_pincfg[]) {
6921 { 0x11, 0x90130110 }, /* speaker */
6922 { }
6923 }
Takashi Iwaifc091762010-08-04 23:53:36 +02006924 },
6925};
6926
6927static struct snd_pci_quirk alc260_fixup_tbl[] = {
6928 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
6929 {}
6930};
6931
6932/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006933 * ALC260 configurations
6934 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006935static const char *alc260_models[ALC260_MODEL_LAST] = {
6936 [ALC260_BASIC] = "basic",
6937 [ALC260_HP] = "hp",
6938 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006939 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006940 [ALC260_FUJITSU_S702X] = "fujitsu",
6941 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006942 [ALC260_WILL] = "will",
6943 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006944 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006945#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006946 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006947#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006948 [ALC260_AUTO] = "auto",
6949};
6950
6951static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006952 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006953 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006954 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006955 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006956 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006957 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006958 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006959 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006960 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006961 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6962 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6963 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6964 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6965 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6966 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6967 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6968 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6969 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006970 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006971 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006972 {}
6973};
6974
Kailang Yangdf694da2005-12-05 19:42:22 +01006975static struct alc_config_preset alc260_presets[] = {
6976 [ALC260_BASIC] = {
6977 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01006978 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01006979 .init_verbs = { alc260_init_verbs },
6980 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6981 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006982 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01006983 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01006984 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6985 .channel_mode = alc260_modes,
6986 .input_mux = &alc260_capture_source,
6987 },
6988 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01006989 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006990 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01006991 .init_verbs = { alc260_init_verbs,
6992 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01006993 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
6994 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01006995 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
6996 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01006997 .num_channel_mode = ARRAY_SIZE(alc260_modes),
6998 .channel_mode = alc260_modes,
6999 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007000 .unsol_event = alc260_hp_unsol_event,
7001 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007002 },
Kailang Yang3f878302008-08-26 13:02:23 +02007003 [ALC260_HP_DC7600] = {
7004 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007005 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007006 .init_verbs = { alc260_init_verbs,
7007 alc260_hp_dc7600_verbs },
7008 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7009 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007010 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7011 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007012 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7013 .channel_mode = alc260_modes,
7014 .input_mux = &alc260_capture_source,
7015 .unsol_event = alc260_hp_3012_unsol_event,
7016 .init_hook = alc260_hp_3012_automute,
7017 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007018 [ALC260_HP_3013] = {
7019 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007020 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007021 .init_verbs = { alc260_hp_3013_init_verbs,
7022 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007023 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7024 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007025 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7026 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007027 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7028 .channel_mode = alc260_modes,
7029 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007030 .unsol_event = alc260_hp_3013_unsol_event,
7031 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007032 },
7033 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007034 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007035 .init_verbs = { alc260_fujitsu_init_verbs },
7036 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7037 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007038 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7039 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007040 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7041 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007042 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7043 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007044 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007045 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007046 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007047 .init_verbs = { alc260_acer_init_verbs },
7048 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7049 .dac_nids = alc260_dac_nids,
7050 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7051 .adc_nids = alc260_dual_adc_nids,
7052 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7053 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007054 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7055 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007056 },
Michael Schwingencc959482009-02-22 18:58:45 +01007057 [ALC260_FAVORIT100] = {
7058 .mixers = { alc260_favorit100_mixer },
7059 .init_verbs = { alc260_favorit100_init_verbs },
7060 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7061 .dac_nids = alc260_dac_nids,
7062 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7063 .adc_nids = alc260_dual_adc_nids,
7064 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7065 .channel_mode = alc260_modes,
7066 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7067 .input_mux = alc260_favorit100_capture_sources,
7068 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007069 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007070 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007071 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7072 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7073 .dac_nids = alc260_dac_nids,
7074 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7075 .adc_nids = alc260_adc_nids,
7076 .dig_out_nid = ALC260_DIGOUT_NID,
7077 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7078 .channel_mode = alc260_modes,
7079 .input_mux = &alc260_capture_source,
7080 },
7081 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007082 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007083 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7084 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7085 .dac_nids = alc260_dac_nids,
7086 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7087 .adc_nids = alc260_adc_nids,
7088 .dig_out_nid = ALC260_DIGOUT_NID,
7089 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7090 .channel_mode = alc260_modes,
7091 .input_mux = &alc260_capture_source,
7092 .unsol_event = alc260_replacer_672v_unsol_event,
7093 .init_hook = alc260_replacer_672v_automute,
7094 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007095#ifdef CONFIG_SND_DEBUG
7096 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007097 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007098 .init_verbs = { alc260_test_init_verbs },
7099 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7100 .dac_nids = alc260_test_dac_nids,
7101 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7102 .adc_nids = alc260_test_adc_nids,
7103 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7104 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007105 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7106 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007107 },
7108#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007109};
7110
Linus Torvalds1da177e2005-04-16 15:20:36 -07007111static int patch_alc260(struct hda_codec *codec)
7112{
7113 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007114 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007115
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007116 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007117 if (spec == NULL)
7118 return -ENOMEM;
7119
7120 codec->spec = spec;
7121
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007122 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7123 alc260_models,
7124 alc260_cfg_tbl);
7125 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007126 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007127 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007128 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007129 }
7130
Takashi Iwaifc091762010-08-04 23:53:36 +02007131 if (board_config == ALC260_AUTO)
7132 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7133
Kailang Yangdf694da2005-12-05 19:42:22 +01007134 if (board_config == ALC260_AUTO) {
7135 /* automatic parse from the BIOS config */
7136 err = alc260_parse_auto_config(codec);
7137 if (err < 0) {
7138 alc_free(codec);
7139 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007140 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007141 printk(KERN_INFO
7142 "hda_codec: Cannot set up configuration "
7143 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007144 board_config = ALC260_BASIC;
7145 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007146 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007147
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007148 err = snd_hda_attach_beep_device(codec, 0x1);
7149 if (err < 0) {
7150 alc_free(codec);
7151 return err;
7152 }
7153
Kailang Yangdf694da2005-12-05 19:42:22 +01007154 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007155 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007156
Linus Torvalds1da177e2005-04-16 15:20:36 -07007157 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7158 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307159 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007160
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007161 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7162 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7163
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007164 if (!spec->adc_nids && spec->input_mux) {
7165 /* check whether NID 0x04 is valid */
7166 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007167 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007168 /* get type */
7169 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7170 spec->adc_nids = alc260_adc_nids_alt;
7171 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7172 } else {
7173 spec->adc_nids = alc260_adc_nids;
7174 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7175 }
7176 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007177 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007178 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007179
Takashi Iwaifc091762010-08-04 23:53:36 +02007180 if (board_config == ALC260_AUTO)
7181 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7182
Takashi Iwai2134ea42008-01-10 16:53:55 +01007183 spec->vmaster_nid = 0x08;
7184
Linus Torvalds1da177e2005-04-16 15:20:36 -07007185 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007186 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007187 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007188#ifdef CONFIG_SND_HDA_POWER_SAVE
7189 if (!spec->loopback.amplist)
7190 spec->loopback.amplist = alc260_loopbacks;
7191#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007192
7193 return 0;
7194}
7195
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007196
Linus Torvalds1da177e2005-04-16 15:20:36 -07007197/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007198 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007199 *
7200 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7201 * configuration. Each pin widget can choose any input DACs and a mixer.
7202 * Each ADC is connected from a mixer of all inputs. This makes possible
7203 * 6-channel independent captures.
7204 *
7205 * In addition, an independent DAC for the multi-playback (not used in this
7206 * driver yet).
7207 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007208#define ALC882_DIGOUT_NID 0x06
7209#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007210#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7211#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7212#define ALC1200_DIGOUT_NID 0x10
7213
Linus Torvalds1da177e2005-04-16 15:20:36 -07007214
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007215static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007216 { 8, NULL }
7217};
7218
Takashi Iwai4953550a2009-06-30 15:28:30 +02007219/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007220static hda_nid_t alc882_dac_nids[4] = {
7221 /* front, rear, clfe, rear_surr */
7222 0x02, 0x03, 0x04, 0x05
7223};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007224#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007225
Takashi Iwai4953550a2009-06-30 15:28:30 +02007226/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007227#define alc882_adc_nids alc880_adc_nids
7228#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007229#define alc883_adc_nids alc882_adc_nids_alt
7230static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7231static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7232#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007233
Takashi Iwaie1406342008-02-11 18:32:32 +01007234static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7235static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007236#define alc883_capsrc_nids alc882_capsrc_nids_alt
7237static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7238#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007239
Linus Torvalds1da177e2005-04-16 15:20:36 -07007240/* input MUX */
7241/* FIXME: should be a matrix-type input source selection */
7242
7243static struct hda_input_mux alc882_capture_source = {
7244 .num_items = 4,
7245 .items = {
7246 { "Mic", 0x0 },
7247 { "Front Mic", 0x1 },
7248 { "Line", 0x2 },
7249 { "CD", 0x4 },
7250 },
7251};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007252
Takashi Iwai4953550a2009-06-30 15:28:30 +02007253#define alc883_capture_source alc882_capture_source
7254
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007255static struct hda_input_mux alc889_capture_source = {
7256 .num_items = 3,
7257 .items = {
7258 { "Front Mic", 0x0 },
7259 { "Mic", 0x3 },
7260 { "Line", 0x2 },
7261 },
7262};
7263
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007264static struct hda_input_mux mb5_capture_source = {
7265 .num_items = 3,
7266 .items = {
7267 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307268 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007269 { "CD", 0x4 },
7270 },
7271};
7272
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007273static struct hda_input_mux macmini3_capture_source = {
7274 .num_items = 2,
7275 .items = {
7276 { "Line", 0x2 },
7277 { "CD", 0x4 },
7278 },
7279};
7280
Takashi Iwai4953550a2009-06-30 15:28:30 +02007281static struct hda_input_mux alc883_3stack_6ch_intel = {
7282 .num_items = 4,
7283 .items = {
7284 { "Mic", 0x1 },
7285 { "Front Mic", 0x0 },
7286 { "Line", 0x2 },
7287 { "CD", 0x4 },
7288 },
7289};
7290
7291static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7292 .num_items = 2,
7293 .items = {
7294 { "Mic", 0x1 },
7295 { "Line", 0x2 },
7296 },
7297};
7298
7299static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7300 .num_items = 4,
7301 .items = {
7302 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007303 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007304 { "Line", 0x2 },
7305 { "CD", 0x4 },
7306 },
7307};
7308
7309static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7310 .num_items = 2,
7311 .items = {
7312 { "Mic", 0x0 },
7313 { "Int Mic", 0x1 },
7314 },
7315};
7316
7317static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7318 .num_items = 3,
7319 .items = {
7320 { "Mic", 0x0 },
7321 { "Front Mic", 0x1 },
7322 { "Line", 0x4 },
7323 },
7324};
7325
7326static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7327 .num_items = 2,
7328 .items = {
7329 { "Mic", 0x0 },
7330 { "Line", 0x2 },
7331 },
7332};
7333
7334static struct hda_input_mux alc889A_mb31_capture_source = {
7335 .num_items = 2,
7336 .items = {
7337 { "Mic", 0x0 },
7338 /* Front Mic (0x01) unused */
7339 { "Line", 0x2 },
7340 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007341 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007342 },
7343};
7344
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007345static struct hda_input_mux alc889A_imac91_capture_source = {
7346 .num_items = 2,
7347 .items = {
7348 { "Mic", 0x01 },
7349 { "Line", 0x2 }, /* Not sure! */
7350 },
7351};
7352
Takashi Iwai4953550a2009-06-30 15:28:30 +02007353/*
7354 * 2ch mode
7355 */
7356static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7357 { 2, NULL }
7358};
7359
Kailang Yangdf694da2005-12-05 19:42:22 +01007360/*
Kailang Yang272a5272007-05-14 11:00:38 +02007361 * 2ch mode
7362 */
7363static struct hda_verb alc882_3ST_ch2_init[] = {
7364 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7365 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7366 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7367 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7368 { } /* end */
7369};
7370
7371/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007372 * 4ch mode
7373 */
7374static struct hda_verb alc882_3ST_ch4_init[] = {
7375 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7376 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7377 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7378 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7379 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7380 { } /* end */
7381};
7382
7383/*
Kailang Yang272a5272007-05-14 11:00:38 +02007384 * 6ch mode
7385 */
7386static struct hda_verb alc882_3ST_ch6_init[] = {
7387 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7388 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7389 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7390 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7391 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7392 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7393 { } /* end */
7394};
7395
Takashi Iwai4953550a2009-06-30 15:28:30 +02007396static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007397 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007398 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007399 { 6, alc882_3ST_ch6_init },
7400};
7401
Takashi Iwai4953550a2009-06-30 15:28:30 +02007402#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7403
Kailang Yang272a5272007-05-14 11:00:38 +02007404/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307405 * 2ch mode
7406 */
7407static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7408 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7409 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7410 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7411 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7412 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7413 { } /* end */
7414};
7415
7416/*
7417 * 4ch mode
7418 */
7419static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7420 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7421 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7422 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7423 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7424 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7425 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7426 { } /* end */
7427};
7428
7429/*
7430 * 6ch mode
7431 */
7432static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7433 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7434 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7435 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7436 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7437 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7438 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7439 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7440 { } /* end */
7441};
7442
7443static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7444 { 2, alc883_3ST_ch2_clevo_init },
7445 { 4, alc883_3ST_ch4_clevo_init },
7446 { 6, alc883_3ST_ch6_clevo_init },
7447};
7448
7449
7450/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007451 * 6ch mode
7452 */
7453static struct hda_verb alc882_sixstack_ch6_init[] = {
7454 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7455 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7456 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7457 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7458 { } /* end */
7459};
7460
7461/*
7462 * 8ch mode
7463 */
7464static struct hda_verb alc882_sixstack_ch8_init[] = {
7465 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7466 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7467 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7468 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7469 { } /* end */
7470};
7471
7472static struct hda_channel_mode alc882_sixstack_modes[2] = {
7473 { 6, alc882_sixstack_ch6_init },
7474 { 8, alc882_sixstack_ch8_init },
7475};
7476
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007477
7478/* Macbook Air 2,1 */
7479
7480static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7481 { 2, NULL },
7482};
7483
Takashi Iwai87350ad2007-08-16 18:19:38 +02007484/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007485 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007486 */
7487
7488/*
7489 * 2ch mode
7490 */
7491static struct hda_verb alc885_mbp_ch2_init[] = {
7492 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7493 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7494 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7495 { } /* end */
7496};
7497
7498/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007499 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007500 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007501static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007502 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7503 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7504 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7505 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7506 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7507 { } /* end */
7508};
7509
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007510static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007511 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007512 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007513};
7514
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007515/*
7516 * 2ch
7517 * Speakers/Woofer/HP = Front
7518 * LineIn = Input
7519 */
7520static struct hda_verb alc885_mb5_ch2_init[] = {
7521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7522 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7523 { } /* end */
7524};
7525
7526/*
7527 * 6ch mode
7528 * Speakers/HP = Front
7529 * Woofer = LFE
7530 * LineIn = Surround
7531 */
7532static struct hda_verb alc885_mb5_ch6_init[] = {
7533 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7534 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7535 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7536 { } /* end */
7537};
7538
7539static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7540 { 2, alc885_mb5_ch2_init },
7541 { 6, alc885_mb5_ch6_init },
7542};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007543
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007544#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007545
7546/*
7547 * 2ch mode
7548 */
7549static struct hda_verb alc883_4ST_ch2_init[] = {
7550 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7551 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7552 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7553 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7554 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7555 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7556 { } /* end */
7557};
7558
7559/*
7560 * 4ch mode
7561 */
7562static struct hda_verb alc883_4ST_ch4_init[] = {
7563 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7564 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7565 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7566 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7567 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7568 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7569 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7570 { } /* end */
7571};
7572
7573/*
7574 * 6ch mode
7575 */
7576static struct hda_verb alc883_4ST_ch6_init[] = {
7577 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7578 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7579 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7580 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7581 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7582 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7583 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7584 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7585 { } /* end */
7586};
7587
7588/*
7589 * 8ch mode
7590 */
7591static struct hda_verb alc883_4ST_ch8_init[] = {
7592 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7593 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7594 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7595 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7596 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7597 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7598 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7599 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7600 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7601 { } /* end */
7602};
7603
7604static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7605 { 2, alc883_4ST_ch2_init },
7606 { 4, alc883_4ST_ch4_init },
7607 { 6, alc883_4ST_ch6_init },
7608 { 8, alc883_4ST_ch8_init },
7609};
7610
7611
7612/*
7613 * 2ch mode
7614 */
7615static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7616 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7617 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7618 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7619 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7620 { } /* end */
7621};
7622
7623/*
7624 * 4ch mode
7625 */
7626static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7627 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7628 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7629 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7630 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7631 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7632 { } /* end */
7633};
7634
7635/*
7636 * 6ch mode
7637 */
7638static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7639 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7640 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7641 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7642 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7643 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7644 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7645 { } /* end */
7646};
7647
7648static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7649 { 2, alc883_3ST_ch2_intel_init },
7650 { 4, alc883_3ST_ch4_intel_init },
7651 { 6, alc883_3ST_ch6_intel_init },
7652};
7653
7654/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007655 * 2ch mode
7656 */
7657static struct hda_verb alc889_ch2_intel_init[] = {
7658 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7659 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7660 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7661 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7662 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7663 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7664 { } /* end */
7665};
7666
7667/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007668 * 6ch mode
7669 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007670static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007671 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7672 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7673 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7674 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7675 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007676 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7677 { } /* end */
7678};
7679
7680/*
7681 * 8ch mode
7682 */
7683static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007684 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7685 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7686 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7687 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7688 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007689 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7690 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007691 { } /* end */
7692};
7693
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007694static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7695 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007696 { 6, alc889_ch6_intel_init },
7697 { 8, alc889_ch8_intel_init },
7698};
7699
7700/*
7701 * 6ch mode
7702 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007703static struct hda_verb alc883_sixstack_ch6_init[] = {
7704 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7705 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7706 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7707 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7708 { } /* end */
7709};
7710
7711/*
7712 * 8ch mode
7713 */
7714static struct hda_verb alc883_sixstack_ch8_init[] = {
7715 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7716 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7717 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7718 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7719 { } /* end */
7720};
7721
7722static struct hda_channel_mode alc883_sixstack_modes[2] = {
7723 { 6, alc883_sixstack_ch6_init },
7724 { 8, alc883_sixstack_ch8_init },
7725};
7726
7727
Linus Torvalds1da177e2005-04-16 15:20:36 -07007728/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7729 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7730 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007731static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007732 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007733 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007734 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007735 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007736 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7737 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007738 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7739 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007740 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007741 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007742 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7743 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7744 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7745 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7746 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7747 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007748 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007749 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7750 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007751 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007752 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007753 { } /* end */
7754};
7755
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007756/* Macbook Air 2,1 same control for HP and internal Speaker */
7757
7758static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7759 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7760 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7761 { }
7762};
7763
7764
Takashi Iwai87350ad2007-08-16 18:19:38 +02007765static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007766 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7767 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7768 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7769 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7770 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007771 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7772 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7774 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007775 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007776 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7777 { } /* end */
7778};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007779
7780static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007781 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7782 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7783 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7784 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7785 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7786 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307787 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7788 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307789 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7790 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7792 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7793 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7794 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7795 { } /* end */
7796};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007797
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007798static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7799 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7800 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7801 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7802 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7803 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7804 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7805 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7806 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7807 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7808 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7809 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7810 { } /* end */
7811};
7812
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007813static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007814 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7815 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007816 { } /* end */
7817};
7818
7819
Kailang Yangbdd148a2007-05-08 15:19:08 +02007820static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7821 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7822 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7823 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7824 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7825 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7826 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7827 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7828 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7829 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007830 { } /* end */
7831};
7832
Kailang Yang272a5272007-05-14 11:00:38 +02007833static struct snd_kcontrol_new alc882_targa_mixer[] = {
7834 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7835 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7836 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7837 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7838 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7839 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7840 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7841 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7842 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007843 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007844 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7845 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007846 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007847 { } /* end */
7848};
7849
7850/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7851 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7852 */
7853static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7854 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7855 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7856 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7857 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7858 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7859 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7860 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7861 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7862 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7863 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7864 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7865 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007866 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007867 { } /* end */
7868};
7869
Takashi Iwai914759b2007-09-06 14:52:04 +02007870static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7871 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7872 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7873 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7874 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7875 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7876 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7877 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7880 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007881 { } /* end */
7882};
7883
Kailang Yangdf694da2005-12-05 19:42:22 +01007884static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7885 {
7886 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7887 .name = "Channel Mode",
7888 .info = alc_ch_mode_info,
7889 .get = alc_ch_mode_get,
7890 .put = alc_ch_mode_put,
7891 },
7892 { } /* end */
7893};
7894
Takashi Iwai4953550a2009-06-30 15:28:30 +02007895static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007896 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007897 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7898 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007899 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007900 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7901 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007902 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007903 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7904 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007905 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007906 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7907 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007908
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007909 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007910 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007911 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007912 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007913 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007914 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007916 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007917 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007918 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007919 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007920 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007921 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007922 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007923 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007924 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007925 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007926 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007927 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7928 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007929 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007930 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7931 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007932 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007933 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7934 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7935 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7936 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7937 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007938 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007939 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007940
7941 /* FIXME: use matrix-type input source selection */
7942 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007943 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007944 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007945 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007946 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007947 /* ADC2: mute amp left and right */
7948 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007949 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007950 /* ADC3: mute amp left and right */
7951 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007952 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007953
7954 { }
7955};
7956
Takashi Iwai4953550a2009-06-30 15:28:30 +02007957static struct hda_verb alc882_adc1_init_verbs[] = {
7958 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7959 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7960 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7961 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7962 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7963 /* ADC1: mute amp left and right */
7964 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7965 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7966 { }
7967};
7968
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007969static struct hda_verb alc882_eapd_verbs[] = {
7970 /* change to EAPD mode */
7971 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007972 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007973 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007974};
7975
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007976static struct hda_verb alc889_eapd_verbs[] = {
7977 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
7978 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
7979 { }
7980};
7981
Wu Fengguang6732bd02009-07-30 09:19:14 +02007982static struct hda_verb alc_hp15_unsol_verbs[] = {
7983 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
7984 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7985 {}
7986};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007987
7988static struct hda_verb alc885_init_verbs[] = {
7989 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01007990 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7991 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007992 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007993 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7994 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007995 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007996 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7997 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007998 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01007999 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8000 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008001
8002 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008003 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008004 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8005 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8006 /* Front Pin: output 0 (0x0c) */
8007 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8008 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8009 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8010 /* Rear Pin: output 1 (0x0d) */
8011 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8012 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8013 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8014 /* CLFE Pin: output 2 (0x0e) */
8015 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8016 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8017 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8018 /* Side Pin: output 3 (0x0f) */
8019 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8020 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8021 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8022 /* Mic (rear) pin: input vref at 80% */
8023 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8024 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8025 /* Front Mic pin: input vref at 80% */
8026 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8027 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8028 /* Line In pin: input */
8029 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8030 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8031
8032 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8033 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008034 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008035 /* Input mixer2 */
8036 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008037 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008038 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008039 /* ADC2: mute amp left and right */
8040 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8041 /* ADC3: mute amp left and right */
8042 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8043
8044 { }
8045};
8046
8047static struct hda_verb alc885_init_input_verbs[] = {
8048 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8049 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8050 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8051 { }
8052};
8053
8054
8055/* Unmute Selector 24h and set the default input to front mic */
8056static struct hda_verb alc889_init_input_verbs[] = {
8057 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8058 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8059 { }
8060};
8061
8062
Takashi Iwai4953550a2009-06-30 15:28:30 +02008063#define alc883_init_verbs alc882_base_init_verbs
8064
Tobin Davis9102cd12006-12-15 10:02:12 +01008065/* Mac Pro test */
8066static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8067 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8068 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8069 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8070 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8071 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008072 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008073 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8074 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008075 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008076 { } /* end */
8077};
8078
8079static struct hda_verb alc882_macpro_init_verbs[] = {
8080 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8082 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8083 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8084 /* Front Pin: output 0 (0x0c) */
8085 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8086 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8087 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8088 /* Front Mic pin: input vref at 80% */
8089 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8090 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8091 /* Speaker: output */
8092 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8093 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8094 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8095 /* Headphone output (output 0 - 0x0c) */
8096 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8097 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8098 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8099
8100 /* FIXME: use matrix-type input source selection */
8101 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8102 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8103 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8104 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8105 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8106 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8107 /* Input mixer2 */
8108 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8109 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8110 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8112 /* Input mixer3 */
8113 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8114 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8115 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8117 /* ADC1: mute amp left and right */
8118 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8119 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8120 /* ADC2: mute amp left and right */
8121 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8122 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8123 /* ADC3: mute amp left and right */
8124 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8125 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8126
8127 { }
8128};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008129
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008130/* Macbook 5,1 */
8131static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008132 /* DACs */
8133 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8134 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8135 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8136 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008137 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008138 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8139 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8140 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008141 /* Surround mixer */
8142 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8143 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8144 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8145 /* LFE mixer */
8146 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8147 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8149 /* HP mixer */
8150 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8151 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8152 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8153 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008154 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8155 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008156 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8157 /* LFE Pin (0x0e) */
8158 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8159 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8160 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8161 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008162 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8163 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008164 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308165 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008166 /* Front Mic pin: input vref at 80% */
8167 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8168 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8169 /* Line In pin */
8170 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8171 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8172
Alex Murrayb8f171e2010-06-14 12:08:43 +09308173 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8174 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8175 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008176 { }
8177};
8178
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008179/* Macmini 3,1 */
8180static struct hda_verb alc885_macmini3_init_verbs[] = {
8181 /* DACs */
8182 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8183 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8184 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8185 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8186 /* Front mixer */
8187 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8188 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8189 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8190 /* Surround mixer */
8191 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8192 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8193 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8194 /* LFE mixer */
8195 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8196 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8197 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8198 /* HP mixer */
8199 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8200 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8201 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8202 /* Front Pin (0x0c) */
8203 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8204 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8205 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8206 /* LFE Pin (0x0e) */
8207 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8208 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8209 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8210 /* HP Pin (0x0f) */
8211 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8212 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8213 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8214 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8215 /* Line In pin */
8216 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8217 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8218
8219 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8220 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8221 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8222 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8223 { }
8224};
8225
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008226
8227static struct hda_verb alc885_mba21_init_verbs[] = {
8228 /*Internal and HP Speaker Mixer*/
8229 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8230 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8231 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8232 /*Internal Speaker Pin (0x0c)*/
8233 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8234 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8235 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8236 /* HP Pin: output 0 (0x0e) */
8237 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8238 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8239 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8240 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8241 /* Line in (is hp when jack connected)*/
8242 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8243 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8244
8245 { }
8246 };
8247
8248
Takashi Iwai87350ad2007-08-16 18:19:38 +02008249/* Macbook Pro rev3 */
8250static struct hda_verb alc885_mbp3_init_verbs[] = {
8251 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8252 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8253 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8255 /* Rear mixer */
8256 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8257 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8258 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008259 /* HP mixer */
8260 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8261 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8262 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008263 /* Front Pin: output 0 (0x0c) */
8264 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8265 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8266 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008267 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008269 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8270 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008271 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8272 /* Mic (rear) pin: input vref at 80% */
8273 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8274 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8275 /* Front Mic pin: input vref at 80% */
8276 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8277 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8278 /* Line In pin: use output 1 when in LineOut mode */
8279 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8280 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8281 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8282
8283 /* FIXME: use matrix-type input source selection */
8284 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8285 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8290 /* Input mixer2 */
8291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8292 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8293 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8295 /* Input mixer3 */
8296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8300 /* ADC1: mute amp left and right */
8301 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8302 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8303 /* ADC2: mute amp left and right */
8304 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8305 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8306 /* ADC3: mute amp left and right */
8307 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8308 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8309
8310 { }
8311};
8312
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008313/* iMac 9,1 */
8314static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008315 /* Internal Speaker Pin (0x0c) */
8316 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8317 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8318 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8319 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8320 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8321 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8322 /* HP Pin: Rear */
8323 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8324 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8325 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8326 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8327 /* Line in Rear */
8328 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8329 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8330 /* Front Mic pin: input vref at 80% */
8331 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8332 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008333 /* Rear mixer */
8334 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8335 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8336 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008337 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8341 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008342 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8343 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8344 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8345 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008346 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008347 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8348 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8349 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8350 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008351 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008352 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8353 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8354 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8355 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008356 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008357 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8358 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008359 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008360 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8361 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008362 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008363 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8364 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008365 { }
8366};
8367
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008368/* iMac 24 mixer. */
8369static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8370 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8371 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8372 { } /* end */
8373};
8374
8375/* iMac 24 init verbs. */
8376static struct hda_verb alc885_imac24_init_verbs[] = {
8377 /* Internal speakers: output 0 (0x0c) */
8378 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8379 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8380 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8381 /* Internal speakers: output 0 (0x0c) */
8382 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8383 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8384 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8385 /* Headphone: output 0 (0x0c) */
8386 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8387 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8388 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8389 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8390 /* Front Mic: input vref at 80% */
8391 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8392 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8393 { }
8394};
8395
8396/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008397static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008398{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008399 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008400
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008401 spec->autocfg.hp_pins[0] = 0x14;
8402 spec->autocfg.speaker_pins[0] = 0x18;
8403 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008404}
8405
Takashi Iwai9d54f082010-02-22 08:34:40 +01008406#define alc885_mb5_setup alc885_imac24_setup
8407#define alc885_macmini3_setup alc885_imac24_setup
8408
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008409/* Macbook Air 2,1 */
8410static void alc885_mba21_setup(struct hda_codec *codec)
8411{
8412 struct alc_spec *spec = codec->spec;
8413
8414 spec->autocfg.hp_pins[0] = 0x14;
8415 spec->autocfg.speaker_pins[0] = 0x18;
8416}
8417
8418
8419
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008420static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008421{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008422 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008423
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008424 spec->autocfg.hp_pins[0] = 0x15;
8425 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008426}
8427
Takashi Iwai9d54f082010-02-22 08:34:40 +01008428static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308429{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008430 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308431
Takashi Iwai9d54f082010-02-22 08:34:40 +01008432 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008433 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008434 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008435}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008436
Kailang Yang272a5272007-05-14 11:00:38 +02008437static struct hda_verb alc882_targa_verbs[] = {
8438 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8439 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8440
8441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8442 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008443
Kailang Yang272a5272007-05-14 11:00:38 +02008444 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8445 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8446 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8447
8448 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008449 { } /* end */
8450};
8451
8452/* toggle speaker-output according to the hp-jack state */
8453static void alc882_targa_automute(struct hda_codec *codec)
8454{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008455 struct alc_spec *spec = codec->spec;
8456 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008457 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008458 spec->jack_present ? 1 : 3);
8459}
8460
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008461static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008462{
8463 struct alc_spec *spec = codec->spec;
8464
8465 spec->autocfg.hp_pins[0] = 0x14;
8466 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008467}
8468
8469static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8470{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008471 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008472 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008473}
8474
8475static struct hda_verb alc882_asus_a7j_verbs[] = {
8476 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8477 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8478
8479 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8480 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8481 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008482
Kailang Yang272a5272007-05-14 11:00:38 +02008483 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8484 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8485 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8486
8487 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8488 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8489 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8490 { } /* end */
8491};
8492
Takashi Iwai914759b2007-09-06 14:52:04 +02008493static struct hda_verb alc882_asus_a7m_verbs[] = {
8494 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8495 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8496
8497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8498 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8499 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008500
Takashi Iwai914759b2007-09-06 14:52:04 +02008501 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8502 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8503 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8504
8505 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8506 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8507 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8508 { } /* end */
8509};
8510
Tobin Davis9102cd12006-12-15 10:02:12 +01008511static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8512{
8513 unsigned int gpiostate, gpiomask, gpiodir;
8514
8515 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8516 AC_VERB_GET_GPIO_DATA, 0);
8517
8518 if (!muted)
8519 gpiostate |= (1 << pin);
8520 else
8521 gpiostate &= ~(1 << pin);
8522
8523 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8524 AC_VERB_GET_GPIO_MASK, 0);
8525 gpiomask |= (1 << pin);
8526
8527 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8528 AC_VERB_GET_GPIO_DIRECTION, 0);
8529 gpiodir |= (1 << pin);
8530
8531
8532 snd_hda_codec_write(codec, codec->afg, 0,
8533 AC_VERB_SET_GPIO_MASK, gpiomask);
8534 snd_hda_codec_write(codec, codec->afg, 0,
8535 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8536
8537 msleep(1);
8538
8539 snd_hda_codec_write(codec, codec->afg, 0,
8540 AC_VERB_SET_GPIO_DATA, gpiostate);
8541}
8542
Takashi Iwai7debbe52007-08-16 15:01:03 +02008543/* set up GPIO at initialization */
8544static void alc885_macpro_init_hook(struct hda_codec *codec)
8545{
8546 alc882_gpio_mute(codec, 0, 0);
8547 alc882_gpio_mute(codec, 1, 0);
8548}
8549
8550/* set up GPIO and update auto-muting at initialization */
8551static void alc885_imac24_init_hook(struct hda_codec *codec)
8552{
8553 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008554 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008555}
8556
Kailang Yangdf694da2005-12-05 19:42:22 +01008557/*
8558 * generic initialization of ADC, input mixers and output mixers
8559 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008560static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008561 /*
8562 * Unmute ADC0-2 and set the default input to mic-in
8563 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008564 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8565 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8566 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8567 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8568
Kailang Yangdf694da2005-12-05 19:42:22 +01008569 /*
8570 * Set up output mixers (0x0c - 0x0f)
8571 */
8572 /* set vol=0 to output mixers */
8573 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8574 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8575 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8576 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8577 /* set up input amps for analog loopback */
8578 /* Amp Indices: DAC = 0, mixer = 1 */
8579 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8580 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8581 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8582 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8583 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8584 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8585 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8586 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8587 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8588 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8589
8590 /* FIXME: use matrix-type input source selection */
8591 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008592 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008593 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008594 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008596 { }
8597};
8598
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008599/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8600static struct hda_verb alc889A_mb31_ch2_init[] = {
8601 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8602 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8603 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8604 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8605 { } /* end */
8606};
8607
8608/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8609static struct hda_verb alc889A_mb31_ch4_init[] = {
8610 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8611 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8612 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8613 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8614 { } /* end */
8615};
8616
8617/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8618static struct hda_verb alc889A_mb31_ch5_init[] = {
8619 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8620 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8621 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8622 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8623 { } /* end */
8624};
8625
8626/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8627static struct hda_verb alc889A_mb31_ch6_init[] = {
8628 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8629 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8630 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8631 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8632 { } /* end */
8633};
8634
8635static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8636 { 2, alc889A_mb31_ch2_init },
8637 { 4, alc889A_mb31_ch4_init },
8638 { 5, alc889A_mb31_ch5_init },
8639 { 6, alc889A_mb31_ch6_init },
8640};
8641
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008642static struct hda_verb alc883_medion_eapd_verbs[] = {
8643 /* eanable EAPD on medion laptop */
8644 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8645 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8646 { }
8647};
8648
Takashi Iwai4953550a2009-06-30 15:28:30 +02008649#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008650
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008651static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8652 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8653 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8654 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8655 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8656 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8657 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8658 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8659 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8660 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8661 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8662 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8663 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8664 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008665 { } /* end */
8666};
8667
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008668static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008669 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8670 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8671 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8672 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8674 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8675 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8676 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8677 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8678 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008679 { } /* end */
8680};
8681
Jiang zhefb97dc62008-03-06 11:07:11 +01008682static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8683 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8684 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8685 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8686 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8687 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8688 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8689 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8690 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8691 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8692 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008693 { } /* end */
8694};
8695
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008696static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8697 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8698 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8699 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8700 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8701 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8702 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8703 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8704 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008705 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8707 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008708 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008709 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008710 { } /* end */
8711};
8712
8713static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8714 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8715 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8716 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8717 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8718 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8719 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8720 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8721 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8722 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8723 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8724 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8725 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8726 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8727 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008728 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008729 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8730 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008731 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008732 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008733 { } /* end */
8734};
8735
Jiang zhe17bba1b2008-06-04 12:11:07 +02008736static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8737 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8738 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8739 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8740 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8741 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8742 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", 0x15, 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, 0x1, HDA_INPUT),
8752 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8753 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8754 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8755 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8756 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008757 { } /* end */
8758};
8759
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008760static struct snd_kcontrol_new alc885_8ch_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_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8771 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8772 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
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, 0x3, HDA_INPUT),
8776 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, 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),
8781 { } /* end */
8782};
8783
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008784static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008785 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008786 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008787 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008788 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008789 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8790 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008791 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8792 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008793 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8794 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8795 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8796 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8797 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8798 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008799 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008800 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8801 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008802 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008803 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008804 { } /* end */
8805};
8806
Sasha Alexandrc2592492009-06-16 14:52:54 -04008807static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008808 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008809 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008810 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008811 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008812 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8813 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8814 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8815 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8816 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8817 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
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),
Kailang Yangccc656c2006-10-17 12:32:26 +02008824 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008825 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008826};
Kailang Yangccc656c2006-10-17 12:32:26 +02008827
Sasha Alexandrc2592492009-06-16 14:52:54 -04008828static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008829 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008830 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008831 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008832 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008833 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8834 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008836 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008838 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8839 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8840 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008841 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008842};
Kailang Yangccc656c2006-10-17 12:32:26 +02008843
Takashi Iwaib99dba32009-09-17 18:23:00 +02008844static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8845 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8846 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8847 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8848 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8849 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8850 { } /* end */
8851};
8852
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008853static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8854 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8855 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008856 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8857 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008858 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8860 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008862 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008863};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008864
Kailang Yang272a5272007-05-14 11:00:38 +02008865static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8866 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8867 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8868 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8869 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8870 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8871 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02008873 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8874 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008875 { } /* end */
8876};
8877
8878static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8879 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8880 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8881 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8882 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8883 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8884 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8885 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8886 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8887 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008888 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008889};
Kailang Yang272a5272007-05-14 11:00:38 +02008890
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008891static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8892 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8893 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8894 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8895 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8896 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8897 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8898 { } /* end */
8899};
8900
8901static struct hda_verb alc883_medion_wim2160_verbs[] = {
8902 /* Unmute front mixer */
8903 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8904 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8905
8906 /* Set speaker pin to front mixer */
8907 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8908
8909 /* Init headphone pin */
8910 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8911 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8912 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8913 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8914
8915 { } /* end */
8916};
8917
8918/* toggle speaker-output according to the hp-jack state */
8919static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8920{
8921 struct alc_spec *spec = codec->spec;
8922
8923 spec->autocfg.hp_pins[0] = 0x1a;
8924 spec->autocfg.speaker_pins[0] = 0x15;
8925}
8926
Tobin Davis2880a862007-08-07 11:50:26 +02008927static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008928 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8929 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008930 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008931 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8932 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008933 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8934 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8935 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008936 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008937};
Tobin Davis2880a862007-08-07 11:50:26 +02008938
Tony Vroond2fd4b02009-06-21 00:40:10 +01008939static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8940 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008941 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008942 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8943 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008944 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8945 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8946 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8947 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8948 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8949 { } /* end */
8950};
8951
Kailang Yange2757d52008-08-26 13:17:46 +02008952static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8953 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8954 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8955 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8956 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8957 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8958 0x0d, 1, 0x0, HDA_OUTPUT),
8959 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8960 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8961 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8962 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8963 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008964 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8965 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8966 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8967 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8968 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8969 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8970 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8971 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8972 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8973 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008974 { } /* end */
8975};
8976
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008977static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
8978 /* Output mixers */
8979 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8980 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
8981 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
8982 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
8983 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
8984 HDA_OUTPUT),
8985 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
8986 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
8987 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
8988 /* Output switches */
8989 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
8990 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
8991 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
8992 /* Boost mixers */
8993 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
8994 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
8995 /* Input mixers */
8996 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
8997 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
8998 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8999 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9000 { } /* end */
9001};
9002
Guido Günther3e1647c52009-06-05 00:47:26 +02009003static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9004 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9005 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9006 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9007 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9008 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
9009 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9010 { } /* end */
9011};
9012
Kailang Yange2757d52008-08-26 13:17:46 +02009013static struct hda_bind_ctls alc883_bind_cap_vol = {
9014 .ops = &snd_hda_bind_vol,
9015 .values = {
9016 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9017 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9018 0
9019 },
9020};
9021
9022static struct hda_bind_ctls alc883_bind_cap_switch = {
9023 .ops = &snd_hda_bind_sw,
9024 .values = {
9025 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9026 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9027 0
9028 },
9029};
9030
9031static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9032 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9033 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9034 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9035 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9036 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9037 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9038 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9039 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009040 { } /* end */
9041};
9042
9043static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009044 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9045 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9046 {
9047 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9048 /* .name = "Capture Source", */
9049 .name = "Input Source",
9050 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009051 .info = alc_mux_enum_info,
9052 .get = alc_mux_enum_get,
9053 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009054 },
9055 { } /* end */
9056};
9057
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009058static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9059 {
9060 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9061 .name = "Channel Mode",
9062 .info = alc_ch_mode_info,
9063 .get = alc_ch_mode_get,
9064 .put = alc_ch_mode_put,
9065 },
9066 { } /* end */
9067};
9068
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009069/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009070static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009071{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009072 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009073
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009074 spec->autocfg.hp_pins[0] = 0x15;
9075 spec->autocfg.speaker_pins[0] = 0x14;
9076 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009077}
9078
9079/* auto-toggle front mic */
9080/*
9081static void alc883_mitac_mic_automute(struct hda_codec *codec)
9082{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009083 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009084
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009085 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
9086}
9087*/
9088
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009089static struct hda_verb alc883_mitac_verbs[] = {
9090 /* HP */
9091 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9092 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9093 /* Subwoofer */
9094 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9095 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9096
9097 /* enable unsolicited event */
9098 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9099 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9100
9101 { } /* end */
9102};
9103
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309104static struct hda_verb alc883_clevo_m540r_verbs[] = {
9105 /* HP */
9106 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9107 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9108 /* Int speaker */
9109 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9110
9111 /* enable unsolicited event */
9112 /*
9113 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9114 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9115 */
9116
9117 { } /* end */
9118};
9119
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009120static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009121 /* HP */
9122 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9123 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9124 /* Int speaker */
9125 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9126 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9127
9128 /* enable unsolicited event */
9129 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009130 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009131
9132 { } /* end */
9133};
9134
Jiang zhefb97dc62008-03-06 11:07:11 +01009135static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9136 /* HP */
9137 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9138 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9139 /* Subwoofer */
9140 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9141 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9142
9143 /* enable unsolicited event */
9144 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9145
9146 { } /* end */
9147};
9148
Sasha Alexandrc2592492009-06-16 14:52:54 -04009149static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009150 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9151 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9152
9153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9154 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009155
David Heidelberger64a8be72009-06-08 16:15:18 +02009156/* Connect Line-Out side jack (SPDIF) to Side */
9157 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9158 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9159 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9160/* Connect Mic jack to CLFE */
9161 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9162 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9163 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9164/* Connect Line-in jack to Surround */
9165 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9166 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9167 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9168/* Connect HP out jack to Front */
9169 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9170 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9171 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009172
9173 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009174
9175 { } /* end */
9176};
9177
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009178static struct hda_verb alc883_lenovo_101e_verbs[] = {
9179 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9180 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9181 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9182 { } /* end */
9183};
9184
Kailang Yang272a5272007-05-14 11:00:38 +02009185static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9186 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9187 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9188 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9189 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9190 { } /* end */
9191};
9192
9193static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9194 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9195 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9196 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9197 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9198 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9199 { } /* end */
9200};
9201
Kailang Yang189609a2007-08-20 11:31:23 +02009202static struct hda_verb alc883_haier_w66_verbs[] = {
9203 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9204 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9205
9206 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9207
9208 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9209 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9210 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9211 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9212 { } /* end */
9213};
9214
Kailang Yange2757d52008-08-26 13:17:46 +02009215static struct hda_verb alc888_lenovo_sky_verbs[] = {
9216 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9217 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9218 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9219 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9220 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9221 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9222 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9223 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9224 { } /* end */
9225};
9226
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009227static struct hda_verb alc888_6st_dell_verbs[] = {
9228 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9229 { }
9230};
9231
Guido Günther3e1647c52009-06-05 00:47:26 +02009232static struct hda_verb alc883_vaiott_verbs[] = {
9233 /* HP */
9234 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9235 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9236
9237 /* enable unsolicited event */
9238 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9239
9240 { } /* end */
9241};
9242
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009243static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009244{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009245 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009246
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009247 spec->autocfg.hp_pins[0] = 0x1b;
9248 spec->autocfg.speaker_pins[0] = 0x14;
9249 spec->autocfg.speaker_pins[1] = 0x16;
9250 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009251}
9252
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009253static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009254 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009255 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9256 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009257 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009258 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009259};
9260
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009261/*
9262 * 2ch mode
9263 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009264static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009265 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9266 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9267 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9268 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009269 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009270};
9271
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009272/*
9273 * 4ch mode
9274 */
9275static struct hda_verb alc888_3st_hp_4ch_init[] = {
9276 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9277 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9278 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9279 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9280 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9281 { } /* end */
9282};
9283
9284/*
9285 * 6ch mode
9286 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009287static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009288 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9289 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009290 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009291 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9292 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009293 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9294 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009295};
9296
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009297static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009298 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009299 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009300 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009301};
9302
Kailang Yang272a5272007-05-14 11:00:38 +02009303/* toggle front-jack and RCA according to the hp-jack state */
9304static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9305{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009306 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009307
Takashi Iwai47fd8302007-08-10 17:11:07 +02009308 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9309 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9310 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9311 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009312}
9313
9314/* toggle RCA according to the front-jack state */
9315static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9316{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009317 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009318
Takashi Iwai47fd8302007-08-10 17:11:07 +02009319 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9320 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009321}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009322
Kailang Yang272a5272007-05-14 11:00:38 +02009323static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9324 unsigned int res)
9325{
9326 if ((res >> 26) == ALC880_HP_EVENT)
9327 alc888_lenovo_ms7195_front_automute(codec);
9328 if ((res >> 26) == ALC880_FRONT_EVENT)
9329 alc888_lenovo_ms7195_rca_automute(codec);
9330}
9331
9332static struct hda_verb alc883_medion_md2_verbs[] = {
9333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9334 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9335
9336 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9337
9338 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9339 { } /* end */
9340};
9341
9342/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009343static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009344{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009345 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009346
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009347 spec->autocfg.hp_pins[0] = 0x14;
9348 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009349}
9350
Kailang Yangccc656c2006-10-17 12:32:26 +02009351/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009352#define alc883_targa_init_hook alc882_targa_init_hook
9353#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009354
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009355static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9356{
9357 unsigned int present;
9358
Takashi Iwaid56757a2009-11-18 08:00:14 +01009359 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009360 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9361 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9362}
9363
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009364static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009365{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009366 struct alc_spec *spec = codec->spec;
9367
9368 spec->autocfg.hp_pins[0] = 0x15;
9369 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009370}
9371
9372static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9373{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009374 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009375 alc883_clevo_m720_mic_automute(codec);
9376}
9377
9378static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009379 unsigned int res)
9380{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009381 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009382 case ALC880_MIC_EVENT:
9383 alc883_clevo_m720_mic_automute(codec);
9384 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009385 default:
9386 alc_automute_amp_unsol_event(codec, res);
9387 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009388 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009389}
9390
Jiang zhefb97dc62008-03-06 11:07:11 +01009391/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009392static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009393{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009394 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009395
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009396 spec->autocfg.hp_pins[0] = 0x14;
9397 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009398}
9399
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009400static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009401{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009402 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009403
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009404 spec->autocfg.hp_pins[0] = 0x1b;
9405 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009406}
9407
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009408static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9409{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009410 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009411
Takashi Iwai47fd8302007-08-10 17:11:07 +02009412 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9413 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009414}
9415
9416static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9417{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009418 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009419
Takashi Iwai47fd8302007-08-10 17:11:07 +02009420 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9421 HDA_AMP_MUTE, bits);
9422 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9423 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009424}
9425
9426static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9427 unsigned int res)
9428{
9429 if ((res >> 26) == ALC880_HP_EVENT)
9430 alc883_lenovo_101e_all_automute(codec);
9431 if ((res >> 26) == ALC880_FRONT_EVENT)
9432 alc883_lenovo_101e_ispeaker_automute(codec);
9433}
9434
Takashi Iwai676a9b52007-08-16 15:23:35 +02009435/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009436static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009437{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009438 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009439
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009440 spec->autocfg.hp_pins[0] = 0x14;
9441 spec->autocfg.speaker_pins[0] = 0x15;
9442 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009443}
9444
Kailang Yangd1a991a2007-08-15 16:21:59 +02009445static struct hda_verb alc883_acer_eapd_verbs[] = {
9446 /* HP Pin: output 0 (0x0c) */
9447 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9449 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9450 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9452 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009453 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009454 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9455 /* eanable EAPD on medion laptop */
9456 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9457 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009458 /* enable unsolicited event */
9459 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009460 { }
9461};
9462
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009463static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9464 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9465 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9466 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9467 { } /* end */
9468};
9469
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009470static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009471{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009472 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009473
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009474 spec->autocfg.hp_pins[0] = 0x1b;
9475 spec->autocfg.speaker_pins[0] = 0x14;
9476 spec->autocfg.speaker_pins[1] = 0x15;
9477 spec->autocfg.speaker_pins[2] = 0x16;
9478 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009479}
9480
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009481static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009482{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009483 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009484
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009485 spec->autocfg.hp_pins[0] = 0x1b;
9486 spec->autocfg.speaker_pins[0] = 0x14;
9487 spec->autocfg.speaker_pins[1] = 0x15;
9488 spec->autocfg.speaker_pins[2] = 0x16;
9489 spec->autocfg.speaker_pins[3] = 0x17;
9490 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009491}
9492
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009493static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c52009-06-05 00:47:26 +02009494{
9495 struct alc_spec *spec = codec->spec;
9496
9497 spec->autocfg.hp_pins[0] = 0x15;
9498 spec->autocfg.speaker_pins[0] = 0x14;
9499 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c52009-06-05 00:47:26 +02009500}
9501
Kailang Yange2757d52008-08-26 13:17:46 +02009502static struct hda_verb alc888_asus_m90v_verbs[] = {
9503 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9504 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9505 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9506 /* enable unsolicited event */
9507 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9508 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9509 { } /* end */
9510};
9511
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009512static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009513{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009514 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009515
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009516 spec->autocfg.hp_pins[0] = 0x1b;
9517 spec->autocfg.speaker_pins[0] = 0x14;
9518 spec->autocfg.speaker_pins[1] = 0x15;
9519 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009520 spec->ext_mic.pin = 0x18;
9521 spec->int_mic.pin = 0x19;
9522 spec->ext_mic.mux_idx = 0;
9523 spec->int_mic.mux_idx = 1;
9524 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009525}
9526
9527static struct hda_verb alc888_asus_eee1601_verbs[] = {
9528 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9529 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9530 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9531 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9532 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9533 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9534 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9535 /* enable unsolicited event */
9536 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9537 { } /* end */
9538};
9539
Kailang Yange2757d52008-08-26 13:17:46 +02009540static void alc883_eee1601_inithook(struct hda_codec *codec)
9541{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009542 struct alc_spec *spec = codec->spec;
9543
9544 spec->autocfg.hp_pins[0] = 0x14;
9545 spec->autocfg.speaker_pins[0] = 0x1b;
9546 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009547}
9548
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009549static struct hda_verb alc889A_mb31_verbs[] = {
9550 /* Init rear pin (used as headphone output) */
9551 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9552 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9553 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9554 /* Init line pin (used as output in 4ch and 6ch mode) */
9555 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9556 /* Init line 2 pin (used as headphone out by default) */
9557 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9558 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9559 { } /* end */
9560};
9561
9562/* Mute speakers according to the headphone jack state */
9563static void alc889A_mb31_automute(struct hda_codec *codec)
9564{
9565 unsigned int present;
9566
9567 /* Mute only in 2ch or 4ch mode */
9568 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9569 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009570 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009571 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9572 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9573 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9574 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9575 }
9576}
9577
9578static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9579{
9580 if ((res >> 26) == ALC880_HP_EVENT)
9581 alc889A_mb31_automute(codec);
9582}
9583
Takashi Iwai4953550a2009-06-30 15:28:30 +02009584
Takashi Iwaicb53c622007-08-10 17:21:45 +02009585#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009586#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009587#endif
9588
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009589/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009590#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9591#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9592#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9593#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9594
9595static hda_nid_t alc883_slave_dig_outs[] = {
9596 ALC1200_DIGOUT_NID, 0,
9597};
9598
9599static hda_nid_t alc1200_slave_dig_outs[] = {
9600 ALC883_DIGOUT_NID, 0,
9601};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009602
9603/*
9604 * configuration and preset
9605 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009606static const char *alc882_models[ALC882_MODEL_LAST] = {
9607 [ALC882_3ST_DIG] = "3stack-dig",
9608 [ALC882_6ST_DIG] = "6stack-dig",
9609 [ALC882_ARIMA] = "arima",
9610 [ALC882_W2JC] = "w2jc",
9611 [ALC882_TARGA] = "targa",
9612 [ALC882_ASUS_A7J] = "asus-a7j",
9613 [ALC882_ASUS_A7M] = "asus-a7m",
9614 [ALC885_MACPRO] = "macpro",
9615 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009616 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009617 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009618 [ALC885_MBP3] = "mbp3",
9619 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009620 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009621 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009622 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9623 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009624 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009625 [ALC883_TARGA_DIG] = "targa-dig",
9626 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009627 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009628 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009629 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009630 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009631 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009632 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009633 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009634 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009635 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009636 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009637 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009638 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009639 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9640 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009641 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009642 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009643 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009644 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009645 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309646 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009647 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009648 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009649 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009650 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009651 [ALC889A_INTEL] = "intel-alc889a",
9652 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009653 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009654 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c52009-06-05 00:47:26 +02009655 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009656 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009657};
9658
Takashi Iwai4953550a2009-06-30 15:28:30 +02009659static struct snd_pci_quirk alc882_cfg_tbl[] = {
9660 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9661
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009662 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009663 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009664 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009665 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9666 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009667 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009668 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9669 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009670 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009671 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009672 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9673 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009674 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9675 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009676 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9677 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009678 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009679 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009680 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009681 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009682 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9683 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009684 /* default Acer -- disabled as it causes more problems.
9685 * model=auto should work fine now
9686 */
9687 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009688
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009689 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009690
Tobin Davisfebe3372007-06-12 11:27:46 +02009691 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009692 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9693 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009694 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009695 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009696 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009697
9698 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9699 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9700 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009701 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009702 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9703 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9704 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009705 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009706 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009707 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009708 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009709
9710 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009711 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009712 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009713 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009714 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9715 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009716 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009717 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009718 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9719
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009720 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9721 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9722 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009723 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009724 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009725 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009726 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009727 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009728 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9729 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9730 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9731 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9732 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9733 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009734 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009735 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9736 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9737 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009738 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009739 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009740 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9741 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009742 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009743 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009744 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009745 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009746 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009747 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009748 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009749 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009750 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009751
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009752 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009753 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009754 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9755 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309756 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009757 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009758 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009759 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009760 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009761 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009762 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009763 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009764 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009765 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009766 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009767 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9768 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009769 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009770 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009771 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009772 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009773 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009774
Jiang zhe17bba1b2008-06-04 12:11:07 +02009775 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9776 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009777 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009778 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9779 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9780 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009781 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009782
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009783 {}
9784};
9785
Takashi Iwai4953550a2009-06-30 15:28:30 +02009786/* codec SSID table for Intel Mac */
9787static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9788 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9789 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9790 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9791 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9792 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9793 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9794 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009795 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009796 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009797 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009798 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009799 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9800 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9801 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009802 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009803 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009804 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009805 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9806 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009807 */
9808 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009809 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009810 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009811 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009812};
9813
Takashi Iwai4953550a2009-06-30 15:28:30 +02009814static struct alc_config_preset alc882_presets[] = {
9815 [ALC882_3ST_DIG] = {
9816 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009817 .init_verbs = { alc882_base_init_verbs,
9818 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009819 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9820 .dac_nids = alc882_dac_nids,
9821 .dig_out_nid = ALC882_DIGOUT_NID,
9822 .dig_in_nid = ALC882_DIGIN_NID,
9823 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9824 .channel_mode = alc882_ch_modes,
9825 .need_dac_fix = 1,
9826 .input_mux = &alc882_capture_source,
9827 },
9828 [ALC882_6ST_DIG] = {
9829 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009830 .init_verbs = { alc882_base_init_verbs,
9831 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009832 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9833 .dac_nids = alc882_dac_nids,
9834 .dig_out_nid = ALC882_DIGOUT_NID,
9835 .dig_in_nid = ALC882_DIGIN_NID,
9836 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9837 .channel_mode = alc882_sixstack_modes,
9838 .input_mux = &alc882_capture_source,
9839 },
9840 [ALC882_ARIMA] = {
9841 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009842 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9843 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009844 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9845 .dac_nids = alc882_dac_nids,
9846 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9847 .channel_mode = alc882_sixstack_modes,
9848 .input_mux = &alc882_capture_source,
9849 },
9850 [ALC882_W2JC] = {
9851 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009852 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9853 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009854 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9855 .dac_nids = alc882_dac_nids,
9856 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9857 .channel_mode = alc880_threestack_modes,
9858 .need_dac_fix = 1,
9859 .input_mux = &alc882_capture_source,
9860 .dig_out_nid = ALC882_DIGOUT_NID,
9861 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009862 [ALC885_MBA21] = {
9863 .mixers = { alc885_mba21_mixer },
9864 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9865 .num_dacs = 2,
9866 .dac_nids = alc882_dac_nids,
9867 .channel_mode = alc885_mba21_ch_modes,
9868 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9869 .input_mux = &alc882_capture_source,
9870 .unsol_event = alc_automute_amp_unsol_event,
9871 .setup = alc885_mba21_setup,
9872 .init_hook = alc_automute_amp,
9873 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009874 [ALC885_MBP3] = {
9875 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9876 .init_verbs = { alc885_mbp3_init_verbs,
9877 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009878 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009879 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009880 .hp_nid = 0x04,
9881 .channel_mode = alc885_mbp_4ch_modes,
9882 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009883 .input_mux = &alc882_capture_source,
9884 .dig_out_nid = ALC882_DIGOUT_NID,
9885 .dig_in_nid = ALC882_DIGIN_NID,
9886 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009887 .setup = alc885_mbp3_setup,
9888 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009889 },
9890 [ALC885_MB5] = {
9891 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9892 .init_verbs = { alc885_mb5_init_verbs,
9893 alc880_gpio1_init_verbs },
9894 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9895 .dac_nids = alc882_dac_nids,
9896 .channel_mode = alc885_mb5_6ch_modes,
9897 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9898 .input_mux = &mb5_capture_source,
9899 .dig_out_nid = ALC882_DIGOUT_NID,
9900 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009901 .unsol_event = alc_automute_amp_unsol_event,
9902 .setup = alc885_mb5_setup,
9903 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009904 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009905 [ALC885_MACMINI3] = {
9906 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9907 .init_verbs = { alc885_macmini3_init_verbs,
9908 alc880_gpio1_init_verbs },
9909 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9910 .dac_nids = alc882_dac_nids,
9911 .channel_mode = alc885_macmini3_6ch_modes,
9912 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9913 .input_mux = &macmini3_capture_source,
9914 .dig_out_nid = ALC882_DIGOUT_NID,
9915 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009916 .unsol_event = alc_automute_amp_unsol_event,
9917 .setup = alc885_macmini3_setup,
9918 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009919 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009920 [ALC885_MACPRO] = {
9921 .mixers = { alc882_macpro_mixer },
9922 .init_verbs = { alc882_macpro_init_verbs },
9923 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9924 .dac_nids = alc882_dac_nids,
9925 .dig_out_nid = ALC882_DIGOUT_NID,
9926 .dig_in_nid = ALC882_DIGIN_NID,
9927 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9928 .channel_mode = alc882_ch_modes,
9929 .input_mux = &alc882_capture_source,
9930 .init_hook = alc885_macpro_init_hook,
9931 },
9932 [ALC885_IMAC24] = {
9933 .mixers = { alc885_imac24_mixer },
9934 .init_verbs = { alc885_imac24_init_verbs },
9935 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9936 .dac_nids = alc882_dac_nids,
9937 .dig_out_nid = ALC882_DIGOUT_NID,
9938 .dig_in_nid = ALC882_DIGIN_NID,
9939 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9940 .channel_mode = alc882_ch_modes,
9941 .input_mux = &alc882_capture_source,
9942 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009943 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009944 .init_hook = alc885_imac24_init_hook,
9945 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009946 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009947 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009948 .init_verbs = { alc885_imac91_init_verbs,
9949 alc880_gpio1_init_verbs },
9950 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9951 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009952 .channel_mode = alc885_mba21_ch_modes,
9953 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9954 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009955 .dig_out_nid = ALC882_DIGOUT_NID,
9956 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009957 .unsol_event = alc_automute_amp_unsol_event,
9958 .setup = alc885_imac91_setup,
9959 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009960 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009961 [ALC882_TARGA] = {
9962 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009963 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009964 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009965 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9966 .dac_nids = alc882_dac_nids,
9967 .dig_out_nid = ALC882_DIGOUT_NID,
9968 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9969 .adc_nids = alc882_adc_nids,
9970 .capsrc_nids = alc882_capsrc_nids,
9971 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9972 .channel_mode = alc882_3ST_6ch_modes,
9973 .need_dac_fix = 1,
9974 .input_mux = &alc882_capture_source,
9975 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009976 .setup = alc882_targa_setup,
9977 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009978 },
9979 [ALC882_ASUS_A7J] = {
9980 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009981 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9982 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009983 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9984 .dac_nids = alc882_dac_nids,
9985 .dig_out_nid = ALC882_DIGOUT_NID,
9986 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9987 .adc_nids = alc882_adc_nids,
9988 .capsrc_nids = alc882_capsrc_nids,
9989 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9990 .channel_mode = alc882_3ST_6ch_modes,
9991 .need_dac_fix = 1,
9992 .input_mux = &alc882_capture_source,
9993 },
9994 [ALC882_ASUS_A7M] = {
9995 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009996 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9997 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009998 alc882_asus_a7m_verbs },
9999 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10000 .dac_nids = alc882_dac_nids,
10001 .dig_out_nid = ALC882_DIGOUT_NID,
10002 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10003 .channel_mode = alc880_threestack_modes,
10004 .need_dac_fix = 1,
10005 .input_mux = &alc882_capture_source,
10006 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010007 [ALC883_3ST_2ch_DIG] = {
10008 .mixers = { alc883_3ST_2ch_mixer },
10009 .init_verbs = { alc883_init_verbs },
10010 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10011 .dac_nids = alc883_dac_nids,
10012 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010013 .dig_in_nid = ALC883_DIGIN_NID,
10014 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10015 .channel_mode = alc883_3ST_2ch_modes,
10016 .input_mux = &alc883_capture_source,
10017 },
10018 [ALC883_3ST_6ch_DIG] = {
10019 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10020 .init_verbs = { alc883_init_verbs },
10021 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10022 .dac_nids = alc883_dac_nids,
10023 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010024 .dig_in_nid = ALC883_DIGIN_NID,
10025 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10026 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010027 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010028 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010029 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010030 [ALC883_3ST_6ch] = {
10031 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10032 .init_verbs = { alc883_init_verbs },
10033 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10034 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010035 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10036 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010037 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010038 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010039 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010040 [ALC883_3ST_6ch_INTEL] = {
10041 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10042 .init_verbs = { alc883_init_verbs },
10043 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10044 .dac_nids = alc883_dac_nids,
10045 .dig_out_nid = ALC883_DIGOUT_NID,
10046 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010047 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010048 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10049 .channel_mode = alc883_3ST_6ch_intel_modes,
10050 .need_dac_fix = 1,
10051 .input_mux = &alc883_3stack_6ch_intel,
10052 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010053 [ALC889A_INTEL] = {
10054 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010055 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10056 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010057 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10058 .dac_nids = alc883_dac_nids,
10059 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10060 .adc_nids = alc889_adc_nids,
10061 .dig_out_nid = ALC883_DIGOUT_NID,
10062 .dig_in_nid = ALC883_DIGIN_NID,
10063 .slave_dig_outs = alc883_slave_dig_outs,
10064 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10065 .channel_mode = alc889_8ch_intel_modes,
10066 .capsrc_nids = alc889_capsrc_nids,
10067 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010068 .setup = alc889_automute_setup,
10069 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010070 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010071 .need_dac_fix = 1,
10072 },
10073 [ALC889_INTEL] = {
10074 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10075 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010076 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010077 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10078 .dac_nids = alc883_dac_nids,
10079 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10080 .adc_nids = alc889_adc_nids,
10081 .dig_out_nid = ALC883_DIGOUT_NID,
10082 .dig_in_nid = ALC883_DIGIN_NID,
10083 .slave_dig_outs = alc883_slave_dig_outs,
10084 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10085 .channel_mode = alc889_8ch_intel_modes,
10086 .capsrc_nids = alc889_capsrc_nids,
10087 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010088 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010089 .init_hook = alc889_intel_init_hook,
10090 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010091 .need_dac_fix = 1,
10092 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010093 [ALC883_6ST_DIG] = {
10094 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10095 .init_verbs = { alc883_init_verbs },
10096 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10097 .dac_nids = alc883_dac_nids,
10098 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010099 .dig_in_nid = ALC883_DIGIN_NID,
10100 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10101 .channel_mode = alc883_sixstack_modes,
10102 .input_mux = &alc883_capture_source,
10103 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010104 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010105 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010106 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10107 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010108 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10109 .dac_nids = alc883_dac_nids,
10110 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010111 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10112 .channel_mode = alc883_3ST_6ch_modes,
10113 .need_dac_fix = 1,
10114 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010115 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010116 .setup = alc882_targa_setup,
10117 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010118 },
10119 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010120 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010121 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10122 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010123 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10124 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010125 .adc_nids = alc883_adc_nids_alt,
10126 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010127 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010128 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010129 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10130 .channel_mode = alc883_3ST_2ch_modes,
10131 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010132 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010133 .setup = alc882_targa_setup,
10134 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010135 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010136 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010137 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10138 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010139 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010140 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010141 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10142 .dac_nids = alc883_dac_nids,
10143 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10144 .adc_nids = alc883_adc_nids_rev,
10145 .capsrc_nids = alc883_capsrc_nids_rev,
10146 .dig_out_nid = ALC883_DIGOUT_NID,
10147 .dig_in_nid = ALC883_DIGIN_NID,
10148 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10149 .channel_mode = alc883_4ST_8ch_modes,
10150 .need_dac_fix = 1,
10151 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010152 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010153 .setup = alc882_targa_setup,
10154 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010155 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010156 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010157 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010158 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10159 * and the headphone jack. Turn this on and rely on the
10160 * standard mute methods whenever the user wants to turn
10161 * these outputs off.
10162 */
10163 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10164 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10165 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010166 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10167 .channel_mode = alc883_3ST_2ch_modes,
10168 .input_mux = &alc883_capture_source,
10169 },
Tobin Davis2880a862007-08-07 11:50:26 +020010170 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010171 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010172 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010173 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10174 .dac_nids = alc883_dac_nids,
10175 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010176 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10177 .channel_mode = alc883_3ST_2ch_modes,
10178 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010179 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010180 .setup = alc883_acer_aspire_setup,
10181 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010182 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010183 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010184 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010185 alc883_chmode_mixer },
10186 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10187 alc888_acer_aspire_4930g_verbs },
10188 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10189 .dac_nids = alc883_dac_nids,
10190 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10191 .adc_nids = alc883_adc_nids_rev,
10192 .capsrc_nids = alc883_capsrc_nids_rev,
10193 .dig_out_nid = ALC883_DIGOUT_NID,
10194 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10195 .channel_mode = alc883_3ST_6ch_modes,
10196 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010197 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010198 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010199 ARRAY_SIZE(alc888_2_capture_sources),
10200 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010201 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010202 .setup = alc888_acer_aspire_4930g_setup,
10203 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010204 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010205 [ALC888_ACER_ASPIRE_6530G] = {
10206 .mixers = { alc888_acer_aspire_6530_mixer },
10207 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10208 alc888_acer_aspire_6530g_verbs },
10209 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10210 .dac_nids = alc883_dac_nids,
10211 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10212 .adc_nids = alc883_adc_nids_rev,
10213 .capsrc_nids = alc883_capsrc_nids_rev,
10214 .dig_out_nid = ALC883_DIGOUT_NID,
10215 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10216 .channel_mode = alc883_3ST_2ch_modes,
10217 .num_mux_defs =
10218 ARRAY_SIZE(alc888_2_capture_sources),
10219 .input_mux = alc888_acer_aspire_6530_sources,
10220 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010221 .setup = alc888_acer_aspire_6530g_setup,
10222 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010223 },
Hector Martin3b315d72009-06-02 10:54:19 +020010224 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010225 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010226 alc883_chmode_mixer },
10227 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010228 alc889_acer_aspire_8930g_verbs,
10229 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010230 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10231 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010232 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10233 .adc_nids = alc889_adc_nids,
10234 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010235 .dig_out_nid = ALC883_DIGOUT_NID,
10236 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10237 .channel_mode = alc883_3ST_6ch_modes,
10238 .need_dac_fix = 1,
10239 .const_channel_count = 6,
10240 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010241 ARRAY_SIZE(alc889_capture_sources),
10242 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010243 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010244 .setup = alc889_acer_aspire_8930g_setup,
10245 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010246#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010247 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010248#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010249 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010250 [ALC888_ACER_ASPIRE_7730G] = {
10251 .mixers = { alc883_3ST_6ch_mixer,
10252 alc883_chmode_mixer },
10253 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10254 alc888_acer_aspire_7730G_verbs },
10255 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10256 .dac_nids = alc883_dac_nids,
10257 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10258 .adc_nids = alc883_adc_nids_rev,
10259 .capsrc_nids = alc883_capsrc_nids_rev,
10260 .dig_out_nid = ALC883_DIGOUT_NID,
10261 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10262 .channel_mode = alc883_3ST_6ch_modes,
10263 .need_dac_fix = 1,
10264 .const_channel_count = 6,
10265 .input_mux = &alc883_capture_source,
10266 .unsol_event = alc_automute_amp_unsol_event,
10267 .setup = alc888_acer_aspire_6530g_setup,
10268 .init_hook = alc_automute_amp,
10269 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010270 [ALC883_MEDION] = {
10271 .mixers = { alc883_fivestack_mixer,
10272 alc883_chmode_mixer },
10273 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010274 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010275 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10276 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010277 .adc_nids = alc883_adc_nids_alt,
10278 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010279 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010280 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10281 .channel_mode = alc883_sixstack_modes,
10282 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010283 },
Kailang Yang272a5272007-05-14 11:00:38 +020010284 [ALC883_MEDION_MD2] = {
10285 .mixers = { alc883_medion_md2_mixer},
10286 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
10287 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10288 .dac_nids = alc883_dac_nids,
10289 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010290 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10291 .channel_mode = alc883_3ST_2ch_modes,
10292 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010293 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010294 .setup = alc883_medion_md2_setup,
10295 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020010296 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010297 [ALC883_MEDION_WIM2160] = {
10298 .mixers = { alc883_medion_wim2160_mixer },
10299 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10300 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10301 .dac_nids = alc883_dac_nids,
10302 .dig_out_nid = ALC883_DIGOUT_NID,
10303 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10304 .adc_nids = alc883_adc_nids,
10305 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10306 .channel_mode = alc883_3ST_2ch_modes,
10307 .input_mux = &alc883_capture_source,
10308 .unsol_event = alc_automute_amp_unsol_event,
10309 .setup = alc883_medion_wim2160_setup,
10310 .init_hook = alc_automute_amp,
10311 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010312 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010313 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010314 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10315 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10316 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010317 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10318 .channel_mode = alc883_3ST_2ch_modes,
10319 .input_mux = &alc883_capture_source,
10320 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010321 [ALC883_CLEVO_M540R] = {
10322 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10323 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10324 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10325 .dac_nids = alc883_dac_nids,
10326 .dig_out_nid = ALC883_DIGOUT_NID,
10327 .dig_in_nid = ALC883_DIGIN_NID,
10328 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10329 .channel_mode = alc883_3ST_6ch_clevo_modes,
10330 .need_dac_fix = 1,
10331 .input_mux = &alc883_capture_source,
10332 /* This machine has the hardware HP auto-muting, thus
10333 * we need no software mute via unsol event
10334 */
10335 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010336 [ALC883_CLEVO_M720] = {
10337 .mixers = { alc883_clevo_m720_mixer },
10338 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010339 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10340 .dac_nids = alc883_dac_nids,
10341 .dig_out_nid = ALC883_DIGOUT_NID,
10342 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10343 .channel_mode = alc883_3ST_2ch_modes,
10344 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010345 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010346 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010347 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010348 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010349 [ALC883_LENOVO_101E_2ch] = {
10350 .mixers = { alc883_lenovo_101e_2ch_mixer},
10351 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10352 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10353 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010354 .adc_nids = alc883_adc_nids_alt,
10355 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010356 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010357 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10358 .channel_mode = alc883_3ST_2ch_modes,
10359 .input_mux = &alc883_lenovo_101e_capture_source,
10360 .unsol_event = alc883_lenovo_101e_unsol_event,
10361 .init_hook = alc883_lenovo_101e_all_automute,
10362 },
Kailang Yang272a5272007-05-14 11:00:38 +020010363 [ALC883_LENOVO_NB0763] = {
10364 .mixers = { alc883_lenovo_nb0763_mixer },
10365 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10366 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10367 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010368 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10369 .channel_mode = alc883_3ST_2ch_modes,
10370 .need_dac_fix = 1,
10371 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010372 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010373 .setup = alc883_medion_md2_setup,
10374 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010375 },
10376 [ALC888_LENOVO_MS7195_DIG] = {
10377 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10378 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10379 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10380 .dac_nids = alc883_dac_nids,
10381 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010382 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10383 .channel_mode = alc883_3ST_6ch_modes,
10384 .need_dac_fix = 1,
10385 .input_mux = &alc883_capture_source,
10386 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10387 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010388 },
10389 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010390 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010391 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10392 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10393 .dac_nids = alc883_dac_nids,
10394 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010395 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10396 .channel_mode = alc883_3ST_2ch_modes,
10397 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010398 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010399 .setup = alc883_haier_w66_setup,
10400 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010401 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010402 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010403 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010404 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010405 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10406 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010407 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10408 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010409 .need_dac_fix = 1,
10410 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010411 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010412 .setup = alc888_3st_hp_setup,
10413 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010414 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010415 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010416 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010417 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10418 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10419 .dac_nids = alc883_dac_nids,
10420 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010421 .dig_in_nid = ALC883_DIGIN_NID,
10422 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10423 .channel_mode = alc883_sixstack_modes,
10424 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010425 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010426 .setup = alc888_6st_dell_setup,
10427 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010428 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010429 [ALC883_MITAC] = {
10430 .mixers = { alc883_mitac_mixer },
10431 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10432 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10433 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010434 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10435 .channel_mode = alc883_3ST_2ch_modes,
10436 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010437 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010438 .setup = alc883_mitac_setup,
10439 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010440 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010441 [ALC883_FUJITSU_PI2515] = {
10442 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10443 .init_verbs = { alc883_init_verbs,
10444 alc883_2ch_fujitsu_pi2515_verbs},
10445 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10446 .dac_nids = alc883_dac_nids,
10447 .dig_out_nid = ALC883_DIGOUT_NID,
10448 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10449 .channel_mode = alc883_3ST_2ch_modes,
10450 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010451 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010452 .setup = alc883_2ch_fujitsu_pi2515_setup,
10453 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010454 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010455 [ALC888_FUJITSU_XA3530] = {
10456 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10457 .init_verbs = { alc883_init_verbs,
10458 alc888_fujitsu_xa3530_verbs },
10459 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10460 .dac_nids = alc883_dac_nids,
10461 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10462 .adc_nids = alc883_adc_nids_rev,
10463 .capsrc_nids = alc883_capsrc_nids_rev,
10464 .dig_out_nid = ALC883_DIGOUT_NID,
10465 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10466 .channel_mode = alc888_4ST_8ch_intel_modes,
10467 .num_mux_defs =
10468 ARRAY_SIZE(alc888_2_capture_sources),
10469 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010470 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010471 .setup = alc888_fujitsu_xa3530_setup,
10472 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010473 },
Kailang Yange2757d52008-08-26 13:17:46 +020010474 [ALC888_LENOVO_SKY] = {
10475 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10476 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10477 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10478 .dac_nids = alc883_dac_nids,
10479 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010480 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10481 .channel_mode = alc883_sixstack_modes,
10482 .need_dac_fix = 1,
10483 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010484 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010485 .setup = alc888_lenovo_sky_setup,
10486 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010487 },
10488 [ALC888_ASUS_M90V] = {
10489 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10490 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10491 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10492 .dac_nids = alc883_dac_nids,
10493 .dig_out_nid = ALC883_DIGOUT_NID,
10494 .dig_in_nid = ALC883_DIGIN_NID,
10495 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10496 .channel_mode = alc883_3ST_6ch_modes,
10497 .need_dac_fix = 1,
10498 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010499 .unsol_event = alc_sku_unsol_event,
10500 .setup = alc883_mode2_setup,
10501 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010502 },
10503 [ALC888_ASUS_EEE1601] = {
10504 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010505 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010506 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10507 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10508 .dac_nids = alc883_dac_nids,
10509 .dig_out_nid = ALC883_DIGOUT_NID,
10510 .dig_in_nid = ALC883_DIGIN_NID,
10511 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10512 .channel_mode = alc883_3ST_2ch_modes,
10513 .need_dac_fix = 1,
10514 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010515 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010516 .init_hook = alc883_eee1601_inithook,
10517 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010518 [ALC1200_ASUS_P5Q] = {
10519 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10520 .init_verbs = { alc883_init_verbs },
10521 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10522 .dac_nids = alc883_dac_nids,
10523 .dig_out_nid = ALC1200_DIGOUT_NID,
10524 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010525 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010526 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10527 .channel_mode = alc883_sixstack_modes,
10528 .input_mux = &alc883_capture_source,
10529 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010530 [ALC889A_MB31] = {
10531 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10532 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10533 alc880_gpio1_init_verbs },
10534 .adc_nids = alc883_adc_nids,
10535 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010536 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010537 .dac_nids = alc883_dac_nids,
10538 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10539 .channel_mode = alc889A_mb31_6ch_modes,
10540 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10541 .input_mux = &alc889A_mb31_capture_source,
10542 .dig_out_nid = ALC883_DIGOUT_NID,
10543 .unsol_event = alc889A_mb31_unsol_event,
10544 .init_hook = alc889A_mb31_automute,
10545 },
Guido Günther3e1647c52009-06-05 00:47:26 +020010546 [ALC883_SONY_VAIO_TT] = {
10547 .mixers = { alc883_vaiott_mixer },
10548 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10549 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10550 .dac_nids = alc883_dac_nids,
10551 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10552 .channel_mode = alc883_3ST_2ch_modes,
10553 .input_mux = &alc883_capture_source,
10554 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010555 .setup = alc883_vaiott_setup,
10556 .init_hook = alc_automute_amp,
Guido Günther3e1647c52009-06-05 00:47:26 +020010557 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010558};
10559
10560
10561/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010562 * Pin config fixes
10563 */
10564enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010565 PINFIX_ABIT_AW9D_MAX,
10566 PINFIX_PB_M5210,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010567};
10568
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010569static const struct alc_fixup alc882_fixups[] = {
10570 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010571 .pins = (const struct alc_pincfg[]) {
10572 { 0x15, 0x01080104 }, /* side */
10573 { 0x16, 0x01011012 }, /* rear */
10574 { 0x17, 0x01016011 }, /* clfe */
10575 { }
10576 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010577 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010578 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010579 .verbs = (const struct hda_verb[]) {
10580 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10581 {}
10582 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010583 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010584};
10585
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010586static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010587 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010588 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10589 {}
10590};
10591
10592/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010593 * BIOS auto configuration
10594 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010595static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10596 const struct auto_pin_cfg *cfg)
10597{
10598 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10599}
10600
Takashi Iwai4953550a2009-06-30 15:28:30 +020010601static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010602 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010603 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010604{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010605 int idx;
10606
Takashi Iwai489008c2010-04-07 09:06:00 +020010607 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010608 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010609
Takashi Iwai489008c2010-04-07 09:06:00 +020010610 if (dac == 0x25)
10611 idx = 4;
10612 else if (dac >= 0x02 && dac <= 0x05)
10613 idx = dac - 2;
10614 else
10615 return;
10616 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010617}
10618
Takashi Iwai4953550a2009-06-30 15:28:30 +020010619static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010620{
10621 struct alc_spec *spec = codec->spec;
10622 int i;
10623
10624 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010625 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010626 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010627 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010628 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010629 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010630 }
10631}
10632
Takashi Iwai4953550a2009-06-30 15:28:30 +020010633static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010634{
10635 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010636 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010637 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010638
Takashi Iwai5855fb82010-09-16 18:24:02 +020010639 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10640 pin = spec->autocfg.hp_pins[i];
10641 if (!pin)
10642 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010643 dac = spec->multiout.hp_nid;
10644 if (!dac)
10645 dac = spec->multiout.dac_nids[0]; /* to front */
10646 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10647 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010648 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10649 pin = spec->autocfg.speaker_pins[i];
10650 if (!pin)
10651 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010652 dac = spec->multiout.extra_out_nid[0];
10653 if (!dac)
10654 dac = spec->multiout.dac_nids[0]; /* to front */
10655 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10656 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010657}
10658
Takashi Iwai4953550a2009-06-30 15:28:30 +020010659static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010660{
10661 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010662 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010663 int i;
10664
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010665 for (i = 0; i < cfg->num_inputs; i++) {
10666 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010667 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010668 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10669 snd_hda_codec_write(codec, nid, 0,
10670 AC_VERB_SET_AMP_GAIN_MUTE,
10671 AMP_OUT_MUTE);
10672 }
10673}
10674
10675static void alc882_auto_init_input_src(struct hda_codec *codec)
10676{
10677 struct alc_spec *spec = codec->spec;
10678 int c;
10679
10680 for (c = 0; c < spec->num_adc_nids; c++) {
10681 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10682 hda_nid_t nid = spec->capsrc_nids[c];
10683 unsigned int mux_idx;
10684 const struct hda_input_mux *imux;
10685 int conns, mute, idx, item;
10686
10687 conns = snd_hda_get_connections(codec, nid, conn_list,
10688 ARRAY_SIZE(conn_list));
10689 if (conns < 0)
10690 continue;
10691 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10692 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010693 if (!imux->num_items && mux_idx > 0)
10694 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010695 for (idx = 0; idx < conns; idx++) {
10696 /* if the current connection is the selected one,
10697 * unmute it as default - otherwise mute it
10698 */
10699 mute = AMP_IN_MUTE(idx);
10700 for (item = 0; item < imux->num_items; item++) {
10701 if (imux->items[item].index == idx) {
10702 if (spec->cur_mux[c] == item)
10703 mute = AMP_IN_UNMUTE(idx);
10704 break;
10705 }
10706 }
10707 /* check if we have a selector or mixer
10708 * we could check for the widget type instead, but
10709 * just check for Amp-In presence (in case of mixer
10710 * without amp-in there is something wrong, this
10711 * function shouldn't be used or capsrc nid is wrong)
10712 */
10713 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010714 snd_hda_codec_write(codec, nid, 0,
10715 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010716 mute);
10717 else if (mute != AMP_IN_MUTE(idx))
10718 snd_hda_codec_write(codec, nid, 0,
10719 AC_VERB_SET_CONNECT_SEL,
10720 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010721 }
10722 }
10723}
10724
Takashi Iwai4953550a2009-06-30 15:28:30 +020010725/* add mic boosts if needed */
10726static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010727{
10728 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010729 struct auto_pin_cfg *cfg = &spec->autocfg;
10730 int i, err;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010731 hda_nid_t nid;
10732
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010733 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010734 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010735 break;
10736 nid = cfg->inputs[i].pin;
10737 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +020010738 char label[32];
10739 snprintf(label, sizeof(label), "%s Boost",
10740 hda_get_autocfg_input_label(codec, cfg, i));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010741 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010742 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010743 if (err < 0)
10744 return err;
10745 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010746 }
10747 return 0;
10748}
10749
10750/* almost identical with ALC880 parser... */
10751static int alc882_parse_auto_config(struct hda_codec *codec)
10752{
10753 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010754 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010755 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010756
Takashi Iwai05f5f472009-08-25 13:10:18 +020010757 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10758 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010759 if (err < 0)
10760 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010761 if (!spec->autocfg.line_outs)
10762 return 0; /* can't find valid BIOS pin config */
10763
10764 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10765 if (err < 0)
10766 return err;
10767 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10768 if (err < 0)
10769 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010770 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10771 "Headphone");
10772 if (err < 0)
10773 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010774 err = alc880_auto_create_extra_out(spec,
10775 spec->autocfg.speaker_pins[0],
10776 "Speaker");
10777 if (err < 0)
10778 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010779 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10780 if (err < 0)
10781 return err;
10782
10783 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10784
Takashi Iwai757899a2010-07-30 10:48:14 +020010785 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010786
10787 if (spec->kctls.list)
10788 add_mixer(spec, spec->kctls.list);
10789
10790 add_verb(spec, alc883_auto_init_verbs);
10791 /* if ADC 0x07 is available, initialize it, too */
10792 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10793 add_verb(spec, alc882_adc1_init_verbs);
10794
10795 spec->num_mux_defs = 1;
10796 spec->input_mux = &spec->private_imux[0];
10797
Kailang Yang6227cdc2010-02-25 08:36:52 +010010798 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010799
10800 err = alc_auto_add_mic_boost(codec);
10801 if (err < 0)
10802 return err;
10803
Takashi Iwai776e1842007-08-29 15:07:11 +020010804 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010805}
10806
10807/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010808static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010809{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010810 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010811 alc882_auto_init_multi_out(codec);
10812 alc882_auto_init_hp_out(codec);
10813 alc882_auto_init_analog_input(codec);
10814 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010815 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010816 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010817 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010818}
10819
Takashi Iwai4953550a2009-06-30 15:28:30 +020010820static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010821{
10822 struct alc_spec *spec;
10823 int err, board_config;
10824
10825 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10826 if (spec == NULL)
10827 return -ENOMEM;
10828
10829 codec->spec = spec;
10830
Kailang Yangda00c242010-03-19 11:23:45 +010010831 alc_auto_parse_customize_define(codec);
10832
Takashi Iwai4953550a2009-06-30 15:28:30 +020010833 switch (codec->vendor_id) {
10834 case 0x10ec0882:
10835 case 0x10ec0885:
10836 break;
10837 default:
10838 /* ALC883 and variants */
10839 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10840 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010841 }
10842
Takashi Iwai4953550a2009-06-30 15:28:30 +020010843 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10844 alc882_models,
10845 alc882_cfg_tbl);
10846
10847 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10848 board_config = snd_hda_check_board_codec_sid_config(codec,
10849 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10850
10851 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010852 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010853 codec->chip_name);
10854 board_config = ALC882_AUTO;
10855 }
10856
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010857 if (board_config == ALC882_AUTO)
10858 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010859
10860 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010861 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010862 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010863 if (err < 0) {
10864 alc_free(codec);
10865 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010866 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010867 printk(KERN_INFO
10868 "hda_codec: Cannot set up configuration "
10869 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010870 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010871 }
10872 }
10873
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010874 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010875 err = snd_hda_attach_beep_device(codec, 0x1);
10876 if (err < 0) {
10877 alc_free(codec);
10878 return err;
10879 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010880 }
10881
Takashi Iwai4953550a2009-06-30 15:28:30 +020010882 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010883 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010884
Takashi Iwai4953550a2009-06-30 15:28:30 +020010885 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10886 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10887 /* FIXME: setup DAC5 */
10888 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10889 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10890
10891 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10892 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10893
Takashi Iwai4953550a2009-06-30 15:28:30 +020010894 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010895 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010896 spec->num_adc_nids = 0;
10897 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010898 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010899 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010900 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010901 hda_nid_t nid = alc882_adc_nids[i];
10902 unsigned int wcap = get_wcaps(codec, nid);
10903 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010904 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010905 if (wcap != AC_WID_AUD_IN)
10906 continue;
10907 spec->private_adc_nids[spec->num_adc_nids] = nid;
10908 err = snd_hda_get_connections(codec, nid, &cap, 1);
10909 if (err < 0)
10910 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010911 err = snd_hda_get_connections(codec, cap, items,
10912 ARRAY_SIZE(items));
10913 if (err < 0)
10914 continue;
10915 for (j = 0; j < imux->num_items; j++)
10916 if (imux->items[j].index >= err)
10917 break;
10918 if (j < imux->num_items)
10919 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010920 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10921 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010922 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010923 spec->adc_nids = spec->private_adc_nids;
10924 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010925 }
10926
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010927 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010928
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010929 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010010930 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010931
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010932 if (board_config == ALC882_AUTO)
10933 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10934
Takashi Iwai2134ea42008-01-10 16:53:55 +010010935 spec->vmaster_nid = 0x0c;
10936
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010937 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010938 if (board_config == ALC882_AUTO)
10939 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010940#ifdef CONFIG_SND_HDA_POWER_SAVE
10941 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010942 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010943#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010944
10945 return 0;
10946}
10947
Takashi Iwai4953550a2009-06-30 15:28:30 +020010948
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010949/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010950 * ALC262 support
10951 */
10952
10953#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10954#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10955
10956#define alc262_dac_nids alc260_dac_nids
10957#define alc262_adc_nids alc882_adc_nids
10958#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010959#define alc262_capsrc_nids alc882_capsrc_nids
10960#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010961
10962#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010963#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010964
Kailang Yang4e555fe2008-08-26 13:05:55 +020010965static hda_nid_t alc262_dmic_adc_nids[1] = {
10966 /* ADC0 */
10967 0x09
10968};
10969
10970static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10971
Kailang Yangdf694da2005-12-05 19:42:22 +010010972static struct snd_kcontrol_new alc262_base_mixer[] = {
10973 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10974 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10975 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10976 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10977 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10978 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10979 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010981 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010982 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10983 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010984 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010985 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10986 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10987 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10988 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010989 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010990};
10991
Takashi Iwaice875f02008-01-28 18:17:43 +010010992/* update HP, line and mono-out pins according to the master switch */
10993static void alc262_hp_master_update(struct hda_codec *codec)
10994{
10995 struct alc_spec *spec = codec->spec;
10996 int val = spec->master_sw;
10997
10998 /* HP & line-out */
10999 snd_hda_codec_write_cache(codec, 0x1b, 0,
11000 AC_VERB_SET_PIN_WIDGET_CONTROL,
11001 val ? PIN_HP : 0);
11002 snd_hda_codec_write_cache(codec, 0x15, 0,
11003 AC_VERB_SET_PIN_WIDGET_CONTROL,
11004 val ? PIN_HP : 0);
11005 /* mono (speaker) depending on the HP jack sense */
11006 val = val && !spec->jack_present;
11007 snd_hda_codec_write_cache(codec, 0x16, 0,
11008 AC_VERB_SET_PIN_WIDGET_CONTROL,
11009 val ? PIN_OUT : 0);
11010}
11011
11012static void alc262_hp_bpc_automute(struct hda_codec *codec)
11013{
11014 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011015
11016 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011017 alc262_hp_master_update(codec);
11018}
11019
11020static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11021{
11022 if ((res >> 26) != ALC880_HP_EVENT)
11023 return;
11024 alc262_hp_bpc_automute(codec);
11025}
11026
11027static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11028{
11029 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011030
11031 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011032 alc262_hp_master_update(codec);
11033}
11034
11035static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11036 unsigned int res)
11037{
11038 if ((res >> 26) != ALC880_HP_EVENT)
11039 return;
11040 alc262_hp_wildwest_automute(codec);
11041}
11042
Takashi Iwaib72519b2009-05-08 14:31:55 +020011043#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011044
11045static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11046 struct snd_ctl_elem_value *ucontrol)
11047{
11048 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11049 struct alc_spec *spec = codec->spec;
11050 int val = !!*ucontrol->value.integer.value;
11051
11052 if (val == spec->master_sw)
11053 return 0;
11054 spec->master_sw = val;
11055 alc262_hp_master_update(codec);
11056 return 1;
11057}
11058
Takashi Iwaib72519b2009-05-08 14:31:55 +020011059#define ALC262_HP_MASTER_SWITCH \
11060 { \
11061 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11062 .name = "Master Playback Switch", \
11063 .info = snd_ctl_boolean_mono_info, \
11064 .get = alc262_hp_master_sw_get, \
11065 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011066 }, \
11067 { \
11068 .iface = NID_MAPPING, \
11069 .name = "Master Playback Switch", \
11070 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011071 }
11072
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011073
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011074static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011075 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011076 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11077 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11078 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011079 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11080 HDA_OUTPUT),
11081 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11082 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11084 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011085 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011086 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11087 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011088 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011089 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11090 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11091 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11092 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011093 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11094 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11095 { } /* end */
11096};
11097
Kailang Yangcd7509a2007-01-26 18:33:17 +010011098static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011099 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011100 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11101 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11102 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11103 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011104 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11105 HDA_OUTPUT),
11106 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11107 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011108 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11109 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011110 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011111 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11112 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11113 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11114 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011115 { } /* end */
11116};
11117
11118static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11119 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11120 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011121 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011122 { } /* end */
11123};
11124
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011125/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011126static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011127{
11128 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011129
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011130 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011131 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011132}
11133
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011134static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011135 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11136 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011137 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11139 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11140 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11141 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11142 { } /* end */
11143};
11144
11145static struct hda_verb alc262_hp_t5735_verbs[] = {
11146 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11147 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11148
11149 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11150 { }
11151};
11152
Kailang Yang8c427222008-01-10 13:03:59 +010011153static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011154 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11155 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011156 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11157 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011158 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11159 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11160 { } /* end */
11161};
11162
11163static struct hda_verb alc262_hp_rp5700_verbs[] = {
11164 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11165 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11166 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11167 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11168 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11169 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11170 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11172 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11173 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11174 {}
11175};
11176
11177static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11178 .num_items = 1,
11179 .items = {
11180 { "Line", 0x1 },
11181 },
11182};
11183
Takashi Iwai42171c12009-05-08 14:11:43 +020011184/* bind hp and internal speaker mute (with plug check) as master switch */
11185static void alc262_hippo_master_update(struct hda_codec *codec)
11186{
11187 struct alc_spec *spec = codec->spec;
11188 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11189 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11190 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11191 unsigned int mute;
11192
11193 /* HP */
11194 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11195 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11196 HDA_AMP_MUTE, mute);
11197 /* mute internal speaker per jack sense */
11198 if (spec->jack_present)
11199 mute = HDA_AMP_MUTE;
11200 if (line_nid)
11201 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11202 HDA_AMP_MUTE, mute);
11203 if (speaker_nid && speaker_nid != line_nid)
11204 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11205 HDA_AMP_MUTE, mute);
11206}
11207
11208#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11209
11210static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11211 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011212{
11213 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011214 struct alc_spec *spec = codec->spec;
11215 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011216
Takashi Iwai42171c12009-05-08 14:11:43 +020011217 if (val == spec->master_sw)
11218 return 0;
11219 spec->master_sw = val;
11220 alc262_hippo_master_update(codec);
11221 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011222}
Takashi Iwai5b319542007-07-26 11:49:22 +020011223
Takashi Iwai42171c12009-05-08 14:11:43 +020011224#define ALC262_HIPPO_MASTER_SWITCH \
11225 { \
11226 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11227 .name = "Master Playback Switch", \
11228 .info = snd_ctl_boolean_mono_info, \
11229 .get = alc262_hippo_master_sw_get, \
11230 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011231 }, \
11232 { \
11233 .iface = NID_MAPPING, \
11234 .name = "Master Playback Switch", \
11235 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11236 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011237 }
11238
11239static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11240 ALC262_HIPPO_MASTER_SWITCH,
11241 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11242 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11243 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11244 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11245 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11246 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11247 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11248 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11249 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11250 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11251 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11252 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11253 { } /* end */
11254};
11255
11256static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11257 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11258 ALC262_HIPPO_MASTER_SWITCH,
11259 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11260 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11261 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11262 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11263 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11264 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11265 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11266 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11267 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11268 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11269 { } /* end */
11270};
11271
11272/* mute/unmute internal speaker according to the hp jack and mute state */
11273static void alc262_hippo_automute(struct hda_codec *codec)
11274{
11275 struct alc_spec *spec = codec->spec;
11276 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011277
Wu Fengguang864f92b2009-11-18 12:38:02 +080011278 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011279 alc262_hippo_master_update(codec);
11280}
11281
11282static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11283{
11284 if ((res >> 26) != ALC880_HP_EVENT)
11285 return;
11286 alc262_hippo_automute(codec);
11287}
11288
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011289static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011290{
11291 struct alc_spec *spec = codec->spec;
11292
11293 spec->autocfg.hp_pins[0] = 0x15;
11294 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011295}
11296
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011297static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011298{
11299 struct alc_spec *spec = codec->spec;
11300
11301 spec->autocfg.hp_pins[0] = 0x1b;
11302 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011303}
11304
11305
Kailang Yang272a5272007-05-14 11:00:38 +020011306static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011307 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011308 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011309 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11310 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11311 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11312 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11313 { } /* end */
11314};
11315
Kailang Yang83c34212007-07-05 11:43:05 +020011316static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011317 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11318 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011319 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11320 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11321 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11322 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11323 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11324 { } /* end */
11325};
Kailang Yang272a5272007-05-14 11:00:38 +020011326
Tony Vroonba340e82009-02-02 19:01:30 +000011327static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11328 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11329 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11330 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11331 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11332 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11333 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11334 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11335 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11336 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11339 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11340 { } /* end */
11341};
11342
11343static struct hda_verb alc262_tyan_verbs[] = {
11344 /* Headphone automute */
11345 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11346 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11347 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11348
11349 /* P11 AUX_IN, white 4-pin connector */
11350 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11351 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11352 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11353 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11354
11355 {}
11356};
11357
11358/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011359static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011360{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011361 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011362
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011363 spec->autocfg.hp_pins[0] = 0x1b;
11364 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011365}
11366
Tony Vroonba340e82009-02-02 19:01:30 +000011367
Kailang Yangdf694da2005-12-05 19:42:22 +010011368#define alc262_capture_mixer alc882_capture_mixer
11369#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11370
11371/*
11372 * generic initialization of ADC, input mixers and output mixers
11373 */
11374static struct hda_verb alc262_init_verbs[] = {
11375 /*
11376 * Unmute ADC0-2 and set the default input to mic-in
11377 */
11378 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11380 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11381 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11382 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11383 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11384
Takashi Iwaicb53c622007-08-10 17:21:45 +020011385 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011386 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011387 * Note: PASD motherboards uses the Line In 2 as the input for
11388 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011389 */
11390 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011391 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11392 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11393 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11394 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11395 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011396
11397 /*
11398 * Set up output mixers (0x0c - 0x0e)
11399 */
11400 /* set vol=0 to output mixers */
11401 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11402 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11403 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11404 /* set up input amps for analog loopback */
11405 /* Amp Indices: DAC = 0, mixer = 1 */
11406 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11407 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11410 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11411 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11412
11413 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11414 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11415 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11417 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11418 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11419
11420 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11422 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11423 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11424 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011425
Kailang Yangdf694da2005-12-05 19:42:22 +010011426 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11427 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011428
Kailang Yangdf694da2005-12-05 19:42:22 +010011429 /* FIXME: use matrix-type input source selection */
11430 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11431 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11432 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11433 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11434 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11435 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11436 /* Input mixer2 */
11437 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11438 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11439 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11440 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11441 /* Input mixer3 */
11442 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11443 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11444 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011445 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011446
11447 { }
11448};
11449
Kailang Yang4e555fe2008-08-26 13:05:55 +020011450static struct hda_verb alc262_eapd_verbs[] = {
11451 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11452 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11453 { }
11454};
11455
Kailang Yangccc656c2006-10-17 12:32:26 +020011456static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11457 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11458 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11459 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11460
11461 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11462 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11463 {}
11464};
11465
Kailang Yang272a5272007-05-14 11:00:38 +020011466static struct hda_verb alc262_sony_unsol_verbs[] = {
11467 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11468 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11469 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11470
11471 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11472 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011473 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011474};
11475
Kailang Yang4e555fe2008-08-26 13:05:55 +020011476static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11477 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11478 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11479 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11480 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11481 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011482 { } /* end */
11483};
11484
11485static struct hda_verb alc262_toshiba_s06_verbs[] = {
11486 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11487 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11488 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11489 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11490 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11491 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11492 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11493 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11494 {}
11495};
11496
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011497static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011498{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011499 struct alc_spec *spec = codec->spec;
11500
11501 spec->autocfg.hp_pins[0] = 0x15;
11502 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011503 spec->ext_mic.pin = 0x18;
11504 spec->ext_mic.mux_idx = 0;
11505 spec->int_mic.pin = 0x12;
11506 spec->int_mic.mux_idx = 9;
11507 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011508}
11509
Takashi Iwai834be882006-03-01 14:16:17 +010011510/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011511 * nec model
11512 * 0x15 = headphone
11513 * 0x16 = internal speaker
11514 * 0x18 = external mic
11515 */
11516
11517static struct snd_kcontrol_new alc262_nec_mixer[] = {
11518 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11519 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11520
11521 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11522 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11523 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11524
11525 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11526 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11527 { } /* end */
11528};
11529
11530static struct hda_verb alc262_nec_verbs[] = {
11531 /* Unmute Speaker */
11532 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11533
11534 /* Headphone */
11535 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11536 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11537
11538 /* External mic to headphone */
11539 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11540 /* External mic to speaker */
11541 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11542 {}
11543};
11544
11545/*
Takashi Iwai834be882006-03-01 14:16:17 +010011546 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011547 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11548 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011549 */
11550
11551#define ALC_HP_EVENT 0x37
11552
11553static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11554 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11555 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011556 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11557 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011558 {}
11559};
11560
Jiang zhe0e31daf2008-03-20 12:12:39 +010011561static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11562 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11563 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11564 {}
11565};
11566
Daniel T Chene2595322009-12-19 18:19:02 -050011567static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11568 /* Front Mic pin: input vref at 50% */
11569 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11570 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11571 {}
11572};
11573
Takashi Iwai834be882006-03-01 14:16:17 +010011574static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011575 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011576 .items = {
11577 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011578 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011579 { "CD", 0x4 },
11580 },
11581};
11582
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011583static struct hda_input_mux alc262_HP_capture_source = {
11584 .num_items = 5,
11585 .items = {
11586 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011587 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011588 { "Line", 0x2 },
11589 { "CD", 0x4 },
11590 { "AUX IN", 0x6 },
11591 },
11592};
11593
zhejiangaccbe492007-08-31 12:36:05 +020011594static struct hda_input_mux alc262_HP_D7000_capture_source = {
11595 .num_items = 4,
11596 .items = {
11597 { "Mic", 0x0 },
11598 { "Front Mic", 0x2 },
11599 { "Line", 0x1 },
11600 { "CD", 0x4 },
11601 },
11602};
11603
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011604/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011605static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11606{
11607 struct alc_spec *spec = codec->spec;
11608 unsigned int mute;
11609
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011610 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011611 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11612 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011613 spec->sense_updated = 1;
11614 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011615 /* unmute internal speaker only if both HPs are unplugged and
11616 * master switch is on
11617 */
11618 if (spec->jack_present)
11619 mute = HDA_AMP_MUTE;
11620 else
Takashi Iwai834be882006-03-01 14:16:17 +010011621 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011622 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11623 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011624}
11625
11626/* unsolicited event for HP jack sensing */
11627static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11628 unsigned int res)
11629{
11630 if ((res >> 26) != ALC_HP_EVENT)
11631 return;
11632 alc262_fujitsu_automute(codec, 1);
11633}
11634
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011635static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11636{
11637 alc262_fujitsu_automute(codec, 1);
11638}
11639
Takashi Iwai834be882006-03-01 14:16:17 +010011640/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011641static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11642 .ops = &snd_hda_bind_vol,
11643 .values = {
11644 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11645 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11646 0
11647 },
11648};
Takashi Iwai834be882006-03-01 14:16:17 +010011649
Jiang zhe0e31daf2008-03-20 12:12:39 +010011650/* mute/unmute internal speaker according to the hp jack and mute state */
11651static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11652{
11653 struct alc_spec *spec = codec->spec;
11654 unsigned int mute;
11655
11656 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011657 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011658 spec->sense_updated = 1;
11659 }
11660 if (spec->jack_present) {
11661 /* mute internal speaker */
11662 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11663 HDA_AMP_MUTE, HDA_AMP_MUTE);
11664 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11665 HDA_AMP_MUTE, HDA_AMP_MUTE);
11666 } else {
11667 /* unmute internal speaker if necessary */
11668 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11669 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11670 HDA_AMP_MUTE, mute);
11671 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11672 HDA_AMP_MUTE, mute);
11673 }
11674}
11675
11676/* unsolicited event for HP jack sensing */
11677static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11678 unsigned int res)
11679{
11680 if ((res >> 26) != ALC_HP_EVENT)
11681 return;
11682 alc262_lenovo_3000_automute(codec, 1);
11683}
11684
Takashi Iwai8de56b72009-07-24 16:51:47 +020011685static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11686 int dir, int idx, long *valp)
11687{
11688 int i, change = 0;
11689
11690 for (i = 0; i < 2; i++, valp++)
11691 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11692 HDA_AMP_MUTE,
11693 *valp ? 0 : HDA_AMP_MUTE);
11694 return change;
11695}
11696
Takashi Iwai834be882006-03-01 14:16:17 +010011697/* bind hp and internal speaker mute (with plug check) */
11698static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11699 struct snd_ctl_elem_value *ucontrol)
11700{
11701 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11702 long *valp = ucontrol->value.integer.value;
11703 int change;
11704
Takashi Iwai8de56b72009-07-24 16:51:47 +020011705 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11706 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011707 if (change)
11708 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011709 return change;
11710}
11711
11712static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011713 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011714 {
11715 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11716 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011717 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011718 .info = snd_hda_mixer_amp_switch_info,
11719 .get = snd_hda_mixer_amp_switch_get,
11720 .put = alc262_fujitsu_master_sw_put,
11721 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11722 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011723 {
11724 .iface = NID_MAPPING,
11725 .name = "Master Playback Switch",
11726 .private_value = 0x1b,
11727 },
Takashi Iwai834be882006-03-01 14:16:17 +010011728 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11729 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11730 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011733 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11734 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11735 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011736 { } /* end */
11737};
11738
Jiang zhe0e31daf2008-03-20 12:12:39 +010011739/* bind hp and internal speaker mute (with plug check) */
11740static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11741 struct snd_ctl_elem_value *ucontrol)
11742{
11743 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11744 long *valp = ucontrol->value.integer.value;
11745 int change;
11746
Takashi Iwai8de56b72009-07-24 16:51:47 +020011747 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011748 if (change)
11749 alc262_lenovo_3000_automute(codec, 0);
11750 return change;
11751}
11752
11753static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11754 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11755 {
11756 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11757 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011758 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011759 .info = snd_hda_mixer_amp_switch_info,
11760 .get = snd_hda_mixer_amp_switch_get,
11761 .put = alc262_lenovo_3000_master_sw_put,
11762 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11763 },
11764 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11765 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11766 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11767 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11768 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11769 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11770 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11771 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11772 { } /* end */
11773};
11774
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011775static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11776 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011777 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011778 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11779 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11780 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11781 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11782 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11783 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11784 { } /* end */
11785};
11786
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011787/* additional init verbs for Benq laptops */
11788static struct hda_verb alc262_EAPD_verbs[] = {
11789 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11790 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11791 {}
11792};
11793
Kailang Yang83c34212007-07-05 11:43:05 +020011794static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11795 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11796 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11797
11798 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11799 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11800 {}
11801};
11802
Tobin Davisf651b502007-10-26 12:40:47 +020011803/* Samsung Q1 Ultra Vista model setup */
11804static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011805 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11806 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011807 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11808 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11809 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011810 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011811 { } /* end */
11812};
11813
11814static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011815 /* output mixer */
11816 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11817 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11818 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11819 /* speaker */
11820 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11821 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11822 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11823 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11824 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011826 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11827 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11828 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11829 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11830 /* internal mic */
11831 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11832 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11833 /* ADC, choose mic */
11834 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11835 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11836 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11837 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11838 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11839 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11840 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11841 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11842 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11843 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011844 {}
11845};
11846
Tobin Davisf651b502007-10-26 12:40:47 +020011847/* mute/unmute internal speaker according to the hp jack and mute state */
11848static void alc262_ultra_automute(struct hda_codec *codec)
11849{
11850 struct alc_spec *spec = codec->spec;
11851 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011852
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011853 mute = 0;
11854 /* auto-mute only when HP is used as HP */
11855 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011856 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011857 if (spec->jack_present)
11858 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011859 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011860 /* mute/unmute internal speaker */
11861 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11862 HDA_AMP_MUTE, mute);
11863 /* mute/unmute HP */
11864 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11865 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011866}
11867
11868/* unsolicited event for HP jack sensing */
11869static void alc262_ultra_unsol_event(struct hda_codec *codec,
11870 unsigned int res)
11871{
11872 if ((res >> 26) != ALC880_HP_EVENT)
11873 return;
11874 alc262_ultra_automute(codec);
11875}
11876
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011877static struct hda_input_mux alc262_ultra_capture_source = {
11878 .num_items = 2,
11879 .items = {
11880 { "Mic", 0x1 },
11881 { "Headphone", 0x7 },
11882 },
11883};
11884
11885static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11886 struct snd_ctl_elem_value *ucontrol)
11887{
11888 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11889 struct alc_spec *spec = codec->spec;
11890 int ret;
11891
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011892 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011893 if (!ret)
11894 return 0;
11895 /* reprogram the HP pin as mic or HP according to the input source */
11896 snd_hda_codec_write_cache(codec, 0x15, 0,
11897 AC_VERB_SET_PIN_WIDGET_CONTROL,
11898 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11899 alc262_ultra_automute(codec); /* mute/unmute HP */
11900 return ret;
11901}
11902
11903static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11904 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11905 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11906 {
11907 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11908 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011909 .info = alc_mux_enum_info,
11910 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011911 .put = alc262_ultra_mux_enum_put,
11912 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011913 {
11914 .iface = NID_MAPPING,
11915 .name = "Capture Source",
11916 .private_value = 0x15,
11917 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011918 { } /* end */
11919};
11920
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011921/* We use two mixers depending on the output pin; 0x16 is a mono output
11922 * and thus it's bound with a different mixer.
11923 * This function returns which mixer amp should be used.
11924 */
11925static int alc262_check_volbit(hda_nid_t nid)
11926{
11927 if (!nid)
11928 return 0;
11929 else if (nid == 0x16)
11930 return 2;
11931 else
11932 return 1;
11933}
11934
11935static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011936 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011937{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011938 unsigned long val;
11939 int vbit;
11940
11941 vbit = alc262_check_volbit(nid);
11942 if (!vbit)
11943 return 0;
11944 if (*vbits & vbit) /* a volume control for this mixer already there */
11945 return 0;
11946 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011947 if (vbit == 2)
11948 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11949 else
11950 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011951 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011952}
11953
11954static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011955 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011956{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011957 unsigned long val;
11958
11959 if (!nid)
11960 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011961 if (nid == 0x16)
11962 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11963 else
11964 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011965 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011966}
11967
Kailang Yangdf694da2005-12-05 19:42:22 +010011968/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011969static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11970 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011971{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011972 const char *pfx;
11973 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020011974 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011975
11976 spec->multiout.num_dacs = 1; /* only use one dac */
11977 spec->multiout.dac_nids = spec->private_dac_nids;
11978 spec->multiout.dac_nids[0] = 2;
11979
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011980 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11981 pfx = "Master";
11982 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11983 pfx = "Speaker";
Takashi Iwai033688a2010-09-08 15:47:09 +020011984 else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
11985 pfx = "Headphone";
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011986 else
11987 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020011988 for (i = 0; i < 2; i++) {
11989 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
11990 if (err < 0)
11991 return err;
11992 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
11993 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
11994 "Speaker", i);
11995 if (err < 0)
11996 return err;
11997 }
11998 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
11999 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12000 "Headphone", i);
12001 if (err < 0)
12002 return err;
12003 }
12004 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012005
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012006 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12007 alc262_check_volbit(cfg->speaker_pins[0]) |
12008 alc262_check_volbit(cfg->hp_pins[0]);
12009 if (vbits == 1 || vbits == 2)
12010 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012011 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012012 for (i = 0; i < 2; i++) {
12013 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12014 &vbits, i);
12015 if (err < 0)
12016 return err;
12017 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12018 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12019 "Speaker", &vbits, i);
12020 if (err < 0)
12021 return err;
12022 }
12023 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12024 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12025 "Headphone", &vbits, i);
12026 if (err < 0)
12027 return err;
12028 }
12029 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012030 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012031}
12032
Takashi Iwai05f5f472009-08-25 13:10:18 +020012033#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012034 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012035
12036/*
12037 * generic initialization of ADC, input mixers and output mixers
12038 */
12039static struct hda_verb alc262_volume_init_verbs[] = {
12040 /*
12041 * Unmute ADC0-2 and set the default input to mic-in
12042 */
12043 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12044 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12045 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12046 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12047 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12048 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12049
Takashi Iwaicb53c622007-08-10 17:21:45 +020012050 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012051 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012052 * Note: PASD motherboards uses the Line In 2 as the input for
12053 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012054 */
12055 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012056 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12057 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12058 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12059 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12060 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012061
12062 /*
12063 * Set up output mixers (0x0c - 0x0f)
12064 */
12065 /* set vol=0 to output mixers */
12066 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12067 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12068 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012069
Kailang Yangdf694da2005-12-05 19:42:22 +010012070 /* set up input amps for analog loopback */
12071 /* Amp Indices: DAC = 0, mixer = 1 */
12072 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12074 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12075 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12076 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12077 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12078
12079 /* FIXME: use matrix-type input source selection */
12080 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12081 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12082 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12083 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12084 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12085 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12086 /* Input mixer2 */
12087 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12088 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12089 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12090 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12091 /* Input mixer3 */
12092 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12093 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12094 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12095 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12096
12097 { }
12098};
12099
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012100static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12101 /*
12102 * Unmute ADC0-2 and set the default input to mic-in
12103 */
12104 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12105 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12106 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12107 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12108 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12109 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12110
Takashi Iwaicb53c622007-08-10 17:21:45 +020012111 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012112 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012113 * Note: PASD motherboards uses the Line In 2 as the input for
12114 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012115 */
12116 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12119 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12120 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12121 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12122 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12123 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012124
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012125 /*
12126 * Set up output mixers (0x0c - 0x0e)
12127 */
12128 /* set vol=0 to output mixers */
12129 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12130 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12131 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12132
12133 /* set up input amps for analog loopback */
12134 /* Amp Indices: DAC = 0, mixer = 1 */
12135 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12136 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12137 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12138 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12139 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12140 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12141
Takashi Iwaice875f02008-01-28 18:17:43 +010012142 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012143 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12144 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12145
12146 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12147 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12148
12149 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12150 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12151
12152 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12153 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12154 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12155 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12156 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12157
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012158 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012159 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12160 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012161 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012162 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12163 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12164
12165
12166 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012167 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12168 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012169 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12172 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12173 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12174 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12175 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12176 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12177 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012178 /* Input mixer2 */
12179 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012180 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12181 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12182 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12183 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12184 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12185 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12186 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012188 /* Input mixer3 */
12189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012190 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12191 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12192 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12193 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12194 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12195 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012198
Takashi Iwaice875f02008-01-28 18:17:43 +010012199 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12200
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012201 { }
12202};
12203
Kailang Yangcd7509a2007-01-26 18:33:17 +010012204static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12205 /*
12206 * Unmute ADC0-2 and set the default input to mic-in
12207 */
12208 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12210 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12211 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12212 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12214
Takashi Iwaicb53c622007-08-10 17:21:45 +020012215 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012216 * mixer widget
12217 * Note: PASD motherboards uses the Line In 2 as the input for front
12218 * panel mic (mic 2)
12219 */
12220 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12222 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12223 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12224 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12225 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12226 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12227 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12228 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012229 /*
12230 * Set up output mixers (0x0c - 0x0e)
12231 */
12232 /* set vol=0 to output mixers */
12233 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12234 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12236
12237 /* set up input amps for analog loopback */
12238 /* Amp Indices: DAC = 0, mixer = 1 */
12239 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12241 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12242 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12243 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12244 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12245
12246
12247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12248 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12249 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12250 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12251 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12252 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12253 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12254
12255 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12256 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12257
12258 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12259 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12260
12261 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12262 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12263 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12264 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12265 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12266 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12267
12268 /* FIXME: use matrix-type input source selection */
12269 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12270 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12271 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12272 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12276 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12278 /* Input mixer2 */
12279 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12281 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12282 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12284 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12285 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12286 /* Input mixer3 */
12287 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12289 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12290 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12291 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12292 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12293 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12294
Takashi Iwaice875f02008-01-28 18:17:43 +010012295 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12296
Kailang Yangcd7509a2007-01-26 18:33:17 +010012297 { }
12298};
12299
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012300static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12301
12302 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12304 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12305
12306 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12307 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12308 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12309 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12310
12311 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12312 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12313 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12314 {}
12315};
12316
Takashi Iwai18675e42010-09-08 15:55:44 +020012317/*
12318 * Pin config fixes
12319 */
12320enum {
12321 PINFIX_FSC_H270,
12322};
12323
12324static const struct alc_fixup alc262_fixups[] = {
12325 [PINFIX_FSC_H270] = {
12326 .pins = (const struct alc_pincfg[]) {
12327 { 0x14, 0x99130110 }, /* speaker */
12328 { 0x15, 0x0221142f }, /* front HP */
12329 { 0x1b, 0x0121141f }, /* rear HP */
12330 { }
12331 }
12332 },
12333 [PINFIX_PB_M5210] = {
12334 .verbs = (const struct hda_verb[]) {
12335 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12336 {}
12337 }
12338 },
12339};
12340
12341static struct snd_pci_quirk alc262_fixup_tbl[] = {
12342 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12343 {}
12344};
12345
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012346
Takashi Iwaicb53c622007-08-10 17:21:45 +020012347#ifdef CONFIG_SND_HDA_POWER_SAVE
12348#define alc262_loopbacks alc880_loopbacks
12349#endif
12350
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012351/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012352#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12353#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12354#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12355#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12356
12357/*
12358 * BIOS auto configuration
12359 */
12360static int alc262_parse_auto_config(struct hda_codec *codec)
12361{
12362 struct alc_spec *spec = codec->spec;
12363 int err;
12364 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12365
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012366 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12367 alc262_ignore);
12368 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012369 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012370 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012371 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012372 spec->multiout.max_channels = 2;
12373 spec->no_analog = 1;
12374 goto dig_only;
12375 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012376 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012377 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012378 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12379 if (err < 0)
12380 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012381 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012382 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012383 return err;
12384
12385 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12386
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012387 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012388 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012389
Takashi Iwai603c4012008-07-30 15:01:44 +020012390 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012391 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012392
Takashi Iwaid88897e2008-10-31 15:01:37 +010012393 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012394 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012395 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012396
Takashi Iwai776e1842007-08-29 15:07:11 +020012397 err = alc_auto_add_mic_boost(codec);
12398 if (err < 0)
12399 return err;
12400
Kailang Yang6227cdc2010-02-25 08:36:52 +010012401 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012402
Kailang Yangdf694da2005-12-05 19:42:22 +010012403 return 1;
12404}
12405
12406#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12407#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12408#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012409#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012410
12411
12412/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012413static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012414{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012415 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012416 alc262_auto_init_multi_out(codec);
12417 alc262_auto_init_hp_out(codec);
12418 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012419 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012420 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012421 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012422 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012423}
12424
12425/*
12426 * configuration and preset
12427 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012428static const char *alc262_models[ALC262_MODEL_LAST] = {
12429 [ALC262_BASIC] = "basic",
12430 [ALC262_HIPPO] = "hippo",
12431 [ALC262_HIPPO_1] = "hippo_1",
12432 [ALC262_FUJITSU] = "fujitsu",
12433 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012434 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012435 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012436 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012437 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012438 [ALC262_BENQ_T31] = "benq-t31",
12439 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012440 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012441 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012442 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012443 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012444 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012445 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012446 [ALC262_AUTO] = "auto",
12447};
12448
12449static struct snd_pci_quirk alc262_cfg_tbl[] = {
12450 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012451 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012452 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12453 ALC262_HP_BPC),
12454 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12455 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012456 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12457 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012458 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012459 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012460 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012461 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012462 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012463 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012464 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012465 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012466 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12467 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12468 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012469 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12470 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012471 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012472 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012473 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012474 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012475 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012476 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012477 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012478 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012479#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012480 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12481 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012482#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012483 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012484 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012485 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012486 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012487 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012488 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012489 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12490 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012491 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012492 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012493 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012494 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012495 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012496 {}
12497};
12498
12499static struct alc_config_preset alc262_presets[] = {
12500 [ALC262_BASIC] = {
12501 .mixers = { alc262_base_mixer },
12502 .init_verbs = { alc262_init_verbs },
12503 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12504 .dac_nids = alc262_dac_nids,
12505 .hp_nid = 0x03,
12506 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12507 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012508 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012509 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012510 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012511 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012512 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012513 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12514 .dac_nids = alc262_dac_nids,
12515 .hp_nid = 0x03,
12516 .dig_out_nid = ALC262_DIGOUT_NID,
12517 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12518 .channel_mode = alc262_modes,
12519 .input_mux = &alc262_capture_source,
12520 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012521 .setup = alc262_hippo_setup,
12522 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012523 },
12524 [ALC262_HIPPO_1] = {
12525 .mixers = { alc262_hippo1_mixer },
12526 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12527 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12528 .dac_nids = alc262_dac_nids,
12529 .hp_nid = 0x02,
12530 .dig_out_nid = ALC262_DIGOUT_NID,
12531 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12532 .channel_mode = alc262_modes,
12533 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012534 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012535 .setup = alc262_hippo1_setup,
12536 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012537 },
Takashi Iwai834be882006-03-01 14:16:17 +010012538 [ALC262_FUJITSU] = {
12539 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012540 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12541 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012542 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12543 .dac_nids = alc262_dac_nids,
12544 .hp_nid = 0x03,
12545 .dig_out_nid = ALC262_DIGOUT_NID,
12546 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12547 .channel_mode = alc262_modes,
12548 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012549 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012550 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012551 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012552 [ALC262_HP_BPC] = {
12553 .mixers = { alc262_HP_BPC_mixer },
12554 .init_verbs = { alc262_HP_BPC_init_verbs },
12555 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12556 .dac_nids = alc262_dac_nids,
12557 .hp_nid = 0x03,
12558 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12559 .channel_mode = alc262_modes,
12560 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012561 .unsol_event = alc262_hp_bpc_unsol_event,
12562 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012563 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012564 [ALC262_HP_BPC_D7000_WF] = {
12565 .mixers = { alc262_HP_BPC_WildWest_mixer },
12566 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12567 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12568 .dac_nids = alc262_dac_nids,
12569 .hp_nid = 0x03,
12570 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12571 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012572 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012573 .unsol_event = alc262_hp_wildwest_unsol_event,
12574 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012575 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012576 [ALC262_HP_BPC_D7000_WL] = {
12577 .mixers = { alc262_HP_BPC_WildWest_mixer,
12578 alc262_HP_BPC_WildWest_option_mixer },
12579 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12580 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12581 .dac_nids = alc262_dac_nids,
12582 .hp_nid = 0x03,
12583 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12584 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012585 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012586 .unsol_event = alc262_hp_wildwest_unsol_event,
12587 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012588 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012589 [ALC262_HP_TC_T5735] = {
12590 .mixers = { alc262_hp_t5735_mixer },
12591 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12592 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12593 .dac_nids = alc262_dac_nids,
12594 .hp_nid = 0x03,
12595 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12596 .channel_mode = alc262_modes,
12597 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012598 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012599 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012600 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012601 },
12602 [ALC262_HP_RP5700] = {
12603 .mixers = { alc262_hp_rp5700_mixer },
12604 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12605 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12606 .dac_nids = alc262_dac_nids,
12607 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12608 .channel_mode = alc262_modes,
12609 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012610 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012611 [ALC262_BENQ_ED8] = {
12612 .mixers = { alc262_base_mixer },
12613 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12614 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12615 .dac_nids = alc262_dac_nids,
12616 .hp_nid = 0x03,
12617 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12618 .channel_mode = alc262_modes,
12619 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012620 },
Kailang Yang272a5272007-05-14 11:00:38 +020012621 [ALC262_SONY_ASSAMD] = {
12622 .mixers = { alc262_sony_mixer },
12623 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12624 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12625 .dac_nids = alc262_dac_nids,
12626 .hp_nid = 0x02,
12627 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12628 .channel_mode = alc262_modes,
12629 .input_mux = &alc262_capture_source,
12630 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012631 .setup = alc262_hippo_setup,
12632 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012633 },
12634 [ALC262_BENQ_T31] = {
12635 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012636 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12637 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012638 .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,
12644 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012645 .setup = alc262_hippo_setup,
12646 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012647 },
Tobin Davisf651b502007-10-26 12:40:47 +020012648 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012649 .mixers = { alc262_ultra_mixer },
12650 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012651 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012652 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12653 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012654 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12655 .channel_mode = alc262_modes,
12656 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012657 .adc_nids = alc262_adc_nids, /* ADC0 */
12658 .capsrc_nids = alc262_capsrc_nids,
12659 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012660 .unsol_event = alc262_ultra_unsol_event,
12661 .init_hook = alc262_ultra_automute,
12662 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012663 [ALC262_LENOVO_3000] = {
12664 .mixers = { alc262_lenovo_3000_mixer },
12665 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012666 alc262_lenovo_3000_unsol_verbs,
12667 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012668 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12669 .dac_nids = alc262_dac_nids,
12670 .hp_nid = 0x03,
12671 .dig_out_nid = ALC262_DIGOUT_NID,
12672 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12673 .channel_mode = alc262_modes,
12674 .input_mux = &alc262_fujitsu_capture_source,
12675 .unsol_event = alc262_lenovo_3000_unsol_event,
12676 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012677 [ALC262_NEC] = {
12678 .mixers = { alc262_nec_mixer },
12679 .init_verbs = { alc262_nec_verbs },
12680 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12681 .dac_nids = alc262_dac_nids,
12682 .hp_nid = 0x03,
12683 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12684 .channel_mode = alc262_modes,
12685 .input_mux = &alc262_capture_source,
12686 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012687 [ALC262_TOSHIBA_S06] = {
12688 .mixers = { alc262_toshiba_s06_mixer },
12689 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12690 alc262_eapd_verbs },
12691 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12692 .capsrc_nids = alc262_dmic_capsrc_nids,
12693 .dac_nids = alc262_dac_nids,
12694 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012695 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012696 .dig_out_nid = ALC262_DIGOUT_NID,
12697 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12698 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012699 .unsol_event = alc_sku_unsol_event,
12700 .setup = alc262_toshiba_s06_setup,
12701 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012702 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012703 [ALC262_TOSHIBA_RX1] = {
12704 .mixers = { alc262_toshiba_rx1_mixer },
12705 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12706 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12707 .dac_nids = alc262_dac_nids,
12708 .hp_nid = 0x03,
12709 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12710 .channel_mode = alc262_modes,
12711 .input_mux = &alc262_capture_source,
12712 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012713 .setup = alc262_hippo_setup,
12714 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012715 },
Tony Vroonba340e82009-02-02 19:01:30 +000012716 [ALC262_TYAN] = {
12717 .mixers = { alc262_tyan_mixer },
12718 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12719 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12720 .dac_nids = alc262_dac_nids,
12721 .hp_nid = 0x02,
12722 .dig_out_nid = ALC262_DIGOUT_NID,
12723 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12724 .channel_mode = alc262_modes,
12725 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012726 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012727 .setup = alc262_tyan_setup,
12728 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012729 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012730};
12731
12732static int patch_alc262(struct hda_codec *codec)
12733{
12734 struct alc_spec *spec;
12735 int board_config;
12736 int err;
12737
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012738 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012739 if (spec == NULL)
12740 return -ENOMEM;
12741
12742 codec->spec = spec;
12743#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012744 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12745 * under-run
12746 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012747 {
12748 int tmp;
12749 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12750 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12751 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12752 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12753 }
12754#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012755 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012756
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012757 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12758
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012759 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12760 alc262_models,
12761 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012762
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012763 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012764 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12765 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012766 board_config = ALC262_AUTO;
12767 }
12768
Takashi Iwai18675e42010-09-08 15:55:44 +020012769 if (board_config == ALC262_AUTO)
12770 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12771
Kailang Yangdf694da2005-12-05 19:42:22 +010012772 if (board_config == ALC262_AUTO) {
12773 /* automatic parse from the BIOS config */
12774 err = alc262_parse_auto_config(codec);
12775 if (err < 0) {
12776 alc_free(codec);
12777 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012778 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012779 printk(KERN_INFO
12780 "hda_codec: Cannot set up configuration "
12781 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012782 board_config = ALC262_BASIC;
12783 }
12784 }
12785
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012786 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012787 err = snd_hda_attach_beep_device(codec, 0x1);
12788 if (err < 0) {
12789 alc_free(codec);
12790 return err;
12791 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012792 }
12793
Kailang Yangdf694da2005-12-05 19:42:22 +010012794 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012795 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012796
Kailang Yangdf694da2005-12-05 19:42:22 +010012797 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12798 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012799
Kailang Yangdf694da2005-12-05 19:42:22 +010012800 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12801 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12802
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012803 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012804 int i;
12805 /* check whether the digital-mic has to be supported */
12806 for (i = 0; i < spec->input_mux->num_items; i++) {
12807 if (spec->input_mux->items[i].index >= 9)
12808 break;
12809 }
12810 if (i < spec->input_mux->num_items) {
12811 /* use only ADC0 */
12812 spec->adc_nids = alc262_dmic_adc_nids;
12813 spec->num_adc_nids = 1;
12814 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012815 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012816 /* all analog inputs */
12817 /* check whether NID 0x07 is valid */
12818 unsigned int wcap = get_wcaps(codec, 0x07);
12819
12820 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012821 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012822 if (wcap != AC_WID_AUD_IN) {
12823 spec->adc_nids = alc262_adc_nids_alt;
12824 spec->num_adc_nids =
12825 ARRAY_SIZE(alc262_adc_nids_alt);
12826 spec->capsrc_nids = alc262_capsrc_nids_alt;
12827 } else {
12828 spec->adc_nids = alc262_adc_nids;
12829 spec->num_adc_nids =
12830 ARRAY_SIZE(alc262_adc_nids);
12831 spec->capsrc_nids = alc262_capsrc_nids;
12832 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012833 }
12834 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012835 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012836 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012837 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012838 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012839
Takashi Iwai18675e42010-09-08 15:55:44 +020012840 if (board_config == ALC262_AUTO)
12841 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12842
Takashi Iwai2134ea42008-01-10 16:53:55 +010012843 spec->vmaster_nid = 0x0c;
12844
Kailang Yangdf694da2005-12-05 19:42:22 +010012845 codec->patch_ops = alc_patch_ops;
12846 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012847 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012848#ifdef CONFIG_SND_HDA_POWER_SAVE
12849 if (!spec->loopback.amplist)
12850 spec->loopback.amplist = alc262_loopbacks;
12851#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012852
Kailang Yangdf694da2005-12-05 19:42:22 +010012853 return 0;
12854}
12855
Kailang Yangdf694da2005-12-05 19:42:22 +010012856/*
Kailang Yanga361d842007-06-05 12:30:55 +020012857 * ALC268 channel source setting (2 channel)
12858 */
12859#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12860#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012861
Kailang Yanga361d842007-06-05 12:30:55 +020012862static hda_nid_t alc268_dac_nids[2] = {
12863 /* front, hp */
12864 0x02, 0x03
12865};
12866
12867static hda_nid_t alc268_adc_nids[2] = {
12868 /* ADC0-1 */
12869 0x08, 0x07
12870};
12871
12872static hda_nid_t alc268_adc_nids_alt[1] = {
12873 /* ADC0 */
12874 0x08
12875};
12876
Takashi Iwaie1406342008-02-11 18:32:32 +010012877static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12878
Kailang Yanga361d842007-06-05 12:30:55 +020012879static struct snd_kcontrol_new alc268_base_mixer[] = {
12880 /* output mixer control */
12881 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12882 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12883 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12884 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012885 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12886 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12887 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012888 { }
12889};
12890
Takashi Iwai42171c12009-05-08 14:11:43 +020012891static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12892 /* output mixer control */
12893 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12894 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12895 ALC262_HIPPO_MASTER_SWITCH,
12896 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12897 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12898 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12899 { }
12900};
12901
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012902/* bind Beep switches of both NID 0x0f and 0x10 */
12903static struct hda_bind_ctls alc268_bind_beep_sw = {
12904 .ops = &snd_hda_bind_sw,
12905 .values = {
12906 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12907 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12908 0
12909 },
12910};
12911
12912static struct snd_kcontrol_new alc268_beep_mixer[] = {
12913 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12914 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12915 { }
12916};
12917
Kailang Yangd1a991a2007-08-15 16:21:59 +020012918static struct hda_verb alc268_eapd_verbs[] = {
12919 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12920 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12921 { }
12922};
12923
Takashi Iwaid2738092007-08-16 14:59:45 +020012924/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012925static struct hda_verb alc268_toshiba_verbs[] = {
12926 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12927 { } /* end */
12928};
12929
12930/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012931/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012932static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12933 .ops = &snd_hda_bind_vol,
12934 .values = {
12935 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12936 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12937 0
12938 },
12939};
12940
Takashi Iwai889c4392007-08-23 18:56:52 +020012941/* mute/unmute internal speaker according to the hp jack and mute state */
12942static void alc268_acer_automute(struct hda_codec *codec, int force)
12943{
12944 struct alc_spec *spec = codec->spec;
12945 unsigned int mute;
12946
12947 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012948 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012949 spec->sense_updated = 1;
12950 }
12951 if (spec->jack_present)
12952 mute = HDA_AMP_MUTE; /* mute internal speaker */
12953 else /* unmute internal speaker if necessary */
12954 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12955 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12956 HDA_AMP_MUTE, mute);
12957}
12958
12959
12960/* bind hp and internal speaker mute (with plug check) */
12961static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12962 struct snd_ctl_elem_value *ucontrol)
12963{
12964 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12965 long *valp = ucontrol->value.integer.value;
12966 int change;
12967
Takashi Iwai8de56b72009-07-24 16:51:47 +020012968 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012969 if (change)
12970 alc268_acer_automute(codec, 0);
12971 return change;
12972}
Takashi Iwaid2738092007-08-16 14:59:45 +020012973
Kailang Yang8ef355d2008-08-26 13:10:22 +020012974static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12975 /* output mixer control */
12976 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12977 {
12978 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12979 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012980 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012981 .info = snd_hda_mixer_amp_switch_info,
12982 .get = snd_hda_mixer_amp_switch_get,
12983 .put = alc268_acer_master_sw_put,
12984 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12985 },
12986 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12987 { }
12988};
12989
Takashi Iwaid2738092007-08-16 14:59:45 +020012990static struct snd_kcontrol_new alc268_acer_mixer[] = {
12991 /* output mixer control */
12992 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12993 {
12994 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12995 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012996 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012997 .info = snd_hda_mixer_amp_switch_info,
12998 .get = snd_hda_mixer_amp_switch_get,
12999 .put = alc268_acer_master_sw_put,
13000 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13001 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020013002 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13003 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13004 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013005 { }
13006};
13007
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013008static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13009 /* output mixer control */
13010 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13011 {
13012 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13013 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013014 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013015 .info = snd_hda_mixer_amp_switch_info,
13016 .get = snd_hda_mixer_amp_switch_get,
13017 .put = alc268_acer_master_sw_put,
13018 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13019 },
13020 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13021 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13022 { }
13023};
13024
Kailang Yang8ef355d2008-08-26 13:10:22 +020013025static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13026 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13027 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13028 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13029 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13030 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13031 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13032 { }
13033};
13034
Takashi Iwaid2738092007-08-16 14:59:45 +020013035static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013036 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13037 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013038 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13039 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013040 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13041 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013042 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13043 { }
13044};
13045
13046/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013047#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013048#define alc268_toshiba_setup alc262_hippo_setup
13049#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013050
13051static void alc268_acer_unsol_event(struct hda_codec *codec,
13052 unsigned int res)
13053{
Takashi Iwai889c4392007-08-23 18:56:52 +020013054 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013055 return;
13056 alc268_acer_automute(codec, 1);
13057}
13058
Takashi Iwai889c4392007-08-23 18:56:52 +020013059static void alc268_acer_init_hook(struct hda_codec *codec)
13060{
13061 alc268_acer_automute(codec, 1);
13062}
13063
Kailang Yang8ef355d2008-08-26 13:10:22 +020013064/* toggle speaker-output according to the hp-jack state */
13065static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13066{
13067 unsigned int present;
13068 unsigned char bits;
13069
Wu Fengguang864f92b2009-11-18 12:38:02 +080013070 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013071 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013072 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013073 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013074 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013075 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013076}
13077
Kailang Yang8ef355d2008-08-26 13:10:22 +020013078static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13079 unsigned int res)
13080{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013081 switch (res >> 26) {
13082 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013083 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013084 break;
13085 case ALC880_MIC_EVENT:
13086 alc_mic_automute(codec);
13087 break;
13088 }
13089}
13090
13091static void alc268_acer_lc_setup(struct hda_codec *codec)
13092{
13093 struct alc_spec *spec = codec->spec;
13094 spec->ext_mic.pin = 0x18;
13095 spec->ext_mic.mux_idx = 0;
13096 spec->int_mic.pin = 0x12;
13097 spec->int_mic.mux_idx = 6;
13098 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013099}
13100
13101static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13102{
13103 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013104 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013105}
13106
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013107static struct snd_kcontrol_new alc268_dell_mixer[] = {
13108 /* output mixer control */
13109 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13110 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13111 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13112 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13114 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13115 { }
13116};
13117
13118static struct hda_verb alc268_dell_verbs[] = {
13119 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13120 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13121 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013122 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013123 { }
13124};
13125
13126/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013127static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013128{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013129 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013130
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013131 spec->autocfg.hp_pins[0] = 0x15;
13132 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013133 spec->ext_mic.pin = 0x18;
13134 spec->ext_mic.mux_idx = 0;
13135 spec->int_mic.pin = 0x19;
13136 spec->int_mic.mux_idx = 1;
13137 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013138}
13139
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013140static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13141 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13142 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13143 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13144 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13145 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13146 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13147 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13148 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13149 { }
13150};
13151
13152static struct hda_verb alc267_quanta_il1_verbs[] = {
13153 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13154 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13155 { }
13156};
13157
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013158static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013159{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013160 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013161 spec->autocfg.hp_pins[0] = 0x15;
13162 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013163 spec->ext_mic.pin = 0x18;
13164 spec->ext_mic.mux_idx = 0;
13165 spec->int_mic.pin = 0x19;
13166 spec->int_mic.mux_idx = 1;
13167 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013168}
13169
Kailang Yanga361d842007-06-05 12:30:55 +020013170/*
13171 * generic initialization of ADC, input mixers and output mixers
13172 */
13173static struct hda_verb alc268_base_init_verbs[] = {
13174 /* Unmute DAC0-1 and set vol = 0 */
13175 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013176 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013177
13178 /*
13179 * Set up output mixers (0x0c - 0x0e)
13180 */
13181 /* set vol=0 to output mixers */
13182 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013183 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13184
13185 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13186 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13187
13188 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13189 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13190 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13191 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13192 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13193 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13194 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13195 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13196
13197 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13198 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13199 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13200 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013201 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013202
13203 /* set PCBEEP vol = 0, mute connections */
13204 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13205 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13206 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013207
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013208 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013209
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013210 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13212 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13213 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013214
Kailang Yanga361d842007-06-05 12:30:55 +020013215 { }
13216};
13217
13218/*
13219 * generic initialization of ADC, input mixers and output mixers
13220 */
13221static struct hda_verb alc268_volume_init_verbs[] = {
13222 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013223 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13224 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013225
13226 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13227 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13228 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13229 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13230 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13231
Kailang Yanga361d842007-06-05 12:30:55 +020013232 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013233 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13234 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13235
13236 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013237 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013238
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013239 /* set PCBEEP vol = 0, mute connections */
13240 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13241 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13242 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013243
13244 { }
13245};
13246
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013247static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13248 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13249 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13250 { } /* end */
13251};
13252
Kailang Yanga361d842007-06-05 12:30:55 +020013253static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13254 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13255 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013256 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013257 { } /* end */
13258};
13259
13260static struct snd_kcontrol_new alc268_capture_mixer[] = {
13261 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13262 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13263 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13264 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013265 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013266 { } /* end */
13267};
13268
13269static struct hda_input_mux alc268_capture_source = {
13270 .num_items = 4,
13271 .items = {
13272 { "Mic", 0x0 },
13273 { "Front Mic", 0x1 },
13274 { "Line", 0x2 },
13275 { "CD", 0x3 },
13276 },
13277};
13278
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013279static struct hda_input_mux alc268_acer_capture_source = {
13280 .num_items = 3,
13281 .items = {
13282 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013283 { "Internal Mic", 0x1 },
13284 { "Line", 0x2 },
13285 },
13286};
13287
13288static struct hda_input_mux alc268_acer_dmic_capture_source = {
13289 .num_items = 3,
13290 .items = {
13291 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013292 { "Internal Mic", 0x6 },
13293 { "Line", 0x2 },
13294 },
13295};
13296
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013297#ifdef CONFIG_SND_DEBUG
13298static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013299 /* Volume widgets */
13300 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13301 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13302 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13303 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13304 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13305 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13306 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13307 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13308 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13309 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13310 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13311 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13312 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013313 /* The below appears problematic on some hardwares */
13314 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013315 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13316 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13317 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13318 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13319
13320 /* Modes for retasking pin widgets */
13321 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13322 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13323 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13324 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13325
13326 /* Controls for GPIO pins, assuming they are configured as outputs */
13327 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13328 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13329 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13330 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13331
13332 /* Switches to allow the digital SPDIF output pin to be enabled.
13333 * The ALC268 does not have an SPDIF input.
13334 */
13335 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13336
13337 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13338 * this output to turn on an external amplifier.
13339 */
13340 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13341 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13342
13343 { } /* end */
13344};
13345#endif
13346
Kailang Yanga361d842007-06-05 12:30:55 +020013347/* create input playback/capture controls for the given pin */
13348static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13349 const char *ctlname, int idx)
13350{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013351 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013352 int err;
13353
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013354 switch (nid) {
13355 case 0x14:
13356 case 0x16:
13357 dac = 0x02;
13358 break;
13359 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013360 case 0x1a: /* ALC259/269 only */
13361 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013362 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013363 dac = 0x03;
13364 break;
13365 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013366 snd_printd(KERN_WARNING "hda_codec: "
13367 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013368 return 0;
13369 }
13370 if (spec->multiout.dac_nids[0] != dac &&
13371 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013372 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013373 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013374 HDA_OUTPUT));
13375 if (err < 0)
13376 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013377 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13378 }
13379
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013380 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013381 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013382 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013383 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013384 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013385 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013386 if (err < 0)
13387 return err;
13388 return 0;
13389}
13390
13391/* add playback controls from the parsed DAC table */
13392static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13393 const struct auto_pin_cfg *cfg)
13394{
13395 hda_nid_t nid;
13396 int err;
13397
Kailang Yanga361d842007-06-05 12:30:55 +020013398 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013399
13400 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013401 if (nid) {
13402 const char *name;
13403 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13404 name = "Speaker";
13405 else
13406 name = "Front";
13407 err = alc268_new_analog_output(spec, nid, name, 0);
13408 if (err < 0)
13409 return err;
13410 }
Kailang Yanga361d842007-06-05 12:30:55 +020013411
13412 nid = cfg->speaker_pins[0];
13413 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013414 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013415 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13416 if (err < 0)
13417 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013418 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013419 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13420 if (err < 0)
13421 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013422 }
13423 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013424 if (nid) {
13425 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13426 if (err < 0)
13427 return err;
13428 }
Kailang Yanga361d842007-06-05 12:30:55 +020013429
13430 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13431 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013432 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013433 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013434 if (err < 0)
13435 return err;
13436 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013437 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013438}
13439
13440/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013441static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013442 const struct auto_pin_cfg *cfg)
13443{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013444 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013445}
13446
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013447static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13448 hda_nid_t nid, int pin_type)
13449{
13450 int idx;
13451
13452 alc_set_pin_output(codec, nid, pin_type);
13453 if (nid == 0x14 || nid == 0x16)
13454 idx = 0;
13455 else
13456 idx = 1;
13457 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13458}
13459
13460static void alc268_auto_init_multi_out(struct hda_codec *codec)
13461{
13462 struct alc_spec *spec = codec->spec;
13463 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13464 if (nid) {
13465 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13466 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13467 }
13468}
13469
13470static void alc268_auto_init_hp_out(struct hda_codec *codec)
13471{
13472 struct alc_spec *spec = codec->spec;
13473 hda_nid_t pin;
13474
13475 pin = spec->autocfg.hp_pins[0];
13476 if (pin)
13477 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13478 pin = spec->autocfg.speaker_pins[0];
13479 if (pin)
13480 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13481}
13482
Kailang Yanga361d842007-06-05 12:30:55 +020013483static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13484{
13485 struct alc_spec *spec = codec->spec;
13486 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13487 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13488 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13489 unsigned int dac_vol1, dac_vol2;
13490
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013491 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013492 snd_hda_codec_write(codec, speaker_nid, 0,
13493 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013494 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013495 snd_hda_codec_write(codec, 0x0f, 0,
13496 AC_VERB_SET_AMP_GAIN_MUTE,
13497 AMP_IN_UNMUTE(1));
13498 snd_hda_codec_write(codec, 0x10, 0,
13499 AC_VERB_SET_AMP_GAIN_MUTE,
13500 AMP_IN_UNMUTE(1));
13501 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013502 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013503 snd_hda_codec_write(codec, 0x0f, 0,
13504 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13505 snd_hda_codec_write(codec, 0x10, 0,
13506 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13507 }
13508
13509 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013510 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013511 dac_vol2 = AMP_OUT_ZERO;
13512 else if (line_nid == 0x15)
13513 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013514 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013515 dac_vol2 = AMP_OUT_ZERO;
13516 else if (hp_nid == 0x15)
13517 dac_vol1 = AMP_OUT_ZERO;
13518 if (line_nid != 0x16 || hp_nid != 0x16 ||
13519 spec->autocfg.line_out_pins[1] != 0x16 ||
13520 spec->autocfg.line_out_pins[2] != 0x16)
13521 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13522
13523 snd_hda_codec_write(codec, 0x02, 0,
13524 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13525 snd_hda_codec_write(codec, 0x03, 0,
13526 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13527}
13528
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013529/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013530#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13531#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013532#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013533#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13534
13535/*
13536 * BIOS auto configuration
13537 */
13538static int alc268_parse_auto_config(struct hda_codec *codec)
13539{
13540 struct alc_spec *spec = codec->spec;
13541 int err;
13542 static hda_nid_t alc268_ignore[] = { 0 };
13543
13544 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13545 alc268_ignore);
13546 if (err < 0)
13547 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013548 if (!spec->autocfg.line_outs) {
13549 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13550 spec->multiout.max_channels = 2;
13551 spec->no_analog = 1;
13552 goto dig_only;
13553 }
Kailang Yanga361d842007-06-05 12:30:55 +020013554 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013555 }
Kailang Yanga361d842007-06-05 12:30:55 +020013556 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13557 if (err < 0)
13558 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013559 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013560 if (err < 0)
13561 return err;
13562
13563 spec->multiout.max_channels = 2;
13564
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013565 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013566 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013567 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013568 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013569 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013570
Takashi Iwai892981f2009-03-02 08:04:35 +010013571 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013572 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013573
Takashi Iwaid88897e2008-10-31 15:01:37 +010013574 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013575 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013576 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013577
Takashi Iwai776e1842007-08-29 15:07:11 +020013578 err = alc_auto_add_mic_boost(codec);
13579 if (err < 0)
13580 return err;
13581
Kailang Yang6227cdc2010-02-25 08:36:52 +010013582 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013583
Kailang Yanga361d842007-06-05 12:30:55 +020013584 return 1;
13585}
13586
Kailang Yanga361d842007-06-05 12:30:55 +020013587#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13588
13589/* init callback for auto-configuration model -- overriding the default init */
13590static void alc268_auto_init(struct hda_codec *codec)
13591{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013592 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013593 alc268_auto_init_multi_out(codec);
13594 alc268_auto_init_hp_out(codec);
13595 alc268_auto_init_mono_speaker_out(codec);
13596 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013597 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013598 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013599 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013600}
13601
13602/*
13603 * configuration and preset
13604 */
13605static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013606 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013607 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013608 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013609 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013610 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013611 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013612 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013613 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013614#ifdef CONFIG_SND_DEBUG
13615 [ALC268_TEST] = "test",
13616#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013617 [ALC268_AUTO] = "auto",
13618};
13619
13620static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013621 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013622 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013623 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013624 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013625 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013626 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13627 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013628 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013629 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13630 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013631 /* almost compatible with toshiba but with optional digital outs;
13632 * auto-probing seems working fine
13633 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013634 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013635 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013636 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013637 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013638 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013639 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013640 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013641 {}
13642};
13643
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013644/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13645static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13646 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13647 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13648 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13649 ALC268_TOSHIBA),
13650 {}
13651};
13652
Kailang Yanga361d842007-06-05 12:30:55 +020013653static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013654 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013655 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13656 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013657 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13658 alc267_quanta_il1_verbs },
13659 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13660 .dac_nids = alc268_dac_nids,
13661 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13662 .adc_nids = alc268_adc_nids_alt,
13663 .hp_nid = 0x03,
13664 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13665 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013666 .unsol_event = alc_sku_unsol_event,
13667 .setup = alc267_quanta_il1_setup,
13668 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013669 },
Kailang Yanga361d842007-06-05 12:30:55 +020013670 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013671 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13672 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013673 .init_verbs = { alc268_base_init_verbs },
13674 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13675 .dac_nids = alc268_dac_nids,
13676 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13677 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013678 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013679 .hp_nid = 0x03,
13680 .dig_out_nid = ALC268_DIGOUT_NID,
13681 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13682 .channel_mode = alc268_modes,
13683 .input_mux = &alc268_capture_source,
13684 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013685 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013686 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013687 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013688 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13689 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013690 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13691 .dac_nids = alc268_dac_nids,
13692 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13693 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013694 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013695 .hp_nid = 0x03,
13696 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13697 .channel_mode = alc268_modes,
13698 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013699 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013700 .setup = alc268_toshiba_setup,
13701 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013702 },
13703 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013704 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013705 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013706 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13707 alc268_acer_verbs },
13708 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13709 .dac_nids = alc268_dac_nids,
13710 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13711 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013712 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013713 .hp_nid = 0x02,
13714 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13715 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013716 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013717 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013718 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013719 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013720 [ALC268_ACER_DMIC] = {
13721 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13722 alc268_beep_mixer },
13723 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13724 alc268_acer_verbs },
13725 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13726 .dac_nids = alc268_dac_nids,
13727 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13728 .adc_nids = alc268_adc_nids_alt,
13729 .capsrc_nids = alc268_capsrc_nids,
13730 .hp_nid = 0x02,
13731 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13732 .channel_mode = alc268_modes,
13733 .input_mux = &alc268_acer_dmic_capture_source,
13734 .unsol_event = alc268_acer_unsol_event,
13735 .init_hook = alc268_acer_init_hook,
13736 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013737 [ALC268_ACER_ASPIRE_ONE] = {
13738 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013739 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013740 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013741 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13742 alc268_acer_aspire_one_verbs },
13743 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13744 .dac_nids = alc268_dac_nids,
13745 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13746 .adc_nids = alc268_adc_nids_alt,
13747 .capsrc_nids = alc268_capsrc_nids,
13748 .hp_nid = 0x03,
13749 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13750 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013751 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013752 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013753 .init_hook = alc268_acer_lc_init_hook,
13754 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013755 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013756 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13757 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013758 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13759 alc268_dell_verbs },
13760 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13761 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013762 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13763 .adc_nids = alc268_adc_nids_alt,
13764 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013765 .hp_nid = 0x02,
13766 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13767 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013768 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013769 .setup = alc268_dell_setup,
13770 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013771 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013772 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013773 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13774 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013775 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13776 alc268_toshiba_verbs },
13777 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13778 .dac_nids = alc268_dac_nids,
13779 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13780 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013781 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013782 .hp_nid = 0x03,
13783 .dig_out_nid = ALC268_DIGOUT_NID,
13784 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13785 .channel_mode = alc268_modes,
13786 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013787 .setup = alc268_toshiba_setup,
13788 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013789 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013790#ifdef CONFIG_SND_DEBUG
13791 [ALC268_TEST] = {
13792 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13793 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13794 alc268_volume_init_verbs },
13795 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13796 .dac_nids = alc268_dac_nids,
13797 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13798 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013799 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013800 .hp_nid = 0x03,
13801 .dig_out_nid = ALC268_DIGOUT_NID,
13802 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13803 .channel_mode = alc268_modes,
13804 .input_mux = &alc268_capture_source,
13805 },
13806#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013807};
13808
13809static int patch_alc268(struct hda_codec *codec)
13810{
13811 struct alc_spec *spec;
13812 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013813 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013814
Julia Lawallef86f582009-12-19 08:18:03 +010013815 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013816 if (spec == NULL)
13817 return -ENOMEM;
13818
13819 codec->spec = spec;
13820
13821 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13822 alc268_models,
13823 alc268_cfg_tbl);
13824
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013825 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13826 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013827 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013828
Kailang Yanga361d842007-06-05 12:30:55 +020013829 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013830 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13831 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013832 board_config = ALC268_AUTO;
13833 }
13834
13835 if (board_config == ALC268_AUTO) {
13836 /* automatic parse from the BIOS config */
13837 err = alc268_parse_auto_config(codec);
13838 if (err < 0) {
13839 alc_free(codec);
13840 return err;
13841 } else if (!err) {
13842 printk(KERN_INFO
13843 "hda_codec: Cannot set up configuration "
13844 "from BIOS. Using base mode...\n");
13845 board_config = ALC268_3ST;
13846 }
13847 }
13848
13849 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013850 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013851
Kailang Yanga361d842007-06-05 12:30:55 +020013852 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13853 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013854 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013855
Kailang Yanga361d842007-06-05 12:30:55 +020013856 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13857
Takashi Iwai22971e32009-02-10 11:56:44 +010013858 has_beep = 0;
13859 for (i = 0; i < spec->num_mixers; i++) {
13860 if (spec->mixers[i] == alc268_beep_mixer) {
13861 has_beep = 1;
13862 break;
13863 }
13864 }
13865
13866 if (has_beep) {
13867 err = snd_hda_attach_beep_device(codec, 0x1);
13868 if (err < 0) {
13869 alc_free(codec);
13870 return err;
13871 }
13872 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13873 /* override the amp caps for beep generator */
13874 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013875 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13876 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13877 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13878 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013879 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013880
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013881 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013882 /* check whether NID 0x07 is valid */
13883 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013884 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013885
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013886 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013887 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013888 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013889 if (spec->auto_mic ||
13890 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013891 spec->adc_nids = alc268_adc_nids_alt;
13892 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013893 if (spec->auto_mic)
13894 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013895 if (spec->auto_mic || spec->input_mux->num_items == 1)
13896 add_mixer(spec, alc268_capture_nosrc_mixer);
13897 else
13898 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013899 } else {
13900 spec->adc_nids = alc268_adc_nids;
13901 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013902 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013903 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013904 /* set default input source */
13905 for (i = 0; i < spec->num_adc_nids; i++)
13906 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13907 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013908 i < spec->num_mux_defs ?
13909 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013910 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013911 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013912
13913 spec->vmaster_nid = 0x02;
13914
Kailang Yanga361d842007-06-05 12:30:55 +020013915 codec->patch_ops = alc_patch_ops;
13916 if (board_config == ALC268_AUTO)
13917 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013918
Kailang Yanga361d842007-06-05 12:30:55 +020013919 return 0;
13920}
13921
13922/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013923 * ALC269 channel source setting (2 channel)
13924 */
13925#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13926
13927#define alc269_dac_nids alc260_dac_nids
13928
13929static hda_nid_t alc269_adc_nids[1] = {
13930 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013931 0x08,
13932};
13933
Takashi Iwaie01bf502008-08-21 16:25:07 +020013934static hda_nid_t alc269_capsrc_nids[1] = {
13935 0x23,
13936};
13937
Kailang Yang84898e82010-02-04 14:16:14 +010013938static hda_nid_t alc269vb_adc_nids[1] = {
13939 /* ADC1 */
13940 0x09,
13941};
13942
13943static hda_nid_t alc269vb_capsrc_nids[1] = {
13944 0x22,
13945};
13946
Takashi Iwai66946352010-03-29 17:21:45 +020013947static hda_nid_t alc269_adc_candidates[] = {
13948 0x08, 0x09, 0x07,
13949};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013950
Kailang Yangf6a92242007-12-13 16:52:54 +010013951#define alc269_modes alc260_modes
13952#define alc269_capture_source alc880_lg_lw_capture_source
13953
13954static struct snd_kcontrol_new alc269_base_mixer[] = {
13955 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13956 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13957 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13958 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13961 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13962 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13963 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13964 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13965 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13966 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13967 { } /* end */
13968};
13969
Kailang Yang60db6b52008-08-26 13:13:00 +020013970static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13971 /* output mixer control */
13972 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13973 {
13974 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13975 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013976 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013977 .info = snd_hda_mixer_amp_switch_info,
13978 .get = snd_hda_mixer_amp_switch_get,
13979 .put = alc268_acer_master_sw_put,
13980 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13981 },
13982 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13984 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13985 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13986 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13987 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013988 { }
13989};
13990
Tony Vroon64154832008-11-06 15:08:49 +000013991static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13992 /* output mixer control */
13993 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13994 {
13995 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13996 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013997 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013998 .info = snd_hda_mixer_amp_switch_info,
13999 .get = snd_hda_mixer_amp_switch_get,
14000 .put = alc268_acer_master_sw_put,
14001 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14002 },
14003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14004 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14005 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14006 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14007 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14008 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
14009 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14010 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
14011 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014012 { }
14013};
14014
Kailang Yang84898e82010-02-04 14:16:14 +010014015static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014016 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014017 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014018 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014019 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014020 { } /* end */
14021};
14022
Kailang Yang84898e82010-02-04 14:16:14 +010014023static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14024 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14025 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14026 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14027 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14028 { } /* end */
14029};
14030
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014031static struct snd_kcontrol_new alc269_asus_mixer[] = {
14032 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14033 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14034 { } /* end */
14035};
14036
Kailang Yangf6a92242007-12-13 16:52:54 +010014037/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014038static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14039 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14040 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14041 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14042 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14043 { } /* end */
14044};
14045
14046static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014047 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14048 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014049 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14050 { } /* end */
14051};
14052
Kailang Yang84898e82010-02-04 14:16:14 +010014053static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14054 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14055 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14056 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14057 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14058 { } /* end */
14059};
14060
14061static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14062 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14063 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14064 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14065 { } /* end */
14066};
14067
Takashi Iwai26f5df22008-11-03 17:39:46 +010014068/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014069#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014070
Kailang Yang60db6b52008-08-26 13:13:00 +020014071static struct hda_verb alc269_quanta_fl1_verbs[] = {
14072 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14073 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14074 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14075 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14076 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14077 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14078 { }
14079};
14080
Tony Vroon64154832008-11-06 15:08:49 +000014081static struct hda_verb alc269_lifebook_verbs[] = {
14082 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14083 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14084 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14085 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14086 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14087 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14088 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14089 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14090 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14091 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14092 { }
14093};
14094
Kailang Yang60db6b52008-08-26 13:13:00 +020014095/* toggle speaker-output according to the hp-jack state */
14096static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14097{
14098 unsigned int present;
14099 unsigned char bits;
14100
Wu Fengguang864f92b2009-11-18 12:38:02 +080014101 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014102 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014103 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014104 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014105 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014106 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014107
14108 snd_hda_codec_write(codec, 0x20, 0,
14109 AC_VERB_SET_COEF_INDEX, 0x0c);
14110 snd_hda_codec_write(codec, 0x20, 0,
14111 AC_VERB_SET_PROC_COEF, 0x680);
14112
14113 snd_hda_codec_write(codec, 0x20, 0,
14114 AC_VERB_SET_COEF_INDEX, 0x0c);
14115 snd_hda_codec_write(codec, 0x20, 0,
14116 AC_VERB_SET_PROC_COEF, 0x480);
14117}
14118
Tony Vroon64154832008-11-06 15:08:49 +000014119/* toggle speaker-output according to the hp-jacks state */
14120static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14121{
14122 unsigned int present;
14123 unsigned char bits;
14124
14125 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014126 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014127
14128 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014129 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014130
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014131 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014132 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014133 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014134 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014135 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014136
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, 0x680);
14141
14142 snd_hda_codec_write(codec, 0x20, 0,
14143 AC_VERB_SET_COEF_INDEX, 0x0c);
14144 snd_hda_codec_write(codec, 0x20, 0,
14145 AC_VERB_SET_PROC_COEF, 0x480);
14146}
14147
Tony Vroon64154832008-11-06 15:08:49 +000014148static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14149{
14150 unsigned int present_laptop;
14151 unsigned int present_dock;
14152
Wu Fengguang864f92b2009-11-18 12:38:02 +080014153 present_laptop = snd_hda_jack_detect(codec, 0x18);
14154 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014155
14156 /* Laptop mic port overrides dock mic port, design decision */
14157 if (present_dock)
14158 snd_hda_codec_write(codec, 0x23, 0,
14159 AC_VERB_SET_CONNECT_SEL, 0x3);
14160 if (present_laptop)
14161 snd_hda_codec_write(codec, 0x23, 0,
14162 AC_VERB_SET_CONNECT_SEL, 0x0);
14163 if (!present_dock && !present_laptop)
14164 snd_hda_codec_write(codec, 0x23, 0,
14165 AC_VERB_SET_CONNECT_SEL, 0x1);
14166}
14167
Kailang Yang60db6b52008-08-26 13:13:00 +020014168static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14169 unsigned int res)
14170{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014171 switch (res >> 26) {
14172 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014173 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014174 break;
14175 case ALC880_MIC_EVENT:
14176 alc_mic_automute(codec);
14177 break;
14178 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014179}
14180
Tony Vroon64154832008-11-06 15:08:49 +000014181static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14182 unsigned int res)
14183{
14184 if ((res >> 26) == ALC880_HP_EVENT)
14185 alc269_lifebook_speaker_automute(codec);
14186 if ((res >> 26) == ALC880_MIC_EVENT)
14187 alc269_lifebook_mic_autoswitch(codec);
14188}
14189
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014190static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14191{
14192 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014193 spec->autocfg.hp_pins[0] = 0x15;
14194 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014195 spec->ext_mic.pin = 0x18;
14196 spec->ext_mic.mux_idx = 0;
14197 spec->int_mic.pin = 0x19;
14198 spec->int_mic.mux_idx = 1;
14199 spec->auto_mic = 1;
14200}
14201
Kailang Yang60db6b52008-08-26 13:13:00 +020014202static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14203{
14204 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014205 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014206}
14207
Tony Vroon64154832008-11-06 15:08:49 +000014208static void alc269_lifebook_init_hook(struct hda_codec *codec)
14209{
14210 alc269_lifebook_speaker_automute(codec);
14211 alc269_lifebook_mic_autoswitch(codec);
14212}
14213
Kailang Yang84898e82010-02-04 14:16:14 +010014214static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014215 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14216 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14217 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14218 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14219 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14220 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14221 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14222 {}
14223};
14224
Kailang Yang84898e82010-02-04 14:16:14 +010014225static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014226 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14227 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14228 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14229 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14230 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14231 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14232 {}
14233};
14234
Kailang Yang84898e82010-02-04 14:16:14 +010014235static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14236 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14237 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14238 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14239 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14240 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14241 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14242 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14243 {}
14244};
14245
14246static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14247 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14248 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14249 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14250 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14251 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14252 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14253 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14254 {}
14255};
14256
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014257static struct hda_verb alc271_acer_dmic_verbs[] = {
14258 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14259 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14260 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14262 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14263 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14264 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14265 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14266 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14267 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14268 { }
14269};
14270
Kailang Yang60db6b52008-08-26 13:13:00 +020014271/* toggle speaker-output according to the hp-jack state */
14272static void alc269_speaker_automute(struct hda_codec *codec)
14273{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014274 struct alc_spec *spec = codec->spec;
14275 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014276 unsigned int present;
14277 unsigned char bits;
14278
Kailang Yangebb83ee2009-12-17 12:23:00 +010014279 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014280 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014281 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014282 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014283 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014284 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014285}
14286
Kailang Yang60db6b52008-08-26 13:13:00 +020014287/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014288static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014289 unsigned int res)
14290{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014291 switch (res >> 26) {
14292 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014293 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014294 break;
14295 case ALC880_MIC_EVENT:
14296 alc_mic_automute(codec);
14297 break;
14298 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014299}
14300
Kailang Yang226b1ec2010-04-09 11:01:20 +020014301static void alc269_laptop_amic_setup(struct hda_codec *codec)
14302{
14303 struct alc_spec *spec = codec->spec;
14304 spec->autocfg.hp_pins[0] = 0x15;
14305 spec->autocfg.speaker_pins[0] = 0x14;
14306 spec->ext_mic.pin = 0x18;
14307 spec->ext_mic.mux_idx = 0;
14308 spec->int_mic.pin = 0x19;
14309 spec->int_mic.mux_idx = 1;
14310 spec->auto_mic = 1;
14311}
14312
Kailang Yang84898e82010-02-04 14:16:14 +010014313static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014314{
14315 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014316 spec->autocfg.hp_pins[0] = 0x15;
14317 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014318 spec->ext_mic.pin = 0x18;
14319 spec->ext_mic.mux_idx = 0;
14320 spec->int_mic.pin = 0x12;
14321 spec->int_mic.mux_idx = 5;
14322 spec->auto_mic = 1;
14323}
14324
Kailang Yang226b1ec2010-04-09 11:01:20 +020014325static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014326{
14327 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014328 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014329 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014330 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 Yang226b1ec2010-04-09 11:01:20 +020014337static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14338{
14339 struct alc_spec *spec = codec->spec;
14340 spec->autocfg.hp_pins[0] = 0x21;
14341 spec->autocfg.speaker_pins[0] = 0x14;
14342 spec->ext_mic.pin = 0x18;
14343 spec->ext_mic.mux_idx = 0;
14344 spec->int_mic.pin = 0x12;
14345 spec->int_mic.mux_idx = 6;
14346 spec->auto_mic = 1;
14347}
14348
Kailang Yang84898e82010-02-04 14:16:14 +010014349static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014350{
14351 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014352 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014353}
14354
Kailang Yangf6a92242007-12-13 16:52:54 +010014355/*
14356 * generic initialization of ADC, input mixers and output mixers
14357 */
14358static struct hda_verb alc269_init_verbs[] = {
14359 /*
14360 * Unmute ADC0 and set the default input to mic-in
14361 */
Kailang Yang84898e82010-02-04 14:16:14 +010014362 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014363
14364 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014365 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014366 */
14367 /* set vol=0 to output mixers */
14368 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14369 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14370
14371 /* set up input amps for analog loopback */
14372 /* Amp Indices: DAC = 0, mixer = 1 */
14373 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14374 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14375 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14376 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14377 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14378 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14379
14380 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14381 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14382 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14383 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14384 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14385 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14386 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14387
14388 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14389 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014390
Kailang Yang84898e82010-02-04 14:16:14 +010014391 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014392 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14393 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014394 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014395
14396 /* set EAPD */
14397 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014398 { }
14399};
14400
14401static struct hda_verb alc269vb_init_verbs[] = {
14402 /*
14403 * Unmute ADC0 and set the default input to mic-in
14404 */
14405 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14406
14407 /*
14408 * Set up output mixers (0x02 - 0x03)
14409 */
14410 /* set vol=0 to output mixers */
14411 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14412 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14413
14414 /* set up input amps for analog loopback */
14415 /* Amp Indices: DAC = 0, mixer = 1 */
14416 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14417 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14418 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14419 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14420 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14421 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14422
14423 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14424 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14425 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14426 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14427 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14428 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14429 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14430
14431 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14432 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14433
14434 /* FIXME: use Mux-type input source selection */
14435 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14436 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14437 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14438
14439 /* set EAPD */
14440 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014441 { }
14442};
14443
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014444#define alc269_auto_create_multi_out_ctls \
14445 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014446#define alc269_auto_create_input_ctls \
14447 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014448
14449#ifdef CONFIG_SND_HDA_POWER_SAVE
14450#define alc269_loopbacks alc880_loopbacks
14451#endif
14452
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014453/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014454#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14455#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14456#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14457#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14458
Takashi Iwaif03d3112009-03-05 14:18:16 +010014459static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14460 .substreams = 1,
14461 .channels_min = 2,
14462 .channels_max = 8,
14463 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14464 /* NID is set in alc_build_pcms */
14465 .ops = {
14466 .open = alc880_playback_pcm_open,
14467 .prepare = alc880_playback_pcm_prepare,
14468 .cleanup = alc880_playback_pcm_cleanup
14469 },
14470};
14471
14472static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14473 .substreams = 1,
14474 .channels_min = 2,
14475 .channels_max = 2,
14476 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14477 /* NID is set in alc_build_pcms */
14478};
14479
Takashi Iwaiad358792010-03-30 18:00:59 +020014480#ifdef CONFIG_SND_HDA_POWER_SAVE
14481static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14482{
14483 switch (codec->subsystem_id) {
14484 case 0x103c1586:
14485 return 1;
14486 }
14487 return 0;
14488}
14489
14490static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14491{
14492 /* update mute-LED according to the speaker mute state */
14493 if (nid == 0x01 || nid == 0x14) {
14494 int pinval;
14495 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14496 HDA_AMP_MUTE)
14497 pinval = 0x24;
14498 else
14499 pinval = 0x20;
14500 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014501 snd_hda_codec_update_cache(codec, 0x19, 0,
14502 AC_VERB_SET_PIN_WIDGET_CONTROL,
14503 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014504 }
14505 return alc_check_power_status(codec, nid);
14506}
14507#endif /* CONFIG_SND_HDA_POWER_SAVE */
14508
Takashi Iwai840b64c2010-07-13 22:49:01 +020014509static int alc275_setup_dual_adc(struct hda_codec *codec)
14510{
14511 struct alc_spec *spec = codec->spec;
14512
14513 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14514 return 0;
14515 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14516 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14517 if (spec->ext_mic.pin <= 0x12) {
14518 spec->private_adc_nids[0] = 0x08;
14519 spec->private_adc_nids[1] = 0x11;
14520 spec->private_capsrc_nids[0] = 0x23;
14521 spec->private_capsrc_nids[1] = 0x22;
14522 } else {
14523 spec->private_adc_nids[0] = 0x11;
14524 spec->private_adc_nids[1] = 0x08;
14525 spec->private_capsrc_nids[0] = 0x22;
14526 spec->private_capsrc_nids[1] = 0x23;
14527 }
14528 spec->adc_nids = spec->private_adc_nids;
14529 spec->capsrc_nids = spec->private_capsrc_nids;
14530 spec->num_adc_nids = 2;
14531 spec->dual_adc_switch = 1;
14532 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14533 spec->adc_nids[0], spec->adc_nids[1]);
14534 return 1;
14535 }
14536 return 0;
14537}
14538
Kailang Yangf6a92242007-12-13 16:52:54 +010014539/*
14540 * BIOS auto configuration
14541 */
14542static int alc269_parse_auto_config(struct hda_codec *codec)
14543{
14544 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014545 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014546 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14547
14548 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14549 alc269_ignore);
14550 if (err < 0)
14551 return err;
14552
14553 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14554 if (err < 0)
14555 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014556 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014557 if (err < 0)
14558 return err;
14559
14560 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14561
Takashi Iwai757899a2010-07-30 10:48:14 +020014562 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014563
Takashi Iwai603c4012008-07-30 15:01:44 +020014564 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014565 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014566
Kailang Yang84898e82010-02-04 14:16:14 +010014567 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14568 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014569 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014570 } else {
14571 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014572 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014573 }
14574
Kailang Yangf6a92242007-12-13 16:52:54 +010014575 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014576 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014577
14578 if (!alc275_setup_dual_adc(codec))
14579 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14580 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014581
Takashi Iwaie01bf502008-08-21 16:25:07 +020014582 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014583 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014584 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14585 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014586
14587 err = alc_auto_add_mic_boost(codec);
14588 if (err < 0)
14589 return err;
14590
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014591 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014592 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014593
Kailang Yangf6a92242007-12-13 16:52:54 +010014594 return 1;
14595}
14596
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014597#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14598#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014599#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14600
14601
14602/* init callback for auto-configuration model -- overriding the default init */
14603static void alc269_auto_init(struct hda_codec *codec)
14604{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014605 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014606 alc269_auto_init_multi_out(codec);
14607 alc269_auto_init_hp_out(codec);
14608 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014609 alc_auto_init_digital(codec);
Kailang Yang9ad0e492010-09-14 23:22:00 +020014610 alc_init_jacks(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014611 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014612 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014613}
14614
Kailang Yang977ddd62010-09-15 10:02:29 +020014615#ifdef CONFIG_SND_HDA_POWER_SAVE
14616static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14617{
14618 struct alc_spec *spec = codec->spec;
14619 int val;
14620
14621 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14622 val = alc_read_coef_idx(codec, 0x04);
14623 /* Power down output pin */
14624 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14625 }
14626
14627 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14628 val = alc_read_coef_idx(codec, 0x04);
14629 /* Power down output pin */
14630 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14631 msleep(150);
14632 }
14633
14634 alc_shutup(codec);
14635 if (spec && spec->power_hook)
14636 spec->power_hook(codec);
14637 return 0;
14638}
14639#endif
14640#ifdef SND_HDA_NEEDS_RESUME
14641static int alc269_resume(struct hda_codec *codec)
14642{
14643 int val;
14644
14645 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14646 val = alc_read_coef_idx(codec, 0x04);
14647 /* Power down output pin */
14648 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14649 msleep(150);
14650 }
14651
14652 codec->patch_ops.init(codec);
14653
14654 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14655 val = alc_read_coef_idx(codec, 0x04);
14656 /* Power up output pin */
14657 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14658 msleep(200);
14659 }
14660
14661 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14662 val = alc_read_coef_idx(codec, 0x04);
14663 /* Power up output pin */
14664 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14665 }
14666
14667 snd_hda_codec_resume_amp(codec);
14668 snd_hda_codec_resume_cache(codec);
14669#ifdef CONFIG_SND_HDA_POWER_SAVE
14670 if (codec->patch_ops.check_power_status)
14671 codec->patch_ops.check_power_status(codec, 0x01);
14672#endif
14673 return 0;
14674}
14675#endif
14676
Takashi Iwaiff818c22010-04-12 08:59:25 +020014677enum {
14678 ALC269_FIXUP_SONY_VAIO,
14679};
14680
Takashi Iwaiff818c22010-04-12 08:59:25 +020014681static const struct alc_fixup alc269_fixups[] = {
14682 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014683 .verbs = (const struct hda_verb[]) {
14684 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14685 {}
14686 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014687 },
14688};
14689
14690static struct snd_pci_quirk alc269_fixup_tbl[] = {
14691 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningssondbbcbc02010-08-23 08:14:35 +020014692 SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014693 {}
14694};
14695
14696
Kailang Yangf6a92242007-12-13 16:52:54 +010014697/*
14698 * configuration and preset
14699 */
14700static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014701 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014702 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014703 [ALC269_AMIC] = "laptop-amic",
14704 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014705 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014706 [ALC269_LIFEBOOK] = "lifebook",
14707 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014708};
14709
14710static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014711 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014712 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014713 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014714 ALC269_AMIC),
14715 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14716 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14717 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14718 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14719 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14720 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14721 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14722 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14723 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14724 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14725 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14726 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14727 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14728 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14729 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14730 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14731 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14732 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14733 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14734 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14735 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14736 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14737 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14738 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14739 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14740 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14741 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14742 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14743 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14744 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14745 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14746 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14747 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14748 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14749 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14750 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014751 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014752 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014753 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014754 ALC269_DMIC),
14755 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14756 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014757 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014758 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014759 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14760 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14761 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14762 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14763 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14764 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014765 {}
14766};
14767
14768static struct alc_config_preset alc269_presets[] = {
14769 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014770 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014771 .init_verbs = { alc269_init_verbs },
14772 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14773 .dac_nids = alc269_dac_nids,
14774 .hp_nid = 0x03,
14775 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14776 .channel_mode = alc269_modes,
14777 .input_mux = &alc269_capture_source,
14778 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014779 [ALC269_QUANTA_FL1] = {
14780 .mixers = { alc269_quanta_fl1_mixer },
14781 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14782 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14783 .dac_nids = alc269_dac_nids,
14784 .hp_nid = 0x03,
14785 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14786 .channel_mode = alc269_modes,
14787 .input_mux = &alc269_capture_source,
14788 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014789 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014790 .init_hook = alc269_quanta_fl1_init_hook,
14791 },
Kailang Yang84898e82010-02-04 14:16:14 +010014792 [ALC269_AMIC] = {
14793 .mixers = { alc269_laptop_mixer },
14794 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014795 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014796 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014797 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14798 .dac_nids = alc269_dac_nids,
14799 .hp_nid = 0x03,
14800 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14801 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014802 .unsol_event = alc269_laptop_unsol_event,
14803 .setup = alc269_laptop_amic_setup,
14804 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014805 },
Kailang Yang84898e82010-02-04 14:16:14 +010014806 [ALC269_DMIC] = {
14807 .mixers = { alc269_laptop_mixer },
14808 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014809 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014810 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014811 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14812 .dac_nids = alc269_dac_nids,
14813 .hp_nid = 0x03,
14814 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14815 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014816 .unsol_event = alc269_laptop_unsol_event,
14817 .setup = alc269_laptop_dmic_setup,
14818 .init_hook = alc269_laptop_inithook,
14819 },
14820 [ALC269VB_AMIC] = {
14821 .mixers = { alc269vb_laptop_mixer },
14822 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14823 .init_verbs = { alc269vb_init_verbs,
14824 alc269vb_laptop_amic_init_verbs },
14825 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14826 .dac_nids = alc269_dac_nids,
14827 .hp_nid = 0x03,
14828 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14829 .channel_mode = alc269_modes,
14830 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014831 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014832 .init_hook = alc269_laptop_inithook,
14833 },
14834 [ALC269VB_DMIC] = {
14835 .mixers = { alc269vb_laptop_mixer },
14836 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14837 .init_verbs = { alc269vb_init_verbs,
14838 alc269vb_laptop_dmic_init_verbs },
14839 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14840 .dac_nids = alc269_dac_nids,
14841 .hp_nid = 0x03,
14842 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14843 .channel_mode = alc269_modes,
14844 .unsol_event = alc269_laptop_unsol_event,
14845 .setup = alc269vb_laptop_dmic_setup,
14846 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014847 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014848 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014849 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014850 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014851 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014852 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014853 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14854 .dac_nids = alc269_dac_nids,
14855 .hp_nid = 0x03,
14856 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14857 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014858 .unsol_event = alc269_laptop_unsol_event,
14859 .setup = alc269_laptop_dmic_setup,
14860 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014861 },
Tony Vroon64154832008-11-06 15:08:49 +000014862 [ALC269_LIFEBOOK] = {
14863 .mixers = { alc269_lifebook_mixer },
14864 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14865 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14866 .dac_nids = alc269_dac_nids,
14867 .hp_nid = 0x03,
14868 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14869 .channel_mode = alc269_modes,
14870 .input_mux = &alc269_capture_source,
14871 .unsol_event = alc269_lifebook_unsol_event,
14872 .init_hook = alc269_lifebook_init_hook,
14873 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014874 [ALC271_ACER] = {
14875 .mixers = { alc269_asus_mixer },
14876 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14877 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14878 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14879 .dac_nids = alc269_dac_nids,
14880 .adc_nids = alc262_dmic_adc_nids,
14881 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14882 .capsrc_nids = alc262_dmic_capsrc_nids,
14883 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14884 .channel_mode = alc269_modes,
14885 .input_mux = &alc269_capture_source,
14886 .dig_out_nid = ALC880_DIGOUT_NID,
14887 .unsol_event = alc_sku_unsol_event,
14888 .setup = alc269vb_laptop_dmic_setup,
14889 .init_hook = alc_inithook,
14890 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014891};
14892
Kailang Yang977ddd62010-09-15 10:02:29 +020014893static int alc269_fill_coef(struct hda_codec *codec)
14894{
14895 int val;
14896
14897 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
14898 alc_write_coef_idx(codec, 0xf, 0x960b);
14899 alc_write_coef_idx(codec, 0xe, 0x8817);
14900 }
14901
14902 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
14903 alc_write_coef_idx(codec, 0xf, 0x960b);
14904 alc_write_coef_idx(codec, 0xe, 0x8814);
14905 }
14906
14907 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14908 val = alc_read_coef_idx(codec, 0x04);
14909 /* Power up output pin */
14910 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14911 }
14912
14913 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14914 val = alc_read_coef_idx(codec, 0xd);
14915 if ((val & 0x0c00) >> 10 != 0x1) {
14916 /* Capless ramp up clock control */
14917 alc_write_coef_idx(codec, 0xd, val | 1<<10);
14918 }
14919 val = alc_read_coef_idx(codec, 0x17);
14920 if ((val & 0x01c0) >> 6 != 0x4) {
14921 /* Class D power on reset */
14922 alc_write_coef_idx(codec, 0x17, val | 1<<7);
14923 }
14924 }
14925 return 0;
14926}
14927
Kailang Yangf6a92242007-12-13 16:52:54 +010014928static int patch_alc269(struct hda_codec *codec)
14929{
14930 struct alc_spec *spec;
14931 int board_config;
14932 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014933 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014934
14935 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14936 if (spec == NULL)
14937 return -ENOMEM;
14938
14939 codec->spec = spec;
14940
Kailang Yangda00c242010-03-19 11:23:45 +010014941 alc_auto_parse_customize_define(codec);
14942
Kailang Yang274693f2009-12-03 10:07:50 +010014943 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014944 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14945 spec->cdefine.platform_type == 1)
14946 alc_codec_rename(codec, "ALC271X");
14947 else
14948 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014949 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014950 } else
14951 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014952
Kailang Yang977ddd62010-09-15 10:02:29 +020014953 alc269_fill_coef(codec);
14954
Kailang Yangf6a92242007-12-13 16:52:54 +010014955 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14956 alc269_models,
14957 alc269_cfg_tbl);
14958
14959 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014960 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14961 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014962 board_config = ALC269_AUTO;
14963 }
14964
Takashi Iwaiff818c22010-04-12 08:59:25 +020014965 if (board_config == ALC269_AUTO)
14966 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14967
Kailang Yangf6a92242007-12-13 16:52:54 +010014968 if (board_config == ALC269_AUTO) {
14969 /* automatic parse from the BIOS config */
14970 err = alc269_parse_auto_config(codec);
14971 if (err < 0) {
14972 alc_free(codec);
14973 return err;
14974 } else if (!err) {
14975 printk(KERN_INFO
14976 "hda_codec: Cannot set up configuration "
14977 "from BIOS. Using base mode...\n");
14978 board_config = ALC269_BASIC;
14979 }
14980 }
14981
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014982 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020014983 err = snd_hda_attach_beep_device(codec, 0x1);
14984 if (err < 0) {
14985 alc_free(codec);
14986 return err;
14987 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014988 }
14989
Kailang Yangf6a92242007-12-13 16:52:54 +010014990 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014991 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014992
Kailang Yang84898e82010-02-04 14:16:14 +010014993 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014994 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14995 * fix the sample rate of analog I/O to 44.1kHz
14996 */
14997 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14998 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020014999 } else if (spec->dual_adc_switch) {
15000 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15001 /* switch ADC dynamically */
15002 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015003 } else {
15004 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15005 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15006 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015007 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15008 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15009
Takashi Iwai66946352010-03-29 17:21:45 +020015010 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
15011 if (!is_alc269vb) {
15012 spec->adc_nids = alc269_adc_nids;
15013 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15014 spec->capsrc_nids = alc269_capsrc_nids;
15015 } else {
15016 spec->adc_nids = alc269vb_adc_nids;
15017 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15018 spec->capsrc_nids = alc269vb_capsrc_nids;
15019 }
Kailang Yang84898e82010-02-04 14:16:14 +010015020 }
15021
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015022 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015023 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015024 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015025 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015026
Takashi Iwaiff818c22010-04-12 08:59:25 +020015027 if (board_config == ALC269_AUTO)
15028 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
15029
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015030 spec->vmaster_nid = 0x02;
15031
Kailang Yangf6a92242007-12-13 16:52:54 +010015032 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015033#ifdef CONFIG_SND_HDA_POWER_SAVE
15034 codec->patch_ops.suspend = alc269_suspend;
15035#endif
15036#ifdef SND_HDA_NEEDS_RESUME
15037 codec->patch_ops.resume = alc269_resume;
15038#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015039 if (board_config == ALC269_AUTO)
15040 spec->init_hook = alc269_auto_init;
15041#ifdef CONFIG_SND_HDA_POWER_SAVE
15042 if (!spec->loopback.amplist)
15043 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015044 if (alc269_mic2_for_mute_led(codec))
15045 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015046#endif
15047
15048 return 0;
15049}
15050
15051/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015052 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15053 */
15054
15055/*
15056 * set the path ways for 2 channel output
15057 * need to set the codec line out and mic 1 pin widgets to inputs
15058 */
15059static struct hda_verb alc861_threestack_ch2_init[] = {
15060 /* set pin widget 1Ah (line in) for input */
15061 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015062 /* set pin widget 18h (mic1/2) for input, for mic also enable
15063 * the vref
15064 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015065 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15066
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015067 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15068#if 0
15069 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15070 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15071#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015072 { } /* end */
15073};
15074/*
15075 * 6ch mode
15076 * need to set the codec line out and mic 1 pin widgets to outputs
15077 */
15078static struct hda_verb alc861_threestack_ch6_init[] = {
15079 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15080 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15081 /* set pin widget 18h (mic1) for output (CLFE)*/
15082 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15083
15084 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015085 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015086
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015087 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15088#if 0
15089 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15090 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15091#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015092 { } /* end */
15093};
15094
15095static struct hda_channel_mode alc861_threestack_modes[2] = {
15096 { 2, alc861_threestack_ch2_init },
15097 { 6, alc861_threestack_ch6_init },
15098};
Takashi Iwai22309c32006-08-09 16:57:28 +020015099/* Set mic1 as input and unmute the mixer */
15100static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15101 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15102 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15103 { } /* end */
15104};
15105/* Set mic1 as output and mute mixer */
15106static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15107 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15108 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15109 { } /* end */
15110};
15111
15112static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15113 { 2, alc861_uniwill_m31_ch2_init },
15114 { 4, alc861_uniwill_m31_ch4_init },
15115};
Kailang Yangdf694da2005-12-05 19:42:22 +010015116
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015117/* Set mic1 and line-in as input and unmute the mixer */
15118static struct hda_verb alc861_asus_ch2_init[] = {
15119 /* set pin widget 1Ah (line in) for input */
15120 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015121 /* set pin widget 18h (mic1/2) for input, for mic also enable
15122 * the vref
15123 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015124 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15125
15126 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15127#if 0
15128 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15129 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15130#endif
15131 { } /* end */
15132};
15133/* Set mic1 nad line-in as output and mute mixer */
15134static struct hda_verb alc861_asus_ch6_init[] = {
15135 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15136 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15137 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15138 /* set pin widget 18h (mic1) for output (CLFE)*/
15139 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15140 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15141 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15142 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15143
15144 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15145#if 0
15146 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15147 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15148#endif
15149 { } /* end */
15150};
15151
15152static struct hda_channel_mode alc861_asus_modes[2] = {
15153 { 2, alc861_asus_ch2_init },
15154 { 6, alc861_asus_ch6_init },
15155};
15156
Kailang Yangdf694da2005-12-05 19:42:22 +010015157/* patch-ALC861 */
15158
15159static struct snd_kcontrol_new alc861_base_mixer[] = {
15160 /* output mixer control */
15161 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15162 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15163 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15164 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15165 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15166
15167 /*Input mixer control */
15168 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15169 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15170 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15171 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15172 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15173 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15174 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15175 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15176 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15177 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015178
Kailang Yangdf694da2005-12-05 19:42:22 +010015179 { } /* end */
15180};
15181
15182static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15183 /* output mixer control */
15184 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15185 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15186 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15187 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15188 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15189
15190 /* Input mixer control */
15191 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15192 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15193 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15194 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15195 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15196 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15197 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15198 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15199 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15200 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015201
Kailang Yangdf694da2005-12-05 19:42:22 +010015202 {
15203 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15204 .name = "Channel Mode",
15205 .info = alc_ch_mode_info,
15206 .get = alc_ch_mode_get,
15207 .put = alc_ch_mode_put,
15208 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15209 },
15210 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015211};
15212
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015213static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015214 /* output mixer control */
15215 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15216 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15217 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015218
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015219 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015220};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015221
Takashi Iwai22309c32006-08-09 16:57:28 +020015222static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15223 /* output mixer control */
15224 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15225 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15226 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15227 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15228 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15229
15230 /* Input mixer control */
15231 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15232 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15233 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15234 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15235 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15236 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15237 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15238 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15239 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15240 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015241
Takashi Iwai22309c32006-08-09 16:57:28 +020015242 {
15243 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15244 .name = "Channel Mode",
15245 .info = alc_ch_mode_info,
15246 .get = alc_ch_mode_get,
15247 .put = alc_ch_mode_put,
15248 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15249 },
15250 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015251};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015252
15253static struct snd_kcontrol_new alc861_asus_mixer[] = {
15254 /* output mixer control */
15255 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15256 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15257 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15258 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15259 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15260
15261 /* Input mixer control */
15262 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15263 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15264 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15265 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15266 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15267 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15268 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15269 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15270 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015271 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15272
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015273 {
15274 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15275 .name = "Channel Mode",
15276 .info = alc_ch_mode_info,
15277 .get = alc_ch_mode_get,
15278 .put = alc_ch_mode_put,
15279 .private_value = ARRAY_SIZE(alc861_asus_modes),
15280 },
15281 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015282};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015283
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015284/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015285static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015286 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15287 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015288 { }
15289};
15290
Kailang Yangdf694da2005-12-05 19:42:22 +010015291/*
15292 * generic initialization of ADC, input mixers and output mixers
15293 */
15294static struct hda_verb alc861_base_init_verbs[] = {
15295 /*
15296 * Unmute ADC0 and set the default input to mic-in
15297 */
15298 /* port-A for surround (rear panel) */
15299 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15300 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15301 /* port-B for mic-in (rear panel) with vref */
15302 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15303 /* port-C for line-in (rear panel) */
15304 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15305 /* port-D for Front */
15306 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15307 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15308 /* port-E for HP out (front panel) */
15309 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15310 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015311 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015312 /* port-F for mic-in (front panel) with vref */
15313 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15314 /* port-G for CLFE (rear panel) */
15315 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15316 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15317 /* port-H for side (rear panel) */
15318 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15319 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15320 /* CD-in */
15321 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15322 /* route front mic to ADC1*/
15323 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15324 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015325
Kailang Yangdf694da2005-12-05 19:42:22 +010015326 /* Unmute DAC0~3 & spdif out*/
15327 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15328 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15329 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15330 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15331 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015332
Kailang Yangdf694da2005-12-05 19:42:22 +010015333 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15334 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15335 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15336 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15337 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015338
Kailang Yangdf694da2005-12-05 19:42:22 +010015339 /* Unmute Stereo Mixer 15 */
15340 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15341 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15342 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015343 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015344
15345 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15346 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15347 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15348 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15349 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15350 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15352 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015353 /* hp used DAC 3 (Front) */
15354 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015355 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15356
15357 { }
15358};
15359
15360static struct hda_verb alc861_threestack_init_verbs[] = {
15361 /*
15362 * Unmute ADC0 and set the default input to mic-in
15363 */
15364 /* port-A for surround (rear panel) */
15365 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15366 /* port-B for mic-in (rear panel) with vref */
15367 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15368 /* port-C for line-in (rear panel) */
15369 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15370 /* port-D for Front */
15371 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15372 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15373 /* port-E for HP out (front panel) */
15374 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15375 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015376 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015377 /* port-F for mic-in (front panel) with vref */
15378 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15379 /* port-G for CLFE (rear panel) */
15380 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15381 /* port-H for side (rear panel) */
15382 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15383 /* CD-in */
15384 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15385 /* route front mic to ADC1*/
15386 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15387 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15388 /* Unmute DAC0~3 & spdif out*/
15389 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15390 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15391 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15392 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15393 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015394
Kailang Yangdf694da2005-12-05 19:42:22 +010015395 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15396 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15397 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15398 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15399 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015400
Kailang Yangdf694da2005-12-05 19:42:22 +010015401 /* Unmute Stereo Mixer 15 */
15402 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15403 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15404 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015405 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015406
15407 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15408 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15409 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15410 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15412 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15413 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15414 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015415 /* hp used DAC 3 (Front) */
15416 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015417 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15418 { }
15419};
Takashi Iwai22309c32006-08-09 16:57:28 +020015420
15421static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15422 /*
15423 * Unmute ADC0 and set the default input to mic-in
15424 */
15425 /* port-A for surround (rear panel) */
15426 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15427 /* port-B for mic-in (rear panel) with vref */
15428 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15429 /* port-C for line-in (rear panel) */
15430 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15431 /* port-D for Front */
15432 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15433 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15434 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015435 /* this has to be set to VREF80 */
15436 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015437 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015438 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015439 /* port-F for mic-in (front panel) with vref */
15440 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15441 /* port-G for CLFE (rear panel) */
15442 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15443 /* port-H for side (rear panel) */
15444 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15445 /* CD-in */
15446 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15447 /* route front mic to ADC1*/
15448 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15449 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15450 /* Unmute DAC0~3 & spdif out*/
15451 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15452 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15453 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15454 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15455 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015456
Takashi Iwai22309c32006-08-09 16:57:28 +020015457 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15458 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15459 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15460 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15461 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015462
Takashi Iwai22309c32006-08-09 16:57:28 +020015463 /* Unmute Stereo Mixer 15 */
15464 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15465 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15466 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015467 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015468
15469 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15470 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15471 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15472 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15473 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15474 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15475 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15476 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015477 /* hp used DAC 3 (Front) */
15478 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015479 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15480 { }
15481};
15482
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015483static struct hda_verb alc861_asus_init_verbs[] = {
15484 /*
15485 * Unmute ADC0 and set the default input to mic-in
15486 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015487 /* port-A for surround (rear panel)
15488 * according to codec#0 this is the HP jack
15489 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015490 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15491 /* route front PCM to HP */
15492 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15493 /* port-B for mic-in (rear panel) with vref */
15494 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15495 /* port-C for line-in (rear panel) */
15496 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15497 /* port-D for Front */
15498 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15499 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15500 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015501 /* this has to be set to VREF80 */
15502 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015503 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015504 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015505 /* port-F for mic-in (front panel) with vref */
15506 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15507 /* port-G for CLFE (rear panel) */
15508 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15509 /* port-H for side (rear panel) */
15510 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15511 /* CD-in */
15512 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15513 /* route front mic to ADC1*/
15514 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15515 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15516 /* Unmute DAC0~3 & spdif out*/
15517 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15518 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15519 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15520 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15521 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15522 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15523 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15524 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15525 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15526 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015527
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015528 /* Unmute Stereo Mixer 15 */
15529 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15530 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15531 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015532 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015533
15534 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15535 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15536 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15537 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15538 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15539 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15540 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15541 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015542 /* hp used DAC 3 (Front) */
15543 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015544 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15545 { }
15546};
15547
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015548/* additional init verbs for ASUS laptops */
15549static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15550 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15551 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15552 { }
15553};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015554
Kailang Yangdf694da2005-12-05 19:42:22 +010015555/*
15556 * generic initialization of ADC, input mixers and output mixers
15557 */
15558static struct hda_verb alc861_auto_init_verbs[] = {
15559 /*
15560 * Unmute ADC0 and set the default input to mic-in
15561 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015562 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015563 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015564
Kailang Yangdf694da2005-12-05 19:42:22 +010015565 /* Unmute DAC0~3 & spdif out*/
15566 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15567 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15568 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15569 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15570 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015571
Kailang Yangdf694da2005-12-05 19:42:22 +010015572 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15573 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15574 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15575 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15576 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015577
Kailang Yangdf694da2005-12-05 19:42:22 +010015578 /* Unmute Stereo Mixer 15 */
15579 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15580 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15581 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15582 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15583
Takashi Iwai1c209302009-07-22 15:17:45 +020015584 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15585 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15586 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15587 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15588 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15589 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15590 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15591 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015592
15593 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15594 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015595 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15596 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015597 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15598 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015599 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15600 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015601
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015602 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015603
15604 { }
15605};
15606
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015607static struct hda_verb alc861_toshiba_init_verbs[] = {
15608 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015609
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015610 { }
15611};
15612
15613/* toggle speaker-output according to the hp-jack state */
15614static void alc861_toshiba_automute(struct hda_codec *codec)
15615{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015616 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015617
Takashi Iwai47fd8302007-08-10 17:11:07 +020015618 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15619 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15620 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15621 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015622}
15623
15624static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15625 unsigned int res)
15626{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015627 if ((res >> 26) == ALC880_HP_EVENT)
15628 alc861_toshiba_automute(codec);
15629}
15630
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015631/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015632#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15633#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15634#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15635#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15636
15637
15638#define ALC861_DIGOUT_NID 0x07
15639
15640static struct hda_channel_mode alc861_8ch_modes[1] = {
15641 { 8, NULL }
15642};
15643
15644static hda_nid_t alc861_dac_nids[4] = {
15645 /* front, surround, clfe, side */
15646 0x03, 0x06, 0x05, 0x04
15647};
15648
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015649static hda_nid_t alc660_dac_nids[3] = {
15650 /* front, clfe, surround */
15651 0x03, 0x05, 0x06
15652};
15653
Kailang Yangdf694da2005-12-05 19:42:22 +010015654static hda_nid_t alc861_adc_nids[1] = {
15655 /* ADC0-2 */
15656 0x08,
15657};
15658
15659static struct hda_input_mux alc861_capture_source = {
15660 .num_items = 5,
15661 .items = {
15662 { "Mic", 0x0 },
15663 { "Front Mic", 0x3 },
15664 { "Line", 0x1 },
15665 { "CD", 0x4 },
15666 { "Mixer", 0x5 },
15667 },
15668};
15669
Takashi Iwai1c209302009-07-22 15:17:45 +020015670static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15671{
15672 struct alc_spec *spec = codec->spec;
15673 hda_nid_t mix, srcs[5];
15674 int i, j, num;
15675
15676 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15677 return 0;
15678 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15679 if (num < 0)
15680 return 0;
15681 for (i = 0; i < num; i++) {
15682 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015683 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015684 if (type != AC_WID_AUD_OUT)
15685 continue;
15686 for (j = 0; j < spec->multiout.num_dacs; j++)
15687 if (spec->multiout.dac_nids[j] == srcs[i])
15688 break;
15689 if (j >= spec->multiout.num_dacs)
15690 return srcs[i];
15691 }
15692 return 0;
15693}
15694
Kailang Yangdf694da2005-12-05 19:42:22 +010015695/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015696static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015697 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015698{
Takashi Iwai1c209302009-07-22 15:17:45 +020015699 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015700 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015701 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015702
15703 spec->multiout.dac_nids = spec->private_dac_nids;
15704 for (i = 0; i < cfg->line_outs; i++) {
15705 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015706 dac = alc861_look_for_dac(codec, nid);
15707 if (!dac)
15708 continue;
15709 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015710 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015711 return 0;
15712}
15713
Takashi Iwai1c209302009-07-22 15:17:45 +020015714static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15715 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015716{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015717 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015718 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15719}
15720
15721/* add playback controls from the parsed DAC table */
15722static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15723 const struct auto_pin_cfg *cfg)
15724{
15725 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015726 static const char *chname[4] = {
15727 "Front", "Surround", NULL /*CLFE*/, "Side"
15728 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015729 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015730 int i, err;
15731
15732 if (cfg->line_outs == 1) {
15733 const char *pfx = NULL;
15734 if (!cfg->hp_outs)
15735 pfx = "Master";
15736 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15737 pfx = "Speaker";
15738 if (pfx) {
15739 nid = spec->multiout.dac_nids[0];
15740 return alc861_create_out_sw(codec, pfx, nid, 3);
15741 }
15742 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015743
15744 for (i = 0; i < cfg->line_outs; i++) {
15745 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015746 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015747 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015748 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015749 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015750 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015751 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015752 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015753 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015754 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015755 return err;
15756 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015757 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015758 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015759 return err;
15760 }
15761 }
15762 return 0;
15763}
15764
Takashi Iwai1c209302009-07-22 15:17:45 +020015765static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015766{
Takashi Iwai1c209302009-07-22 15:17:45 +020015767 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015768 int err;
15769 hda_nid_t nid;
15770
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015771 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015772 return 0;
15773
15774 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015775 nid = alc861_look_for_dac(codec, pin);
15776 if (nid) {
15777 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15778 if (err < 0)
15779 return err;
15780 spec->multiout.hp_nid = nid;
15781 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015782 }
15783 return 0;
15784}
15785
15786/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015787static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015788 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015789{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015790 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015791}
15792
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015793static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15794 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015795 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015796{
Takashi Iwai1c209302009-07-22 15:17:45 +020015797 hda_nid_t mix, srcs[5];
15798 int i, num;
15799
Jacek Luczak564c5be2008-05-03 18:41:23 +020015800 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15801 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015802 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015803 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015804 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15805 return;
15806 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15807 if (num < 0)
15808 return;
15809 for (i = 0; i < num; i++) {
15810 unsigned int mute;
15811 if (srcs[i] == dac || srcs[i] == 0x15)
15812 mute = AMP_IN_UNMUTE(i);
15813 else
15814 mute = AMP_IN_MUTE(i);
15815 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15816 mute);
15817 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015818}
15819
15820static void alc861_auto_init_multi_out(struct hda_codec *codec)
15821{
15822 struct alc_spec *spec = codec->spec;
15823 int i;
15824
15825 for (i = 0; i < spec->autocfg.line_outs; i++) {
15826 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015827 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015828 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015829 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015830 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015831 }
15832}
15833
15834static void alc861_auto_init_hp_out(struct hda_codec *codec)
15835{
15836 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015837
Takashi Iwai15870f02009-10-05 08:25:13 +020015838 if (spec->autocfg.hp_outs)
15839 alc861_auto_set_output_and_unmute(codec,
15840 spec->autocfg.hp_pins[0],
15841 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015842 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015843 if (spec->autocfg.speaker_outs)
15844 alc861_auto_set_output_and_unmute(codec,
15845 spec->autocfg.speaker_pins[0],
15846 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015847 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015848}
15849
15850static void alc861_auto_init_analog_input(struct hda_codec *codec)
15851{
15852 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015853 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010015854 int i;
15855
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015856 for (i = 0; i < cfg->num_inputs; i++) {
15857 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010015858 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020015859 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015860 }
15861}
15862
15863/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015864/* return 1 if successful, 0 if the proper config is not found,
15865 * or a negative error code
15866 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015867static int alc861_parse_auto_config(struct hda_codec *codec)
15868{
15869 struct alc_spec *spec = codec->spec;
15870 int err;
15871 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15872
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015873 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15874 alc861_ignore);
15875 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015876 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015877 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015878 return 0; /* can't find valid BIOS pin config */
15879
Takashi Iwai1c209302009-07-22 15:17:45 +020015880 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015881 if (err < 0)
15882 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015883 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015884 if (err < 0)
15885 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015886 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015887 if (err < 0)
15888 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015889 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015890 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015891 return err;
15892
15893 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15894
Takashi Iwai757899a2010-07-30 10:48:14 +020015895 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015896
Takashi Iwai603c4012008-07-30 15:01:44 +020015897 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015898 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015899
Takashi Iwaid88897e2008-10-31 15:01:37 +010015900 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015901
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015902 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015903 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015904
15905 spec->adc_nids = alc861_adc_nids;
15906 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015907 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015908
Kailang Yang6227cdc2010-02-25 08:36:52 +010015909 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015910
Kailang Yangdf694da2005-12-05 19:42:22 +010015911 return 1;
15912}
15913
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015914/* additional initialization for auto-configuration model */
15915static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015916{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015917 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015918 alc861_auto_init_multi_out(codec);
15919 alc861_auto_init_hp_out(codec);
15920 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020015921 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015922 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015923 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015924}
15925
Takashi Iwaicb53c622007-08-10 17:21:45 +020015926#ifdef CONFIG_SND_HDA_POWER_SAVE
15927static struct hda_amp_list alc861_loopbacks[] = {
15928 { 0x15, HDA_INPUT, 0 },
15929 { 0x15, HDA_INPUT, 1 },
15930 { 0x15, HDA_INPUT, 2 },
15931 { 0x15, HDA_INPUT, 3 },
15932 { } /* end */
15933};
15934#endif
15935
Kailang Yangdf694da2005-12-05 19:42:22 +010015936
15937/*
15938 * configuration and preset
15939 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015940static const char *alc861_models[ALC861_MODEL_LAST] = {
15941 [ALC861_3ST] = "3stack",
15942 [ALC660_3ST] = "3stack-660",
15943 [ALC861_3ST_DIG] = "3stack-dig",
15944 [ALC861_6ST_DIG] = "6stack-dig",
15945 [ALC861_UNIWILL_M31] = "uniwill-m31",
15946 [ALC861_TOSHIBA] = "toshiba",
15947 [ALC861_ASUS] = "asus",
15948 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15949 [ALC861_AUTO] = "auto",
15950};
15951
15952static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015953 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015954 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15955 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15956 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015957 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015958 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015959 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015960 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15961 * Any other models that need this preset?
15962 */
15963 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015964 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15965 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015966 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15967 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15968 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15969 /* FIXME: the below seems conflict */
15970 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15971 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15972 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015973 {}
15974};
15975
15976static struct alc_config_preset alc861_presets[] = {
15977 [ALC861_3ST] = {
15978 .mixers = { alc861_3ST_mixer },
15979 .init_verbs = { alc861_threestack_init_verbs },
15980 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15981 .dac_nids = alc861_dac_nids,
15982 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15983 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015984 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015985 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15986 .adc_nids = alc861_adc_nids,
15987 .input_mux = &alc861_capture_source,
15988 },
15989 [ALC861_3ST_DIG] = {
15990 .mixers = { alc861_base_mixer },
15991 .init_verbs = { alc861_threestack_init_verbs },
15992 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15993 .dac_nids = alc861_dac_nids,
15994 .dig_out_nid = ALC861_DIGOUT_NID,
15995 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15996 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015997 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015998 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15999 .adc_nids = alc861_adc_nids,
16000 .input_mux = &alc861_capture_source,
16001 },
16002 [ALC861_6ST_DIG] = {
16003 .mixers = { alc861_base_mixer },
16004 .init_verbs = { alc861_base_init_verbs },
16005 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16006 .dac_nids = alc861_dac_nids,
16007 .dig_out_nid = ALC861_DIGOUT_NID,
16008 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16009 .channel_mode = alc861_8ch_modes,
16010 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16011 .adc_nids = alc861_adc_nids,
16012 .input_mux = &alc861_capture_source,
16013 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016014 [ALC660_3ST] = {
16015 .mixers = { alc861_3ST_mixer },
16016 .init_verbs = { alc861_threestack_init_verbs },
16017 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16018 .dac_nids = alc660_dac_nids,
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,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016022 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16023 .adc_nids = alc861_adc_nids,
16024 .input_mux = &alc861_capture_source,
16025 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016026 [ALC861_UNIWILL_M31] = {
16027 .mixers = { alc861_uniwill_m31_mixer },
16028 .init_verbs = { alc861_uniwill_m31_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_uniwill_m31_modes),
16033 .channel_mode = alc861_uniwill_m31_modes,
16034 .need_dac_fix = 1,
16035 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16036 .adc_nids = alc861_adc_nids,
16037 .input_mux = &alc861_capture_source,
16038 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016039 [ALC861_TOSHIBA] = {
16040 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016041 .init_verbs = { alc861_base_init_verbs,
16042 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016043 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16044 .dac_nids = alc861_dac_nids,
16045 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16046 .channel_mode = alc883_3ST_2ch_modes,
16047 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16048 .adc_nids = alc861_adc_nids,
16049 .input_mux = &alc861_capture_source,
16050 .unsol_event = alc861_toshiba_unsol_event,
16051 .init_hook = alc861_toshiba_automute,
16052 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016053 [ALC861_ASUS] = {
16054 .mixers = { alc861_asus_mixer },
16055 .init_verbs = { alc861_asus_init_verbs },
16056 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16057 .dac_nids = alc861_dac_nids,
16058 .dig_out_nid = ALC861_DIGOUT_NID,
16059 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16060 .channel_mode = alc861_asus_modes,
16061 .need_dac_fix = 1,
16062 .hp_nid = 0x06,
16063 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16064 .adc_nids = alc861_adc_nids,
16065 .input_mux = &alc861_capture_source,
16066 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016067 [ALC861_ASUS_LAPTOP] = {
16068 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16069 .init_verbs = { alc861_asus_init_verbs,
16070 alc861_asus_laptop_init_verbs },
16071 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16072 .dac_nids = alc861_dac_nids,
16073 .dig_out_nid = ALC861_DIGOUT_NID,
16074 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16075 .channel_mode = alc883_3ST_2ch_modes,
16076 .need_dac_fix = 1,
16077 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16078 .adc_nids = alc861_adc_nids,
16079 .input_mux = &alc861_capture_source,
16080 },
16081};
Kailang Yangdf694da2005-12-05 19:42:22 +010016082
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016083/* Pin config fixes */
16084enum {
16085 PINFIX_FSC_AMILO_PI1505,
16086};
16087
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016088static const struct alc_fixup alc861_fixups[] = {
16089 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016090 .pins = (const struct alc_pincfg[]) {
16091 { 0x0b, 0x0221101f }, /* HP */
16092 { 0x0f, 0x90170310 }, /* speaker */
16093 { }
16094 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016095 },
16096};
16097
16098static struct snd_pci_quirk alc861_fixup_tbl[] = {
16099 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16100 {}
16101};
Kailang Yangdf694da2005-12-05 19:42:22 +010016102
16103static int patch_alc861(struct hda_codec *codec)
16104{
16105 struct alc_spec *spec;
16106 int board_config;
16107 int err;
16108
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016109 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016110 if (spec == NULL)
16111 return -ENOMEM;
16112
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016113 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016114
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016115 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16116 alc861_models,
16117 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016118
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016119 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016120 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16121 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016122 board_config = ALC861_AUTO;
16123 }
16124
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016125 if (board_config == ALC861_AUTO)
16126 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016127
Kailang Yangdf694da2005-12-05 19:42:22 +010016128 if (board_config == ALC861_AUTO) {
16129 /* automatic parse from the BIOS config */
16130 err = alc861_parse_auto_config(codec);
16131 if (err < 0) {
16132 alc_free(codec);
16133 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016134 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016135 printk(KERN_INFO
16136 "hda_codec: Cannot set up configuration "
16137 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016138 board_config = ALC861_3ST_DIG;
16139 }
16140 }
16141
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016142 err = snd_hda_attach_beep_device(codec, 0x23);
16143 if (err < 0) {
16144 alc_free(codec);
16145 return err;
16146 }
16147
Kailang Yangdf694da2005-12-05 19:42:22 +010016148 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016149 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016150
Kailang Yangdf694da2005-12-05 19:42:22 +010016151 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16152 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16153
Kailang Yangdf694da2005-12-05 19:42:22 +010016154 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16155 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16156
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016157 if (!spec->cap_mixer)
16158 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016159 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16160
Takashi Iwai2134ea42008-01-10 16:53:55 +010016161 spec->vmaster_nid = 0x03;
16162
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016163 if (board_config == ALC861_AUTO)
16164 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
16165
Kailang Yangdf694da2005-12-05 19:42:22 +010016166 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016167 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016168 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016169#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016170 spec->power_hook = alc_power_eapd;
16171#endif
16172 }
16173#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016174 if (!spec->loopback.amplist)
16175 spec->loopback.amplist = alc861_loopbacks;
16176#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016177
Kailang Yangdf694da2005-12-05 19:42:22 +010016178 return 0;
16179}
16180
16181/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016182 * ALC861-VD support
16183 *
16184 * Based on ALC882
16185 *
16186 * In addition, an independent DAC
16187 */
16188#define ALC861VD_DIGOUT_NID 0x06
16189
16190static hda_nid_t alc861vd_dac_nids[4] = {
16191 /* front, surr, clfe, side surr */
16192 0x02, 0x03, 0x04, 0x05
16193};
16194
16195/* dac_nids for ALC660vd are in a different order - according to
16196 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016197 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016198 * of ALC660vd codecs, but for now there is only 3stack mixer
16199 * - and it is the same as in 861vd.
16200 * adc_nids in ALC660vd are (is) the same as in 861vd
16201 */
16202static hda_nid_t alc660vd_dac_nids[3] = {
16203 /* front, rear, clfe, rear_surr */
16204 0x02, 0x04, 0x03
16205};
16206
16207static hda_nid_t alc861vd_adc_nids[1] = {
16208 /* ADC0 */
16209 0x09,
16210};
16211
Takashi Iwaie1406342008-02-11 18:32:32 +010016212static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16213
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016214/* input MUX */
16215/* FIXME: should be a matrix-type input source selection */
16216static struct hda_input_mux alc861vd_capture_source = {
16217 .num_items = 4,
16218 .items = {
16219 { "Mic", 0x0 },
16220 { "Front Mic", 0x1 },
16221 { "Line", 0x2 },
16222 { "CD", 0x4 },
16223 },
16224};
16225
Kailang Yang272a5272007-05-14 11:00:38 +020016226static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016227 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016228 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010016229 { "Ext Mic", 0x0 },
16230 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016231 },
16232};
16233
Kailang Yangd1a991a2007-08-15 16:21:59 +020016234static struct hda_input_mux alc861vd_hp_capture_source = {
16235 .num_items = 2,
16236 .items = {
16237 { "Front Mic", 0x0 },
16238 { "ATAPI Mic", 0x1 },
16239 },
16240};
16241
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016242/*
16243 * 2ch mode
16244 */
16245static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16246 { 2, NULL }
16247};
16248
16249/*
16250 * 6ch mode
16251 */
16252static struct hda_verb alc861vd_6stack_ch6_init[] = {
16253 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16254 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16255 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16256 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16257 { } /* end */
16258};
16259
16260/*
16261 * 8ch mode
16262 */
16263static struct hda_verb alc861vd_6stack_ch8_init[] = {
16264 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16265 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16266 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16267 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16268 { } /* end */
16269};
16270
16271static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16272 { 6, alc861vd_6stack_ch6_init },
16273 { 8, alc861vd_6stack_ch8_init },
16274};
16275
16276static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16277 {
16278 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16279 .name = "Channel Mode",
16280 .info = alc_ch_mode_info,
16281 .get = alc_ch_mode_get,
16282 .put = alc_ch_mode_put,
16283 },
16284 { } /* end */
16285};
16286
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016287/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16288 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16289 */
16290static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16291 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16292 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16293
16294 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16295 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16296
16297 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16298 HDA_OUTPUT),
16299 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16300 HDA_OUTPUT),
16301 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16302 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16303
16304 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16305 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16306
16307 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16308
16309 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16310 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16311 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16312
16313 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16314 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16315 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16316
16317 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16318 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16319
16320 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16321 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16322
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016323 { } /* end */
16324};
16325
16326static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16327 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16328 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16329
16330 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16331
16332 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16333 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16334 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16335
16336 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16339
16340 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16341 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16342
16343 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16344 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16345
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016346 { } /* end */
16347};
16348
Kailang Yangbdd148a2007-05-08 15:19:08 +020016349static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16350 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16351 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16352 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
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("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16365 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16366
16367 { } /* end */
16368};
16369
Tobin Davisb419f342008-03-07 11:57:51 +010016370/* Pin assignment: Speaker=0x14, HP = 0x15,
16371 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016372 */
16373static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016374 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16375 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016376 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16377 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016378 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16379 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16380 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16381 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16382 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16383 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016384 { } /* end */
16385};
16386
Kailang Yangd1a991a2007-08-15 16:21:59 +020016387/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16388 * Front Mic=0x18, ATAPI Mic = 0x19,
16389 */
16390static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16391 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16392 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16393 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16394 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16395 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16396 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16397 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16398 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016399
Kailang Yangd1a991a2007-08-15 16:21:59 +020016400 { } /* end */
16401};
16402
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016403/*
16404 * generic initialization of ADC, input mixers and output mixers
16405 */
16406static struct hda_verb alc861vd_volume_init_verbs[] = {
16407 /*
16408 * Unmute ADC0 and set the default input to mic-in
16409 */
16410 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16411 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16412
16413 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16414 * the analog-loopback mixer widget
16415 */
16416 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016417 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16418 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16419 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16420 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16421 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016422
16423 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016424 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16425 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16426 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016427 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016428
16429 /*
16430 * Set up output mixers (0x02 - 0x05)
16431 */
16432 /* set vol=0 to output mixers */
16433 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16434 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16435 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16436 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16437
16438 /* set up input amps for analog loopback */
16439 /* Amp Indices: DAC = 0, mixer = 1 */
16440 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16441 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16442 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16443 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16444 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16445 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16446 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16447 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16448
16449 { }
16450};
16451
16452/*
16453 * 3-stack pin configuration:
16454 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16455 */
16456static struct hda_verb alc861vd_3stack_init_verbs[] = {
16457 /*
16458 * Set pin mode and muting
16459 */
16460 /* set front pin widgets 0x14 for output */
16461 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16462 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16463 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16464
16465 /* Mic (rear) pin: input vref at 80% */
16466 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16467 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16468 /* Front Mic pin: input vref at 80% */
16469 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16470 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16471 /* Line In pin: input */
16472 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16473 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16474 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16475 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16476 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16477 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16478 /* CD pin widget for input */
16479 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16480
16481 { }
16482};
16483
16484/*
16485 * 6-stack pin configuration:
16486 */
16487static struct hda_verb alc861vd_6stack_init_verbs[] = {
16488 /*
16489 * Set pin mode and muting
16490 */
16491 /* set front pin widgets 0x14 for output */
16492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16494 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16495
16496 /* Rear Pin: output 1 (0x0d) */
16497 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16499 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16500 /* CLFE Pin: output 2 (0x0e) */
16501 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16502 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16503 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16504 /* Side Pin: output 3 (0x0f) */
16505 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16506 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16507 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16508
16509 /* Mic (rear) pin: input vref at 80% */
16510 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16511 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16512 /* Front Mic pin: input vref at 80% */
16513 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16514 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16515 /* Line In pin: input */
16516 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16517 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16518 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16519 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16520 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16521 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16522 /* CD pin widget for input */
16523 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16524
16525 { }
16526};
16527
Kailang Yangbdd148a2007-05-08 15:19:08 +020016528static struct hda_verb alc861vd_eapd_verbs[] = {
16529 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16530 { }
16531};
16532
Kailang Yangf9423e72008-05-27 12:32:25 +020016533static struct hda_verb alc660vd_eapd_verbs[] = {
16534 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16535 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16536 { }
16537};
16538
Kailang Yangbdd148a2007-05-08 15:19:08 +020016539static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16540 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16541 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16542 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16543 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016544 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016545 {}
16546};
16547
Kailang Yangbdd148a2007-05-08 15:19:08 +020016548static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16549{
16550 unsigned int present;
16551 unsigned char bits;
16552
Wu Fengguang864f92b2009-11-18 12:38:02 +080016553 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016554 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016555
Takashi Iwai47fd8302007-08-10 17:11:07 +020016556 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16557 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016558}
16559
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016560static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016561{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016562 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016563 spec->autocfg.hp_pins[0] = 0x1b;
16564 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016565}
16566
16567static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16568{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016569 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016570 alc861vd_lenovo_mic_automute(codec);
16571}
16572
16573static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16574 unsigned int res)
16575{
16576 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016577 case ALC880_MIC_EVENT:
16578 alc861vd_lenovo_mic_automute(codec);
16579 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016580 default:
16581 alc_automute_amp_unsol_event(codec, res);
16582 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016583 }
16584}
16585
Kailang Yang272a5272007-05-14 11:00:38 +020016586static struct hda_verb alc861vd_dallas_verbs[] = {
16587 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16588 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16589 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16590 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16591
16592 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16593 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16594 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16595 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16596 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16597 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16598 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16599 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016600
Kailang Yang272a5272007-05-14 11:00:38 +020016601 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16602 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16603 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16604 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16605 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16606 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16607 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16608 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16609
16610 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16611 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16612 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16613 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16614 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16615 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16616 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16617 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16618
16619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16620 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16621 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16622 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16623
16624 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016625 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016626 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16627
16628 { } /* end */
16629};
16630
16631/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016632static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016633{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016634 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016635
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016636 spec->autocfg.hp_pins[0] = 0x15;
16637 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016638}
16639
Takashi Iwaicb53c622007-08-10 17:21:45 +020016640#ifdef CONFIG_SND_HDA_POWER_SAVE
16641#define alc861vd_loopbacks alc880_loopbacks
16642#endif
16643
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016644/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016645#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16646#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16647#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16648#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16649
16650/*
16651 * configuration and preset
16652 */
16653static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16654 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016655 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016656 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016657 [ALC861VD_3ST] = "3stack",
16658 [ALC861VD_3ST_DIG] = "3stack-digout",
16659 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016660 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016661 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016662 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016663 [ALC861VD_AUTO] = "auto",
16664};
16665
16666static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016667 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16668 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016669 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016670 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016671 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016672 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016673 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016674 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016675 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016676 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016677 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016678 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016679 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016680 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016681 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016682 {}
16683};
16684
16685static struct alc_config_preset alc861vd_presets[] = {
16686 [ALC660VD_3ST] = {
16687 .mixers = { alc861vd_3st_mixer },
16688 .init_verbs = { alc861vd_volume_init_verbs,
16689 alc861vd_3stack_init_verbs },
16690 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16691 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016692 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16693 .channel_mode = alc861vd_3stack_2ch_modes,
16694 .input_mux = &alc861vd_capture_source,
16695 },
Mike Crash6963f842007-06-25 12:12:51 +020016696 [ALC660VD_3ST_DIG] = {
16697 .mixers = { alc861vd_3st_mixer },
16698 .init_verbs = { alc861vd_volume_init_verbs,
16699 alc861vd_3stack_init_verbs },
16700 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16701 .dac_nids = alc660vd_dac_nids,
16702 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016703 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16704 .channel_mode = alc861vd_3stack_2ch_modes,
16705 .input_mux = &alc861vd_capture_source,
16706 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016707 [ALC861VD_3ST] = {
16708 .mixers = { alc861vd_3st_mixer },
16709 .init_verbs = { alc861vd_volume_init_verbs,
16710 alc861vd_3stack_init_verbs },
16711 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16712 .dac_nids = alc861vd_dac_nids,
16713 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16714 .channel_mode = alc861vd_3stack_2ch_modes,
16715 .input_mux = &alc861vd_capture_source,
16716 },
16717 [ALC861VD_3ST_DIG] = {
16718 .mixers = { alc861vd_3st_mixer },
16719 .init_verbs = { alc861vd_volume_init_verbs,
16720 alc861vd_3stack_init_verbs },
16721 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16722 .dac_nids = alc861vd_dac_nids,
16723 .dig_out_nid = ALC861VD_DIGOUT_NID,
16724 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16725 .channel_mode = alc861vd_3stack_2ch_modes,
16726 .input_mux = &alc861vd_capture_source,
16727 },
16728 [ALC861VD_6ST_DIG] = {
16729 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16730 .init_verbs = { alc861vd_volume_init_verbs,
16731 alc861vd_6stack_init_verbs },
16732 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16733 .dac_nids = alc861vd_dac_nids,
16734 .dig_out_nid = ALC861VD_DIGOUT_NID,
16735 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16736 .channel_mode = alc861vd_6stack_modes,
16737 .input_mux = &alc861vd_capture_source,
16738 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016739 [ALC861VD_LENOVO] = {
16740 .mixers = { alc861vd_lenovo_mixer },
16741 .init_verbs = { alc861vd_volume_init_verbs,
16742 alc861vd_3stack_init_verbs,
16743 alc861vd_eapd_verbs,
16744 alc861vd_lenovo_unsol_verbs },
16745 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16746 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016747 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16748 .channel_mode = alc861vd_3stack_2ch_modes,
16749 .input_mux = &alc861vd_capture_source,
16750 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016751 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016752 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016753 },
Kailang Yang272a5272007-05-14 11:00:38 +020016754 [ALC861VD_DALLAS] = {
16755 .mixers = { alc861vd_dallas_mixer },
16756 .init_verbs = { alc861vd_dallas_verbs },
16757 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16758 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016759 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16760 .channel_mode = alc861vd_3stack_2ch_modes,
16761 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016762 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016763 .setup = alc861vd_dallas_setup,
16764 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016765 },
16766 [ALC861VD_HP] = {
16767 .mixers = { alc861vd_hp_mixer },
16768 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16769 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16770 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016771 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016772 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16773 .channel_mode = alc861vd_3stack_2ch_modes,
16774 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016775 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016776 .setup = alc861vd_dallas_setup,
16777 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016778 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016779 [ALC660VD_ASUS_V1S] = {
16780 .mixers = { alc861vd_lenovo_mixer },
16781 .init_verbs = { alc861vd_volume_init_verbs,
16782 alc861vd_3stack_init_verbs,
16783 alc861vd_eapd_verbs,
16784 alc861vd_lenovo_unsol_verbs },
16785 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16786 .dac_nids = alc660vd_dac_nids,
16787 .dig_out_nid = ALC861VD_DIGOUT_NID,
16788 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16789 .channel_mode = alc861vd_3stack_2ch_modes,
16790 .input_mux = &alc861vd_capture_source,
16791 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016792 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016793 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016794 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016795};
16796
16797/*
16798 * BIOS auto configuration
16799 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016800static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16801 const struct auto_pin_cfg *cfg)
16802{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016803 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016804}
16805
16806
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016807static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16808 hda_nid_t nid, int pin_type, int dac_idx)
16809{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016810 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016811}
16812
16813static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16814{
16815 struct alc_spec *spec = codec->spec;
16816 int i;
16817
16818 for (i = 0; i <= HDA_SIDE; i++) {
16819 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016820 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016821 if (nid)
16822 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016823 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016824 }
16825}
16826
16827
16828static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16829{
16830 struct alc_spec *spec = codec->spec;
16831 hda_nid_t pin;
16832
16833 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016834 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016835 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016836 pin = spec->autocfg.speaker_pins[0];
16837 if (pin)
16838 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016839}
16840
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016841#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16842
16843static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16844{
16845 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016846 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016847 int i;
16848
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016849 for (i = 0; i < cfg->num_inputs; i++) {
16850 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016851 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020016852 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016853 if (nid != ALC861VD_PIN_CD_NID &&
16854 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016855 snd_hda_codec_write(codec, nid, 0,
16856 AC_VERB_SET_AMP_GAIN_MUTE,
16857 AMP_OUT_MUTE);
16858 }
16859 }
16860}
16861
Takashi Iwaif511b012008-08-15 16:46:42 +020016862#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16863
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016864#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16865#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16866
16867/* add playback controls from the parsed DAC table */
16868/* Based on ALC880 version. But ALC861VD has separate,
16869 * different NIDs for mute/unmute switch and volume control */
16870static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16871 const struct auto_pin_cfg *cfg)
16872{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016873 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16874 hda_nid_t nid_v, nid_s;
16875 int i, err;
16876
16877 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016878 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016879 continue;
16880 nid_v = alc861vd_idx_to_mixer_vol(
16881 alc880_dac_to_idx(
16882 spec->multiout.dac_nids[i]));
16883 nid_s = alc861vd_idx_to_mixer_switch(
16884 alc880_dac_to_idx(
16885 spec->multiout.dac_nids[i]));
16886
16887 if (i == 2) {
16888 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016889 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16890 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016891 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16892 HDA_OUTPUT));
16893 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016894 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016895 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16896 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016897 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16898 HDA_OUTPUT));
16899 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016900 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016901 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16902 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016903 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16904 HDA_INPUT));
16905 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016906 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016907 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16908 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016909 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16910 HDA_INPUT));
16911 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016912 return err;
16913 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016914 const char *pfx;
16915 if (cfg->line_outs == 1 &&
16916 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16917 if (!cfg->hp_pins)
16918 pfx = "Speaker";
16919 else
16920 pfx = "PCM";
16921 } else
16922 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016923 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016924 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16925 HDA_OUTPUT));
16926 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016927 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016928 if (cfg->line_outs == 1 &&
16929 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16930 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016931 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016932 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016933 HDA_INPUT));
16934 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016935 return err;
16936 }
16937 }
16938 return 0;
16939}
16940
16941/* add playback controls for speaker and HP outputs */
16942/* Based on ALC880 version. But ALC861VD has separate,
16943 * different NIDs for mute/unmute switch and volume control */
16944static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16945 hda_nid_t pin, const char *pfx)
16946{
16947 hda_nid_t nid_v, nid_s;
16948 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016949
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016950 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016951 return 0;
16952
16953 if (alc880_is_fixed_pin(pin)) {
16954 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16955 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016956 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016957 spec->multiout.hp_nid = nid_v;
16958 else
16959 spec->multiout.extra_out_nid[0] = nid_v;
16960 /* control HP volume/switch on the output mixer amp */
16961 nid_v = alc861vd_idx_to_mixer_vol(
16962 alc880_fixed_pin_idx(pin));
16963 nid_s = alc861vd_idx_to_mixer_switch(
16964 alc880_fixed_pin_idx(pin));
16965
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016966 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016967 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16968 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016969 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016970 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016971 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16972 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016973 return err;
16974 } else if (alc880_is_multi_pin(pin)) {
16975 /* set manual connection */
16976 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016977 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016978 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16979 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016980 return err;
16981 }
16982 return 0;
16983}
16984
16985/* parse the BIOS configuration and set up the alc_spec
16986 * return 1 if successful, 0 if the proper config is not found,
16987 * or a negative error code
16988 * Based on ALC880 version - had to change it to override
16989 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16990static int alc861vd_parse_auto_config(struct hda_codec *codec)
16991{
16992 struct alc_spec *spec = codec->spec;
16993 int err;
16994 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16995
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016996 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16997 alc861vd_ignore);
16998 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016999 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017000 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017001 return 0; /* can't find valid BIOS pin config */
17002
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017003 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17004 if (err < 0)
17005 return err;
17006 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17007 if (err < 0)
17008 return err;
17009 err = alc861vd_auto_create_extra_out(spec,
17010 spec->autocfg.speaker_pins[0],
17011 "Speaker");
17012 if (err < 0)
17013 return err;
17014 err = alc861vd_auto_create_extra_out(spec,
17015 spec->autocfg.hp_pins[0],
17016 "Headphone");
17017 if (err < 0)
17018 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017019 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017020 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017021 return err;
17022
17023 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17024
Takashi Iwai757899a2010-07-30 10:48:14 +020017025 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017026
Takashi Iwai603c4012008-07-30 15:01:44 +020017027 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017028 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017029
Takashi Iwaid88897e2008-10-31 15:01:37 +010017030 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017031
17032 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017033 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017034
Takashi Iwai776e1842007-08-29 15:07:11 +020017035 err = alc_auto_add_mic_boost(codec);
17036 if (err < 0)
17037 return err;
17038
Kailang Yang6227cdc2010-02-25 08:36:52 +010017039 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017040
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017041 return 1;
17042}
17043
17044/* additional initialization for auto-configuration model */
17045static void alc861vd_auto_init(struct hda_codec *codec)
17046{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017047 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017048 alc861vd_auto_init_multi_out(codec);
17049 alc861vd_auto_init_hp_out(codec);
17050 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017051 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017052 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017053 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017054 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017055}
17056
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017057enum {
17058 ALC660VD_FIX_ASUS_GPIO1
17059};
17060
17061/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017062static const struct alc_fixup alc861vd_fixups[] = {
17063 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020017064 .verbs = (const struct hda_verb[]) {
17065 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17066 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17067 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17068 { }
17069 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017070 },
17071};
17072
17073static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17074 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17075 {}
17076};
17077
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017078static int patch_alc861vd(struct hda_codec *codec)
17079{
17080 struct alc_spec *spec;
17081 int err, board_config;
17082
17083 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17084 if (spec == NULL)
17085 return -ENOMEM;
17086
17087 codec->spec = spec;
17088
17089 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17090 alc861vd_models,
17091 alc861vd_cfg_tbl);
17092
17093 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017094 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17095 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017096 board_config = ALC861VD_AUTO;
17097 }
17098
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017099 if (board_config == ALC861VD_AUTO)
17100 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017101
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017102 if (board_config == ALC861VD_AUTO) {
17103 /* automatic parse from the BIOS config */
17104 err = alc861vd_parse_auto_config(codec);
17105 if (err < 0) {
17106 alc_free(codec);
17107 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017108 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017109 printk(KERN_INFO
17110 "hda_codec: Cannot set up configuration "
17111 "from BIOS. Using base mode...\n");
17112 board_config = ALC861VD_3ST;
17113 }
17114 }
17115
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017116 err = snd_hda_attach_beep_device(codec, 0x23);
17117 if (err < 0) {
17118 alc_free(codec);
17119 return err;
17120 }
17121
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017122 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017123 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017124
Kailang Yang2f893282008-05-27 12:14:47 +020017125 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017126 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017127 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017128 }
17129
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017130 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17131 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17132
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017133 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17134 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17135
Takashi Iwaidd704692009-08-11 08:45:11 +020017136 if (!spec->adc_nids) {
17137 spec->adc_nids = alc861vd_adc_nids;
17138 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17139 }
17140 if (!spec->capsrc_nids)
17141 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017142
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017143 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017144 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017145
Takashi Iwai2134ea42008-01-10 16:53:55 +010017146 spec->vmaster_nid = 0x02;
17147
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017148 if (board_config == ALC861VD_AUTO)
17149 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
17150
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017151 codec->patch_ops = alc_patch_ops;
17152
17153 if (board_config == ALC861VD_AUTO)
17154 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017155#ifdef CONFIG_SND_HDA_POWER_SAVE
17156 if (!spec->loopback.amplist)
17157 spec->loopback.amplist = alc861vd_loopbacks;
17158#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017159
17160 return 0;
17161}
17162
17163/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017164 * ALC662 support
17165 *
17166 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17167 * configuration. Each pin widget can choose any input DACs and a mixer.
17168 * Each ADC is connected from a mixer of all inputs. This makes possible
17169 * 6-channel independent captures.
17170 *
17171 * In addition, an independent DAC for the multi-playback (not used in this
17172 * driver yet).
17173 */
17174#define ALC662_DIGOUT_NID 0x06
17175#define ALC662_DIGIN_NID 0x0a
17176
17177static hda_nid_t alc662_dac_nids[4] = {
17178 /* front, rear, clfe, rear_surr */
17179 0x02, 0x03, 0x04
17180};
17181
Kailang Yang622e84c2009-04-21 07:39:04 +020017182static hda_nid_t alc272_dac_nids[2] = {
17183 0x02, 0x03
17184};
17185
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017186static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017187 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017188 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017189};
Takashi Iwaie1406342008-02-11 18:32:32 +010017190
Kailang Yang622e84c2009-04-21 07:39:04 +020017191static hda_nid_t alc272_adc_nids[1] = {
17192 /* ADC1-2 */
17193 0x08,
17194};
17195
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017196static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017197static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17198
Takashi Iwaie1406342008-02-11 18:32:32 +010017199
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017200/* input MUX */
17201/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017202static struct hda_input_mux alc662_capture_source = {
17203 .num_items = 4,
17204 .items = {
17205 { "Mic", 0x0 },
17206 { "Front Mic", 0x1 },
17207 { "Line", 0x2 },
17208 { "CD", 0x4 },
17209 },
17210};
17211
17212static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17213 .num_items = 2,
17214 .items = {
17215 { "Mic", 0x1 },
17216 { "Line", 0x2 },
17217 },
17218};
Kailang Yang291702f2007-10-16 14:28:03 +020017219
Kailang Yang6dda9f42008-05-27 12:05:31 +020017220static struct hda_input_mux alc663_capture_source = {
17221 .num_items = 3,
17222 .items = {
17223 { "Mic", 0x0 },
17224 { "Front Mic", 0x1 },
17225 { "Line", 0x2 },
17226 },
17227};
17228
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017229#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017230static struct hda_input_mux alc272_nc10_capture_source = {
17231 .num_items = 16,
17232 .items = {
17233 { "Autoselect Mic", 0x0 },
17234 { "Internal Mic", 0x1 },
17235 { "In-0x02", 0x2 },
17236 { "In-0x03", 0x3 },
17237 { "In-0x04", 0x4 },
17238 { "In-0x05", 0x5 },
17239 { "In-0x06", 0x6 },
17240 { "In-0x07", 0x7 },
17241 { "In-0x08", 0x8 },
17242 { "In-0x09", 0x9 },
17243 { "In-0x0a", 0x0a },
17244 { "In-0x0b", 0x0b },
17245 { "In-0x0c", 0x0c },
17246 { "In-0x0d", 0x0d },
17247 { "In-0x0e", 0x0e },
17248 { "In-0x0f", 0x0f },
17249 },
17250};
17251#endif
17252
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017253/*
17254 * 2ch mode
17255 */
17256static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17257 { 2, NULL }
17258};
17259
17260/*
17261 * 2ch mode
17262 */
17263static struct hda_verb alc662_3ST_ch2_init[] = {
17264 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17265 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17266 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17267 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17268 { } /* end */
17269};
17270
17271/*
17272 * 6ch mode
17273 */
17274static struct hda_verb alc662_3ST_ch6_init[] = {
17275 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17276 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17277 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17278 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17279 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17280 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17281 { } /* end */
17282};
17283
17284static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17285 { 2, alc662_3ST_ch2_init },
17286 { 6, alc662_3ST_ch6_init },
17287};
17288
17289/*
17290 * 2ch mode
17291 */
17292static struct hda_verb alc662_sixstack_ch6_init[] = {
17293 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17294 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17295 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17296 { } /* end */
17297};
17298
17299/*
17300 * 6ch mode
17301 */
17302static struct hda_verb alc662_sixstack_ch8_init[] = {
17303 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17304 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17305 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17306 { } /* end */
17307};
17308
17309static struct hda_channel_mode alc662_5stack_modes[2] = {
17310 { 2, alc662_sixstack_ch6_init },
17311 { 6, alc662_sixstack_ch8_init },
17312};
17313
17314/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17315 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17316 */
17317
17318static struct snd_kcontrol_new alc662_base_mixer[] = {
17319 /* output mixer control */
17320 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017321 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017322 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017323 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017324 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17325 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017326 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17327 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017328 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17329
17330 /*Input mixer control */
17331 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17332 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17333 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17334 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17335 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17336 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17337 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17338 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017339 { } /* end */
17340};
17341
17342static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17343 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017344 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017345 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17346 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17347 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17348 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17349 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17351 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17352 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17353 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017354 { } /* end */
17355};
17356
17357static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17358 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017359 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017360 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017361 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017362 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17363 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017364 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17365 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017366 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17367 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17368 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17369 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17370 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17371 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17372 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17373 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17374 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017375 { } /* end */
17376};
17377
17378static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17379 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17380 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017381 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17382 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017383 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17384 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17385 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17386 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17387 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017388 { } /* end */
17389};
17390
Kailang Yang291702f2007-10-16 14:28:03 +020017391static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017392 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17393 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017394
17395 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17396 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17397 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17398
17399 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17400 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17401 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17402 { } /* end */
17403};
17404
Kailang Yang8c427222008-01-10 13:03:59 +010017405static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017406 ALC262_HIPPO_MASTER_SWITCH,
17407 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017408 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017409 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17410 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017411 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17412 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17413 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17414 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17415 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17416 { } /* end */
17417};
17418
Kailang Yangf1d4e282008-08-26 14:03:29 +020017419static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17420 .ops = &snd_hda_bind_vol,
17421 .values = {
17422 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17423 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17424 0
17425 },
17426};
17427
17428static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17429 .ops = &snd_hda_bind_sw,
17430 .values = {
17431 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17432 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17433 0
17434 },
17435};
17436
Kailang Yang6dda9f42008-05-27 12:05:31 +020017437static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017438 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17439 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17440 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17441 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17442 { } /* end */
17443};
17444
17445static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17446 .ops = &snd_hda_bind_sw,
17447 .values = {
17448 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17449 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17450 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17451 0
17452 },
17453};
17454
17455static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17456 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17457 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17458 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17459 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17460 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17461 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17462
17463 { } /* end */
17464};
17465
17466static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17467 .ops = &snd_hda_bind_sw,
17468 .values = {
17469 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17470 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17471 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17472 0
17473 },
17474};
17475
17476static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17477 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17478 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17479 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17480 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17481 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17482 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17483 { } /* end */
17484};
17485
17486static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017487 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17488 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017489 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17490 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17491 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17492 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17493 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17494 { } /* end */
17495};
17496
17497static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17498 .ops = &snd_hda_bind_vol,
17499 .values = {
17500 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17501 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17502 0
17503 },
17504};
17505
17506static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17507 .ops = &snd_hda_bind_sw,
17508 .values = {
17509 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17510 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17511 0
17512 },
17513};
17514
17515static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17516 HDA_BIND_VOL("Master Playback Volume",
17517 &alc663_asus_two_bind_master_vol),
17518 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017520 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17521 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17522 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017523 { } /* end */
17524};
17525
17526static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17527 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17528 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17529 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17530 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17531 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17532 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017533 { } /* end */
17534};
17535
17536static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17537 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17538 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17539 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17540 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17541 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17542
17543 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17544 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17545 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17546 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17547 { } /* end */
17548};
17549
17550static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17551 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17552 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17553 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17554
17555 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17556 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17557 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17558 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17559 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17560 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17561 { } /* end */
17562};
17563
Kailang Yangebb83ee2009-12-17 12:23:00 +010017564static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17565 .ops = &snd_hda_bind_sw,
17566 .values = {
17567 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17568 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17569 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17570 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17571 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17572 0
17573 },
17574};
17575
17576static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17577 .ops = &snd_hda_bind_sw,
17578 .values = {
17579 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17580 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17581 0
17582 },
17583};
17584
17585static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17586 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17587 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17588 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17589 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17590 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17591 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17592 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17593 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17594 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17595 { } /* end */
17596};
17597
17598static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17599 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17600 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17601 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17602 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17603 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17604 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17605 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17606 { } /* end */
17607};
17608
17609
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017610static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17611 {
17612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17613 .name = "Channel Mode",
17614 .info = alc_ch_mode_info,
17615 .get = alc_ch_mode_get,
17616 .put = alc_ch_mode_put,
17617 },
17618 { } /* end */
17619};
17620
17621static struct hda_verb alc662_init_verbs[] = {
17622 /* ADC: mute amp left and right */
17623 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17624 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017625
Kailang Yangb60dd392007-09-20 12:50:29 +020017626 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17628 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17629 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17630 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17631 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017632
17633 /* Front Pin: output 0 (0x0c) */
17634 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17635 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17636
17637 /* Rear Pin: output 1 (0x0d) */
17638 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17639 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17640
17641 /* CLFE Pin: output 2 (0x0e) */
17642 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17643 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17644
17645 /* Mic (rear) pin: input vref at 80% */
17646 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17647 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17648 /* Front Mic pin: input vref at 80% */
17649 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17650 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17651 /* Line In pin: input */
17652 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17653 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17654 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17655 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17656 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17657 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17658 /* CD pin widget for input */
17659 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17660
17661 /* FIXME: use matrix-type input source selection */
17662 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17663 /* Input mixer */
17664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017666
17667 /* always trun on EAPD */
17668 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17669 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17670
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017671 { }
17672};
17673
Kailang Yangcec27c82010-02-04 14:18:18 +010017674static struct hda_verb alc663_init_verbs[] = {
17675 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17676 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17677 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17678 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17679 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17680 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17681 { }
17682};
17683
17684static struct hda_verb alc272_init_verbs[] = {
17685 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17686 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17687 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17688 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17689 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17690 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17691 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17692 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17693 { }
17694};
17695
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017696static struct hda_verb alc662_sue_init_verbs[] = {
17697 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17698 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017699 {}
17700};
17701
17702static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17703 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17704 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17705 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017706};
17707
Kailang Yang8c427222008-01-10 13:03:59 +010017708/* Set Unsolicited Event*/
17709static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17710 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17711 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17712 {}
17713};
17714
Kailang Yang6dda9f42008-05-27 12:05:31 +020017715static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017716 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17717 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017718 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17719 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017720 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17721 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17722 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017723 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17724 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17725 {}
17726};
17727
Kailang Yangf1d4e282008-08-26 14:03:29 +020017728static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17729 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17730 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17731 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17732 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17733 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17734 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17735 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17736 {}
17737};
17738
17739static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17740 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17741 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17742 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17743 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17744 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17745 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17746 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17747 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17748 {}
17749};
17750
17751static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17752 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17753 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17754 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17755 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17756 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17757 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17758 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17759 {}
17760};
17761
17762static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17763 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17764 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17765 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17766 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17767 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17768 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17769 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17770 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17771 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17772 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17773 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17774 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17775 {}
17776};
17777
17778static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17779 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17780 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17781 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17782 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17783 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17784 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17785 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17786 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17787 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17788 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17789 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17790 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17791 {}
17792};
17793
Kailang Yang6dda9f42008-05-27 12:05:31 +020017794static struct hda_verb alc663_g71v_init_verbs[] = {
17795 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17796 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17797 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17798
17799 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17800 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17801 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17802
17803 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17804 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17805 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17806 {}
17807};
17808
17809static struct hda_verb alc663_g50v_init_verbs[] = {
17810 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17811 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17812 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17813
17814 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17815 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17816 {}
17817};
17818
Kailang Yangf1d4e282008-08-26 14:03:29 +020017819static struct hda_verb alc662_ecs_init_verbs[] = {
17820 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17821 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17822 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17823 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17824 {}
17825};
17826
Kailang Yang622e84c2009-04-21 07:39:04 +020017827static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17828 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17829 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17830 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17831 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17832 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17833 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17834 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17835 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17836 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17837 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17838 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17839 {}
17840};
17841
17842static struct hda_verb alc272_dell_init_verbs[] = {
17843 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17844 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17845 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17846 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17847 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17848 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17849 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17850 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17851 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17852 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17853 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17854 {}
17855};
17856
Kailang Yangebb83ee2009-12-17 12:23:00 +010017857static struct hda_verb alc663_mode7_init_verbs[] = {
17858 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17859 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17860 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17861 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17862 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17863 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17864 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17865 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17866 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17867 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17869 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17870 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17871 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17872 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17873 {}
17874};
17875
17876static struct hda_verb alc663_mode8_init_verbs[] = {
17877 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17878 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17879 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17880 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17881 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17882 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17883 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17884 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17885 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17886 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17887 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17888 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17889 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17890 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17891 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17892 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17893 {}
17894};
17895
Kailang Yangf1d4e282008-08-26 14:03:29 +020017896static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17897 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17898 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17899 { } /* end */
17900};
17901
Kailang Yang622e84c2009-04-21 07:39:04 +020017902static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17903 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17904 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17905 { } /* end */
17906};
17907
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017908static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17909{
17910 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017911 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017912
Wu Fengguang864f92b2009-11-18 12:38:02 +080017913 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017914 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017915
Takashi Iwai47fd8302007-08-10 17:11:07 +020017916 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17917 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017918}
17919
17920static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17921{
17922 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017923 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017924
Wu Fengguang864f92b2009-11-18 12:38:02 +080017925 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017926 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017927
Takashi Iwai47fd8302007-08-10 17:11:07 +020017928 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17929 HDA_AMP_MUTE, bits);
17930 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17931 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017932}
17933
17934static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17935 unsigned int res)
17936{
17937 if ((res >> 26) == ALC880_HP_EVENT)
17938 alc662_lenovo_101e_all_automute(codec);
17939 if ((res >> 26) == ALC880_FRONT_EVENT)
17940 alc662_lenovo_101e_ispeaker_automute(codec);
17941}
17942
Kailang Yang291702f2007-10-16 14:28:03 +020017943/* unsolicited event for HP jack sensing */
17944static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17945 unsigned int res)
17946{
Kailang Yang291702f2007-10-16 14:28:03 +020017947 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017948 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017949 else
17950 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017951}
17952
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017953static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017954{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017955 struct alc_spec *spec = codec->spec;
17956
17957 alc262_hippo1_setup(codec);
17958 spec->ext_mic.pin = 0x18;
17959 spec->ext_mic.mux_idx = 0;
17960 spec->int_mic.pin = 0x19;
17961 spec->int_mic.mux_idx = 1;
17962 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017963}
17964
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017965static void alc662_eeepc_inithook(struct hda_codec *codec)
17966{
17967 alc262_hippo_automute(codec);
17968 alc_mic_automute(codec);
17969}
17970
17971static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017972{
Takashi Iwai42171c12009-05-08 14:11:43 +020017973 struct alc_spec *spec = codec->spec;
17974
17975 spec->autocfg.hp_pins[0] = 0x14;
17976 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017977}
17978
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017979#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17980
Kailang Yang6dda9f42008-05-27 12:05:31 +020017981static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17982{
17983 unsigned int present;
17984 unsigned char bits;
17985
Wu Fengguang864f92b2009-11-18 12:38:02 +080017986 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017987 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017988 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017989 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017990 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017991 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017992}
17993
17994static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17995{
17996 unsigned int present;
17997 unsigned char bits;
17998
Wu Fengguang864f92b2009-11-18 12:38:02 +080017999 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018000 bits = present ? HDA_AMP_MUTE : 0;
18001 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018002 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018003 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018004 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018005 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018006 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018007 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018008 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018009}
18010
18011static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18012{
18013 unsigned int present;
18014 unsigned char bits;
18015
Wu Fengguang864f92b2009-11-18 12:38:02 +080018016 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018017 bits = present ? HDA_AMP_MUTE : 0;
18018 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018019 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018020 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018021 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018022 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018023 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018024 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018025 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018026}
18027
18028static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18029{
18030 unsigned int present;
18031 unsigned char bits;
18032
Wu Fengguang864f92b2009-11-18 12:38:02 +080018033 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018034 bits = present ? 0 : PIN_OUT;
18035 snd_hda_codec_write(codec, 0x14, 0,
18036 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18037}
18038
18039static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18040{
18041 unsigned int present1, present2;
18042
Wu Fengguang864f92b2009-11-18 12:38:02 +080018043 present1 = snd_hda_jack_detect(codec, 0x21);
18044 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018045
18046 if (present1 || present2) {
18047 snd_hda_codec_write_cache(codec, 0x14, 0,
18048 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18049 } else {
18050 snd_hda_codec_write_cache(codec, 0x14, 0,
18051 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18052 }
18053}
18054
18055static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18056{
18057 unsigned int present1, present2;
18058
Wu Fengguang864f92b2009-11-18 12:38:02 +080018059 present1 = snd_hda_jack_detect(codec, 0x1b);
18060 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018061
18062 if (present1 || present2) {
18063 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018064 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018065 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018066 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018067 } else {
18068 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018069 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018070 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018071 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018072 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018073}
18074
Kailang Yangebb83ee2009-12-17 12:23:00 +010018075static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18076{
18077 unsigned int present1, present2;
18078
18079 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18080 AC_VERB_GET_PIN_SENSE, 0)
18081 & AC_PINSENSE_PRESENCE;
18082 present2 = snd_hda_codec_read(codec, 0x21, 0,
18083 AC_VERB_GET_PIN_SENSE, 0)
18084 & AC_PINSENSE_PRESENCE;
18085
18086 if (present1 || present2) {
18087 snd_hda_codec_write_cache(codec, 0x14, 0,
18088 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18089 snd_hda_codec_write_cache(codec, 0x17, 0,
18090 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18091 } else {
18092 snd_hda_codec_write_cache(codec, 0x14, 0,
18093 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18094 snd_hda_codec_write_cache(codec, 0x17, 0,
18095 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18096 }
18097}
18098
18099static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18100{
18101 unsigned int present1, present2;
18102
18103 present1 = snd_hda_codec_read(codec, 0x21, 0,
18104 AC_VERB_GET_PIN_SENSE, 0)
18105 & AC_PINSENSE_PRESENCE;
18106 present2 = snd_hda_codec_read(codec, 0x15, 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
Kailang Yang6dda9f42008-05-27 12:05:31 +020018123static void alc663_m51va_unsol_event(struct hda_codec *codec,
18124 unsigned int res)
18125{
18126 switch (res >> 26) {
18127 case ALC880_HP_EVENT:
18128 alc663_m51va_speaker_automute(codec);
18129 break;
18130 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018131 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018132 break;
18133 }
18134}
18135
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018136static void alc663_m51va_setup(struct hda_codec *codec)
18137{
18138 struct alc_spec *spec = codec->spec;
18139 spec->ext_mic.pin = 0x18;
18140 spec->ext_mic.mux_idx = 0;
18141 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018142 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018143 spec->auto_mic = 1;
18144}
18145
Kailang Yang6dda9f42008-05-27 12:05:31 +020018146static void alc663_m51va_inithook(struct hda_codec *codec)
18147{
18148 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018149 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018150}
18151
Kailang Yangf1d4e282008-08-26 14:03:29 +020018152/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018153#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018154
18155static void alc663_mode1_setup(struct hda_codec *codec)
18156{
18157 struct alc_spec *spec = codec->spec;
18158 spec->ext_mic.pin = 0x18;
18159 spec->ext_mic.mux_idx = 0;
18160 spec->int_mic.pin = 0x19;
18161 spec->int_mic.mux_idx = 1;
18162 spec->auto_mic = 1;
18163}
18164
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018165#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018166
Kailang Yangf1d4e282008-08-26 14:03:29 +020018167/* ***************** Mode2 ******************************/
18168static void alc662_mode2_unsol_event(struct hda_codec *codec,
18169 unsigned int res)
18170{
18171 switch (res >> 26) {
18172 case ALC880_HP_EVENT:
18173 alc662_f5z_speaker_automute(codec);
18174 break;
18175 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018176 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018177 break;
18178 }
18179}
18180
Kailang Yangebb83ee2009-12-17 12:23:00 +010018181#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018182
Kailang Yangf1d4e282008-08-26 14:03:29 +020018183static void alc662_mode2_inithook(struct hda_codec *codec)
18184{
18185 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018186 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018187}
18188/* ***************** Mode3 ******************************/
18189static void alc663_mode3_unsol_event(struct hda_codec *codec,
18190 unsigned int res)
18191{
18192 switch (res >> 26) {
18193 case ALC880_HP_EVENT:
18194 alc663_two_hp_m1_speaker_automute(codec);
18195 break;
18196 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018197 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018198 break;
18199 }
18200}
18201
Kailang Yangebb83ee2009-12-17 12:23:00 +010018202#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018203
Kailang Yangf1d4e282008-08-26 14:03:29 +020018204static void alc663_mode3_inithook(struct hda_codec *codec)
18205{
18206 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018207 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018208}
18209/* ***************** Mode4 ******************************/
18210static void alc663_mode4_unsol_event(struct hda_codec *codec,
18211 unsigned int res)
18212{
18213 switch (res >> 26) {
18214 case ALC880_HP_EVENT:
18215 alc663_21jd_two_speaker_automute(codec);
18216 break;
18217 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018218 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018219 break;
18220 }
18221}
18222
Kailang Yangebb83ee2009-12-17 12:23:00 +010018223#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018224
Kailang Yangf1d4e282008-08-26 14:03:29 +020018225static void alc663_mode4_inithook(struct hda_codec *codec)
18226{
18227 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018228 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018229}
18230/* ***************** Mode5 ******************************/
18231static void alc663_mode5_unsol_event(struct hda_codec *codec,
18232 unsigned int res)
18233{
18234 switch (res >> 26) {
18235 case ALC880_HP_EVENT:
18236 alc663_15jd_two_speaker_automute(codec);
18237 break;
18238 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018239 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018240 break;
18241 }
18242}
18243
Kailang Yangebb83ee2009-12-17 12:23:00 +010018244#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018245
Kailang Yangf1d4e282008-08-26 14:03:29 +020018246static void alc663_mode5_inithook(struct hda_codec *codec)
18247{
18248 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018249 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018250}
18251/* ***************** Mode6 ******************************/
18252static void alc663_mode6_unsol_event(struct hda_codec *codec,
18253 unsigned int res)
18254{
18255 switch (res >> 26) {
18256 case ALC880_HP_EVENT:
18257 alc663_two_hp_m2_speaker_automute(codec);
18258 break;
18259 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018260 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018261 break;
18262 }
18263}
18264
Kailang Yangebb83ee2009-12-17 12:23:00 +010018265#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018266
Kailang Yangf1d4e282008-08-26 14:03:29 +020018267static void alc663_mode6_inithook(struct hda_codec *codec)
18268{
18269 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018270 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018271}
18272
Kailang Yangebb83ee2009-12-17 12:23:00 +010018273/* ***************** Mode7 ******************************/
18274static void alc663_mode7_unsol_event(struct hda_codec *codec,
18275 unsigned int res)
18276{
18277 switch (res >> 26) {
18278 case ALC880_HP_EVENT:
18279 alc663_two_hp_m7_speaker_automute(codec);
18280 break;
18281 case ALC880_MIC_EVENT:
18282 alc_mic_automute(codec);
18283 break;
18284 }
18285}
18286
18287#define alc663_mode7_setup alc663_mode1_setup
18288
18289static void alc663_mode7_inithook(struct hda_codec *codec)
18290{
18291 alc663_two_hp_m7_speaker_automute(codec);
18292 alc_mic_automute(codec);
18293}
18294
18295/* ***************** Mode8 ******************************/
18296static void alc663_mode8_unsol_event(struct hda_codec *codec,
18297 unsigned int res)
18298{
18299 switch (res >> 26) {
18300 case ALC880_HP_EVENT:
18301 alc663_two_hp_m8_speaker_automute(codec);
18302 break;
18303 case ALC880_MIC_EVENT:
18304 alc_mic_automute(codec);
18305 break;
18306 }
18307}
18308
18309#define alc663_mode8_setup alc663_m51va_setup
18310
18311static void alc663_mode8_inithook(struct hda_codec *codec)
18312{
18313 alc663_two_hp_m8_speaker_automute(codec);
18314 alc_mic_automute(codec);
18315}
18316
Kailang Yang6dda9f42008-05-27 12:05:31 +020018317static void alc663_g71v_hp_automute(struct hda_codec *codec)
18318{
18319 unsigned int present;
18320 unsigned char bits;
18321
Wu Fengguang864f92b2009-11-18 12:38:02 +080018322 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018323 bits = present ? HDA_AMP_MUTE : 0;
18324 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18325 HDA_AMP_MUTE, bits);
18326 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18327 HDA_AMP_MUTE, bits);
18328}
18329
18330static void alc663_g71v_front_automute(struct hda_codec *codec)
18331{
18332 unsigned int present;
18333 unsigned char bits;
18334
Wu Fengguang864f92b2009-11-18 12:38:02 +080018335 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018336 bits = present ? HDA_AMP_MUTE : 0;
18337 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18338 HDA_AMP_MUTE, bits);
18339}
18340
18341static void alc663_g71v_unsol_event(struct hda_codec *codec,
18342 unsigned int res)
18343{
18344 switch (res >> 26) {
18345 case ALC880_HP_EVENT:
18346 alc663_g71v_hp_automute(codec);
18347 break;
18348 case ALC880_FRONT_EVENT:
18349 alc663_g71v_front_automute(codec);
18350 break;
18351 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018352 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018353 break;
18354 }
18355}
18356
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018357#define alc663_g71v_setup alc663_m51va_setup
18358
Kailang Yang6dda9f42008-05-27 12:05:31 +020018359static void alc663_g71v_inithook(struct hda_codec *codec)
18360{
18361 alc663_g71v_front_automute(codec);
18362 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018363 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018364}
18365
18366static void alc663_g50v_unsol_event(struct hda_codec *codec,
18367 unsigned int res)
18368{
18369 switch (res >> 26) {
18370 case ALC880_HP_EVENT:
18371 alc663_m51va_speaker_automute(codec);
18372 break;
18373 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018374 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018375 break;
18376 }
18377}
18378
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018379#define alc663_g50v_setup alc663_m51va_setup
18380
Kailang Yang6dda9f42008-05-27 12:05:31 +020018381static void alc663_g50v_inithook(struct hda_codec *codec)
18382{
18383 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018384 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018385}
18386
Kailang Yangf1d4e282008-08-26 14:03:29 +020018387static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18388 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018389 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018390
18391 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18392 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18393 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18394
18395 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18396 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18397 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18398 { } /* end */
18399};
18400
Chris Pockelé9541ba12009-05-12 08:08:53 +020018401static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18402 /* Master Playback automatically created from Speaker and Headphone */
18403 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18404 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18405 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18406 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18407
18408 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18409 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18410 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18411
18412 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18413 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18414 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18415 { } /* end */
18416};
18417
Takashi Iwaicb53c622007-08-10 17:21:45 +020018418#ifdef CONFIG_SND_HDA_POWER_SAVE
18419#define alc662_loopbacks alc880_loopbacks
18420#endif
18421
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018422
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018423/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018424#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18425#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18426#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18427#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18428
18429/*
18430 * configuration and preset
18431 */
18432static const char *alc662_models[ALC662_MODEL_LAST] = {
18433 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18434 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18435 [ALC662_3ST_6ch] = "3stack-6ch",
18436 [ALC662_5ST_DIG] = "6stack-dig",
18437 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018438 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018439 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018440 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018441 [ALC663_ASUS_M51VA] = "m51va",
18442 [ALC663_ASUS_G71V] = "g71v",
18443 [ALC663_ASUS_H13] = "h13",
18444 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018445 [ALC663_ASUS_MODE1] = "asus-mode1",
18446 [ALC662_ASUS_MODE2] = "asus-mode2",
18447 [ALC663_ASUS_MODE3] = "asus-mode3",
18448 [ALC663_ASUS_MODE4] = "asus-mode4",
18449 [ALC663_ASUS_MODE5] = "asus-mode5",
18450 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018451 [ALC663_ASUS_MODE7] = "asus-mode7",
18452 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018453 [ALC272_DELL] = "dell",
18454 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018455 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018456 [ALC662_AUTO] = "auto",
18457};
18458
18459static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018460 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018461 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18462 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018463 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18464 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018465 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018466 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18467 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18468 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18469 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018470 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18471 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018472 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018473 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18474 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18475 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18476 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18477 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018478 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018479 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18480 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018481 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18482 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18483 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18484 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018485 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018486 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18487 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18488 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018489 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18490 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18491 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18492 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018493 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018494 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18495 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018496 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018497 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18498 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18499 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018500 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018501 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018502 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18503 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018504 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18505 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18506 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018507 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018508 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18509 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018510 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018511 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018512 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018513 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18514 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18515 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018516 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018517 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18518 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018519 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018520 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018521 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018522 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018523 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18524 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018525 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018526 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018527 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18528 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018529 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018530 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018531 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018532 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018533 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018534 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018535 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18536 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018537 {}
18538};
18539
18540static struct alc_config_preset alc662_presets[] = {
18541 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018542 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018543 .init_verbs = { alc662_init_verbs },
18544 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18545 .dac_nids = alc662_dac_nids,
18546 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018547 .dig_in_nid = ALC662_DIGIN_NID,
18548 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18549 .channel_mode = alc662_3ST_2ch_modes,
18550 .input_mux = &alc662_capture_source,
18551 },
18552 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018553 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018554 .init_verbs = { alc662_init_verbs },
18555 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18556 .dac_nids = alc662_dac_nids,
18557 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018558 .dig_in_nid = ALC662_DIGIN_NID,
18559 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18560 .channel_mode = alc662_3ST_6ch_modes,
18561 .need_dac_fix = 1,
18562 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018563 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018564 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018565 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018566 .init_verbs = { alc662_init_verbs },
18567 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18568 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018569 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18570 .channel_mode = alc662_3ST_6ch_modes,
18571 .need_dac_fix = 1,
18572 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018573 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018574 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018575 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018576 .init_verbs = { alc662_init_verbs },
18577 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18578 .dac_nids = alc662_dac_nids,
18579 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018580 .dig_in_nid = ALC662_DIGIN_NID,
18581 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18582 .channel_mode = alc662_5stack_modes,
18583 .input_mux = &alc662_capture_source,
18584 },
18585 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018586 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018587 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18588 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18589 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018590 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18591 .channel_mode = alc662_3ST_2ch_modes,
18592 .input_mux = &alc662_lenovo_101e_capture_source,
18593 .unsol_event = alc662_lenovo_101e_unsol_event,
18594 .init_hook = alc662_lenovo_101e_all_automute,
18595 },
Kailang Yang291702f2007-10-16 14:28:03 +020018596 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018597 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018598 .init_verbs = { alc662_init_verbs,
18599 alc662_eeepc_sue_init_verbs },
18600 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18601 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018602 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18603 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018604 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018605 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018606 .init_hook = alc662_eeepc_inithook,
18607 },
Kailang Yang8c427222008-01-10 13:03:59 +010018608 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018609 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018610 alc662_chmode_mixer },
18611 .init_verbs = { alc662_init_verbs,
18612 alc662_eeepc_ep20_sue_init_verbs },
18613 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18614 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018615 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18616 .channel_mode = alc662_3ST_6ch_modes,
18617 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018618 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018619 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018620 .init_hook = alc662_eeepc_ep20_inithook,
18621 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018622 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018623 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018624 .init_verbs = { alc662_init_verbs,
18625 alc662_ecs_init_verbs },
18626 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18627 .dac_nids = alc662_dac_nids,
18628 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18629 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018630 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018631 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018632 .init_hook = alc662_eeepc_inithook,
18633 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018634 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018635 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018636 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18637 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18638 .dac_nids = alc662_dac_nids,
18639 .dig_out_nid = ALC662_DIGOUT_NID,
18640 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18641 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018642 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018643 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018644 .init_hook = alc663_m51va_inithook,
18645 },
18646 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018647 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018648 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18649 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18650 .dac_nids = alc662_dac_nids,
18651 .dig_out_nid = ALC662_DIGOUT_NID,
18652 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18653 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018654 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018655 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018656 .init_hook = alc663_g71v_inithook,
18657 },
18658 [ALC663_ASUS_H13] = {
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 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18664 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018665 .unsol_event = alc663_m51va_unsol_event,
18666 .init_hook = alc663_m51va_inithook,
18667 },
18668 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018669 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018670 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18671 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18672 .dac_nids = alc662_dac_nids,
18673 .dig_out_nid = ALC662_DIGOUT_NID,
18674 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18675 .channel_mode = alc662_3ST_6ch_modes,
18676 .input_mux = &alc663_capture_source,
18677 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018678 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018679 .init_hook = alc663_g50v_inithook,
18680 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018681 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018682 .mixers = { alc663_m51va_mixer },
18683 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018684 .init_verbs = { alc662_init_verbs,
18685 alc663_21jd_amic_init_verbs },
18686 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18687 .hp_nid = 0x03,
18688 .dac_nids = alc662_dac_nids,
18689 .dig_out_nid = ALC662_DIGOUT_NID,
18690 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18691 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018692 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018693 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018694 .init_hook = alc663_mode1_inithook,
18695 },
18696 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018697 .mixers = { alc662_1bjd_mixer },
18698 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018699 .init_verbs = { alc662_init_verbs,
18700 alc662_1bjd_amic_init_verbs },
18701 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18702 .dac_nids = alc662_dac_nids,
18703 .dig_out_nid = ALC662_DIGOUT_NID,
18704 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18705 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018706 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018707 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018708 .init_hook = alc662_mode2_inithook,
18709 },
18710 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018711 .mixers = { alc663_two_hp_m1_mixer },
18712 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018713 .init_verbs = { alc662_init_verbs,
18714 alc663_two_hp_amic_m1_init_verbs },
18715 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18716 .hp_nid = 0x03,
18717 .dac_nids = alc662_dac_nids,
18718 .dig_out_nid = ALC662_DIGOUT_NID,
18719 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18720 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018721 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018722 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018723 .init_hook = alc663_mode3_inithook,
18724 },
18725 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018726 .mixers = { alc663_asus_21jd_clfe_mixer },
18727 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018728 .init_verbs = { alc662_init_verbs,
18729 alc663_21jd_amic_init_verbs},
18730 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18731 .hp_nid = 0x03,
18732 .dac_nids = alc662_dac_nids,
18733 .dig_out_nid = ALC662_DIGOUT_NID,
18734 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18735 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018736 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018737 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018738 .init_hook = alc663_mode4_inithook,
18739 },
18740 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018741 .mixers = { alc663_asus_15jd_clfe_mixer },
18742 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018743 .init_verbs = { alc662_init_verbs,
18744 alc663_15jd_amic_init_verbs },
18745 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18746 .hp_nid = 0x03,
18747 .dac_nids = alc662_dac_nids,
18748 .dig_out_nid = ALC662_DIGOUT_NID,
18749 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18750 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018751 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018752 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018753 .init_hook = alc663_mode5_inithook,
18754 },
18755 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018756 .mixers = { alc663_two_hp_m2_mixer },
18757 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018758 .init_verbs = { alc662_init_verbs,
18759 alc663_two_hp_amic_m2_init_verbs },
18760 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18761 .hp_nid = 0x03,
18762 .dac_nids = alc662_dac_nids,
18763 .dig_out_nid = ALC662_DIGOUT_NID,
18764 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18765 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018766 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018767 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018768 .init_hook = alc663_mode6_inithook,
18769 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018770 [ALC663_ASUS_MODE7] = {
18771 .mixers = { alc663_mode7_mixer },
18772 .cap_mixer = alc662_auto_capture_mixer,
18773 .init_verbs = { alc662_init_verbs,
18774 alc663_mode7_init_verbs },
18775 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18776 .hp_nid = 0x03,
18777 .dac_nids = alc662_dac_nids,
18778 .dig_out_nid = ALC662_DIGOUT_NID,
18779 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18780 .channel_mode = alc662_3ST_2ch_modes,
18781 .unsol_event = alc663_mode7_unsol_event,
18782 .setup = alc663_mode7_setup,
18783 .init_hook = alc663_mode7_inithook,
18784 },
18785 [ALC663_ASUS_MODE8] = {
18786 .mixers = { alc663_mode8_mixer },
18787 .cap_mixer = alc662_auto_capture_mixer,
18788 .init_verbs = { alc662_init_verbs,
18789 alc663_mode8_init_verbs },
18790 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18791 .hp_nid = 0x03,
18792 .dac_nids = alc662_dac_nids,
18793 .dig_out_nid = ALC662_DIGOUT_NID,
18794 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18795 .channel_mode = alc662_3ST_2ch_modes,
18796 .unsol_event = alc663_mode8_unsol_event,
18797 .setup = alc663_mode8_setup,
18798 .init_hook = alc663_mode8_inithook,
18799 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018800 [ALC272_DELL] = {
18801 .mixers = { alc663_m51va_mixer },
18802 .cap_mixer = alc272_auto_capture_mixer,
18803 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18804 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18805 .dac_nids = alc662_dac_nids,
18806 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18807 .adc_nids = alc272_adc_nids,
18808 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18809 .capsrc_nids = alc272_capsrc_nids,
18810 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018811 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018812 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018813 .init_hook = alc663_m51va_inithook,
18814 },
18815 [ALC272_DELL_ZM1] = {
18816 .mixers = { alc663_m51va_mixer },
18817 .cap_mixer = alc662_auto_capture_mixer,
18818 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18819 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18820 .dac_nids = alc662_dac_nids,
18821 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18822 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018823 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018824 .capsrc_nids = alc662_capsrc_nids,
18825 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018826 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018827 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018828 .init_hook = alc663_m51va_inithook,
18829 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018830 [ALC272_SAMSUNG_NC10] = {
18831 .mixers = { alc272_nc10_mixer },
18832 .init_verbs = { alc662_init_verbs,
18833 alc663_21jd_amic_init_verbs },
18834 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18835 .dac_nids = alc272_dac_nids,
18836 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18837 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018838 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018839 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018840 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018841 .init_hook = alc663_mode4_inithook,
18842 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018843};
18844
18845
18846/*
18847 * BIOS auto configuration
18848 */
18849
Takashi Iwai7085ec12009-10-02 09:03:58 +020018850/* convert from MIX nid to DAC */
18851static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18852{
18853 if (nid == 0x0f)
18854 return 0x02;
18855 else if (nid >= 0x0c && nid <= 0x0e)
18856 return nid - 0x0c + 0x02;
18857 else
18858 return 0;
18859}
18860
18861/* get MIX nid connected to the given pin targeted to DAC */
18862static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18863 hda_nid_t dac)
18864{
18865 hda_nid_t mix[4];
18866 int i, num;
18867
18868 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18869 for (i = 0; i < num; i++) {
18870 if (alc662_mix_to_dac(mix[i]) == dac)
18871 return mix[i];
18872 }
18873 return 0;
18874}
18875
18876/* look for an empty DAC slot */
18877static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18878{
18879 struct alc_spec *spec = codec->spec;
18880 hda_nid_t srcs[5];
18881 int i, j, num;
18882
18883 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18884 if (num < 0)
18885 return 0;
18886 for (i = 0; i < num; i++) {
18887 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18888 if (!nid)
18889 continue;
18890 for (j = 0; j < spec->multiout.num_dacs; j++)
18891 if (spec->multiout.dac_nids[j] == nid)
18892 break;
18893 if (j >= spec->multiout.num_dacs)
18894 return nid;
18895 }
18896 return 0;
18897}
18898
18899/* fill in the dac_nids table from the parsed pin configuration */
18900static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18901 const struct auto_pin_cfg *cfg)
18902{
18903 struct alc_spec *spec = codec->spec;
18904 int i;
18905 hda_nid_t dac;
18906
18907 spec->multiout.dac_nids = spec->private_dac_nids;
18908 for (i = 0; i < cfg->line_outs; i++) {
18909 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18910 if (!dac)
18911 continue;
18912 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18913 }
18914 return 0;
18915}
18916
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018917static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018918 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018919{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018920 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018921 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18922}
18923
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018924static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018925 hda_nid_t nid, unsigned int chs)
18926{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018927 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018928 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18929}
18930
18931#define alc662_add_stereo_vol(spec, pfx, nid) \
18932 alc662_add_vol_ctl(spec, pfx, nid, 3)
18933#define alc662_add_stereo_sw(spec, pfx, nid) \
18934 alc662_add_sw_ctl(spec, pfx, nid, 3)
18935
18936/* add playback controls from the parsed DAC table */
18937static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18938 const struct auto_pin_cfg *cfg)
18939{
18940 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018941 static const char *chname[4] = {
18942 "Front", "Surround", NULL /*CLFE*/, "Side"
18943 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018944 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018945 int i, err;
18946
18947 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018948 nid = spec->multiout.dac_nids[i];
18949 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018950 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018951 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18952 if (!mix)
18953 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018954 if (i == 2) {
18955 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018956 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018957 if (err < 0)
18958 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018959 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018960 if (err < 0)
18961 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018962 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018963 if (err < 0)
18964 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018965 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018966 if (err < 0)
18967 return err;
18968 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018969 const char *pfx;
18970 if (cfg->line_outs == 1 &&
18971 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018972 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018973 pfx = "Speaker";
18974 else
18975 pfx = "PCM";
18976 } else
18977 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018978 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018979 if (err < 0)
18980 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018981 if (cfg->line_outs == 1 &&
18982 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18983 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018984 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018985 if (err < 0)
18986 return err;
18987 }
18988 }
18989 return 0;
18990}
18991
18992/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018993/* return DAC nid if any new DAC is assigned */
18994static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018995 const char *pfx)
18996{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018997 struct alc_spec *spec = codec->spec;
18998 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018999 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019000
19001 if (!pin)
19002 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019003 nid = alc662_look_for_dac(codec, pin);
19004 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019005 /* the corresponding DAC is already occupied */
19006 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19007 return 0; /* no way */
19008 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019009 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019010 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19011 }
19012
19013 mix = alc662_dac_to_mix(codec, pin, nid);
19014 if (!mix)
19015 return 0;
19016 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19017 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019018 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019019 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19020 if (err < 0)
19021 return err;
19022 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019023}
19024
19025/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019026#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019027 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019028
19029static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19030 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019031 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019032{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019033 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019034 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019035
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019036 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019037 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019038 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19039 if (num <= 1)
19040 return;
19041 for (i = 0; i < num; i++) {
19042 if (alc662_mix_to_dac(srcs[i]) != dac)
19043 continue;
19044 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19045 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019046 }
19047}
19048
19049static void alc662_auto_init_multi_out(struct hda_codec *codec)
19050{
19051 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019052 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019053 int i;
19054
19055 for (i = 0; i <= HDA_SIDE; i++) {
19056 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19057 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019058 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019059 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019060 }
19061}
19062
19063static void alc662_auto_init_hp_out(struct hda_codec *codec)
19064{
19065 struct alc_spec *spec = codec->spec;
19066 hda_nid_t pin;
19067
19068 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019069 if (pin)
19070 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19071 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019072 pin = spec->autocfg.speaker_pins[0];
19073 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019074 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19075 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019076}
19077
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019078#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19079
19080static void alc662_auto_init_analog_input(struct hda_codec *codec)
19081{
19082 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019083 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019084 int i;
19085
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019086 for (i = 0; i < cfg->num_inputs; i++) {
19087 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019088 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019089 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019090 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019091 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019092 snd_hda_codec_write(codec, nid, 0,
19093 AC_VERB_SET_AMP_GAIN_MUTE,
19094 AMP_OUT_MUTE);
19095 }
19096 }
19097}
19098
Takashi Iwaif511b012008-08-15 16:46:42 +020019099#define alc662_auto_init_input_src alc882_auto_init_input_src
19100
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019101static int alc662_parse_auto_config(struct hda_codec *codec)
19102{
19103 struct alc_spec *spec = codec->spec;
19104 int err;
19105 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19106
19107 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19108 alc662_ignore);
19109 if (err < 0)
19110 return err;
19111 if (!spec->autocfg.line_outs)
19112 return 0; /* can't find valid BIOS pin config */
19113
Takashi Iwai7085ec12009-10-02 09:03:58 +020019114 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019115 if (err < 0)
19116 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019117 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019118 if (err < 0)
19119 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019120 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019121 spec->autocfg.speaker_pins[0],
19122 "Speaker");
19123 if (err < 0)
19124 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019125 if (err)
19126 spec->multiout.extra_out_nid[0] = err;
19127 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019128 "Headphone");
19129 if (err < 0)
19130 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019131 if (err)
19132 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019133 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019134 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019135 return err;
19136
19137 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19138
Takashi Iwai757899a2010-07-30 10:48:14 +020019139 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019140
Takashi Iwai603c4012008-07-30 15:01:44 +020019141 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019142 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019143
19144 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019145 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019146
Kailang Yangcec27c82010-02-04 14:18:18 +010019147 add_verb(spec, alc662_init_verbs);
19148 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019149 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019150 add_verb(spec, alc663_init_verbs);
19151
19152 if (codec->vendor_id == 0x10ec0272)
19153 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019154
19155 err = alc_auto_add_mic_boost(codec);
19156 if (err < 0)
19157 return err;
19158
Kailang Yang6227cdc2010-02-25 08:36:52 +010019159 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19160 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19161 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19162 else
19163 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019164
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019165 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019166}
19167
19168/* additional initialization for auto-configuration model */
19169static void alc662_auto_init(struct hda_codec *codec)
19170{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019171 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019172 alc662_auto_init_multi_out(codec);
19173 alc662_auto_init_hp_out(codec);
19174 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019175 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019176 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019177 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019178 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019179}
19180
David Henningsson6cb3b702010-09-09 08:51:44 +020019181enum {
19182 ALC662_FIXUP_IDEAPAD,
19183};
19184
19185static const struct alc_fixup alc662_fixups[] = {
19186 [ALC662_FIXUP_IDEAPAD] = {
19187 .pins = (const struct alc_pincfg[]) {
19188 { 0x17, 0x99130112 }, /* subwoofer */
19189 { }
19190 }
19191 },
19192};
19193
19194static struct snd_pci_quirk alc662_fixup_tbl[] = {
19195 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19196 {}
19197};
19198
19199
19200
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019201static int patch_alc662(struct hda_codec *codec)
19202{
19203 struct alc_spec *spec;
19204 int err, board_config;
19205
19206 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19207 if (!spec)
19208 return -ENOMEM;
19209
19210 codec->spec = spec;
19211
Kailang Yangda00c242010-03-19 11:23:45 +010019212 alc_auto_parse_customize_define(codec);
19213
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019214 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19215
Kailang Yangc027ddc2010-03-19 11:33:06 +010019216 if (alc_read_coef_idx(codec, 0) == 0x8020)
19217 alc_codec_rename(codec, "ALC661");
19218 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
19219 codec->bus->pci->subsystem_vendor == 0x1025 &&
19220 spec->cdefine.platform_type == 1)
19221 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010019222
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019223 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19224 alc662_models,
19225 alc662_cfg_tbl);
19226 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019227 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19228 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019229 board_config = ALC662_AUTO;
19230 }
19231
19232 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019233 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019234 /* automatic parse from the BIOS config */
19235 err = alc662_parse_auto_config(codec);
19236 if (err < 0) {
19237 alc_free(codec);
19238 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019239 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019240 printk(KERN_INFO
19241 "hda_codec: Cannot set up configuration "
19242 "from BIOS. Using base mode...\n");
19243 board_config = ALC662_3ST_2ch_DIG;
19244 }
19245 }
19246
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019247 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019248 err = snd_hda_attach_beep_device(codec, 0x1);
19249 if (err < 0) {
19250 alc_free(codec);
19251 return err;
19252 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019253 }
19254
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019255 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019256 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019257
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019258 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19259 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19260
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019261 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19262 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19263
Takashi Iwaidd704692009-08-11 08:45:11 +020019264 if (!spec->adc_nids) {
19265 spec->adc_nids = alc662_adc_nids;
19266 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19267 }
19268 if (!spec->capsrc_nids)
19269 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019270
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019271 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019272 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019273
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019274 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019275 switch (codec->vendor_id) {
19276 case 0x10ec0662:
19277 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19278 break;
19279 case 0x10ec0272:
19280 case 0x10ec0663:
19281 case 0x10ec0665:
19282 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19283 break;
19284 case 0x10ec0273:
19285 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19286 break;
19287 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019288 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019289 spec->vmaster_nid = 0x02;
19290
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019291 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019292 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019293 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019294 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0);
19295 }
19296
Takashi Iwaicb53c622007-08-10 17:21:45 +020019297#ifdef CONFIG_SND_HDA_POWER_SAVE
19298 if (!spec->loopback.amplist)
19299 spec->loopback.amplist = alc662_loopbacks;
19300#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019301
19302 return 0;
19303}
19304
Kailang Yang274693f2009-12-03 10:07:50 +010019305static int patch_alc888(struct hda_codec *codec)
19306{
19307 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19308 kfree(codec->chip_name);
19309 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019310 if (!codec->chip_name) {
19311 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019312 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019313 }
19314 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019315 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019316 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019317}
19318
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019319/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019320 * ALC680 support
19321 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019322#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019323#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19324#define alc680_modes alc260_modes
19325
19326static hda_nid_t alc680_dac_nids[3] = {
19327 /* Lout1, Lout2, hp */
19328 0x02, 0x03, 0x04
19329};
19330
19331static hda_nid_t alc680_adc_nids[3] = {
19332 /* ADC0-2 */
19333 /* DMIC, MIC, Line-in*/
19334 0x07, 0x08, 0x09
19335};
19336
Kailang Yangc69aefa2010-08-17 10:39:22 +020019337/*
19338 * Analog capture ADC cgange
19339 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019340static void alc680_rec_autoswitch(struct hda_codec *codec)
19341{
19342 struct alc_spec *spec = codec->spec;
19343 struct auto_pin_cfg *cfg = &spec->autocfg;
19344 int pin_found = 0;
19345 int type_found = AUTO_PIN_LAST;
19346 hda_nid_t nid;
19347 int i;
19348
19349 for (i = 0; i < cfg->num_inputs; i++) {
19350 nid = cfg->inputs[i].pin;
19351 if (!(snd_hda_query_pin_caps(codec, nid) &
19352 AC_PINCAP_PRES_DETECT))
19353 continue;
19354 if (snd_hda_jack_detect(codec, nid)) {
19355 if (cfg->inputs[i].type < type_found) {
19356 type_found = cfg->inputs[i].type;
19357 pin_found = nid;
19358 }
19359 }
19360 }
19361
19362 nid = 0x07;
19363 if (pin_found)
19364 snd_hda_get_connections(codec, pin_found, &nid, 1);
19365
19366 if (nid != spec->cur_adc)
19367 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19368 spec->cur_adc = nid;
19369 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19370 spec->cur_adc_format);
19371}
19372
Kailang Yangc69aefa2010-08-17 10:39:22 +020019373static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19374 struct hda_codec *codec,
19375 unsigned int stream_tag,
19376 unsigned int format,
19377 struct snd_pcm_substream *substream)
19378{
19379 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019380
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019381 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019382 spec->cur_adc_stream_tag = stream_tag;
19383 spec->cur_adc_format = format;
19384
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019385 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019386 return 0;
19387}
19388
19389static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19390 struct hda_codec *codec,
19391 struct snd_pcm_substream *substream)
19392{
19393 snd_hda_codec_cleanup_stream(codec, 0x07);
19394 snd_hda_codec_cleanup_stream(codec, 0x08);
19395 snd_hda_codec_cleanup_stream(codec, 0x09);
19396 return 0;
19397}
19398
19399static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19400 .substreams = 1, /* can be overridden */
19401 .channels_min = 2,
19402 .channels_max = 2,
19403 /* NID is set in alc_build_pcms */
19404 .ops = {
19405 .prepare = alc680_capture_pcm_prepare,
19406 .cleanup = alc680_capture_pcm_cleanup
19407 },
19408};
19409
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019410static struct snd_kcontrol_new alc680_base_mixer[] = {
19411 /* output mixer control */
19412 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19413 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19414 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19415 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019416 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019417 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019418 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019419 { }
19420};
19421
Kailang Yangc69aefa2010-08-17 10:39:22 +020019422static struct hda_bind_ctls alc680_bind_cap_vol = {
19423 .ops = &snd_hda_bind_vol,
19424 .values = {
19425 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19426 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19427 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19428 0
19429 },
19430};
19431
19432static struct hda_bind_ctls alc680_bind_cap_switch = {
19433 .ops = &snd_hda_bind_sw,
19434 .values = {
19435 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19436 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19437 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19438 0
19439 },
19440};
19441
19442static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19443 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19444 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019445 { } /* end */
19446};
19447
19448/*
19449 * generic initialization of ADC, input mixers and output mixers
19450 */
19451static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019452 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19453 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19454 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019455
Kailang Yangc69aefa2010-08-17 10:39:22 +020019456 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19457 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19458 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19459 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19460 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19461 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019462
19463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19464 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19465 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19466 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19467 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019468
19469 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19470 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019471 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019472
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019473 { }
19474};
19475
Kailang Yangc69aefa2010-08-17 10:39:22 +020019476/* toggle speaker-output according to the hp-jack state */
19477static void alc680_base_setup(struct hda_codec *codec)
19478{
19479 struct alc_spec *spec = codec->spec;
19480
19481 spec->autocfg.hp_pins[0] = 0x16;
19482 spec->autocfg.speaker_pins[0] = 0x14;
19483 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019484 spec->autocfg.num_inputs = 2;
19485 spec->autocfg.inputs[0].pin = 0x18;
19486 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19487 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019488 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019489}
19490
19491static void alc680_unsol_event(struct hda_codec *codec,
19492 unsigned int res)
19493{
19494 if ((res >> 26) == ALC880_HP_EVENT)
19495 alc_automute_amp(codec);
19496 if ((res >> 26) == ALC880_MIC_EVENT)
19497 alc680_rec_autoswitch(codec);
19498}
19499
19500static void alc680_inithook(struct hda_codec *codec)
19501{
19502 alc_automute_amp(codec);
19503 alc680_rec_autoswitch(codec);
19504}
19505
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019506/* create input playback/capture controls for the given pin */
19507static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19508 const char *ctlname, int idx)
19509{
19510 hda_nid_t dac;
19511 int err;
19512
19513 switch (nid) {
19514 case 0x14:
19515 dac = 0x02;
19516 break;
19517 case 0x15:
19518 dac = 0x03;
19519 break;
19520 case 0x16:
19521 dac = 0x04;
19522 break;
19523 default:
19524 return 0;
19525 }
19526 if (spec->multiout.dac_nids[0] != dac &&
19527 spec->multiout.dac_nids[1] != dac) {
19528 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19529 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19530 HDA_OUTPUT));
19531 if (err < 0)
19532 return err;
19533
19534 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19535 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19536
19537 if (err < 0)
19538 return err;
19539 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19540 }
19541
19542 return 0;
19543}
19544
19545/* add playback controls from the parsed DAC table */
19546static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19547 const struct auto_pin_cfg *cfg)
19548{
19549 hda_nid_t nid;
19550 int err;
19551
19552 spec->multiout.dac_nids = spec->private_dac_nids;
19553
19554 nid = cfg->line_out_pins[0];
19555 if (nid) {
19556 const char *name;
19557 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19558 name = "Speaker";
19559 else
19560 name = "Front";
19561 err = alc680_new_analog_output(spec, nid, name, 0);
19562 if (err < 0)
19563 return err;
19564 }
19565
19566 nid = cfg->speaker_pins[0];
19567 if (nid) {
19568 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19569 if (err < 0)
19570 return err;
19571 }
19572 nid = cfg->hp_pins[0];
19573 if (nid) {
19574 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19575 if (err < 0)
19576 return err;
19577 }
19578
19579 return 0;
19580}
19581
19582static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19583 hda_nid_t nid, int pin_type)
19584{
19585 alc_set_pin_output(codec, nid, pin_type);
19586}
19587
19588static void alc680_auto_init_multi_out(struct hda_codec *codec)
19589{
19590 struct alc_spec *spec = codec->spec;
19591 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19592 if (nid) {
19593 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19594 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19595 }
19596}
19597
19598static void alc680_auto_init_hp_out(struct hda_codec *codec)
19599{
19600 struct alc_spec *spec = codec->spec;
19601 hda_nid_t pin;
19602
19603 pin = spec->autocfg.hp_pins[0];
19604 if (pin)
19605 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19606 pin = spec->autocfg.speaker_pins[0];
19607 if (pin)
19608 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19609}
19610
19611/* pcm configuration: identical with ALC880 */
19612#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19613#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19614#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19615#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019616#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019617
19618/*
19619 * BIOS auto configuration
19620 */
19621static int alc680_parse_auto_config(struct hda_codec *codec)
19622{
19623 struct alc_spec *spec = codec->spec;
19624 int err;
19625 static hda_nid_t alc680_ignore[] = { 0 };
19626
19627 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19628 alc680_ignore);
19629 if (err < 0)
19630 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019631
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019632 if (!spec->autocfg.line_outs) {
19633 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19634 spec->multiout.max_channels = 2;
19635 spec->no_analog = 1;
19636 goto dig_only;
19637 }
19638 return 0; /* can't find valid BIOS pin config */
19639 }
19640 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19641 if (err < 0)
19642 return err;
19643
19644 spec->multiout.max_channels = 2;
19645
19646 dig_only:
19647 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019648 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019649 if (spec->kctls.list)
19650 add_mixer(spec, spec->kctls.list);
19651
19652 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019653
19654 err = alc_auto_add_mic_boost(codec);
19655 if (err < 0)
19656 return err;
19657
19658 return 1;
19659}
19660
19661#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19662
19663/* init callback for auto-configuration model -- overriding the default init */
19664static void alc680_auto_init(struct hda_codec *codec)
19665{
19666 struct alc_spec *spec = codec->spec;
19667 alc680_auto_init_multi_out(codec);
19668 alc680_auto_init_hp_out(codec);
19669 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019670 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019671 if (spec->unsol_event)
19672 alc_inithook(codec);
19673}
19674
19675/*
19676 * configuration and preset
19677 */
19678static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019679 [ALC680_BASE] = "base",
19680 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019681};
19682
19683static struct snd_pci_quirk alc680_cfg_tbl[] = {
19684 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19685 {}
19686};
19687
19688static struct alc_config_preset alc680_presets[] = {
19689 [ALC680_BASE] = {
19690 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019691 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019692 .init_verbs = { alc680_init_verbs },
19693 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19694 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019695 .dig_out_nid = ALC680_DIGOUT_NID,
19696 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19697 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019698 .unsol_event = alc680_unsol_event,
19699 .setup = alc680_base_setup,
19700 .init_hook = alc680_inithook,
19701
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019702 },
19703};
19704
19705static int patch_alc680(struct hda_codec *codec)
19706{
19707 struct alc_spec *spec;
19708 int board_config;
19709 int err;
19710
19711 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19712 if (spec == NULL)
19713 return -ENOMEM;
19714
19715 codec->spec = spec;
19716
19717 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19718 alc680_models,
19719 alc680_cfg_tbl);
19720
19721 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19722 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19723 codec->chip_name);
19724 board_config = ALC680_AUTO;
19725 }
19726
19727 if (board_config == ALC680_AUTO) {
19728 /* automatic parse from the BIOS config */
19729 err = alc680_parse_auto_config(codec);
19730 if (err < 0) {
19731 alc_free(codec);
19732 return err;
19733 } else if (!err) {
19734 printk(KERN_INFO
19735 "hda_codec: Cannot set up configuration "
19736 "from BIOS. Using base mode...\n");
19737 board_config = ALC680_BASE;
19738 }
19739 }
19740
19741 if (board_config != ALC680_AUTO)
19742 setup_preset(codec, &alc680_presets[board_config]);
19743
19744 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019745 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019746 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019747 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019748
19749 if (!spec->adc_nids) {
19750 spec->adc_nids = alc680_adc_nids;
19751 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19752 }
19753
19754 if (!spec->cap_mixer)
19755 set_capture_mixer(codec);
19756
19757 spec->vmaster_nid = 0x02;
19758
19759 codec->patch_ops = alc_patch_ops;
19760 if (board_config == ALC680_AUTO)
19761 spec->init_hook = alc680_auto_init;
19762
19763 return 0;
19764}
19765
19766/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019767 * patch entries
19768 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019769static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019770 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019771 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019772 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019773 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019774 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019775 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019776 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019777 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019778 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019779 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019780 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19781 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19782 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019783 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019784 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019785 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19786 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019787 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019788 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019789 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019790 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019791 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019792 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019793 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019794 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019795 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019796 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019797 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019798 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019799 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020019800 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019801 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019802 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019803 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019804 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019805 {} /* terminator */
19806};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019807
19808MODULE_ALIAS("snd-hda-codec-id:10ec*");
19809
19810MODULE_LICENSE("GPL");
19811MODULE_DESCRIPTION("Realtek HD-audio codec");
19812
19813static struct hda_codec_preset_list realtek_list = {
19814 .preset = snd_hda_preset_realtek,
19815 .owner = THIS_MODULE,
19816};
19817
19818static int __init patch_realtek_init(void)
19819{
19820 return snd_hda_add_codec_preset(&realtek_list);
19821}
19822
19823static void __exit patch_realtek_exit(void)
19824{
19825 snd_hda_delete_codec_preset(&realtek_list);
19826}
19827
19828module_init(patch_realtek_init)
19829module_exit(patch_realtek_exit)