blob: ab2947d87232c97443ccf7a45b47e78dc040a7c0 [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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Avdoninbab282b2006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200234 ALC883_MEDION_MD2,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200235 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100236 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200237 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200238 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200239 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200240 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200241 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200242 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100243 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100244 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430245 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100246 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100247 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800248 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200249 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200250 ALC889A_INTEL,
251 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200252 ALC888_ASUS_M90V,
253 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200254 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100255 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200256 ALC883_SONY_VAIO_TT,
Takashi Iwai49535502009-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 Iwai49535502009-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Kluin4b35d2c2009-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwaic8b6bf9b2005-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 Iwai23f0c042009-02-26 13:03:58 +01005163 alc_set_input_pin(codec, nid, i);
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 Iwaic8b6bf9b2005-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Iwai23f0c042009-02-26 13:03:58 +01006796 alc_set_input_pin(codec, nid, i);
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 Woithe7cf51e42006-02-09 12:01:26 +01006945#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006946 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Woithe7cf51e42006-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-06-30 15:28:30 +02007224#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007225
Takashi Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwaia3f730a2009-08-31 08:15:26 +02007499 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007500 */
Takashi Iwaia3f730a2009-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 Iwaia3f730a2009-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 Iwaia3f730a2009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwaic8b6bf9b2005-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 Iwaia3f730a2009-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 Iwai96fe7cc2007-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 Iwai96fe7cc2007-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 Iwai96fe7cc2007-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwaia3f730a2009-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 Iwaia3f730a2009-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 Iwaia3f730a2009-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 Iwai49535502009-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 Iwai49535502009-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ünther3e1647c2009-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ünther3e1647c2009-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ünther3e1647c2009-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ünther3e1647c2009-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 Iwai49535502009-06-30 15:28:30 +02009584
Takashi Iwaicb53c622007-08-10 17:21:45 +02009585#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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ünther3e1647c2009-06-05 00:47:26 +02009655 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai49535502009-06-30 15:28:30 +02009656 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009657};
9658
Takashi Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-06-30 15:28:30 +02009782
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009783 {}
9784};
9785
Takashi Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-06-30 15:28:30 +02009811 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009812};
9813
Takashi Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Avdoninbab282b2006-08-22 13:31:58 +020010156 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010157 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b2006-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 Avdoninbab282b2006-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ünther3e1647c2009-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ünther3e1647c2009-06-05 00:47:26 +020010557 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010558};
10559
10560
10561/*
Takashi Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai49535502009-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 Iwai9c7f8522006-06-28 15:08:22 +020010637
Takashi Iwaieb06ed82006-09-20 17:10:27 +020010638 pin = spec->autocfg.hp_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010639 if (pin) {
10640 dac = spec->multiout.hp_nid;
10641 if (!dac)
10642 dac = spec->multiout.dac_nids[0]; /* to front */
10643 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10644 }
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010645 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai489008c2010-04-07 09:06:00 +020010646 if (pin) {
10647 dac = spec->multiout.extra_out_nid[0];
10648 if (!dac)
10649 dac = spec->multiout.dac_nids[0]; /* to front */
10650 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10651 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010652}
10653
Takashi Iwai49535502009-06-30 15:28:30 +020010654static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010655{
10656 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010657 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010658 int i;
10659
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010660 for (i = 0; i < cfg->num_inputs; i++) {
10661 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai0d971c92009-06-30 16:11:11 +020010662 alc_set_input_pin(codec, nid, i);
Takashi Iwai49535502009-06-30 15:28:30 +020010663 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10664 snd_hda_codec_write(codec, nid, 0,
10665 AC_VERB_SET_AMP_GAIN_MUTE,
10666 AMP_OUT_MUTE);
10667 }
10668}
10669
10670static void alc882_auto_init_input_src(struct hda_codec *codec)
10671{
10672 struct alc_spec *spec = codec->spec;
10673 int c;
10674
10675 for (c = 0; c < spec->num_adc_nids; c++) {
10676 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10677 hda_nid_t nid = spec->capsrc_nids[c];
10678 unsigned int mux_idx;
10679 const struct hda_input_mux *imux;
10680 int conns, mute, idx, item;
10681
10682 conns = snd_hda_get_connections(codec, nid, conn_list,
10683 ARRAY_SIZE(conn_list));
10684 if (conns < 0)
10685 continue;
10686 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10687 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010688 if (!imux->num_items && mux_idx > 0)
10689 imux = &spec->input_mux[0];
Takashi Iwai49535502009-06-30 15:28:30 +020010690 for (idx = 0; idx < conns; idx++) {
10691 /* if the current connection is the selected one,
10692 * unmute it as default - otherwise mute it
10693 */
10694 mute = AMP_IN_MUTE(idx);
10695 for (item = 0; item < imux->num_items; item++) {
10696 if (imux->items[item].index == idx) {
10697 if (spec->cur_mux[c] == item)
10698 mute = AMP_IN_UNMUTE(idx);
10699 break;
10700 }
10701 }
10702 /* check if we have a selector or mixer
10703 * we could check for the widget type instead, but
10704 * just check for Amp-In presence (in case of mixer
10705 * without amp-in there is something wrong, this
10706 * function shouldn't be used or capsrc nid is wrong)
10707 */
10708 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010709 snd_hda_codec_write(codec, nid, 0,
10710 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai49535502009-06-30 15:28:30 +020010711 mute);
10712 else if (mute != AMP_IN_MUTE(idx))
10713 snd_hda_codec_write(codec, nid, 0,
10714 AC_VERB_SET_CONNECT_SEL,
10715 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010716 }
10717 }
10718}
10719
Takashi Iwai49535502009-06-30 15:28:30 +020010720/* add mic boosts if needed */
10721static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010722{
10723 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010724 struct auto_pin_cfg *cfg = &spec->autocfg;
10725 int i, err;
Takashi Iwai49535502009-06-30 15:28:30 +020010726 hda_nid_t nid;
10727
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010728 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010729 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010730 break;
10731 nid = cfg->inputs[i].pin;
10732 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +020010733 char label[32];
10734 snprintf(label, sizeof(label), "%s Boost",
10735 hda_get_autocfg_input_label(codec, cfg, i));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010736 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
Takashi Iwai49535502009-06-30 15:28:30 +020010737 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010738 if (err < 0)
10739 return err;
10740 }
Takashi Iwai49535502009-06-30 15:28:30 +020010741 }
10742 return 0;
10743}
10744
10745/* almost identical with ALC880 parser... */
10746static int alc882_parse_auto_config(struct hda_codec *codec)
10747{
10748 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010749 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010750 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010751
Takashi Iwai05f5f472009-08-25 13:10:18 +020010752 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10753 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010754 if (err < 0)
10755 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010756 if (!spec->autocfg.line_outs)
10757 return 0; /* can't find valid BIOS pin config */
10758
10759 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10760 if (err < 0)
10761 return err;
10762 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10763 if (err < 0)
10764 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010765 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10766 "Headphone");
10767 if (err < 0)
10768 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010769 err = alc880_auto_create_extra_out(spec,
10770 spec->autocfg.speaker_pins[0],
10771 "Speaker");
10772 if (err < 0)
10773 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010774 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10775 if (err < 0)
10776 return err;
10777
10778 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10779
Takashi Iwai757899a2010-07-30 10:48:14 +020010780 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010781
10782 if (spec->kctls.list)
10783 add_mixer(spec, spec->kctls.list);
10784
10785 add_verb(spec, alc883_auto_init_verbs);
10786 /* if ADC 0x07 is available, initialize it, too */
10787 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10788 add_verb(spec, alc882_adc1_init_verbs);
10789
10790 spec->num_mux_defs = 1;
10791 spec->input_mux = &spec->private_imux[0];
10792
Kailang Yang6227cdc2010-02-25 08:36:52 +010010793 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010794
10795 err = alc_auto_add_mic_boost(codec);
10796 if (err < 0)
10797 return err;
10798
Takashi Iwai776e1842007-08-29 15:07:11 +020010799 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010800}
10801
10802/* additional initialization for auto-configuration model */
Takashi Iwai49535502009-06-30 15:28:30 +020010803static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010804{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010805 struct alc_spec *spec = codec->spec;
Takashi Iwai49535502009-06-30 15:28:30 +020010806 alc882_auto_init_multi_out(codec);
10807 alc882_auto_init_hp_out(codec);
10808 alc882_auto_init_analog_input(codec);
10809 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010810 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010811 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010812 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010813}
10814
Takashi Iwai49535502009-06-30 15:28:30 +020010815static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010816{
10817 struct alc_spec *spec;
10818 int err, board_config;
10819
10820 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10821 if (spec == NULL)
10822 return -ENOMEM;
10823
10824 codec->spec = spec;
10825
Kailang Yangda00c242010-03-19 11:23:45 +010010826 alc_auto_parse_customize_define(codec);
10827
Takashi Iwai49535502009-06-30 15:28:30 +020010828 switch (codec->vendor_id) {
10829 case 0x10ec0882:
10830 case 0x10ec0885:
10831 break;
10832 default:
10833 /* ALC883 and variants */
10834 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10835 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010836 }
10837
Takashi Iwai49535502009-06-30 15:28:30 +020010838 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10839 alc882_models,
10840 alc882_cfg_tbl);
10841
10842 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10843 board_config = snd_hda_check_board_codec_sid_config(codec,
10844 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10845
10846 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010847 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai49535502009-06-30 15:28:30 +020010848 codec->chip_name);
10849 board_config = ALC882_AUTO;
10850 }
10851
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010852 if (board_config == ALC882_AUTO)
10853 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai49535502009-06-30 15:28:30 +020010854
10855 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010856 /* automatic parse from the BIOS config */
Takashi Iwai49535502009-06-30 15:28:30 +020010857 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010858 if (err < 0) {
10859 alc_free(codec);
10860 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010861 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010862 printk(KERN_INFO
10863 "hda_codec: Cannot set up configuration "
10864 "from BIOS. Using base mode...\n");
Takashi Iwai49535502009-06-30 15:28:30 +020010865 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010866 }
10867 }
10868
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010869 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010870 err = snd_hda_attach_beep_device(codec, 0x1);
10871 if (err < 0) {
10872 alc_free(codec);
10873 return err;
10874 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010875 }
10876
Takashi Iwai49535502009-06-30 15:28:30 +020010877 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010878 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010879
Takashi Iwai49535502009-06-30 15:28:30 +020010880 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10881 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10882 /* FIXME: setup DAC5 */
10883 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10884 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10885
10886 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10887 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10888
Takashi Iwai49535502009-06-30 15:28:30 +020010889 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010890 int i, j;
Takashi Iwai49535502009-06-30 15:28:30 +020010891 spec->num_adc_nids = 0;
10892 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010893 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai49535502009-06-30 15:28:30 +020010894 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010895 hda_nid_t items[16];
Takashi Iwai49535502009-06-30 15:28:30 +020010896 hda_nid_t nid = alc882_adc_nids[i];
10897 unsigned int wcap = get_wcaps(codec, nid);
10898 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010899 wcap = get_wcaps_type(wcap);
Takashi Iwai49535502009-06-30 15:28:30 +020010900 if (wcap != AC_WID_AUD_IN)
10901 continue;
10902 spec->private_adc_nids[spec->num_adc_nids] = nid;
10903 err = snd_hda_get_connections(codec, nid, &cap, 1);
10904 if (err < 0)
10905 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010906 err = snd_hda_get_connections(codec, cap, items,
10907 ARRAY_SIZE(items));
10908 if (err < 0)
10909 continue;
10910 for (j = 0; j < imux->num_items; j++)
10911 if (imux->items[j].index >= err)
10912 break;
10913 if (j < imux->num_items)
10914 continue;
Takashi Iwai49535502009-06-30 15:28:30 +020010915 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10916 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010917 }
Takashi Iwai49535502009-06-30 15:28:30 +020010918 spec->adc_nids = spec->private_adc_nids;
10919 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010920 }
10921
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010922 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010923
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010924 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010010925 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010926
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010927 if (board_config == ALC882_AUTO)
10928 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10929
Takashi Iwai2134ea42008-01-10 16:53:55 +010010930 spec->vmaster_nid = 0x0c;
10931
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010932 codec->patch_ops = alc_patch_ops;
Takashi Iwai49535502009-06-30 15:28:30 +020010933 if (board_config == ALC882_AUTO)
10934 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010935#ifdef CONFIG_SND_HDA_POWER_SAVE
10936 if (!spec->loopback.amplist)
Takashi Iwai49535502009-06-30 15:28:30 +020010937 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010938#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010939
10940 return 0;
10941}
10942
Takashi Iwai49535502009-06-30 15:28:30 +020010943
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010944/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010945 * ALC262 support
10946 */
10947
10948#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10949#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10950
10951#define alc262_dac_nids alc260_dac_nids
10952#define alc262_adc_nids alc882_adc_nids
10953#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010954#define alc262_capsrc_nids alc882_capsrc_nids
10955#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010956
10957#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010958#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010959
Kailang Yang4e555fe2008-08-26 13:05:55 +020010960static hda_nid_t alc262_dmic_adc_nids[1] = {
10961 /* ADC0 */
10962 0x09
10963};
10964
10965static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10966
Kailang Yangdf694da2005-12-05 19:42:22 +010010967static struct snd_kcontrol_new alc262_base_mixer[] = {
10968 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10969 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10970 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
10971 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
10972 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
10973 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
10974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
10975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010976 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010977 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
10978 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010010979 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010980 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
10981 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
10982 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
10983 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010010984 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010010985};
10986
Takashi Iwaice875f02008-01-28 18:17:43 +010010987/* update HP, line and mono-out pins according to the master switch */
10988static void alc262_hp_master_update(struct hda_codec *codec)
10989{
10990 struct alc_spec *spec = codec->spec;
10991 int val = spec->master_sw;
10992
10993 /* HP & line-out */
10994 snd_hda_codec_write_cache(codec, 0x1b, 0,
10995 AC_VERB_SET_PIN_WIDGET_CONTROL,
10996 val ? PIN_HP : 0);
10997 snd_hda_codec_write_cache(codec, 0x15, 0,
10998 AC_VERB_SET_PIN_WIDGET_CONTROL,
10999 val ? PIN_HP : 0);
11000 /* mono (speaker) depending on the HP jack sense */
11001 val = val && !spec->jack_present;
11002 snd_hda_codec_write_cache(codec, 0x16, 0,
11003 AC_VERB_SET_PIN_WIDGET_CONTROL,
11004 val ? PIN_OUT : 0);
11005}
11006
11007static void alc262_hp_bpc_automute(struct hda_codec *codec)
11008{
11009 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011010
11011 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011012 alc262_hp_master_update(codec);
11013}
11014
11015static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11016{
11017 if ((res >> 26) != ALC880_HP_EVENT)
11018 return;
11019 alc262_hp_bpc_automute(codec);
11020}
11021
11022static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11023{
11024 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011025
11026 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011027 alc262_hp_master_update(codec);
11028}
11029
11030static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11031 unsigned int res)
11032{
11033 if ((res >> 26) != ALC880_HP_EVENT)
11034 return;
11035 alc262_hp_wildwest_automute(codec);
11036}
11037
Takashi Iwaib72519b2009-05-08 14:31:55 +020011038#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011039
11040static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11041 struct snd_ctl_elem_value *ucontrol)
11042{
11043 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11044 struct alc_spec *spec = codec->spec;
11045 int val = !!*ucontrol->value.integer.value;
11046
11047 if (val == spec->master_sw)
11048 return 0;
11049 spec->master_sw = val;
11050 alc262_hp_master_update(codec);
11051 return 1;
11052}
11053
Takashi Iwaib72519b2009-05-08 14:31:55 +020011054#define ALC262_HP_MASTER_SWITCH \
11055 { \
11056 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11057 .name = "Master Playback Switch", \
11058 .info = snd_ctl_boolean_mono_info, \
11059 .get = alc262_hp_master_sw_get, \
11060 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011061 }, \
11062 { \
11063 .iface = NID_MAPPING, \
11064 .name = "Master Playback Switch", \
11065 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011066 }
11067
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011068
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011069static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011070 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011071 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11072 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11073 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011074 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11075 HDA_OUTPUT),
11076 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11077 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011078 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11079 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011080 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011081 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11082 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011083 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011084 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11085 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11086 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11087 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011088 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11089 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11090 { } /* end */
11091};
11092
Kailang Yangcd7509a2007-01-26 18:33:17 +010011093static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011094 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011095 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11096 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11097 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11098 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011099 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11100 HDA_OUTPUT),
11101 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11102 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011103 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11104 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011105 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011106 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11107 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011110 { } /* end */
11111};
11112
11113static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11114 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11115 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011116 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011117 { } /* end */
11118};
11119
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011120/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011121static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011122{
11123 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011124
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011125 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011126 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011127}
11128
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011129static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011130 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11131 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011132 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11133 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11136 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11137 { } /* end */
11138};
11139
11140static struct hda_verb alc262_hp_t5735_verbs[] = {
11141 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11142 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11143
11144 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11145 { }
11146};
11147
Kailang Yang8c427222008-01-10 13:03:59 +010011148static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011149 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11150 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011151 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11152 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011153 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11154 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11155 { } /* end */
11156};
11157
11158static struct hda_verb alc262_hp_rp5700_verbs[] = {
11159 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11160 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11161 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11162 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11163 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11164 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11165 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11166 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11167 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11169 {}
11170};
11171
11172static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11173 .num_items = 1,
11174 .items = {
11175 { "Line", 0x1 },
11176 },
11177};
11178
Takashi Iwai42171c12009-05-08 14:11:43 +020011179/* bind hp and internal speaker mute (with plug check) as master switch */
11180static void alc262_hippo_master_update(struct hda_codec *codec)
11181{
11182 struct alc_spec *spec = codec->spec;
11183 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11184 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11185 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11186 unsigned int mute;
11187
11188 /* HP */
11189 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11190 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11191 HDA_AMP_MUTE, mute);
11192 /* mute internal speaker per jack sense */
11193 if (spec->jack_present)
11194 mute = HDA_AMP_MUTE;
11195 if (line_nid)
11196 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11197 HDA_AMP_MUTE, mute);
11198 if (speaker_nid && speaker_nid != line_nid)
11199 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11200 HDA_AMP_MUTE, mute);
11201}
11202
11203#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11204
11205static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11206 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011207{
11208 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011209 struct alc_spec *spec = codec->spec;
11210 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011211
Takashi Iwai42171c12009-05-08 14:11:43 +020011212 if (val == spec->master_sw)
11213 return 0;
11214 spec->master_sw = val;
11215 alc262_hippo_master_update(codec);
11216 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011217}
Takashi Iwai5b319542007-07-26 11:49:22 +020011218
Takashi Iwai42171c12009-05-08 14:11:43 +020011219#define ALC262_HIPPO_MASTER_SWITCH \
11220 { \
11221 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11222 .name = "Master Playback Switch", \
11223 .info = snd_ctl_boolean_mono_info, \
11224 .get = alc262_hippo_master_sw_get, \
11225 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011226 }, \
11227 { \
11228 .iface = NID_MAPPING, \
11229 .name = "Master Playback Switch", \
11230 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11231 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011232 }
11233
11234static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11235 ALC262_HIPPO_MASTER_SWITCH,
11236 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11237 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11238 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11239 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11240 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11241 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11242 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11243 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11244 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11245 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11246 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11247 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11248 { } /* end */
11249};
11250
11251static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11252 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11253 ALC262_HIPPO_MASTER_SWITCH,
11254 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11255 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11256 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11257 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11258 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11259 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11260 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11261 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11262 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11263 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11264 { } /* end */
11265};
11266
11267/* mute/unmute internal speaker according to the hp jack and mute state */
11268static void alc262_hippo_automute(struct hda_codec *codec)
11269{
11270 struct alc_spec *spec = codec->spec;
11271 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011272
Wu Fengguang864f92b2009-11-18 12:38:02 +080011273 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011274 alc262_hippo_master_update(codec);
11275}
11276
11277static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11278{
11279 if ((res >> 26) != ALC880_HP_EVENT)
11280 return;
11281 alc262_hippo_automute(codec);
11282}
11283
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011284static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011285{
11286 struct alc_spec *spec = codec->spec;
11287
11288 spec->autocfg.hp_pins[0] = 0x15;
11289 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011290}
11291
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011292static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011293{
11294 struct alc_spec *spec = codec->spec;
11295
11296 spec->autocfg.hp_pins[0] = 0x1b;
11297 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011298}
11299
11300
Kailang Yang272a5272007-05-14 11:00:38 +020011301static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011302 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011303 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011304 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11305 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11306 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11307 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11308 { } /* end */
11309};
11310
Kailang Yang83c34212007-07-05 11:43:05 +020011311static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011312 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11313 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011314 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11315 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11316 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11317 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11318 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11319 { } /* end */
11320};
Kailang Yang272a5272007-05-14 11:00:38 +020011321
Tony Vroonba340e82009-02-02 19:01:30 +000011322static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11323 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11324 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11325 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11326 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11327 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11328 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11329 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11330 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11331 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11332 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11333 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11334 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11335 { } /* end */
11336};
11337
11338static struct hda_verb alc262_tyan_verbs[] = {
11339 /* Headphone automute */
11340 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11341 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11342 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11343
11344 /* P11 AUX_IN, white 4-pin connector */
11345 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11346 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11347 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11348 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11349
11350 {}
11351};
11352
11353/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011354static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011355{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011356 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011357
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011358 spec->autocfg.hp_pins[0] = 0x1b;
11359 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011360}
11361
Tony Vroonba340e82009-02-02 19:01:30 +000011362
Kailang Yangdf694da2005-12-05 19:42:22 +010011363#define alc262_capture_mixer alc882_capture_mixer
11364#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11365
11366/*
11367 * generic initialization of ADC, input mixers and output mixers
11368 */
11369static struct hda_verb alc262_init_verbs[] = {
11370 /*
11371 * Unmute ADC0-2 and set the default input to mic-in
11372 */
11373 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11375 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11376 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11377 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11378 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11379
Takashi Iwaicb53c622007-08-10 17:21:45 +020011380 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011381 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011382 * Note: PASD motherboards uses the Line In 2 as the input for
11383 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011384 */
11385 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011386 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11387 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11388 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11389 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11390 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011391
11392 /*
11393 * Set up output mixers (0x0c - 0x0e)
11394 */
11395 /* set vol=0 to output mixers */
11396 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11397 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11398 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11399 /* set up input amps for analog loopback */
11400 /* Amp Indices: DAC = 0, mixer = 1 */
11401 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11402 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11403 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11404 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11405 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11406 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11407
11408 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11409 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11410 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11411 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11412 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11413 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11414
11415 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11416 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11417 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11418 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11419 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011420
Kailang Yangdf694da2005-12-05 19:42:22 +010011421 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11422 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011423
Kailang Yangdf694da2005-12-05 19:42:22 +010011424 /* FIXME: use matrix-type input source selection */
11425 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11426 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11427 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11428 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11429 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11430 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11431 /* Input mixer2 */
11432 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11433 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11434 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11435 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11436 /* Input mixer3 */
11437 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11438 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11439 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011440 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011441
11442 { }
11443};
11444
Kailang Yang4e555fe2008-08-26 13:05:55 +020011445static struct hda_verb alc262_eapd_verbs[] = {
11446 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11447 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11448 { }
11449};
11450
Kailang Yangccc656c2006-10-17 12:32:26 +020011451static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11452 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11453 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11454 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11455
11456 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11457 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11458 {}
11459};
11460
Kailang Yang272a5272007-05-14 11:00:38 +020011461static struct hda_verb alc262_sony_unsol_verbs[] = {
11462 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11463 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11464 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11465
11466 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11467 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011468 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011469};
11470
Kailang Yang4e555fe2008-08-26 13:05:55 +020011471static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11472 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11473 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11474 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11475 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11476 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011477 { } /* end */
11478};
11479
11480static struct hda_verb alc262_toshiba_s06_verbs[] = {
11481 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11482 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11483 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11484 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11485 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11486 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11487 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11488 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11489 {}
11490};
11491
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011492static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011493{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011494 struct alc_spec *spec = codec->spec;
11495
11496 spec->autocfg.hp_pins[0] = 0x15;
11497 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011498 spec->ext_mic.pin = 0x18;
11499 spec->ext_mic.mux_idx = 0;
11500 spec->int_mic.pin = 0x12;
11501 spec->int_mic.mux_idx = 9;
11502 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011503}
11504
Takashi Iwai834be882006-03-01 14:16:17 +010011505/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011506 * nec model
11507 * 0x15 = headphone
11508 * 0x16 = internal speaker
11509 * 0x18 = external mic
11510 */
11511
11512static struct snd_kcontrol_new alc262_nec_mixer[] = {
11513 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11514 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11515
11516 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11517 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11518 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11519
11520 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11521 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11522 { } /* end */
11523};
11524
11525static struct hda_verb alc262_nec_verbs[] = {
11526 /* Unmute Speaker */
11527 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11528
11529 /* Headphone */
11530 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11531 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11532
11533 /* External mic to headphone */
11534 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11535 /* External mic to speaker */
11536 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11537 {}
11538};
11539
11540/*
Takashi Iwai834be882006-03-01 14:16:17 +010011541 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011542 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11543 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011544 */
11545
11546#define ALC_HP_EVENT 0x37
11547
11548static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11549 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11550 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011551 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11552 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011553 {}
11554};
11555
Jiang zhe0e31daf2008-03-20 12:12:39 +010011556static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11557 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11558 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11559 {}
11560};
11561
Daniel T Chene2595322009-12-19 18:19:02 -050011562static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11563 /* Front Mic pin: input vref at 50% */
11564 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11565 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11566 {}
11567};
11568
Takashi Iwai834be882006-03-01 14:16:17 +010011569static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011570 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011571 .items = {
11572 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011573 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011574 { "CD", 0x4 },
11575 },
11576};
11577
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011578static struct hda_input_mux alc262_HP_capture_source = {
11579 .num_items = 5,
11580 .items = {
11581 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011582 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011583 { "Line", 0x2 },
11584 { "CD", 0x4 },
11585 { "AUX IN", 0x6 },
11586 },
11587};
11588
zhejiangaccbe492007-08-31 12:36:05 +020011589static struct hda_input_mux alc262_HP_D7000_capture_source = {
11590 .num_items = 4,
11591 .items = {
11592 { "Mic", 0x0 },
11593 { "Front Mic", 0x2 },
11594 { "Line", 0x1 },
11595 { "CD", 0x4 },
11596 },
11597};
11598
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011599/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011600static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11601{
11602 struct alc_spec *spec = codec->spec;
11603 unsigned int mute;
11604
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011605 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011606 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11607 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011608 spec->sense_updated = 1;
11609 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011610 /* unmute internal speaker only if both HPs are unplugged and
11611 * master switch is on
11612 */
11613 if (spec->jack_present)
11614 mute = HDA_AMP_MUTE;
11615 else
Takashi Iwai834be882006-03-01 14:16:17 +010011616 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011617 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11618 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011619}
11620
11621/* unsolicited event for HP jack sensing */
11622static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11623 unsigned int res)
11624{
11625 if ((res >> 26) != ALC_HP_EVENT)
11626 return;
11627 alc262_fujitsu_automute(codec, 1);
11628}
11629
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011630static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11631{
11632 alc262_fujitsu_automute(codec, 1);
11633}
11634
Takashi Iwai834be882006-03-01 14:16:17 +010011635/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011636static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11637 .ops = &snd_hda_bind_vol,
11638 .values = {
11639 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11640 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11641 0
11642 },
11643};
Takashi Iwai834be882006-03-01 14:16:17 +010011644
Jiang zhe0e31daf2008-03-20 12:12:39 +010011645/* mute/unmute internal speaker according to the hp jack and mute state */
11646static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11647{
11648 struct alc_spec *spec = codec->spec;
11649 unsigned int mute;
11650
11651 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011652 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011653 spec->sense_updated = 1;
11654 }
11655 if (spec->jack_present) {
11656 /* mute internal speaker */
11657 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11658 HDA_AMP_MUTE, HDA_AMP_MUTE);
11659 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11660 HDA_AMP_MUTE, HDA_AMP_MUTE);
11661 } else {
11662 /* unmute internal speaker if necessary */
11663 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11664 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11665 HDA_AMP_MUTE, mute);
11666 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11667 HDA_AMP_MUTE, mute);
11668 }
11669}
11670
11671/* unsolicited event for HP jack sensing */
11672static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11673 unsigned int res)
11674{
11675 if ((res >> 26) != ALC_HP_EVENT)
11676 return;
11677 alc262_lenovo_3000_automute(codec, 1);
11678}
11679
Takashi Iwai8de56b72009-07-24 16:51:47 +020011680static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11681 int dir, int idx, long *valp)
11682{
11683 int i, change = 0;
11684
11685 for (i = 0; i < 2; i++, valp++)
11686 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11687 HDA_AMP_MUTE,
11688 *valp ? 0 : HDA_AMP_MUTE);
11689 return change;
11690}
11691
Takashi Iwai834be882006-03-01 14:16:17 +010011692/* bind hp and internal speaker mute (with plug check) */
11693static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11694 struct snd_ctl_elem_value *ucontrol)
11695{
11696 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11697 long *valp = ucontrol->value.integer.value;
11698 int change;
11699
Takashi Iwai8de56b72009-07-24 16:51:47 +020011700 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11701 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011702 if (change)
11703 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011704 return change;
11705}
11706
11707static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011708 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011709 {
11710 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11711 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011712 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011713 .info = snd_hda_mixer_amp_switch_info,
11714 .get = snd_hda_mixer_amp_switch_get,
11715 .put = alc262_fujitsu_master_sw_put,
11716 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11717 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011718 {
11719 .iface = NID_MAPPING,
11720 .name = "Master Playback Switch",
11721 .private_value = 0x1b,
11722 },
Takashi Iwai834be882006-03-01 14:16:17 +010011723 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11724 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11725 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11726 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11727 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011728 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11729 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11730 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011731 { } /* end */
11732};
11733
Jiang zhe0e31daf2008-03-20 12:12:39 +010011734/* bind hp and internal speaker mute (with plug check) */
11735static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11736 struct snd_ctl_elem_value *ucontrol)
11737{
11738 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11739 long *valp = ucontrol->value.integer.value;
11740 int change;
11741
Takashi Iwai8de56b72009-07-24 16:51:47 +020011742 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011743 if (change)
11744 alc262_lenovo_3000_automute(codec, 0);
11745 return change;
11746}
11747
11748static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11749 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11750 {
11751 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11752 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011753 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011754 .info = snd_hda_mixer_amp_switch_info,
11755 .get = snd_hda_mixer_amp_switch_get,
11756 .put = alc262_lenovo_3000_master_sw_put,
11757 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11758 },
11759 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11760 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11761 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11762 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11763 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11764 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11765 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11766 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11767 { } /* end */
11768};
11769
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011770static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11771 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011772 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011773 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11774 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11775 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11776 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11777 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11778 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11779 { } /* end */
11780};
11781
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011782/* additional init verbs for Benq laptops */
11783static struct hda_verb alc262_EAPD_verbs[] = {
11784 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11785 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11786 {}
11787};
11788
Kailang Yang83c34212007-07-05 11:43:05 +020011789static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11790 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11791 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11792
11793 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11794 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11795 {}
11796};
11797
Tobin Davisf651b502007-10-26 12:40:47 +020011798/* Samsung Q1 Ultra Vista model setup */
11799static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011800 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11801 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11804 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011805 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011806 { } /* end */
11807};
11808
11809static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011810 /* output mixer */
11811 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11812 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11813 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11814 /* speaker */
11815 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11816 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11817 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11818 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11819 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011820 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011821 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11822 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11823 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11824 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11825 /* internal mic */
11826 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11827 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11828 /* ADC, choose mic */
11829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11830 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11831 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11832 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11833 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11834 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11835 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11836 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11837 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11838 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011839 {}
11840};
11841
Tobin Davisf651b502007-10-26 12:40:47 +020011842/* mute/unmute internal speaker according to the hp jack and mute state */
11843static void alc262_ultra_automute(struct hda_codec *codec)
11844{
11845 struct alc_spec *spec = codec->spec;
11846 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011847
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011848 mute = 0;
11849 /* auto-mute only when HP is used as HP */
11850 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011851 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011852 if (spec->jack_present)
11853 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011854 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011855 /* mute/unmute internal speaker */
11856 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11857 HDA_AMP_MUTE, mute);
11858 /* mute/unmute HP */
11859 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11860 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011861}
11862
11863/* unsolicited event for HP jack sensing */
11864static void alc262_ultra_unsol_event(struct hda_codec *codec,
11865 unsigned int res)
11866{
11867 if ((res >> 26) != ALC880_HP_EVENT)
11868 return;
11869 alc262_ultra_automute(codec);
11870}
11871
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011872static struct hda_input_mux alc262_ultra_capture_source = {
11873 .num_items = 2,
11874 .items = {
11875 { "Mic", 0x1 },
11876 { "Headphone", 0x7 },
11877 },
11878};
11879
11880static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11881 struct snd_ctl_elem_value *ucontrol)
11882{
11883 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11884 struct alc_spec *spec = codec->spec;
11885 int ret;
11886
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011887 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011888 if (!ret)
11889 return 0;
11890 /* reprogram the HP pin as mic or HP according to the input source */
11891 snd_hda_codec_write_cache(codec, 0x15, 0,
11892 AC_VERB_SET_PIN_WIDGET_CONTROL,
11893 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11894 alc262_ultra_automute(codec); /* mute/unmute HP */
11895 return ret;
11896}
11897
11898static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11899 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11900 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11901 {
11902 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11903 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011904 .info = alc_mux_enum_info,
11905 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011906 .put = alc262_ultra_mux_enum_put,
11907 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011908 {
11909 .iface = NID_MAPPING,
11910 .name = "Capture Source",
11911 .private_value = 0x15,
11912 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011913 { } /* end */
11914};
11915
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011916/* We use two mixers depending on the output pin; 0x16 is a mono output
11917 * and thus it's bound with a different mixer.
11918 * This function returns which mixer amp should be used.
11919 */
11920static int alc262_check_volbit(hda_nid_t nid)
11921{
11922 if (!nid)
11923 return 0;
11924 else if (nid == 0x16)
11925 return 2;
11926 else
11927 return 1;
11928}
11929
11930static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011931 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011932{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011933 unsigned long val;
11934 int vbit;
11935
11936 vbit = alc262_check_volbit(nid);
11937 if (!vbit)
11938 return 0;
11939 if (*vbits & vbit) /* a volume control for this mixer already there */
11940 return 0;
11941 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011942 if (vbit == 2)
11943 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11944 else
11945 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011946 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011947}
11948
11949static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011950 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011951{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011952 unsigned long val;
11953
11954 if (!nid)
11955 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011956 if (nid == 0x16)
11957 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11958 else
11959 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011960 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011961}
11962
Kailang Yangdf694da2005-12-05 19:42:22 +010011963/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011964static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11965 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011966{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011967 const char *pfx;
11968 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020011969 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011970
11971 spec->multiout.num_dacs = 1; /* only use one dac */
11972 spec->multiout.dac_nids = spec->private_dac_nids;
11973 spec->multiout.dac_nids[0] = 2;
11974
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011975 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
11976 pfx = "Master";
11977 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
11978 pfx = "Speaker";
Takashi Iwai033688a2010-09-08 15:47:09 +020011979 else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
11980 pfx = "Headphone";
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011981 else
11982 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020011983 for (i = 0; i < 2; i++) {
11984 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
11985 if (err < 0)
11986 return err;
11987 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
11988 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
11989 "Speaker", i);
11990 if (err < 0)
11991 return err;
11992 }
11993 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
11994 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
11995 "Headphone", i);
11996 if (err < 0)
11997 return err;
11998 }
11999 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012000
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012001 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12002 alc262_check_volbit(cfg->speaker_pins[0]) |
12003 alc262_check_volbit(cfg->hp_pins[0]);
12004 if (vbits == 1 || vbits == 2)
12005 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012006 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012007 for (i = 0; i < 2; i++) {
12008 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12009 &vbits, i);
12010 if (err < 0)
12011 return err;
12012 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12013 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12014 "Speaker", &vbits, i);
12015 if (err < 0)
12016 return err;
12017 }
12018 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12019 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12020 "Headphone", &vbits, i);
12021 if (err < 0)
12022 return err;
12023 }
12024 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012025 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012026}
12027
Takashi Iwai05f5f472009-08-25 13:10:18 +020012028#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012029 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012030
12031/*
12032 * generic initialization of ADC, input mixers and output mixers
12033 */
12034static struct hda_verb alc262_volume_init_verbs[] = {
12035 /*
12036 * Unmute ADC0-2 and set the default input to mic-in
12037 */
12038 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12039 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12040 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12041 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12042 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12043 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12044
Takashi Iwaicb53c622007-08-10 17:21:45 +020012045 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012046 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012047 * Note: PASD motherboards uses the Line In 2 as the input for
12048 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012049 */
12050 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012051 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12052 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12053 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12054 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12055 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012056
12057 /*
12058 * Set up output mixers (0x0c - 0x0f)
12059 */
12060 /* set vol=0 to output mixers */
12061 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12062 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12063 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012064
Kailang Yangdf694da2005-12-05 19:42:22 +010012065 /* set up input amps for analog loopback */
12066 /* Amp Indices: DAC = 0, mixer = 1 */
12067 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12068 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12069 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12070 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12071 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12072 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12073
12074 /* FIXME: use matrix-type input source selection */
12075 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12076 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12077 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12078 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12079 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12080 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12081 /* Input mixer2 */
12082 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12083 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12084 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12085 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12086 /* Input mixer3 */
12087 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12088 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12089 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12090 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12091
12092 { }
12093};
12094
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012095static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12096 /*
12097 * Unmute ADC0-2 and set the default input to mic-in
12098 */
12099 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12100 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12101 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12102 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12103 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12104 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12105
Takashi Iwaicb53c622007-08-10 17:21:45 +020012106 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012107 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012108 * Note: PASD motherboards uses the Line In 2 as the input for
12109 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012110 */
12111 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012112 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12113 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12114 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12115 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12116 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12117 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12118 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012119
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012120 /*
12121 * Set up output mixers (0x0c - 0x0e)
12122 */
12123 /* set vol=0 to output mixers */
12124 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12125 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12126 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12127
12128 /* set up input amps for analog loopback */
12129 /* Amp Indices: DAC = 0, mixer = 1 */
12130 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12131 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12132 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12133 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12134 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12135 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12136
Takashi Iwaice875f02008-01-28 18:17:43 +010012137 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012138 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12139 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12140
12141 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12142 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12143
12144 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12145 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12146
12147 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12148 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12149 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12150 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12151 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12152
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012153 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012154 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12155 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012156 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012157 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12158 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12159
12160
12161 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012162 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12163 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012164 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012165 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12166 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12167 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12168 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12169 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12170 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12171 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12172 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012173 /* Input mixer2 */
12174 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012175 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12176 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12177 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12178 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12179 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12180 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12181 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12182 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012183 /* Input mixer3 */
12184 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012185 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12186 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12187 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12188 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12190 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12191 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12192 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012193
Takashi Iwaice875f02008-01-28 18:17:43 +010012194 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12195
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012196 { }
12197};
12198
Kailang Yangcd7509a2007-01-26 18:33:17 +010012199static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12200 /*
12201 * Unmute ADC0-2 and set the default input to mic-in
12202 */
12203 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12204 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12205 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12206 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12207 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12208 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12209
Takashi Iwaicb53c622007-08-10 17:21:45 +020012210 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012211 * mixer widget
12212 * Note: PASD motherboards uses the Line In 2 as the input for front
12213 * panel mic (mic 2)
12214 */
12215 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012216 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12217 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12218 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12219 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12220 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12222 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12223 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012224 /*
12225 * Set up output mixers (0x0c - 0x0e)
12226 */
12227 /* set vol=0 to output mixers */
12228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12229 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12230 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12231
12232 /* set up input amps for analog loopback */
12233 /* Amp Indices: DAC = 0, mixer = 1 */
12234 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12235 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12236 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12237 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12238 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12239 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12240
12241
12242 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12243 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12244 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12245 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12246 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12247 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12248 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12249
12250 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12251 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12252
12253 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12254 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12255
12256 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12257 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12258 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12259 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12260 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12261 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12262
12263 /* FIXME: use matrix-type input source selection */
12264 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12265 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12266 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12267 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12268 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12269 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12270 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12271 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12272 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12273 /* Input mixer2 */
12274 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12275 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12276 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12277 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12278 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12279 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12280 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12281 /* Input mixer3 */
12282 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12283 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12284 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12285 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12286 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12287 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12288 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12289
Takashi Iwaice875f02008-01-28 18:17:43 +010012290 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12291
Kailang Yangcd7509a2007-01-26 18:33:17 +010012292 { }
12293};
12294
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012295static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12296
12297 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12298 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12299 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12300
12301 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12302 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12303 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12304 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12305
12306 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12307 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12308 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12309 {}
12310};
12311
Takashi Iwai18675e42010-09-08 15:55:44 +020012312/*
12313 * Pin config fixes
12314 */
12315enum {
12316 PINFIX_FSC_H270,
12317};
12318
12319static const struct alc_fixup alc262_fixups[] = {
12320 [PINFIX_FSC_H270] = {
12321 .pins = (const struct alc_pincfg[]) {
12322 { 0x14, 0x99130110 }, /* speaker */
12323 { 0x15, 0x0221142f }, /* front HP */
12324 { 0x1b, 0x0121141f }, /* rear HP */
12325 { }
12326 }
12327 },
12328 [PINFIX_PB_M5210] = {
12329 .verbs = (const struct hda_verb[]) {
12330 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12331 {}
12332 }
12333 },
12334};
12335
12336static struct snd_pci_quirk alc262_fixup_tbl[] = {
12337 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12338 {}
12339};
12340
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012341
Takashi Iwaicb53c622007-08-10 17:21:45 +020012342#ifdef CONFIG_SND_HDA_POWER_SAVE
12343#define alc262_loopbacks alc880_loopbacks
12344#endif
12345
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012346/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012347#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12348#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12349#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12350#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12351
12352/*
12353 * BIOS auto configuration
12354 */
12355static int alc262_parse_auto_config(struct hda_codec *codec)
12356{
12357 struct alc_spec *spec = codec->spec;
12358 int err;
12359 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12360
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012361 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12362 alc262_ignore);
12363 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012364 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012365 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012366 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012367 spec->multiout.max_channels = 2;
12368 spec->no_analog = 1;
12369 goto dig_only;
12370 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012371 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012372 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012373 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12374 if (err < 0)
12375 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012376 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012377 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012378 return err;
12379
12380 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12381
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012382 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012383 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012384
Takashi Iwai603c4012008-07-30 15:01:44 +020012385 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012386 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012387
Takashi Iwaid88897e2008-10-31 15:01:37 +010012388 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012389 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012390 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012391
Takashi Iwai776e1842007-08-29 15:07:11 +020012392 err = alc_auto_add_mic_boost(codec);
12393 if (err < 0)
12394 return err;
12395
Kailang Yang6227cdc2010-02-25 08:36:52 +010012396 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012397
Kailang Yangdf694da2005-12-05 19:42:22 +010012398 return 1;
12399}
12400
12401#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12402#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12403#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012404#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012405
12406
12407/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012408static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012409{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012410 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012411 alc262_auto_init_multi_out(codec);
12412 alc262_auto_init_hp_out(codec);
12413 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012414 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012415 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012416 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012417 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012418}
12419
12420/*
12421 * configuration and preset
12422 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012423static const char *alc262_models[ALC262_MODEL_LAST] = {
12424 [ALC262_BASIC] = "basic",
12425 [ALC262_HIPPO] = "hippo",
12426 [ALC262_HIPPO_1] = "hippo_1",
12427 [ALC262_FUJITSU] = "fujitsu",
12428 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012429 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012430 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012431 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012432 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012433 [ALC262_BENQ_T31] = "benq-t31",
12434 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012435 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012436 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012437 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012438 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012439 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012440 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012441 [ALC262_AUTO] = "auto",
12442};
12443
12444static struct snd_pci_quirk alc262_cfg_tbl[] = {
12445 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012446 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012447 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12448 ALC262_HP_BPC),
12449 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12450 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012451 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12452 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012453 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012454 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012455 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012456 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012457 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012458 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012459 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012460 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012461 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12462 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12463 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012464 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12465 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012466 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012467 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012468 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012469 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012470 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012471 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012472 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012473 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012474#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012475 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12476 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012477#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012478 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012479 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012480 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012481 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012482 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012483 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012484 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12485 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012486 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012487 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012488 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012489 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012490 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012491 {}
12492};
12493
12494static struct alc_config_preset alc262_presets[] = {
12495 [ALC262_BASIC] = {
12496 .mixers = { alc262_base_mixer },
12497 .init_verbs = { alc262_init_verbs },
12498 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12499 .dac_nids = alc262_dac_nids,
12500 .hp_nid = 0x03,
12501 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12502 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012503 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012504 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012505 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012506 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012507 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012508 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12509 .dac_nids = alc262_dac_nids,
12510 .hp_nid = 0x03,
12511 .dig_out_nid = ALC262_DIGOUT_NID,
12512 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12513 .channel_mode = alc262_modes,
12514 .input_mux = &alc262_capture_source,
12515 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012516 .setup = alc262_hippo_setup,
12517 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012518 },
12519 [ALC262_HIPPO_1] = {
12520 .mixers = { alc262_hippo1_mixer },
12521 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12522 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12523 .dac_nids = alc262_dac_nids,
12524 .hp_nid = 0x02,
12525 .dig_out_nid = ALC262_DIGOUT_NID,
12526 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12527 .channel_mode = alc262_modes,
12528 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012529 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012530 .setup = alc262_hippo1_setup,
12531 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012532 },
Takashi Iwai834be882006-03-01 14:16:17 +010012533 [ALC262_FUJITSU] = {
12534 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012535 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12536 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012537 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12538 .dac_nids = alc262_dac_nids,
12539 .hp_nid = 0x03,
12540 .dig_out_nid = ALC262_DIGOUT_NID,
12541 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12542 .channel_mode = alc262_modes,
12543 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012544 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012545 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012546 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012547 [ALC262_HP_BPC] = {
12548 .mixers = { alc262_HP_BPC_mixer },
12549 .init_verbs = { alc262_HP_BPC_init_verbs },
12550 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12551 .dac_nids = alc262_dac_nids,
12552 .hp_nid = 0x03,
12553 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12554 .channel_mode = alc262_modes,
12555 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012556 .unsol_event = alc262_hp_bpc_unsol_event,
12557 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012558 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012559 [ALC262_HP_BPC_D7000_WF] = {
12560 .mixers = { alc262_HP_BPC_WildWest_mixer },
12561 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12562 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12563 .dac_nids = alc262_dac_nids,
12564 .hp_nid = 0x03,
12565 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12566 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012567 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012568 .unsol_event = alc262_hp_wildwest_unsol_event,
12569 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012570 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012571 [ALC262_HP_BPC_D7000_WL] = {
12572 .mixers = { alc262_HP_BPC_WildWest_mixer,
12573 alc262_HP_BPC_WildWest_option_mixer },
12574 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12575 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12576 .dac_nids = alc262_dac_nids,
12577 .hp_nid = 0x03,
12578 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12579 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012580 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012581 .unsol_event = alc262_hp_wildwest_unsol_event,
12582 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012583 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012584 [ALC262_HP_TC_T5735] = {
12585 .mixers = { alc262_hp_t5735_mixer },
12586 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12587 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12588 .dac_nids = alc262_dac_nids,
12589 .hp_nid = 0x03,
12590 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12591 .channel_mode = alc262_modes,
12592 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012593 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012594 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012595 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012596 },
12597 [ALC262_HP_RP5700] = {
12598 .mixers = { alc262_hp_rp5700_mixer },
12599 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12600 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12601 .dac_nids = alc262_dac_nids,
12602 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12603 .channel_mode = alc262_modes,
12604 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012605 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012606 [ALC262_BENQ_ED8] = {
12607 .mixers = { alc262_base_mixer },
12608 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12609 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12610 .dac_nids = alc262_dac_nids,
12611 .hp_nid = 0x03,
12612 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12613 .channel_mode = alc262_modes,
12614 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012615 },
Kailang Yang272a5272007-05-14 11:00:38 +020012616 [ALC262_SONY_ASSAMD] = {
12617 .mixers = { alc262_sony_mixer },
12618 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12619 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12620 .dac_nids = alc262_dac_nids,
12621 .hp_nid = 0x02,
12622 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12623 .channel_mode = alc262_modes,
12624 .input_mux = &alc262_capture_source,
12625 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012626 .setup = alc262_hippo_setup,
12627 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012628 },
12629 [ALC262_BENQ_T31] = {
12630 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012631 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12632 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012633 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12634 .dac_nids = alc262_dac_nids,
12635 .hp_nid = 0x03,
12636 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12637 .channel_mode = alc262_modes,
12638 .input_mux = &alc262_capture_source,
12639 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012640 .setup = alc262_hippo_setup,
12641 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012642 },
Tobin Davisf651b502007-10-26 12:40:47 +020012643 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012644 .mixers = { alc262_ultra_mixer },
12645 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012646 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012647 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12648 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012649 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12650 .channel_mode = alc262_modes,
12651 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012652 .adc_nids = alc262_adc_nids, /* ADC0 */
12653 .capsrc_nids = alc262_capsrc_nids,
12654 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012655 .unsol_event = alc262_ultra_unsol_event,
12656 .init_hook = alc262_ultra_automute,
12657 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012658 [ALC262_LENOVO_3000] = {
12659 .mixers = { alc262_lenovo_3000_mixer },
12660 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012661 alc262_lenovo_3000_unsol_verbs,
12662 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012663 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12664 .dac_nids = alc262_dac_nids,
12665 .hp_nid = 0x03,
12666 .dig_out_nid = ALC262_DIGOUT_NID,
12667 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12668 .channel_mode = alc262_modes,
12669 .input_mux = &alc262_fujitsu_capture_source,
12670 .unsol_event = alc262_lenovo_3000_unsol_event,
12671 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012672 [ALC262_NEC] = {
12673 .mixers = { alc262_nec_mixer },
12674 .init_verbs = { alc262_nec_verbs },
12675 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12676 .dac_nids = alc262_dac_nids,
12677 .hp_nid = 0x03,
12678 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12679 .channel_mode = alc262_modes,
12680 .input_mux = &alc262_capture_source,
12681 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012682 [ALC262_TOSHIBA_S06] = {
12683 .mixers = { alc262_toshiba_s06_mixer },
12684 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12685 alc262_eapd_verbs },
12686 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12687 .capsrc_nids = alc262_dmic_capsrc_nids,
12688 .dac_nids = alc262_dac_nids,
12689 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012690 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012691 .dig_out_nid = ALC262_DIGOUT_NID,
12692 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12693 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012694 .unsol_event = alc_sku_unsol_event,
12695 .setup = alc262_toshiba_s06_setup,
12696 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012697 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012698 [ALC262_TOSHIBA_RX1] = {
12699 .mixers = { alc262_toshiba_rx1_mixer },
12700 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12701 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12702 .dac_nids = alc262_dac_nids,
12703 .hp_nid = 0x03,
12704 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12705 .channel_mode = alc262_modes,
12706 .input_mux = &alc262_capture_source,
12707 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012708 .setup = alc262_hippo_setup,
12709 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012710 },
Tony Vroonba340e82009-02-02 19:01:30 +000012711 [ALC262_TYAN] = {
12712 .mixers = { alc262_tyan_mixer },
12713 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12714 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12715 .dac_nids = alc262_dac_nids,
12716 .hp_nid = 0x02,
12717 .dig_out_nid = ALC262_DIGOUT_NID,
12718 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12719 .channel_mode = alc262_modes,
12720 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012721 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012722 .setup = alc262_tyan_setup,
12723 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012724 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012725};
12726
12727static int patch_alc262(struct hda_codec *codec)
12728{
12729 struct alc_spec *spec;
12730 int board_config;
12731 int err;
12732
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012733 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012734 if (spec == NULL)
12735 return -ENOMEM;
12736
12737 codec->spec = spec;
12738#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012739 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12740 * under-run
12741 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012742 {
12743 int tmp;
12744 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12745 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12746 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12747 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12748 }
12749#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012750 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012751
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012752 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12753
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012754 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12755 alc262_models,
12756 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012757
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012758 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012759 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12760 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012761 board_config = ALC262_AUTO;
12762 }
12763
Takashi Iwai18675e42010-09-08 15:55:44 +020012764 if (board_config == ALC262_AUTO)
12765 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12766
Kailang Yangdf694da2005-12-05 19:42:22 +010012767 if (board_config == ALC262_AUTO) {
12768 /* automatic parse from the BIOS config */
12769 err = alc262_parse_auto_config(codec);
12770 if (err < 0) {
12771 alc_free(codec);
12772 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012773 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012774 printk(KERN_INFO
12775 "hda_codec: Cannot set up configuration "
12776 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012777 board_config = ALC262_BASIC;
12778 }
12779 }
12780
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012781 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012782 err = snd_hda_attach_beep_device(codec, 0x1);
12783 if (err < 0) {
12784 alc_free(codec);
12785 return err;
12786 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012787 }
12788
Kailang Yangdf694da2005-12-05 19:42:22 +010012789 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012790 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012791
Kailang Yangdf694da2005-12-05 19:42:22 +010012792 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12793 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012794
Kailang Yangdf694da2005-12-05 19:42:22 +010012795 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12796 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12797
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012798 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012799 int i;
12800 /* check whether the digital-mic has to be supported */
12801 for (i = 0; i < spec->input_mux->num_items; i++) {
12802 if (spec->input_mux->items[i].index >= 9)
12803 break;
12804 }
12805 if (i < spec->input_mux->num_items) {
12806 /* use only ADC0 */
12807 spec->adc_nids = alc262_dmic_adc_nids;
12808 spec->num_adc_nids = 1;
12809 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012810 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012811 /* all analog inputs */
12812 /* check whether NID 0x07 is valid */
12813 unsigned int wcap = get_wcaps(codec, 0x07);
12814
12815 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012816 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012817 if (wcap != AC_WID_AUD_IN) {
12818 spec->adc_nids = alc262_adc_nids_alt;
12819 spec->num_adc_nids =
12820 ARRAY_SIZE(alc262_adc_nids_alt);
12821 spec->capsrc_nids = alc262_capsrc_nids_alt;
12822 } else {
12823 spec->adc_nids = alc262_adc_nids;
12824 spec->num_adc_nids =
12825 ARRAY_SIZE(alc262_adc_nids);
12826 spec->capsrc_nids = alc262_capsrc_nids;
12827 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012828 }
12829 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012830 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012831 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012832 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012833 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012834
Takashi Iwai18675e42010-09-08 15:55:44 +020012835 if (board_config == ALC262_AUTO)
12836 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12837
Takashi Iwai2134ea42008-01-10 16:53:55 +010012838 spec->vmaster_nid = 0x0c;
12839
Kailang Yangdf694da2005-12-05 19:42:22 +010012840 codec->patch_ops = alc_patch_ops;
12841 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012842 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012843#ifdef CONFIG_SND_HDA_POWER_SAVE
12844 if (!spec->loopback.amplist)
12845 spec->loopback.amplist = alc262_loopbacks;
12846#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012847
Kailang Yangdf694da2005-12-05 19:42:22 +010012848 return 0;
12849}
12850
Kailang Yangdf694da2005-12-05 19:42:22 +010012851/*
Kailang Yanga361d842007-06-05 12:30:55 +020012852 * ALC268 channel source setting (2 channel)
12853 */
12854#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12855#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012856
Kailang Yanga361d842007-06-05 12:30:55 +020012857static hda_nid_t alc268_dac_nids[2] = {
12858 /* front, hp */
12859 0x02, 0x03
12860};
12861
12862static hda_nid_t alc268_adc_nids[2] = {
12863 /* ADC0-1 */
12864 0x08, 0x07
12865};
12866
12867static hda_nid_t alc268_adc_nids_alt[1] = {
12868 /* ADC0 */
12869 0x08
12870};
12871
Takashi Iwaie1406342008-02-11 18:32:32 +010012872static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12873
Kailang Yanga361d842007-06-05 12:30:55 +020012874static struct snd_kcontrol_new alc268_base_mixer[] = {
12875 /* output mixer control */
12876 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12877 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12878 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12879 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012880 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12881 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12882 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012883 { }
12884};
12885
Takashi Iwai42171c12009-05-08 14:11:43 +020012886static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12887 /* output mixer control */
12888 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12889 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12890 ALC262_HIPPO_MASTER_SWITCH,
12891 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12892 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12893 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12894 { }
12895};
12896
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012897/* bind Beep switches of both NID 0x0f and 0x10 */
12898static struct hda_bind_ctls alc268_bind_beep_sw = {
12899 .ops = &snd_hda_bind_sw,
12900 .values = {
12901 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12902 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12903 0
12904 },
12905};
12906
12907static struct snd_kcontrol_new alc268_beep_mixer[] = {
12908 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12909 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12910 { }
12911};
12912
Kailang Yangd1a991a2007-08-15 16:21:59 +020012913static struct hda_verb alc268_eapd_verbs[] = {
12914 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12915 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12916 { }
12917};
12918
Takashi Iwaid2738092007-08-16 14:59:45 +020012919/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012920static struct hda_verb alc268_toshiba_verbs[] = {
12921 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12922 { } /* end */
12923};
12924
12925/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012926/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012927static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12928 .ops = &snd_hda_bind_vol,
12929 .values = {
12930 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12931 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12932 0
12933 },
12934};
12935
Takashi Iwai889c4392007-08-23 18:56:52 +020012936/* mute/unmute internal speaker according to the hp jack and mute state */
12937static void alc268_acer_automute(struct hda_codec *codec, int force)
12938{
12939 struct alc_spec *spec = codec->spec;
12940 unsigned int mute;
12941
12942 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012943 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012944 spec->sense_updated = 1;
12945 }
12946 if (spec->jack_present)
12947 mute = HDA_AMP_MUTE; /* mute internal speaker */
12948 else /* unmute internal speaker if necessary */
12949 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12950 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12951 HDA_AMP_MUTE, mute);
12952}
12953
12954
12955/* bind hp and internal speaker mute (with plug check) */
12956static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12957 struct snd_ctl_elem_value *ucontrol)
12958{
12959 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12960 long *valp = ucontrol->value.integer.value;
12961 int change;
12962
Takashi Iwai8de56b72009-07-24 16:51:47 +020012963 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012964 if (change)
12965 alc268_acer_automute(codec, 0);
12966 return change;
12967}
Takashi Iwaid2738092007-08-16 14:59:45 +020012968
Kailang Yang8ef355d2008-08-26 13:10:22 +020012969static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12970 /* output mixer control */
12971 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12972 {
12973 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12974 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012975 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020012976 .info = snd_hda_mixer_amp_switch_info,
12977 .get = snd_hda_mixer_amp_switch_get,
12978 .put = alc268_acer_master_sw_put,
12979 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12980 },
12981 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
12982 { }
12983};
12984
Takashi Iwaid2738092007-08-16 14:59:45 +020012985static struct snd_kcontrol_new alc268_acer_mixer[] = {
12986 /* output mixer control */
12987 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
12988 {
12989 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12990 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010012991 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020012992 .info = snd_hda_mixer_amp_switch_info,
12993 .get = snd_hda_mixer_amp_switch_get,
12994 .put = alc268_acer_master_sw_put,
12995 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
12996 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012997 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12998 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
12999 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013000 { }
13001};
13002
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013003static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13004 /* output mixer control */
13005 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13006 {
13007 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13008 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013009 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013010 .info = snd_hda_mixer_amp_switch_info,
13011 .get = snd_hda_mixer_amp_switch_get,
13012 .put = alc268_acer_master_sw_put,
13013 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13014 },
13015 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13016 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13017 { }
13018};
13019
Kailang Yang8ef355d2008-08-26 13:10:22 +020013020static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13021 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13022 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13023 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13024 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13025 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13026 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13027 { }
13028};
13029
Takashi Iwaid2738092007-08-16 14:59:45 +020013030static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013031 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13032 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013033 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13034 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013035 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13036 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013037 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13038 { }
13039};
13040
13041/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013042#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013043#define alc268_toshiba_setup alc262_hippo_setup
13044#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013045
13046static void alc268_acer_unsol_event(struct hda_codec *codec,
13047 unsigned int res)
13048{
Takashi Iwai889c4392007-08-23 18:56:52 +020013049 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013050 return;
13051 alc268_acer_automute(codec, 1);
13052}
13053
Takashi Iwai889c4392007-08-23 18:56:52 +020013054static void alc268_acer_init_hook(struct hda_codec *codec)
13055{
13056 alc268_acer_automute(codec, 1);
13057}
13058
Kailang Yang8ef355d2008-08-26 13:10:22 +020013059/* toggle speaker-output according to the hp-jack state */
13060static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13061{
13062 unsigned int present;
13063 unsigned char bits;
13064
Wu Fengguang864f92b2009-11-18 12:38:02 +080013065 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013066 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013067 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013068 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013069 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013070 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013071}
13072
Kailang Yang8ef355d2008-08-26 13:10:22 +020013073static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13074 unsigned int res)
13075{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013076 switch (res >> 26) {
13077 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013078 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013079 break;
13080 case ALC880_MIC_EVENT:
13081 alc_mic_automute(codec);
13082 break;
13083 }
13084}
13085
13086static void alc268_acer_lc_setup(struct hda_codec *codec)
13087{
13088 struct alc_spec *spec = codec->spec;
13089 spec->ext_mic.pin = 0x18;
13090 spec->ext_mic.mux_idx = 0;
13091 spec->int_mic.pin = 0x12;
13092 spec->int_mic.mux_idx = 6;
13093 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013094}
13095
13096static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13097{
13098 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013099 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013100}
13101
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013102static struct snd_kcontrol_new alc268_dell_mixer[] = {
13103 /* output mixer control */
13104 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13105 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13106 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13107 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13108 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13109 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13110 { }
13111};
13112
13113static struct hda_verb alc268_dell_verbs[] = {
13114 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13115 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13116 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013117 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013118 { }
13119};
13120
13121/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013122static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013123{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013124 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013125
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013126 spec->autocfg.hp_pins[0] = 0x15;
13127 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013128 spec->ext_mic.pin = 0x18;
13129 spec->ext_mic.mux_idx = 0;
13130 spec->int_mic.pin = 0x19;
13131 spec->int_mic.mux_idx = 1;
13132 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013133}
13134
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013135static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13136 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13137 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13138 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13139 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13140 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13141 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13142 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13143 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13144 { }
13145};
13146
13147static struct hda_verb alc267_quanta_il1_verbs[] = {
13148 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13149 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13150 { }
13151};
13152
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013153static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013154{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013155 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013156 spec->autocfg.hp_pins[0] = 0x15;
13157 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013158 spec->ext_mic.pin = 0x18;
13159 spec->ext_mic.mux_idx = 0;
13160 spec->int_mic.pin = 0x19;
13161 spec->int_mic.mux_idx = 1;
13162 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013163}
13164
Kailang Yanga361d842007-06-05 12:30:55 +020013165/*
13166 * generic initialization of ADC, input mixers and output mixers
13167 */
13168static struct hda_verb alc268_base_init_verbs[] = {
13169 /* Unmute DAC0-1 and set vol = 0 */
13170 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013171 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013172
13173 /*
13174 * Set up output mixers (0x0c - 0x0e)
13175 */
13176 /* set vol=0 to output mixers */
13177 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013178 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13179
13180 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13181 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13182
13183 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13184 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13185 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13186 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13187 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13188 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13189 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13190 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13191
13192 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13193 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13194 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13195 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013196 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013197
13198 /* set PCBEEP vol = 0, mute connections */
13199 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13200 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13201 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013202
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013203 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013204
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013205 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13206 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13207 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13208 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013209
Kailang Yanga361d842007-06-05 12:30:55 +020013210 { }
13211};
13212
13213/*
13214 * generic initialization of ADC, input mixers and output mixers
13215 */
13216static struct hda_verb alc268_volume_init_verbs[] = {
13217 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013218 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13219 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013220
13221 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13222 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13223 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13224 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13225 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13226
Kailang Yanga361d842007-06-05 12:30:55 +020013227 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013228 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13229 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13230
13231 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013232 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013233
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013234 /* set PCBEEP vol = 0, mute connections */
13235 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13236 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13237 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013238
13239 { }
13240};
13241
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013242static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13243 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13244 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13245 { } /* end */
13246};
13247
Kailang Yanga361d842007-06-05 12:30:55 +020013248static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13249 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13250 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013251 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013252 { } /* end */
13253};
13254
13255static struct snd_kcontrol_new alc268_capture_mixer[] = {
13256 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13257 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13258 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13259 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013260 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013261 { } /* end */
13262};
13263
13264static struct hda_input_mux alc268_capture_source = {
13265 .num_items = 4,
13266 .items = {
13267 { "Mic", 0x0 },
13268 { "Front Mic", 0x1 },
13269 { "Line", 0x2 },
13270 { "CD", 0x3 },
13271 },
13272};
13273
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013274static struct hda_input_mux alc268_acer_capture_source = {
13275 .num_items = 3,
13276 .items = {
13277 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013278 { "Internal Mic", 0x1 },
13279 { "Line", 0x2 },
13280 },
13281};
13282
13283static struct hda_input_mux alc268_acer_dmic_capture_source = {
13284 .num_items = 3,
13285 .items = {
13286 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013287 { "Internal Mic", 0x6 },
13288 { "Line", 0x2 },
13289 },
13290};
13291
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013292#ifdef CONFIG_SND_DEBUG
13293static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013294 /* Volume widgets */
13295 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13296 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13297 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13298 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13299 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13300 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13301 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13302 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13303 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13304 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13305 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13306 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13307 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013308 /* The below appears problematic on some hardwares */
13309 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013310 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13311 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13312 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13313 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13314
13315 /* Modes for retasking pin widgets */
13316 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13317 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13318 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13319 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13320
13321 /* Controls for GPIO pins, assuming they are configured as outputs */
13322 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13323 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13324 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13325 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13326
13327 /* Switches to allow the digital SPDIF output pin to be enabled.
13328 * The ALC268 does not have an SPDIF input.
13329 */
13330 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13331
13332 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13333 * this output to turn on an external amplifier.
13334 */
13335 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13336 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13337
13338 { } /* end */
13339};
13340#endif
13341
Kailang Yanga361d842007-06-05 12:30:55 +020013342/* create input playback/capture controls for the given pin */
13343static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13344 const char *ctlname, int idx)
13345{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013346 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013347 int err;
13348
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013349 switch (nid) {
13350 case 0x14:
13351 case 0x16:
13352 dac = 0x02;
13353 break;
13354 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013355 case 0x1a: /* ALC259/269 only */
13356 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013357 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013358 dac = 0x03;
13359 break;
13360 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013361 snd_printd(KERN_WARNING "hda_codec: "
13362 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013363 return 0;
13364 }
13365 if (spec->multiout.dac_nids[0] != dac &&
13366 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013367 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013368 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013369 HDA_OUTPUT));
13370 if (err < 0)
13371 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013372 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13373 }
13374
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013375 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013376 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013377 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013378 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013379 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013380 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013381 if (err < 0)
13382 return err;
13383 return 0;
13384}
13385
13386/* add playback controls from the parsed DAC table */
13387static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13388 const struct auto_pin_cfg *cfg)
13389{
13390 hda_nid_t nid;
13391 int err;
13392
Kailang Yanga361d842007-06-05 12:30:55 +020013393 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013394
13395 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013396 if (nid) {
13397 const char *name;
13398 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13399 name = "Speaker";
13400 else
13401 name = "Front";
13402 err = alc268_new_analog_output(spec, nid, name, 0);
13403 if (err < 0)
13404 return err;
13405 }
Kailang Yanga361d842007-06-05 12:30:55 +020013406
13407 nid = cfg->speaker_pins[0];
13408 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013409 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013410 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13411 if (err < 0)
13412 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013413 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013414 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13415 if (err < 0)
13416 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013417 }
13418 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013419 if (nid) {
13420 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13421 if (err < 0)
13422 return err;
13423 }
Kailang Yanga361d842007-06-05 12:30:55 +020013424
13425 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13426 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013427 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013428 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013429 if (err < 0)
13430 return err;
13431 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013432 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013433}
13434
13435/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013436static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013437 const struct auto_pin_cfg *cfg)
13438{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013439 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013440}
13441
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013442static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13443 hda_nid_t nid, int pin_type)
13444{
13445 int idx;
13446
13447 alc_set_pin_output(codec, nid, pin_type);
13448 if (nid == 0x14 || nid == 0x16)
13449 idx = 0;
13450 else
13451 idx = 1;
13452 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13453}
13454
13455static void alc268_auto_init_multi_out(struct hda_codec *codec)
13456{
13457 struct alc_spec *spec = codec->spec;
13458 hda_nid_t nid = spec->autocfg.line_out_pins[0];
13459 if (nid) {
13460 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13461 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13462 }
13463}
13464
13465static void alc268_auto_init_hp_out(struct hda_codec *codec)
13466{
13467 struct alc_spec *spec = codec->spec;
13468 hda_nid_t pin;
13469
13470 pin = spec->autocfg.hp_pins[0];
13471 if (pin)
13472 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
13473 pin = spec->autocfg.speaker_pins[0];
13474 if (pin)
13475 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
13476}
13477
Kailang Yanga361d842007-06-05 12:30:55 +020013478static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13479{
13480 struct alc_spec *spec = codec->spec;
13481 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13482 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13483 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13484 unsigned int dac_vol1, dac_vol2;
13485
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013486 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013487 snd_hda_codec_write(codec, speaker_nid, 0,
13488 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013489 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013490 snd_hda_codec_write(codec, 0x0f, 0,
13491 AC_VERB_SET_AMP_GAIN_MUTE,
13492 AMP_IN_UNMUTE(1));
13493 snd_hda_codec_write(codec, 0x10, 0,
13494 AC_VERB_SET_AMP_GAIN_MUTE,
13495 AMP_IN_UNMUTE(1));
13496 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013497 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013498 snd_hda_codec_write(codec, 0x0f, 0,
13499 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13500 snd_hda_codec_write(codec, 0x10, 0,
13501 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13502 }
13503
13504 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013505 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013506 dac_vol2 = AMP_OUT_ZERO;
13507 else if (line_nid == 0x15)
13508 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013509 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013510 dac_vol2 = AMP_OUT_ZERO;
13511 else if (hp_nid == 0x15)
13512 dac_vol1 = AMP_OUT_ZERO;
13513 if (line_nid != 0x16 || hp_nid != 0x16 ||
13514 spec->autocfg.line_out_pins[1] != 0x16 ||
13515 spec->autocfg.line_out_pins[2] != 0x16)
13516 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13517
13518 snd_hda_codec_write(codec, 0x02, 0,
13519 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13520 snd_hda_codec_write(codec, 0x03, 0,
13521 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13522}
13523
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013524/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013525#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13526#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013527#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013528#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13529
13530/*
13531 * BIOS auto configuration
13532 */
13533static int alc268_parse_auto_config(struct hda_codec *codec)
13534{
13535 struct alc_spec *spec = codec->spec;
13536 int err;
13537 static hda_nid_t alc268_ignore[] = { 0 };
13538
13539 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13540 alc268_ignore);
13541 if (err < 0)
13542 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013543 if (!spec->autocfg.line_outs) {
13544 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13545 spec->multiout.max_channels = 2;
13546 spec->no_analog = 1;
13547 goto dig_only;
13548 }
Kailang Yanga361d842007-06-05 12:30:55 +020013549 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013550 }
Kailang Yanga361d842007-06-05 12:30:55 +020013551 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13552 if (err < 0)
13553 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013554 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013555 if (err < 0)
13556 return err;
13557
13558 spec->multiout.max_channels = 2;
13559
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013560 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013561 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013562 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013563 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013564 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013565
Takashi Iwai892981f2009-03-02 08:04:35 +010013566 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013567 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013568
Takashi Iwaid88897e2008-10-31 15:01:37 +010013569 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013570 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013571 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013572
Takashi Iwai776e1842007-08-29 15:07:11 +020013573 err = alc_auto_add_mic_boost(codec);
13574 if (err < 0)
13575 return err;
13576
Kailang Yang6227cdc2010-02-25 08:36:52 +010013577 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013578
Kailang Yanga361d842007-06-05 12:30:55 +020013579 return 1;
13580}
13581
Kailang Yanga361d842007-06-05 12:30:55 +020013582#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13583
13584/* init callback for auto-configuration model -- overriding the default init */
13585static void alc268_auto_init(struct hda_codec *codec)
13586{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013587 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013588 alc268_auto_init_multi_out(codec);
13589 alc268_auto_init_hp_out(codec);
13590 alc268_auto_init_mono_speaker_out(codec);
13591 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013592 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013593 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013594 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013595}
13596
13597/*
13598 * configuration and preset
13599 */
13600static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013601 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013602 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013603 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013604 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013605 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013606 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013607 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013608 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013609#ifdef CONFIG_SND_DEBUG
13610 [ALC268_TEST] = "test",
13611#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013612 [ALC268_AUTO] = "auto",
13613};
13614
13615static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013616 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013617 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013618 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013619 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013620 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013621 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13622 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013623 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013624 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13625 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013626 /* almost compatible with toshiba but with optional digital outs;
13627 * auto-probing seems working fine
13628 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013629 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013630 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013631 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013632 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013633 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013634 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013635 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013636 {}
13637};
13638
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013639/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13640static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13641 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13642 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13643 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13644 ALC268_TOSHIBA),
13645 {}
13646};
13647
Kailang Yanga361d842007-06-05 12:30:55 +020013648static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013649 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013650 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13651 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013652 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13653 alc267_quanta_il1_verbs },
13654 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13655 .dac_nids = alc268_dac_nids,
13656 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13657 .adc_nids = alc268_adc_nids_alt,
13658 .hp_nid = 0x03,
13659 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13660 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013661 .unsol_event = alc_sku_unsol_event,
13662 .setup = alc267_quanta_il1_setup,
13663 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013664 },
Kailang Yanga361d842007-06-05 12:30:55 +020013665 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013666 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13667 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013668 .init_verbs = { alc268_base_init_verbs },
13669 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13670 .dac_nids = alc268_dac_nids,
13671 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13672 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013673 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013674 .hp_nid = 0x03,
13675 .dig_out_nid = ALC268_DIGOUT_NID,
13676 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13677 .channel_mode = alc268_modes,
13678 .input_mux = &alc268_capture_source,
13679 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013680 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013681 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013682 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013683 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13684 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013685 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13686 .dac_nids = alc268_dac_nids,
13687 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13688 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013689 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013690 .hp_nid = 0x03,
13691 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13692 .channel_mode = alc268_modes,
13693 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013694 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013695 .setup = alc268_toshiba_setup,
13696 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013697 },
13698 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013699 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013700 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013701 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13702 alc268_acer_verbs },
13703 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13704 .dac_nids = alc268_dac_nids,
13705 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13706 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013707 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013708 .hp_nid = 0x02,
13709 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13710 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013711 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013712 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013713 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013714 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013715 [ALC268_ACER_DMIC] = {
13716 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13717 alc268_beep_mixer },
13718 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13719 alc268_acer_verbs },
13720 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13721 .dac_nids = alc268_dac_nids,
13722 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13723 .adc_nids = alc268_adc_nids_alt,
13724 .capsrc_nids = alc268_capsrc_nids,
13725 .hp_nid = 0x02,
13726 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13727 .channel_mode = alc268_modes,
13728 .input_mux = &alc268_acer_dmic_capture_source,
13729 .unsol_event = alc268_acer_unsol_event,
13730 .init_hook = alc268_acer_init_hook,
13731 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013732 [ALC268_ACER_ASPIRE_ONE] = {
13733 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013734 alc268_beep_mixer,
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013735 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013736 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13737 alc268_acer_aspire_one_verbs },
13738 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13739 .dac_nids = alc268_dac_nids,
13740 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13741 .adc_nids = alc268_adc_nids_alt,
13742 .capsrc_nids = alc268_capsrc_nids,
13743 .hp_nid = 0x03,
13744 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13745 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013746 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013747 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013748 .init_hook = alc268_acer_lc_init_hook,
13749 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013750 [ALC268_DELL] = {
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013751 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13752 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013753 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13754 alc268_dell_verbs },
13755 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13756 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013757 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13758 .adc_nids = alc268_adc_nids_alt,
13759 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013760 .hp_nid = 0x02,
13761 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13762 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013763 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013764 .setup = alc268_dell_setup,
13765 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013766 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013767 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013768 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13769 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013770 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13771 alc268_toshiba_verbs },
13772 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13773 .dac_nids = alc268_dac_nids,
13774 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13775 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013776 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013777 .hp_nid = 0x03,
13778 .dig_out_nid = ALC268_DIGOUT_NID,
13779 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13780 .channel_mode = alc268_modes,
13781 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013782 .setup = alc268_toshiba_setup,
13783 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013784 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013785#ifdef CONFIG_SND_DEBUG
13786 [ALC268_TEST] = {
13787 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13788 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13789 alc268_volume_init_verbs },
13790 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13791 .dac_nids = alc268_dac_nids,
13792 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13793 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013794 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013795 .hp_nid = 0x03,
13796 .dig_out_nid = ALC268_DIGOUT_NID,
13797 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13798 .channel_mode = alc268_modes,
13799 .input_mux = &alc268_capture_source,
13800 },
13801#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013802};
13803
13804static int patch_alc268(struct hda_codec *codec)
13805{
13806 struct alc_spec *spec;
13807 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013808 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013809
Julia Lawallef86f582009-12-19 08:18:03 +010013810 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013811 if (spec == NULL)
13812 return -ENOMEM;
13813
13814 codec->spec = spec;
13815
13816 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13817 alc268_models,
13818 alc268_cfg_tbl);
13819
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013820 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13821 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013822 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013823
Kailang Yanga361d842007-06-05 12:30:55 +020013824 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013825 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13826 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013827 board_config = ALC268_AUTO;
13828 }
13829
13830 if (board_config == ALC268_AUTO) {
13831 /* automatic parse from the BIOS config */
13832 err = alc268_parse_auto_config(codec);
13833 if (err < 0) {
13834 alc_free(codec);
13835 return err;
13836 } else if (!err) {
13837 printk(KERN_INFO
13838 "hda_codec: Cannot set up configuration "
13839 "from BIOS. Using base mode...\n");
13840 board_config = ALC268_3ST;
13841 }
13842 }
13843
13844 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013845 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013846
Kailang Yanga361d842007-06-05 12:30:55 +020013847 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13848 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013849 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013850
Kailang Yanga361d842007-06-05 12:30:55 +020013851 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13852
Takashi Iwai22971e32009-02-10 11:56:44 +010013853 has_beep = 0;
13854 for (i = 0; i < spec->num_mixers; i++) {
13855 if (spec->mixers[i] == alc268_beep_mixer) {
13856 has_beep = 1;
13857 break;
13858 }
13859 }
13860
13861 if (has_beep) {
13862 err = snd_hda_attach_beep_device(codec, 0x1);
13863 if (err < 0) {
13864 alc_free(codec);
13865 return err;
13866 }
13867 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13868 /* override the amp caps for beep generator */
13869 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013870 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13871 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13872 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13873 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013874 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013875
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013876 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013877 /* check whether NID 0x07 is valid */
13878 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013879 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013880
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013881 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013882 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013883 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013884 if (spec->auto_mic ||
13885 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013886 spec->adc_nids = alc268_adc_nids_alt;
13887 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013888 if (spec->auto_mic)
13889 fixup_automic_adc(codec);
Takashi Iwaifdbc6622009-08-19 00:18:10 +020013890 if (spec->auto_mic || spec->input_mux->num_items == 1)
13891 add_mixer(spec, alc268_capture_nosrc_mixer);
13892 else
13893 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013894 } else {
13895 spec->adc_nids = alc268_adc_nids;
13896 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013897 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013898 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013899 /* set default input source */
13900 for (i = 0; i < spec->num_adc_nids; i++)
13901 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13902 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013903 i < spec->num_mux_defs ?
13904 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013905 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013906 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013907
13908 spec->vmaster_nid = 0x02;
13909
Kailang Yanga361d842007-06-05 12:30:55 +020013910 codec->patch_ops = alc_patch_ops;
13911 if (board_config == ALC268_AUTO)
13912 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013913
Kailang Yanga361d842007-06-05 12:30:55 +020013914 return 0;
13915}
13916
13917/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013918 * ALC269 channel source setting (2 channel)
13919 */
13920#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13921
13922#define alc269_dac_nids alc260_dac_nids
13923
13924static hda_nid_t alc269_adc_nids[1] = {
13925 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013926 0x08,
13927};
13928
Takashi Iwaie01bf502008-08-21 16:25:07 +020013929static hda_nid_t alc269_capsrc_nids[1] = {
13930 0x23,
13931};
13932
Kailang Yang84898e82010-02-04 14:16:14 +010013933static hda_nid_t alc269vb_adc_nids[1] = {
13934 /* ADC1 */
13935 0x09,
13936};
13937
13938static hda_nid_t alc269vb_capsrc_nids[1] = {
13939 0x22,
13940};
13941
Takashi Iwai66946352010-03-29 17:21:45 +020013942static hda_nid_t alc269_adc_candidates[] = {
13943 0x08, 0x09, 0x07,
13944};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013945
Kailang Yangf6a92242007-12-13 16:52:54 +010013946#define alc269_modes alc260_modes
13947#define alc269_capture_source alc880_lg_lw_capture_source
13948
13949static struct snd_kcontrol_new alc269_base_mixer[] = {
13950 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13951 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13952 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13953 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13954 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13955 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13956 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13957 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13958 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13959 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13960 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13961 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13962 { } /* end */
13963};
13964
Kailang Yang60db6b52008-08-26 13:13:00 +020013965static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
13966 /* output mixer control */
13967 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13968 {
13969 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13970 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013971 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020013972 .info = snd_hda_mixer_amp_switch_info,
13973 .get = snd_hda_mixer_amp_switch_get,
13974 .put = alc268_acer_master_sw_put,
13975 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13976 },
13977 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13978 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13979 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13980 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13981 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13982 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020013983 { }
13984};
13985
Tony Vroon64154832008-11-06 15:08:49 +000013986static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
13987 /* output mixer control */
13988 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13989 {
13990 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13991 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013992 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000013993 .info = snd_hda_mixer_amp_switch_info,
13994 .get = snd_hda_mixer_amp_switch_get,
13995 .put = alc268_acer_master_sw_put,
13996 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13997 },
13998 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13999 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14000 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14001 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14002 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14003 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
14004 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14005 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
14006 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014007 { }
14008};
14009
Kailang Yang84898e82010-02-04 14:16:14 +010014010static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014011 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014012 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014013 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014014 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014015 { } /* end */
14016};
14017
Kailang Yang84898e82010-02-04 14:16:14 +010014018static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14019 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14020 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14021 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14022 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14023 { } /* end */
14024};
14025
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014026static struct snd_kcontrol_new alc269_asus_mixer[] = {
14027 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14028 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14029 { } /* end */
14030};
14031
Kailang Yangf6a92242007-12-13 16:52:54 +010014032/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014033static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14034 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14035 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14036 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14037 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14038 { } /* end */
14039};
14040
14041static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014042 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14043 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014044 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14045 { } /* end */
14046};
14047
Kailang Yang84898e82010-02-04 14:16:14 +010014048static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14049 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14050 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14051 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14052 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14053 { } /* end */
14054};
14055
14056static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14057 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14058 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14059 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14060 { } /* end */
14061};
14062
Takashi Iwai26f5df22008-11-03 17:39:46 +010014063/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014064#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014065
Kailang Yang60db6b52008-08-26 13:13:00 +020014066static struct hda_verb alc269_quanta_fl1_verbs[] = {
14067 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14068 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14069 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14070 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14071 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14072 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14073 { }
14074};
14075
Tony Vroon64154832008-11-06 15:08:49 +000014076static struct hda_verb alc269_lifebook_verbs[] = {
14077 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14078 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14079 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14081 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14082 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14083 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14084 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14085 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14086 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14087 { }
14088};
14089
Kailang Yang60db6b52008-08-26 13:13:00 +020014090/* toggle speaker-output according to the hp-jack state */
14091static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14092{
14093 unsigned int present;
14094 unsigned char bits;
14095
Wu Fengguang864f92b2009-11-18 12:38:02 +080014096 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014097 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014098 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014099 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014100 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014101 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014102
14103 snd_hda_codec_write(codec, 0x20, 0,
14104 AC_VERB_SET_COEF_INDEX, 0x0c);
14105 snd_hda_codec_write(codec, 0x20, 0,
14106 AC_VERB_SET_PROC_COEF, 0x680);
14107
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, 0x480);
14112}
14113
Tony Vroon64154832008-11-06 15:08:49 +000014114/* toggle speaker-output according to the hp-jacks state */
14115static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14116{
14117 unsigned int present;
14118 unsigned char bits;
14119
14120 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014121 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014122
14123 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014124 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014125
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014126 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014127 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014128 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014129 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014130 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014131
14132 snd_hda_codec_write(codec, 0x20, 0,
14133 AC_VERB_SET_COEF_INDEX, 0x0c);
14134 snd_hda_codec_write(codec, 0x20, 0,
14135 AC_VERB_SET_PROC_COEF, 0x680);
14136
14137 snd_hda_codec_write(codec, 0x20, 0,
14138 AC_VERB_SET_COEF_INDEX, 0x0c);
14139 snd_hda_codec_write(codec, 0x20, 0,
14140 AC_VERB_SET_PROC_COEF, 0x480);
14141}
14142
Tony Vroon64154832008-11-06 15:08:49 +000014143static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14144{
14145 unsigned int present_laptop;
14146 unsigned int present_dock;
14147
Wu Fengguang864f92b2009-11-18 12:38:02 +080014148 present_laptop = snd_hda_jack_detect(codec, 0x18);
14149 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014150
14151 /* Laptop mic port overrides dock mic port, design decision */
14152 if (present_dock)
14153 snd_hda_codec_write(codec, 0x23, 0,
14154 AC_VERB_SET_CONNECT_SEL, 0x3);
14155 if (present_laptop)
14156 snd_hda_codec_write(codec, 0x23, 0,
14157 AC_VERB_SET_CONNECT_SEL, 0x0);
14158 if (!present_dock && !present_laptop)
14159 snd_hda_codec_write(codec, 0x23, 0,
14160 AC_VERB_SET_CONNECT_SEL, 0x1);
14161}
14162
Kailang Yang60db6b52008-08-26 13:13:00 +020014163static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14164 unsigned int res)
14165{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014166 switch (res >> 26) {
14167 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014168 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014169 break;
14170 case ALC880_MIC_EVENT:
14171 alc_mic_automute(codec);
14172 break;
14173 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014174}
14175
Tony Vroon64154832008-11-06 15:08:49 +000014176static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14177 unsigned int res)
14178{
14179 if ((res >> 26) == ALC880_HP_EVENT)
14180 alc269_lifebook_speaker_automute(codec);
14181 if ((res >> 26) == ALC880_MIC_EVENT)
14182 alc269_lifebook_mic_autoswitch(codec);
14183}
14184
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014185static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14186{
14187 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014188 spec->autocfg.hp_pins[0] = 0x15;
14189 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014190 spec->ext_mic.pin = 0x18;
14191 spec->ext_mic.mux_idx = 0;
14192 spec->int_mic.pin = 0x19;
14193 spec->int_mic.mux_idx = 1;
14194 spec->auto_mic = 1;
14195}
14196
Kailang Yang60db6b52008-08-26 13:13:00 +020014197static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14198{
14199 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014200 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014201}
14202
Tony Vroon64154832008-11-06 15:08:49 +000014203static void alc269_lifebook_init_hook(struct hda_codec *codec)
14204{
14205 alc269_lifebook_speaker_automute(codec);
14206 alc269_lifebook_mic_autoswitch(codec);
14207}
14208
Kailang Yang84898e82010-02-04 14:16:14 +010014209static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014210 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14211 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14212 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14213 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14214 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14215 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14216 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14217 {}
14218};
14219
Kailang Yang84898e82010-02-04 14:16:14 +010014220static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014221 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14222 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14223 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14224 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14225 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14226 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14227 {}
14228};
14229
Kailang Yang84898e82010-02-04 14:16:14 +010014230static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14231 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14232 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14233 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14234 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14235 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14236 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14237 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14238 {}
14239};
14240
14241static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14242 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14243 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14244 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14245 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14246 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14247 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14248 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14249 {}
14250};
14251
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014252static struct hda_verb alc271_acer_dmic_verbs[] = {
14253 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14254 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14255 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14257 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14258 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14259 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14260 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14261 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14262 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14263 { }
14264};
14265
Kailang Yang60db6b52008-08-26 13:13:00 +020014266/* toggle speaker-output according to the hp-jack state */
14267static void alc269_speaker_automute(struct hda_codec *codec)
14268{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014269 struct alc_spec *spec = codec->spec;
14270 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014271 unsigned int present;
14272 unsigned char bits;
14273
Kailang Yangebb83ee2009-12-17 12:23:00 +010014274 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014275 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014276 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014277 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014278 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014279 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014280}
14281
Kailang Yang60db6b52008-08-26 13:13:00 +020014282/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014283static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014284 unsigned int res)
14285{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014286 switch (res >> 26) {
14287 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014288 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014289 break;
14290 case ALC880_MIC_EVENT:
14291 alc_mic_automute(codec);
14292 break;
14293 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014294}
14295
Kailang Yang226b1ec2010-04-09 11:01:20 +020014296static void alc269_laptop_amic_setup(struct hda_codec *codec)
14297{
14298 struct alc_spec *spec = codec->spec;
14299 spec->autocfg.hp_pins[0] = 0x15;
14300 spec->autocfg.speaker_pins[0] = 0x14;
14301 spec->ext_mic.pin = 0x18;
14302 spec->ext_mic.mux_idx = 0;
14303 spec->int_mic.pin = 0x19;
14304 spec->int_mic.mux_idx = 1;
14305 spec->auto_mic = 1;
14306}
14307
Kailang Yang84898e82010-02-04 14:16:14 +010014308static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014309{
14310 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014311 spec->autocfg.hp_pins[0] = 0x15;
14312 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014313 spec->ext_mic.pin = 0x18;
14314 spec->ext_mic.mux_idx = 0;
14315 spec->int_mic.pin = 0x12;
14316 spec->int_mic.mux_idx = 5;
14317 spec->auto_mic = 1;
14318}
14319
Kailang Yang226b1ec2010-04-09 11:01:20 +020014320static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014321{
14322 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014323 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014324 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014325 spec->ext_mic.pin = 0x18;
14326 spec->ext_mic.mux_idx = 0;
14327 spec->int_mic.pin = 0x19;
14328 spec->int_mic.mux_idx = 1;
14329 spec->auto_mic = 1;
14330}
14331
Kailang Yang226b1ec2010-04-09 11:01:20 +020014332static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14333{
14334 struct alc_spec *spec = codec->spec;
14335 spec->autocfg.hp_pins[0] = 0x21;
14336 spec->autocfg.speaker_pins[0] = 0x14;
14337 spec->ext_mic.pin = 0x18;
14338 spec->ext_mic.mux_idx = 0;
14339 spec->int_mic.pin = 0x12;
14340 spec->int_mic.mux_idx = 6;
14341 spec->auto_mic = 1;
14342}
14343
Kailang Yang84898e82010-02-04 14:16:14 +010014344static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014345{
14346 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014347 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014348}
14349
Kailang Yangf6a92242007-12-13 16:52:54 +010014350/*
14351 * generic initialization of ADC, input mixers and output mixers
14352 */
14353static struct hda_verb alc269_init_verbs[] = {
14354 /*
14355 * Unmute ADC0 and set the default input to mic-in
14356 */
Kailang Yang84898e82010-02-04 14:16:14 +010014357 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014358
14359 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014360 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014361 */
14362 /* set vol=0 to output mixers */
14363 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14364 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14365
14366 /* set up input amps for analog loopback */
14367 /* Amp Indices: DAC = 0, mixer = 1 */
14368 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14369 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14370 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14371 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14372 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14373 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14374
14375 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14376 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14377 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14378 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14379 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14380 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14381 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14382
14383 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14384 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014385
Kailang Yang84898e82010-02-04 14:16:14 +010014386 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014387 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14388 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014389 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014390
14391 /* set EAPD */
14392 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014393 { }
14394};
14395
14396static struct hda_verb alc269vb_init_verbs[] = {
14397 /*
14398 * Unmute ADC0 and set the default input to mic-in
14399 */
14400 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14401
14402 /*
14403 * Set up output mixers (0x02 - 0x03)
14404 */
14405 /* set vol=0 to output mixers */
14406 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14407 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14408
14409 /* set up input amps for analog loopback */
14410 /* Amp Indices: DAC = 0, mixer = 1 */
14411 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14412 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14413 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14414 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14415 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14416 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14417
14418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14419 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14420 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14421 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14422 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14423 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14424 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14425
14426 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14427 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14428
14429 /* FIXME: use Mux-type input source selection */
14430 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14431 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14432 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14433
14434 /* set EAPD */
14435 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014436 { }
14437};
14438
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014439#define alc269_auto_create_multi_out_ctls \
14440 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014441#define alc269_auto_create_input_ctls \
14442 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014443
14444#ifdef CONFIG_SND_HDA_POWER_SAVE
14445#define alc269_loopbacks alc880_loopbacks
14446#endif
14447
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014448/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014449#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14450#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14451#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14452#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14453
Takashi Iwaif03d3112009-03-05 14:18:16 +010014454static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14455 .substreams = 1,
14456 .channels_min = 2,
14457 .channels_max = 8,
14458 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14459 /* NID is set in alc_build_pcms */
14460 .ops = {
14461 .open = alc880_playback_pcm_open,
14462 .prepare = alc880_playback_pcm_prepare,
14463 .cleanup = alc880_playback_pcm_cleanup
14464 },
14465};
14466
14467static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14468 .substreams = 1,
14469 .channels_min = 2,
14470 .channels_max = 2,
14471 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14472 /* NID is set in alc_build_pcms */
14473};
14474
Takashi Iwaiad358792010-03-30 18:00:59 +020014475#ifdef CONFIG_SND_HDA_POWER_SAVE
14476static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14477{
14478 switch (codec->subsystem_id) {
14479 case 0x103c1586:
14480 return 1;
14481 }
14482 return 0;
14483}
14484
14485static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14486{
14487 /* update mute-LED according to the speaker mute state */
14488 if (nid == 0x01 || nid == 0x14) {
14489 int pinval;
14490 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14491 HDA_AMP_MUTE)
14492 pinval = 0x24;
14493 else
14494 pinval = 0x20;
14495 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a52010-03-30 18:03:44 +020014496 snd_hda_codec_update_cache(codec, 0x19, 0,
14497 AC_VERB_SET_PIN_WIDGET_CONTROL,
14498 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014499 }
14500 return alc_check_power_status(codec, nid);
14501}
14502#endif /* CONFIG_SND_HDA_POWER_SAVE */
14503
Takashi Iwai840b64c2010-07-13 22:49:01 +020014504static int alc275_setup_dual_adc(struct hda_codec *codec)
14505{
14506 struct alc_spec *spec = codec->spec;
14507
14508 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14509 return 0;
14510 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14511 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14512 if (spec->ext_mic.pin <= 0x12) {
14513 spec->private_adc_nids[0] = 0x08;
14514 spec->private_adc_nids[1] = 0x11;
14515 spec->private_capsrc_nids[0] = 0x23;
14516 spec->private_capsrc_nids[1] = 0x22;
14517 } else {
14518 spec->private_adc_nids[0] = 0x11;
14519 spec->private_adc_nids[1] = 0x08;
14520 spec->private_capsrc_nids[0] = 0x22;
14521 spec->private_capsrc_nids[1] = 0x23;
14522 }
14523 spec->adc_nids = spec->private_adc_nids;
14524 spec->capsrc_nids = spec->private_capsrc_nids;
14525 spec->num_adc_nids = 2;
14526 spec->dual_adc_switch = 1;
14527 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14528 spec->adc_nids[0], spec->adc_nids[1]);
14529 return 1;
14530 }
14531 return 0;
14532}
14533
Kailang Yangf6a92242007-12-13 16:52:54 +010014534/*
14535 * BIOS auto configuration
14536 */
14537static int alc269_parse_auto_config(struct hda_codec *codec)
14538{
14539 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014540 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014541 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14542
14543 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14544 alc269_ignore);
14545 if (err < 0)
14546 return err;
14547
14548 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14549 if (err < 0)
14550 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014551 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014552 if (err < 0)
14553 return err;
14554
14555 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14556
Takashi Iwai757899a2010-07-30 10:48:14 +020014557 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014558
Takashi Iwai603c4012008-07-30 15:01:44 +020014559 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014560 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014561
Kailang Yang84898e82010-02-04 14:16:14 +010014562 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14563 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014564 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014565 } else {
14566 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014567 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014568 }
14569
Kailang Yangf6a92242007-12-13 16:52:54 +010014570 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014571 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014572
14573 if (!alc275_setup_dual_adc(codec))
14574 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14575 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014576
Takashi Iwaie01bf502008-08-21 16:25:07 +020014577 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014578 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014579 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14580 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014581
14582 err = alc_auto_add_mic_boost(codec);
14583 if (err < 0)
14584 return err;
14585
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014586 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014587 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014588
Kailang Yangf6a92242007-12-13 16:52:54 +010014589 return 1;
14590}
14591
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014592#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14593#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014594#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14595
14596
14597/* init callback for auto-configuration model -- overriding the default init */
14598static void alc269_auto_init(struct hda_codec *codec)
14599{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014600 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014601 alc269_auto_init_multi_out(codec);
14602 alc269_auto_init_hp_out(codec);
14603 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014604 alc_auto_init_digital(codec);
Kailang Yang9ad0e492010-09-14 23:22:00 +020014605 alc_init_jacks(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014606 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014607 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014608}
14609
Kailang Yang977ddd62010-09-15 10:02:29 +020014610#ifdef CONFIG_SND_HDA_POWER_SAVE
14611static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14612{
14613 struct alc_spec *spec = codec->spec;
14614 int val;
14615
14616 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14617 val = alc_read_coef_idx(codec, 0x04);
14618 /* Power down output pin */
14619 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14620 }
14621
14622 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14623 val = alc_read_coef_idx(codec, 0x04);
14624 /* Power down output pin */
14625 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14626 msleep(150);
14627 }
14628
14629 alc_shutup(codec);
14630 if (spec && spec->power_hook)
14631 spec->power_hook(codec);
14632 return 0;
14633}
14634#endif
14635#ifdef SND_HDA_NEEDS_RESUME
14636static int alc269_resume(struct hda_codec *codec)
14637{
14638 int val;
14639
14640 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14641 val = alc_read_coef_idx(codec, 0x04);
14642 /* Power down output pin */
14643 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14644 msleep(150);
14645 }
14646
14647 codec->patch_ops.init(codec);
14648
14649 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14650 val = alc_read_coef_idx(codec, 0x04);
14651 /* Power up output pin */
14652 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14653 msleep(200);
14654 }
14655
14656 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14657 val = alc_read_coef_idx(codec, 0x04);
14658 /* Power up output pin */
14659 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14660 }
14661
14662 snd_hda_codec_resume_amp(codec);
14663 snd_hda_codec_resume_cache(codec);
14664#ifdef CONFIG_SND_HDA_POWER_SAVE
14665 if (codec->patch_ops.check_power_status)
14666 codec->patch_ops.check_power_status(codec, 0x01);
14667#endif
14668 return 0;
14669}
14670#endif
14671
Takashi Iwaiff818c22010-04-12 08:59:25 +020014672enum {
14673 ALC269_FIXUP_SONY_VAIO,
14674};
14675
Takashi Iwaiff818c22010-04-12 08:59:25 +020014676static const struct alc_fixup alc269_fixups[] = {
14677 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014678 .verbs = (const struct hda_verb[]) {
14679 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14680 {}
14681 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014682 },
14683};
14684
14685static struct snd_pci_quirk alc269_fixup_tbl[] = {
14686 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningssondbbcbc02010-08-23 08:14:35 +020014687 SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014688 {}
14689};
14690
14691
Kailang Yangf6a92242007-12-13 16:52:54 +010014692/*
14693 * configuration and preset
14694 */
14695static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014696 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014697 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014698 [ALC269_AMIC] = "laptop-amic",
14699 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014700 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014701 [ALC269_LIFEBOOK] = "lifebook",
14702 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014703};
14704
14705static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014706 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014707 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014708 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014709 ALC269_AMIC),
14710 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14711 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14712 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14713 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14714 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14715 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14716 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14717 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14718 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14719 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14720 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14721 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14722 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14723 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14724 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14725 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14726 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14727 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14728 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14729 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14730 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14731 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14732 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14733 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14734 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14735 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14736 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14737 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14738 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14739 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14740 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14741 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14742 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14743 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14744 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14745 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014746 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014747 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014748 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014749 ALC269_DMIC),
14750 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14751 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014752 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014753 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014754 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14755 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14756 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14757 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14758 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14759 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014760 {}
14761};
14762
14763static struct alc_config_preset alc269_presets[] = {
14764 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014765 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014766 .init_verbs = { alc269_init_verbs },
14767 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14768 .dac_nids = alc269_dac_nids,
14769 .hp_nid = 0x03,
14770 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14771 .channel_mode = alc269_modes,
14772 .input_mux = &alc269_capture_source,
14773 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014774 [ALC269_QUANTA_FL1] = {
14775 .mixers = { alc269_quanta_fl1_mixer },
14776 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14777 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14778 .dac_nids = alc269_dac_nids,
14779 .hp_nid = 0x03,
14780 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14781 .channel_mode = alc269_modes,
14782 .input_mux = &alc269_capture_source,
14783 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014784 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014785 .init_hook = alc269_quanta_fl1_init_hook,
14786 },
Kailang Yang84898e82010-02-04 14:16:14 +010014787 [ALC269_AMIC] = {
14788 .mixers = { alc269_laptop_mixer },
14789 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014790 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014791 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014792 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14793 .dac_nids = alc269_dac_nids,
14794 .hp_nid = 0x03,
14795 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14796 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014797 .unsol_event = alc269_laptop_unsol_event,
14798 .setup = alc269_laptop_amic_setup,
14799 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014800 },
Kailang Yang84898e82010-02-04 14:16:14 +010014801 [ALC269_DMIC] = {
14802 .mixers = { alc269_laptop_mixer },
14803 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014804 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014805 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014806 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14807 .dac_nids = alc269_dac_nids,
14808 .hp_nid = 0x03,
14809 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14810 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014811 .unsol_event = alc269_laptop_unsol_event,
14812 .setup = alc269_laptop_dmic_setup,
14813 .init_hook = alc269_laptop_inithook,
14814 },
14815 [ALC269VB_AMIC] = {
14816 .mixers = { alc269vb_laptop_mixer },
14817 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14818 .init_verbs = { alc269vb_init_verbs,
14819 alc269vb_laptop_amic_init_verbs },
14820 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14821 .dac_nids = alc269_dac_nids,
14822 .hp_nid = 0x03,
14823 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14824 .channel_mode = alc269_modes,
14825 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014826 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014827 .init_hook = alc269_laptop_inithook,
14828 },
14829 [ALC269VB_DMIC] = {
14830 .mixers = { alc269vb_laptop_mixer },
14831 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14832 .init_verbs = { alc269vb_init_verbs,
14833 alc269vb_laptop_dmic_init_verbs },
14834 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14835 .dac_nids = alc269_dac_nids,
14836 .hp_nid = 0x03,
14837 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14838 .channel_mode = alc269_modes,
14839 .unsol_event = alc269_laptop_unsol_event,
14840 .setup = alc269vb_laptop_dmic_setup,
14841 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014842 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014843 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014844 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014845 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014846 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014847 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014848 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14849 .dac_nids = alc269_dac_nids,
14850 .hp_nid = 0x03,
14851 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14852 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014853 .unsol_event = alc269_laptop_unsol_event,
14854 .setup = alc269_laptop_dmic_setup,
14855 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014856 },
Tony Vroon64154832008-11-06 15:08:49 +000014857 [ALC269_LIFEBOOK] = {
14858 .mixers = { alc269_lifebook_mixer },
14859 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14860 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14861 .dac_nids = alc269_dac_nids,
14862 .hp_nid = 0x03,
14863 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14864 .channel_mode = alc269_modes,
14865 .input_mux = &alc269_capture_source,
14866 .unsol_event = alc269_lifebook_unsol_event,
14867 .init_hook = alc269_lifebook_init_hook,
14868 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014869 [ALC271_ACER] = {
14870 .mixers = { alc269_asus_mixer },
14871 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14872 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14873 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14874 .dac_nids = alc269_dac_nids,
14875 .adc_nids = alc262_dmic_adc_nids,
14876 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14877 .capsrc_nids = alc262_dmic_capsrc_nids,
14878 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14879 .channel_mode = alc269_modes,
14880 .input_mux = &alc269_capture_source,
14881 .dig_out_nid = ALC880_DIGOUT_NID,
14882 .unsol_event = alc_sku_unsol_event,
14883 .setup = alc269vb_laptop_dmic_setup,
14884 .init_hook = alc_inithook,
14885 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014886};
14887
Kailang Yang977ddd62010-09-15 10:02:29 +020014888static int alc269_fill_coef(struct hda_codec *codec)
14889{
14890 int val;
14891
14892 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
14893 alc_write_coef_idx(codec, 0xf, 0x960b);
14894 alc_write_coef_idx(codec, 0xe, 0x8817);
14895 }
14896
14897 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
14898 alc_write_coef_idx(codec, 0xf, 0x960b);
14899 alc_write_coef_idx(codec, 0xe, 0x8814);
14900 }
14901
14902 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14903 val = alc_read_coef_idx(codec, 0x04);
14904 /* Power up output pin */
14905 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14906 }
14907
14908 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14909 val = alc_read_coef_idx(codec, 0xd);
14910 if ((val & 0x0c00) >> 10 != 0x1) {
14911 /* Capless ramp up clock control */
14912 alc_write_coef_idx(codec, 0xd, val | 1<<10);
14913 }
14914 val = alc_read_coef_idx(codec, 0x17);
14915 if ((val & 0x01c0) >> 6 != 0x4) {
14916 /* Class D power on reset */
14917 alc_write_coef_idx(codec, 0x17, val | 1<<7);
14918 }
14919 }
14920 return 0;
14921}
14922
Kailang Yangf6a92242007-12-13 16:52:54 +010014923static int patch_alc269(struct hda_codec *codec)
14924{
14925 struct alc_spec *spec;
14926 int board_config;
14927 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014928 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014929
14930 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14931 if (spec == NULL)
14932 return -ENOMEM;
14933
14934 codec->spec = spec;
14935
Kailang Yangda00c242010-03-19 11:23:45 +010014936 alc_auto_parse_customize_define(codec);
14937
Kailang Yang274693f2009-12-03 10:07:50 +010014938 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014939 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14940 spec->cdefine.platform_type == 1)
14941 alc_codec_rename(codec, "ALC271X");
14942 else
14943 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014944 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014945 } else
14946 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014947
Kailang Yang977ddd62010-09-15 10:02:29 +020014948 alc269_fill_coef(codec);
14949
Kailang Yangf6a92242007-12-13 16:52:54 +010014950 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14951 alc269_models,
14952 alc269_cfg_tbl);
14953
14954 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014955 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14956 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014957 board_config = ALC269_AUTO;
14958 }
14959
Takashi Iwaiff818c22010-04-12 08:59:25 +020014960 if (board_config == ALC269_AUTO)
14961 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14962
Kailang Yangf6a92242007-12-13 16:52:54 +010014963 if (board_config == ALC269_AUTO) {
14964 /* automatic parse from the BIOS config */
14965 err = alc269_parse_auto_config(codec);
14966 if (err < 0) {
14967 alc_free(codec);
14968 return err;
14969 } else if (!err) {
14970 printk(KERN_INFO
14971 "hda_codec: Cannot set up configuration "
14972 "from BIOS. Using base mode...\n");
14973 board_config = ALC269_BASIC;
14974 }
14975 }
14976
Takashi Iwaidc1eae22010-07-29 15:30:02 +020014977 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020014978 err = snd_hda_attach_beep_device(codec, 0x1);
14979 if (err < 0) {
14980 alc_free(codec);
14981 return err;
14982 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090014983 }
14984
Kailang Yangf6a92242007-12-13 16:52:54 +010014985 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014986 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010014987
Kailang Yang84898e82010-02-04 14:16:14 +010014988 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010014989 /* Due to a hardware problem on Lenovo Ideadpad, we need to
14990 * fix the sample rate of analog I/O to 44.1kHz
14991 */
14992 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
14993 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020014994 } else if (spec->dual_adc_switch) {
14995 spec->stream_analog_playback = &alc269_pcm_analog_playback;
14996 /* switch ADC dynamically */
14997 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010014998 } else {
14999 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15000 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15001 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015002 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15003 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15004
Takashi Iwai66946352010-03-29 17:21:45 +020015005 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
15006 if (!is_alc269vb) {
15007 spec->adc_nids = alc269_adc_nids;
15008 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15009 spec->capsrc_nids = alc269_capsrc_nids;
15010 } else {
15011 spec->adc_nids = alc269vb_adc_nids;
15012 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15013 spec->capsrc_nids = alc269vb_capsrc_nids;
15014 }
Kailang Yang84898e82010-02-04 14:16:14 +010015015 }
15016
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015017 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015018 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015019 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015020 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015021
Takashi Iwaiff818c22010-04-12 08:59:25 +020015022 if (board_config == ALC269_AUTO)
15023 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
15024
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015025 spec->vmaster_nid = 0x02;
15026
Kailang Yangf6a92242007-12-13 16:52:54 +010015027 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015028#ifdef CONFIG_SND_HDA_POWER_SAVE
15029 codec->patch_ops.suspend = alc269_suspend;
15030#endif
15031#ifdef SND_HDA_NEEDS_RESUME
15032 codec->patch_ops.resume = alc269_resume;
15033#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015034 if (board_config == ALC269_AUTO)
15035 spec->init_hook = alc269_auto_init;
15036#ifdef CONFIG_SND_HDA_POWER_SAVE
15037 if (!spec->loopback.amplist)
15038 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015039 if (alc269_mic2_for_mute_led(codec))
15040 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015041#endif
15042
15043 return 0;
15044}
15045
15046/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015047 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15048 */
15049
15050/*
15051 * set the path ways for 2 channel output
15052 * need to set the codec line out and mic 1 pin widgets to inputs
15053 */
15054static struct hda_verb alc861_threestack_ch2_init[] = {
15055 /* set pin widget 1Ah (line in) for input */
15056 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015057 /* set pin widget 18h (mic1/2) for input, for mic also enable
15058 * the vref
15059 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015060 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15061
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015062 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15063#if 0
15064 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15065 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15066#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015067 { } /* end */
15068};
15069/*
15070 * 6ch mode
15071 * need to set the codec line out and mic 1 pin widgets to outputs
15072 */
15073static struct hda_verb alc861_threestack_ch6_init[] = {
15074 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15075 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15076 /* set pin widget 18h (mic1) for output (CLFE)*/
15077 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15078
15079 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015080 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015081
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015082 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15083#if 0
15084 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15085 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15086#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015087 { } /* end */
15088};
15089
15090static struct hda_channel_mode alc861_threestack_modes[2] = {
15091 { 2, alc861_threestack_ch2_init },
15092 { 6, alc861_threestack_ch6_init },
15093};
Takashi Iwai22309c32006-08-09 16:57:28 +020015094/* Set mic1 as input and unmute the mixer */
15095static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15096 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15097 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15098 { } /* end */
15099};
15100/* Set mic1 as output and mute mixer */
15101static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15102 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15103 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15104 { } /* end */
15105};
15106
15107static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15108 { 2, alc861_uniwill_m31_ch2_init },
15109 { 4, alc861_uniwill_m31_ch4_init },
15110};
Kailang Yangdf694da2005-12-05 19:42:22 +010015111
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015112/* Set mic1 and line-in as input and unmute the mixer */
15113static struct hda_verb alc861_asus_ch2_init[] = {
15114 /* set pin widget 1Ah (line in) for input */
15115 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015116 /* set pin widget 18h (mic1/2) for input, for mic also enable
15117 * the vref
15118 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015119 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15120
15121 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15122#if 0
15123 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15124 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15125#endif
15126 { } /* end */
15127};
15128/* Set mic1 nad line-in as output and mute mixer */
15129static struct hda_verb alc861_asus_ch6_init[] = {
15130 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15131 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15132 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15133 /* set pin widget 18h (mic1) for output (CLFE)*/
15134 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15135 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15136 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15137 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15138
15139 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15140#if 0
15141 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15142 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15143#endif
15144 { } /* end */
15145};
15146
15147static struct hda_channel_mode alc861_asus_modes[2] = {
15148 { 2, alc861_asus_ch2_init },
15149 { 6, alc861_asus_ch6_init },
15150};
15151
Kailang Yangdf694da2005-12-05 19:42:22 +010015152/* patch-ALC861 */
15153
15154static struct snd_kcontrol_new alc861_base_mixer[] = {
15155 /* output mixer control */
15156 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15157 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15158 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15159 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15160 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15161
15162 /*Input mixer control */
15163 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15164 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15165 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15166 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15167 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15168 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15169 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15170 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15171 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015173
Kailang Yangdf694da2005-12-05 19:42:22 +010015174 { } /* end */
15175};
15176
15177static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15178 /* output mixer control */
15179 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15180 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15181 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15182 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15183 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15184
15185 /* Input mixer control */
15186 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15187 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15188 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15189 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15190 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15191 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15192 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15193 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15194 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15195 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015196
Kailang Yangdf694da2005-12-05 19:42:22 +010015197 {
15198 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15199 .name = "Channel Mode",
15200 .info = alc_ch_mode_info,
15201 .get = alc_ch_mode_get,
15202 .put = alc_ch_mode_put,
15203 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15204 },
15205 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015206};
15207
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015208static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015209 /* output mixer control */
15210 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15211 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15212 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015213
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015214 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015215};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015216
Takashi Iwai22309c32006-08-09 16:57:28 +020015217static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15218 /* output mixer control */
15219 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15220 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15221 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15222 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15223 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15224
15225 /* Input mixer control */
15226 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15227 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15228 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15229 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15230 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15231 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15232 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15233 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15234 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15235 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015236
Takashi Iwai22309c32006-08-09 16:57:28 +020015237 {
15238 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15239 .name = "Channel Mode",
15240 .info = alc_ch_mode_info,
15241 .get = alc_ch_mode_get,
15242 .put = alc_ch_mode_put,
15243 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15244 },
15245 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015246};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015247
15248static struct snd_kcontrol_new alc861_asus_mixer[] = {
15249 /* output mixer control */
15250 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15251 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15252 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15253 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15254 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15255
15256 /* Input mixer control */
15257 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15258 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15259 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15260 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15261 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15262 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15263 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15264 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15265 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015266 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15267
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015268 {
15269 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15270 .name = "Channel Mode",
15271 .info = alc_ch_mode_info,
15272 .get = alc_ch_mode_get,
15273 .put = alc_ch_mode_put,
15274 .private_value = ARRAY_SIZE(alc861_asus_modes),
15275 },
15276 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015277};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015278
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015279/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015280static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015281 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15282 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015283 { }
15284};
15285
Kailang Yangdf694da2005-12-05 19:42:22 +010015286/*
15287 * generic initialization of ADC, input mixers and output mixers
15288 */
15289static struct hda_verb alc861_base_init_verbs[] = {
15290 /*
15291 * Unmute ADC0 and set the default input to mic-in
15292 */
15293 /* port-A for surround (rear panel) */
15294 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15295 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15296 /* port-B for mic-in (rear panel) with vref */
15297 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15298 /* port-C for line-in (rear panel) */
15299 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15300 /* port-D for Front */
15301 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15302 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15303 /* port-E for HP out (front panel) */
15304 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15305 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015306 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015307 /* port-F for mic-in (front panel) with vref */
15308 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15309 /* port-G for CLFE (rear panel) */
15310 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15311 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15312 /* port-H for side (rear panel) */
15313 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15314 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15315 /* CD-in */
15316 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15317 /* route front mic to ADC1*/
15318 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15319 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015320
Kailang Yangdf694da2005-12-05 19:42:22 +010015321 /* Unmute DAC0~3 & spdif out*/
15322 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15323 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15324 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15325 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15326 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015327
Kailang Yangdf694da2005-12-05 19:42:22 +010015328 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15329 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15330 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15331 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15332 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015333
Kailang Yangdf694da2005-12-05 19:42:22 +010015334 /* Unmute Stereo Mixer 15 */
15335 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15336 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15337 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015338 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015339
15340 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15341 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15342 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15343 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15344 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15345 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15346 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15347 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015348 /* hp used DAC 3 (Front) */
15349 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015350 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15351
15352 { }
15353};
15354
15355static struct hda_verb alc861_threestack_init_verbs[] = {
15356 /*
15357 * Unmute ADC0 and set the default input to mic-in
15358 */
15359 /* port-A for surround (rear panel) */
15360 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15361 /* port-B for mic-in (rear panel) with vref */
15362 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15363 /* port-C for line-in (rear panel) */
15364 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15365 /* port-D for Front */
15366 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15367 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15368 /* port-E for HP out (front panel) */
15369 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15370 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015371 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015372 /* port-F for mic-in (front panel) with vref */
15373 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15374 /* port-G for CLFE (rear panel) */
15375 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15376 /* port-H for side (rear panel) */
15377 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15378 /* CD-in */
15379 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15380 /* route front mic to ADC1*/
15381 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15382 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15383 /* Unmute DAC0~3 & spdif out*/
15384 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15385 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15386 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15387 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15388 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015389
Kailang Yangdf694da2005-12-05 19:42:22 +010015390 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15391 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15392 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15393 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15394 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015395
Kailang Yangdf694da2005-12-05 19:42:22 +010015396 /* Unmute Stereo Mixer 15 */
15397 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15398 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15399 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015400 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015401
15402 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15403 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15404 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15405 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15406 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15407 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15408 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15409 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015410 /* hp used DAC 3 (Front) */
15411 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015412 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15413 { }
15414};
Takashi Iwai22309c32006-08-09 16:57:28 +020015415
15416static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15417 /*
15418 * Unmute ADC0 and set the default input to mic-in
15419 */
15420 /* port-A for surround (rear panel) */
15421 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15422 /* port-B for mic-in (rear panel) with vref */
15423 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15424 /* port-C for line-in (rear panel) */
15425 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15426 /* port-D for Front */
15427 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15428 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15429 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015430 /* this has to be set to VREF80 */
15431 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015432 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015433 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015434 /* port-F for mic-in (front panel) with vref */
15435 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15436 /* port-G for CLFE (rear panel) */
15437 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15438 /* port-H for side (rear panel) */
15439 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15440 /* CD-in */
15441 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15442 /* route front mic to ADC1*/
15443 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15444 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15445 /* Unmute DAC0~3 & spdif out*/
15446 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15447 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15448 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15449 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15450 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015451
Takashi Iwai22309c32006-08-09 16:57:28 +020015452 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15453 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15454 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15455 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15456 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015457
Takashi Iwai22309c32006-08-09 16:57:28 +020015458 /* Unmute Stereo Mixer 15 */
15459 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15460 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15461 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015462 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015463
15464 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15465 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15466 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15467 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15468 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15469 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15470 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15471 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015472 /* hp used DAC 3 (Front) */
15473 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015474 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15475 { }
15476};
15477
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015478static struct hda_verb alc861_asus_init_verbs[] = {
15479 /*
15480 * Unmute ADC0 and set the default input to mic-in
15481 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015482 /* port-A for surround (rear panel)
15483 * according to codec#0 this is the HP jack
15484 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015485 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15486 /* route front PCM to HP */
15487 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15488 /* port-B for mic-in (rear panel) with vref */
15489 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15490 /* port-C for line-in (rear panel) */
15491 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15492 /* port-D for Front */
15493 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15494 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15495 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015496 /* this has to be set to VREF80 */
15497 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015498 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015499 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015500 /* port-F for mic-in (front panel) with vref */
15501 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15502 /* port-G for CLFE (rear panel) */
15503 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15504 /* port-H for side (rear panel) */
15505 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15506 /* CD-in */
15507 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15508 /* route front mic to ADC1*/
15509 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15510 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15511 /* Unmute DAC0~3 & spdif out*/
15512 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15513 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15514 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15515 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15516 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15517 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15518 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15519 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15520 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15521 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015522
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015523 /* Unmute Stereo Mixer 15 */
15524 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15525 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15526 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015527 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015528
15529 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15530 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15531 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15532 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15533 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15534 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15535 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15536 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015537 /* hp used DAC 3 (Front) */
15538 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015539 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15540 { }
15541};
15542
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015543/* additional init verbs for ASUS laptops */
15544static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15545 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15546 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15547 { }
15548};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015549
Kailang Yangdf694da2005-12-05 19:42:22 +010015550/*
15551 * generic initialization of ADC, input mixers and output mixers
15552 */
15553static struct hda_verb alc861_auto_init_verbs[] = {
15554 /*
15555 * Unmute ADC0 and set the default input to mic-in
15556 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015557 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015558 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015559
Kailang Yangdf694da2005-12-05 19:42:22 +010015560 /* Unmute DAC0~3 & spdif out*/
15561 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15562 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15563 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15564 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15565 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015566
Kailang Yangdf694da2005-12-05 19:42:22 +010015567 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15568 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15569 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15570 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15571 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015572
Kailang Yangdf694da2005-12-05 19:42:22 +010015573 /* Unmute Stereo Mixer 15 */
15574 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15575 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15576 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15577 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15578
Takashi Iwai1c209302009-07-22 15:17:45 +020015579 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15580 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15581 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15582 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15583 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15584 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15585 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15586 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015587
15588 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15589 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015590 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15591 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015592 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15593 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015594 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15595 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015596
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015597 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015598
15599 { }
15600};
15601
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015602static struct hda_verb alc861_toshiba_init_verbs[] = {
15603 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015604
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015605 { }
15606};
15607
15608/* toggle speaker-output according to the hp-jack state */
15609static void alc861_toshiba_automute(struct hda_codec *codec)
15610{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015611 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015612
Takashi Iwai47fd8302007-08-10 17:11:07 +020015613 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15614 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15615 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15616 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015617}
15618
15619static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15620 unsigned int res)
15621{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015622 if ((res >> 26) == ALC880_HP_EVENT)
15623 alc861_toshiba_automute(codec);
15624}
15625
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015626/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015627#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15628#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15629#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15630#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15631
15632
15633#define ALC861_DIGOUT_NID 0x07
15634
15635static struct hda_channel_mode alc861_8ch_modes[1] = {
15636 { 8, NULL }
15637};
15638
15639static hda_nid_t alc861_dac_nids[4] = {
15640 /* front, surround, clfe, side */
15641 0x03, 0x06, 0x05, 0x04
15642};
15643
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015644static hda_nid_t alc660_dac_nids[3] = {
15645 /* front, clfe, surround */
15646 0x03, 0x05, 0x06
15647};
15648
Kailang Yangdf694da2005-12-05 19:42:22 +010015649static hda_nid_t alc861_adc_nids[1] = {
15650 /* ADC0-2 */
15651 0x08,
15652};
15653
15654static struct hda_input_mux alc861_capture_source = {
15655 .num_items = 5,
15656 .items = {
15657 { "Mic", 0x0 },
15658 { "Front Mic", 0x3 },
15659 { "Line", 0x1 },
15660 { "CD", 0x4 },
15661 { "Mixer", 0x5 },
15662 },
15663};
15664
Takashi Iwai1c209302009-07-22 15:17:45 +020015665static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15666{
15667 struct alc_spec *spec = codec->spec;
15668 hda_nid_t mix, srcs[5];
15669 int i, j, num;
15670
15671 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15672 return 0;
15673 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15674 if (num < 0)
15675 return 0;
15676 for (i = 0; i < num; i++) {
15677 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015678 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015679 if (type != AC_WID_AUD_OUT)
15680 continue;
15681 for (j = 0; j < spec->multiout.num_dacs; j++)
15682 if (spec->multiout.dac_nids[j] == srcs[i])
15683 break;
15684 if (j >= spec->multiout.num_dacs)
15685 return srcs[i];
15686 }
15687 return 0;
15688}
15689
Kailang Yangdf694da2005-12-05 19:42:22 +010015690/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015691static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015692 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015693{
Takashi Iwai1c209302009-07-22 15:17:45 +020015694 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015695 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015696 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015697
15698 spec->multiout.dac_nids = spec->private_dac_nids;
15699 for (i = 0; i < cfg->line_outs; i++) {
15700 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015701 dac = alc861_look_for_dac(codec, nid);
15702 if (!dac)
15703 continue;
15704 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015705 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015706 return 0;
15707}
15708
Takashi Iwai1c209302009-07-22 15:17:45 +020015709static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15710 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015711{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015712 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015713 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15714}
15715
15716/* add playback controls from the parsed DAC table */
15717static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15718 const struct auto_pin_cfg *cfg)
15719{
15720 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015721 static const char *chname[4] = {
15722 "Front", "Surround", NULL /*CLFE*/, "Side"
15723 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015724 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015725 int i, err;
15726
15727 if (cfg->line_outs == 1) {
15728 const char *pfx = NULL;
15729 if (!cfg->hp_outs)
15730 pfx = "Master";
15731 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15732 pfx = "Speaker";
15733 if (pfx) {
15734 nid = spec->multiout.dac_nids[0];
15735 return alc861_create_out_sw(codec, pfx, nid, 3);
15736 }
15737 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015738
15739 for (i = 0; i < cfg->line_outs; i++) {
15740 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015741 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015742 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015743 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015744 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015745 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015746 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015747 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015748 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015749 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015750 return err;
15751 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015752 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015753 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015754 return err;
15755 }
15756 }
15757 return 0;
15758}
15759
Takashi Iwai1c209302009-07-22 15:17:45 +020015760static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015761{
Takashi Iwai1c209302009-07-22 15:17:45 +020015762 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015763 int err;
15764 hda_nid_t nid;
15765
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015766 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015767 return 0;
15768
15769 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015770 nid = alc861_look_for_dac(codec, pin);
15771 if (nid) {
15772 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15773 if (err < 0)
15774 return err;
15775 spec->multiout.hp_nid = nid;
15776 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015777 }
15778 return 0;
15779}
15780
15781/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015782static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015783 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015784{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015785 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015786}
15787
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015788static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15789 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015790 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015791{
Takashi Iwai1c209302009-07-22 15:17:45 +020015792 hda_nid_t mix, srcs[5];
15793 int i, num;
15794
Jacek Luczak564c5be2008-05-03 18:41:23 +020015795 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15796 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015797 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015798 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015799 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15800 return;
15801 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15802 if (num < 0)
15803 return;
15804 for (i = 0; i < num; i++) {
15805 unsigned int mute;
15806 if (srcs[i] == dac || srcs[i] == 0x15)
15807 mute = AMP_IN_UNMUTE(i);
15808 else
15809 mute = AMP_IN_MUTE(i);
15810 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15811 mute);
15812 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015813}
15814
15815static void alc861_auto_init_multi_out(struct hda_codec *codec)
15816{
15817 struct alc_spec *spec = codec->spec;
15818 int i;
15819
15820 for (i = 0; i < spec->autocfg.line_outs; i++) {
15821 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015822 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015823 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015824 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015825 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015826 }
15827}
15828
15829static void alc861_auto_init_hp_out(struct hda_codec *codec)
15830{
15831 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015832
Takashi Iwai15870f02009-10-05 08:25:13 +020015833 if (spec->autocfg.hp_outs)
15834 alc861_auto_set_output_and_unmute(codec,
15835 spec->autocfg.hp_pins[0],
15836 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015837 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015838 if (spec->autocfg.speaker_outs)
15839 alc861_auto_set_output_and_unmute(codec,
15840 spec->autocfg.speaker_pins[0],
15841 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015842 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015843}
15844
15845static void alc861_auto_init_analog_input(struct hda_codec *codec)
15846{
15847 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015848 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010015849 int i;
15850
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015851 for (i = 0; i < cfg->num_inputs; i++) {
15852 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010015853 if (nid >= 0x0c && nid <= 0x11)
15854 alc_set_input_pin(codec, nid, i);
Kailang Yangdf694da2005-12-05 19:42:22 +010015855 }
15856}
15857
15858/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015859/* return 1 if successful, 0 if the proper config is not found,
15860 * or a negative error code
15861 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015862static int alc861_parse_auto_config(struct hda_codec *codec)
15863{
15864 struct alc_spec *spec = codec->spec;
15865 int err;
15866 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15867
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015868 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15869 alc861_ignore);
15870 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015871 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015872 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015873 return 0; /* can't find valid BIOS pin config */
15874
Takashi Iwai1c209302009-07-22 15:17:45 +020015875 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015876 if (err < 0)
15877 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015878 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015879 if (err < 0)
15880 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015881 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015882 if (err < 0)
15883 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015884 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015885 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015886 return err;
15887
15888 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15889
Takashi Iwai757899a2010-07-30 10:48:14 +020015890 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015891
Takashi Iwai603c4012008-07-30 15:01:44 +020015892 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015893 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015894
Takashi Iwaid88897e2008-10-31 15:01:37 +010015895 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015896
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015897 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015898 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015899
15900 spec->adc_nids = alc861_adc_nids;
15901 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015902 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015903
Kailang Yang6227cdc2010-02-25 08:36:52 +010015904 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015905
Kailang Yangdf694da2005-12-05 19:42:22 +010015906 return 1;
15907}
15908
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015909/* additional initialization for auto-configuration model */
15910static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015911{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015912 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015913 alc861_auto_init_multi_out(codec);
15914 alc861_auto_init_hp_out(codec);
15915 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020015916 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015917 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015918 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015919}
15920
Takashi Iwaicb53c622007-08-10 17:21:45 +020015921#ifdef CONFIG_SND_HDA_POWER_SAVE
15922static struct hda_amp_list alc861_loopbacks[] = {
15923 { 0x15, HDA_INPUT, 0 },
15924 { 0x15, HDA_INPUT, 1 },
15925 { 0x15, HDA_INPUT, 2 },
15926 { 0x15, HDA_INPUT, 3 },
15927 { } /* end */
15928};
15929#endif
15930
Kailang Yangdf694da2005-12-05 19:42:22 +010015931
15932/*
15933 * configuration and preset
15934 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015935static const char *alc861_models[ALC861_MODEL_LAST] = {
15936 [ALC861_3ST] = "3stack",
15937 [ALC660_3ST] = "3stack-660",
15938 [ALC861_3ST_DIG] = "3stack-dig",
15939 [ALC861_6ST_DIG] = "6stack-dig",
15940 [ALC861_UNIWILL_M31] = "uniwill-m31",
15941 [ALC861_TOSHIBA] = "toshiba",
15942 [ALC861_ASUS] = "asus",
15943 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15944 [ALC861_AUTO] = "auto",
15945};
15946
15947static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015948 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015949 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15950 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15951 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015952 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015953 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015954 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015955 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15956 * Any other models that need this preset?
15957 */
15958 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015959 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15960 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015961 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15962 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
15963 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
15964 /* FIXME: the below seems conflict */
15965 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
15966 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
15967 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010015968 {}
15969};
15970
15971static struct alc_config_preset alc861_presets[] = {
15972 [ALC861_3ST] = {
15973 .mixers = { alc861_3ST_mixer },
15974 .init_verbs = { alc861_threestack_init_verbs },
15975 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15976 .dac_nids = alc861_dac_nids,
15977 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15978 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015979 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015980 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15981 .adc_nids = alc861_adc_nids,
15982 .input_mux = &alc861_capture_source,
15983 },
15984 [ALC861_3ST_DIG] = {
15985 .mixers = { alc861_base_mixer },
15986 .init_verbs = { alc861_threestack_init_verbs },
15987 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
15988 .dac_nids = alc861_dac_nids,
15989 .dig_out_nid = ALC861_DIGOUT_NID,
15990 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
15991 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020015992 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010015993 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
15994 .adc_nids = alc861_adc_nids,
15995 .input_mux = &alc861_capture_source,
15996 },
15997 [ALC861_6ST_DIG] = {
15998 .mixers = { alc861_base_mixer },
15999 .init_verbs = { alc861_base_init_verbs },
16000 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16001 .dac_nids = alc861_dac_nids,
16002 .dig_out_nid = ALC861_DIGOUT_NID,
16003 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16004 .channel_mode = alc861_8ch_modes,
16005 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16006 .adc_nids = alc861_adc_nids,
16007 .input_mux = &alc861_capture_source,
16008 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016009 [ALC660_3ST] = {
16010 .mixers = { alc861_3ST_mixer },
16011 .init_verbs = { alc861_threestack_init_verbs },
16012 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16013 .dac_nids = alc660_dac_nids,
16014 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16015 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016016 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016017 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16018 .adc_nids = alc861_adc_nids,
16019 .input_mux = &alc861_capture_source,
16020 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016021 [ALC861_UNIWILL_M31] = {
16022 .mixers = { alc861_uniwill_m31_mixer },
16023 .init_verbs = { alc861_uniwill_m31_init_verbs },
16024 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16025 .dac_nids = alc861_dac_nids,
16026 .dig_out_nid = ALC861_DIGOUT_NID,
16027 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16028 .channel_mode = alc861_uniwill_m31_modes,
16029 .need_dac_fix = 1,
16030 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16031 .adc_nids = alc861_adc_nids,
16032 .input_mux = &alc861_capture_source,
16033 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016034 [ALC861_TOSHIBA] = {
16035 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016036 .init_verbs = { alc861_base_init_verbs,
16037 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016038 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16039 .dac_nids = alc861_dac_nids,
16040 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16041 .channel_mode = alc883_3ST_2ch_modes,
16042 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16043 .adc_nids = alc861_adc_nids,
16044 .input_mux = &alc861_capture_source,
16045 .unsol_event = alc861_toshiba_unsol_event,
16046 .init_hook = alc861_toshiba_automute,
16047 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016048 [ALC861_ASUS] = {
16049 .mixers = { alc861_asus_mixer },
16050 .init_verbs = { alc861_asus_init_verbs },
16051 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16052 .dac_nids = alc861_dac_nids,
16053 .dig_out_nid = ALC861_DIGOUT_NID,
16054 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16055 .channel_mode = alc861_asus_modes,
16056 .need_dac_fix = 1,
16057 .hp_nid = 0x06,
16058 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16059 .adc_nids = alc861_adc_nids,
16060 .input_mux = &alc861_capture_source,
16061 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016062 [ALC861_ASUS_LAPTOP] = {
16063 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16064 .init_verbs = { alc861_asus_init_verbs,
16065 alc861_asus_laptop_init_verbs },
16066 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16067 .dac_nids = alc861_dac_nids,
16068 .dig_out_nid = ALC861_DIGOUT_NID,
16069 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16070 .channel_mode = alc883_3ST_2ch_modes,
16071 .need_dac_fix = 1,
16072 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16073 .adc_nids = alc861_adc_nids,
16074 .input_mux = &alc861_capture_source,
16075 },
16076};
Kailang Yangdf694da2005-12-05 19:42:22 +010016077
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016078/* Pin config fixes */
16079enum {
16080 PINFIX_FSC_AMILO_PI1505,
16081};
16082
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016083static const struct alc_fixup alc861_fixups[] = {
16084 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016085 .pins = (const struct alc_pincfg[]) {
16086 { 0x0b, 0x0221101f }, /* HP */
16087 { 0x0f, 0x90170310 }, /* speaker */
16088 { }
16089 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016090 },
16091};
16092
16093static struct snd_pci_quirk alc861_fixup_tbl[] = {
16094 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16095 {}
16096};
Kailang Yangdf694da2005-12-05 19:42:22 +010016097
16098static int patch_alc861(struct hda_codec *codec)
16099{
16100 struct alc_spec *spec;
16101 int board_config;
16102 int err;
16103
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016104 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016105 if (spec == NULL)
16106 return -ENOMEM;
16107
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016108 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016109
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016110 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16111 alc861_models,
16112 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016113
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016114 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016115 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16116 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016117 board_config = ALC861_AUTO;
16118 }
16119
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016120 if (board_config == ALC861_AUTO)
16121 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016122
Kailang Yangdf694da2005-12-05 19:42:22 +010016123 if (board_config == ALC861_AUTO) {
16124 /* automatic parse from the BIOS config */
16125 err = alc861_parse_auto_config(codec);
16126 if (err < 0) {
16127 alc_free(codec);
16128 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016129 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016130 printk(KERN_INFO
16131 "hda_codec: Cannot set up configuration "
16132 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016133 board_config = ALC861_3ST_DIG;
16134 }
16135 }
16136
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016137 err = snd_hda_attach_beep_device(codec, 0x23);
16138 if (err < 0) {
16139 alc_free(codec);
16140 return err;
16141 }
16142
Kailang Yangdf694da2005-12-05 19:42:22 +010016143 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016144 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016145
Kailang Yangdf694da2005-12-05 19:42:22 +010016146 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16147 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16148
Kailang Yangdf694da2005-12-05 19:42:22 +010016149 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16150 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16151
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016152 if (!spec->cap_mixer)
16153 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016154 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16155
Takashi Iwai2134ea42008-01-10 16:53:55 +010016156 spec->vmaster_nid = 0x03;
16157
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016158 if (board_config == ALC861_AUTO)
16159 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
16160
Kailang Yangdf694da2005-12-05 19:42:22 +010016161 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016162 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016163 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016164#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016165 spec->power_hook = alc_power_eapd;
16166#endif
16167 }
16168#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016169 if (!spec->loopback.amplist)
16170 spec->loopback.amplist = alc861_loopbacks;
16171#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016172
Kailang Yangdf694da2005-12-05 19:42:22 +010016173 return 0;
16174}
16175
16176/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016177 * ALC861-VD support
16178 *
16179 * Based on ALC882
16180 *
16181 * In addition, an independent DAC
16182 */
16183#define ALC861VD_DIGOUT_NID 0x06
16184
16185static hda_nid_t alc861vd_dac_nids[4] = {
16186 /* front, surr, clfe, side surr */
16187 0x02, 0x03, 0x04, 0x05
16188};
16189
16190/* dac_nids for ALC660vd are in a different order - according to
16191 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016192 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016193 * of ALC660vd codecs, but for now there is only 3stack mixer
16194 * - and it is the same as in 861vd.
16195 * adc_nids in ALC660vd are (is) the same as in 861vd
16196 */
16197static hda_nid_t alc660vd_dac_nids[3] = {
16198 /* front, rear, clfe, rear_surr */
16199 0x02, 0x04, 0x03
16200};
16201
16202static hda_nid_t alc861vd_adc_nids[1] = {
16203 /* ADC0 */
16204 0x09,
16205};
16206
Takashi Iwaie1406342008-02-11 18:32:32 +010016207static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16208
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016209/* input MUX */
16210/* FIXME: should be a matrix-type input source selection */
16211static struct hda_input_mux alc861vd_capture_source = {
16212 .num_items = 4,
16213 .items = {
16214 { "Mic", 0x0 },
16215 { "Front Mic", 0x1 },
16216 { "Line", 0x2 },
16217 { "CD", 0x4 },
16218 },
16219};
16220
Kailang Yang272a5272007-05-14 11:00:38 +020016221static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016222 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016223 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010016224 { "Ext Mic", 0x0 },
16225 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016226 },
16227};
16228
Kailang Yangd1a991a2007-08-15 16:21:59 +020016229static struct hda_input_mux alc861vd_hp_capture_source = {
16230 .num_items = 2,
16231 .items = {
16232 { "Front Mic", 0x0 },
16233 { "ATAPI Mic", 0x1 },
16234 },
16235};
16236
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016237/*
16238 * 2ch mode
16239 */
16240static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16241 { 2, NULL }
16242};
16243
16244/*
16245 * 6ch mode
16246 */
16247static struct hda_verb alc861vd_6stack_ch6_init[] = {
16248 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16249 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16250 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16251 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16252 { } /* end */
16253};
16254
16255/*
16256 * 8ch mode
16257 */
16258static struct hda_verb alc861vd_6stack_ch8_init[] = {
16259 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16260 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16261 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16262 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16263 { } /* end */
16264};
16265
16266static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16267 { 6, alc861vd_6stack_ch6_init },
16268 { 8, alc861vd_6stack_ch8_init },
16269};
16270
16271static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16272 {
16273 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16274 .name = "Channel Mode",
16275 .info = alc_ch_mode_info,
16276 .get = alc_ch_mode_get,
16277 .put = alc_ch_mode_put,
16278 },
16279 { } /* end */
16280};
16281
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016282/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16283 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16284 */
16285static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16286 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16287 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16288
16289 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16290 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16291
16292 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16293 HDA_OUTPUT),
16294 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16295 HDA_OUTPUT),
16296 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16297 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16298
16299 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16300 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16301
16302 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16303
16304 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16305 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16306 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16307
16308 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16309 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16310 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16311
16312 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16313 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16314
16315 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16316 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16317
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016318 { } /* end */
16319};
16320
16321static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16322 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16323 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16324
16325 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16326
16327 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16328 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16329 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16330
16331 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16332 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16333 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16334
16335 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16336 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16337
16338 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16339 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16340
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016341 { } /* end */
16342};
16343
Kailang Yangbdd148a2007-05-08 15:19:08 +020016344static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16345 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16346 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16347 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16348
16349 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16350
16351 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16352 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16353 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16354
16355 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16356 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16357 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16358
16359 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16360 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16361
16362 { } /* end */
16363};
16364
Tobin Davisb419f342008-03-07 11:57:51 +010016365/* Pin assignment: Speaker=0x14, HP = 0x15,
16366 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016367 */
16368static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016369 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16370 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016371 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16372 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016373 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16374 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16375 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16376 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16377 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16378 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016379 { } /* end */
16380};
16381
Kailang Yangd1a991a2007-08-15 16:21:59 +020016382/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16383 * Front Mic=0x18, ATAPI Mic = 0x19,
16384 */
16385static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16386 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16387 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16388 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16389 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16390 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16391 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16392 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16393 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016394
Kailang Yangd1a991a2007-08-15 16:21:59 +020016395 { } /* end */
16396};
16397
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016398/*
16399 * generic initialization of ADC, input mixers and output mixers
16400 */
16401static struct hda_verb alc861vd_volume_init_verbs[] = {
16402 /*
16403 * Unmute ADC0 and set the default input to mic-in
16404 */
16405 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16406 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16407
16408 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16409 * the analog-loopback mixer widget
16410 */
16411 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016412 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16413 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16414 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16415 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16416 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016417
16418 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016419 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16420 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16421 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016422 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016423
16424 /*
16425 * Set up output mixers (0x02 - 0x05)
16426 */
16427 /* set vol=0 to output mixers */
16428 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16429 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16430 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16431 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16432
16433 /* set up input amps for analog loopback */
16434 /* Amp Indices: DAC = 0, mixer = 1 */
16435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16437 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16438 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16439 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16440 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16441 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16442 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16443
16444 { }
16445};
16446
16447/*
16448 * 3-stack pin configuration:
16449 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16450 */
16451static struct hda_verb alc861vd_3stack_init_verbs[] = {
16452 /*
16453 * Set pin mode and muting
16454 */
16455 /* set front pin widgets 0x14 for output */
16456 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16457 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16458 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16459
16460 /* Mic (rear) pin: input vref at 80% */
16461 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16462 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16463 /* Front Mic pin: input vref at 80% */
16464 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16465 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16466 /* Line In pin: input */
16467 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16468 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16469 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16470 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16471 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16472 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16473 /* CD pin widget for input */
16474 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16475
16476 { }
16477};
16478
16479/*
16480 * 6-stack pin configuration:
16481 */
16482static struct hda_verb alc861vd_6stack_init_verbs[] = {
16483 /*
16484 * Set pin mode and muting
16485 */
16486 /* set front pin widgets 0x14 for output */
16487 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16488 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16489 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16490
16491 /* Rear Pin: output 1 (0x0d) */
16492 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16493 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16494 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16495 /* CLFE Pin: output 2 (0x0e) */
16496 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16497 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16498 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16499 /* Side Pin: output 3 (0x0f) */
16500 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16501 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16502 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16503
16504 /* Mic (rear) pin: input vref at 80% */
16505 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16506 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16507 /* Front Mic pin: input vref at 80% */
16508 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16509 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16510 /* Line In pin: input */
16511 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16512 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16513 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16514 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16515 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16516 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16517 /* CD pin widget for input */
16518 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16519
16520 { }
16521};
16522
Kailang Yangbdd148a2007-05-08 15:19:08 +020016523static struct hda_verb alc861vd_eapd_verbs[] = {
16524 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16525 { }
16526};
16527
Kailang Yangf9423e72008-05-27 12:32:25 +020016528static struct hda_verb alc660vd_eapd_verbs[] = {
16529 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16530 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16531 { }
16532};
16533
Kailang Yangbdd148a2007-05-08 15:19:08 +020016534static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16535 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16536 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16537 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16538 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016539 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016540 {}
16541};
16542
Kailang Yangbdd148a2007-05-08 15:19:08 +020016543static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16544{
16545 unsigned int present;
16546 unsigned char bits;
16547
Wu Fengguang864f92b2009-11-18 12:38:02 +080016548 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016549 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016550
Takashi Iwai47fd8302007-08-10 17:11:07 +020016551 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16552 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016553}
16554
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016555static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016556{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016557 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016558 spec->autocfg.hp_pins[0] = 0x1b;
16559 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016560}
16561
16562static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16563{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016564 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016565 alc861vd_lenovo_mic_automute(codec);
16566}
16567
16568static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16569 unsigned int res)
16570{
16571 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016572 case ALC880_MIC_EVENT:
16573 alc861vd_lenovo_mic_automute(codec);
16574 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016575 default:
16576 alc_automute_amp_unsol_event(codec, res);
16577 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016578 }
16579}
16580
Kailang Yang272a5272007-05-14 11:00:38 +020016581static struct hda_verb alc861vd_dallas_verbs[] = {
16582 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16583 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16584 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16585 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16586
16587 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16588 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16589 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16590 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16591 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16592 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16593 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16594 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016595
Kailang Yang272a5272007-05-14 11:00:38 +020016596 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16597 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16598 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16599 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16600 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16601 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16602 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16603 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16604
16605 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16606 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16607 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16608 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16609 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16610 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16611 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16612 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16613
16614 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16616 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16617 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16618
16619 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016620 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016621 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16622
16623 { } /* end */
16624};
16625
16626/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016627static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016628{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016629 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016630
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016631 spec->autocfg.hp_pins[0] = 0x15;
16632 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016633}
16634
Takashi Iwaicb53c622007-08-10 17:21:45 +020016635#ifdef CONFIG_SND_HDA_POWER_SAVE
16636#define alc861vd_loopbacks alc880_loopbacks
16637#endif
16638
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016639/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016640#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16641#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16642#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16643#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16644
16645/*
16646 * configuration and preset
16647 */
16648static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16649 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016650 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016651 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016652 [ALC861VD_3ST] = "3stack",
16653 [ALC861VD_3ST_DIG] = "3stack-digout",
16654 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016655 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016656 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016657 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016658 [ALC861VD_AUTO] = "auto",
16659};
16660
16661static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016662 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16663 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016664 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016665 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016666 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016667 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016668 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016669 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016670 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016671 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016672 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016673 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016674 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016675 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016676 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016677 {}
16678};
16679
16680static struct alc_config_preset alc861vd_presets[] = {
16681 [ALC660VD_3ST] = {
16682 .mixers = { alc861vd_3st_mixer },
16683 .init_verbs = { alc861vd_volume_init_verbs,
16684 alc861vd_3stack_init_verbs },
16685 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16686 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016687 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16688 .channel_mode = alc861vd_3stack_2ch_modes,
16689 .input_mux = &alc861vd_capture_source,
16690 },
Mike Crash6963f842007-06-25 12:12:51 +020016691 [ALC660VD_3ST_DIG] = {
16692 .mixers = { alc861vd_3st_mixer },
16693 .init_verbs = { alc861vd_volume_init_verbs,
16694 alc861vd_3stack_init_verbs },
16695 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16696 .dac_nids = alc660vd_dac_nids,
16697 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016698 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16699 .channel_mode = alc861vd_3stack_2ch_modes,
16700 .input_mux = &alc861vd_capture_source,
16701 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016702 [ALC861VD_3ST] = {
16703 .mixers = { alc861vd_3st_mixer },
16704 .init_verbs = { alc861vd_volume_init_verbs,
16705 alc861vd_3stack_init_verbs },
16706 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16707 .dac_nids = alc861vd_dac_nids,
16708 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16709 .channel_mode = alc861vd_3stack_2ch_modes,
16710 .input_mux = &alc861vd_capture_source,
16711 },
16712 [ALC861VD_3ST_DIG] = {
16713 .mixers = { alc861vd_3st_mixer },
16714 .init_verbs = { alc861vd_volume_init_verbs,
16715 alc861vd_3stack_init_verbs },
16716 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16717 .dac_nids = alc861vd_dac_nids,
16718 .dig_out_nid = ALC861VD_DIGOUT_NID,
16719 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16720 .channel_mode = alc861vd_3stack_2ch_modes,
16721 .input_mux = &alc861vd_capture_source,
16722 },
16723 [ALC861VD_6ST_DIG] = {
16724 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16725 .init_verbs = { alc861vd_volume_init_verbs,
16726 alc861vd_6stack_init_verbs },
16727 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16728 .dac_nids = alc861vd_dac_nids,
16729 .dig_out_nid = ALC861VD_DIGOUT_NID,
16730 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16731 .channel_mode = alc861vd_6stack_modes,
16732 .input_mux = &alc861vd_capture_source,
16733 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016734 [ALC861VD_LENOVO] = {
16735 .mixers = { alc861vd_lenovo_mixer },
16736 .init_verbs = { alc861vd_volume_init_verbs,
16737 alc861vd_3stack_init_verbs,
16738 alc861vd_eapd_verbs,
16739 alc861vd_lenovo_unsol_verbs },
16740 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16741 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016742 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16743 .channel_mode = alc861vd_3stack_2ch_modes,
16744 .input_mux = &alc861vd_capture_source,
16745 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016746 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016747 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016748 },
Kailang Yang272a5272007-05-14 11:00:38 +020016749 [ALC861VD_DALLAS] = {
16750 .mixers = { alc861vd_dallas_mixer },
16751 .init_verbs = { alc861vd_dallas_verbs },
16752 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16753 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016754 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16755 .channel_mode = alc861vd_3stack_2ch_modes,
16756 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016757 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016758 .setup = alc861vd_dallas_setup,
16759 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016760 },
16761 [ALC861VD_HP] = {
16762 .mixers = { alc861vd_hp_mixer },
16763 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16764 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16765 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016766 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016767 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16768 .channel_mode = alc861vd_3stack_2ch_modes,
16769 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016770 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016771 .setup = alc861vd_dallas_setup,
16772 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016773 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016774 [ALC660VD_ASUS_V1S] = {
16775 .mixers = { alc861vd_lenovo_mixer },
16776 .init_verbs = { alc861vd_volume_init_verbs,
16777 alc861vd_3stack_init_verbs,
16778 alc861vd_eapd_verbs,
16779 alc861vd_lenovo_unsol_verbs },
16780 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16781 .dac_nids = alc660vd_dac_nids,
16782 .dig_out_nid = ALC861VD_DIGOUT_NID,
16783 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16784 .channel_mode = alc861vd_3stack_2ch_modes,
16785 .input_mux = &alc861vd_capture_source,
16786 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016787 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016788 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016789 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016790};
16791
16792/*
16793 * BIOS auto configuration
16794 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016795static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16796 const struct auto_pin_cfg *cfg)
16797{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016798 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016799}
16800
16801
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016802static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16803 hda_nid_t nid, int pin_type, int dac_idx)
16804{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016805 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016806}
16807
16808static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16809{
16810 struct alc_spec *spec = codec->spec;
16811 int i;
16812
16813 for (i = 0; i <= HDA_SIDE; i++) {
16814 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016815 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016816 if (nid)
16817 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016818 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016819 }
16820}
16821
16822
16823static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16824{
16825 struct alc_spec *spec = codec->spec;
16826 hda_nid_t pin;
16827
16828 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016829 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016830 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016831 pin = spec->autocfg.speaker_pins[0];
16832 if (pin)
16833 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016834}
16835
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016836#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16837
16838static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16839{
16840 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016841 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016842 int i;
16843
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016844 for (i = 0; i < cfg->num_inputs; i++) {
16845 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016846 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010016847 alc_set_input_pin(codec, nid, i);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016848 if (nid != ALC861VD_PIN_CD_NID &&
16849 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016850 snd_hda_codec_write(codec, nid, 0,
16851 AC_VERB_SET_AMP_GAIN_MUTE,
16852 AMP_OUT_MUTE);
16853 }
16854 }
16855}
16856
Takashi Iwaif511b012008-08-15 16:46:42 +020016857#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16858
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016859#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16860#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16861
16862/* add playback controls from the parsed DAC table */
16863/* Based on ALC880 version. But ALC861VD has separate,
16864 * different NIDs for mute/unmute switch and volume control */
16865static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16866 const struct auto_pin_cfg *cfg)
16867{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016868 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16869 hda_nid_t nid_v, nid_s;
16870 int i, err;
16871
16872 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016873 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016874 continue;
16875 nid_v = alc861vd_idx_to_mixer_vol(
16876 alc880_dac_to_idx(
16877 spec->multiout.dac_nids[i]));
16878 nid_s = alc861vd_idx_to_mixer_switch(
16879 alc880_dac_to_idx(
16880 spec->multiout.dac_nids[i]));
16881
16882 if (i == 2) {
16883 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016884 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16885 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016886 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16887 HDA_OUTPUT));
16888 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016889 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016890 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16891 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016892 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16893 HDA_OUTPUT));
16894 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016895 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016896 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16897 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016898 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16899 HDA_INPUT));
16900 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016901 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016902 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16903 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016904 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16905 HDA_INPUT));
16906 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016907 return err;
16908 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016909 const char *pfx;
16910 if (cfg->line_outs == 1 &&
16911 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16912 if (!cfg->hp_pins)
16913 pfx = "Speaker";
16914 else
16915 pfx = "PCM";
16916 } else
16917 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016918 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016919 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16920 HDA_OUTPUT));
16921 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016922 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016923 if (cfg->line_outs == 1 &&
16924 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16925 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016926 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016927 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016928 HDA_INPUT));
16929 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016930 return err;
16931 }
16932 }
16933 return 0;
16934}
16935
16936/* add playback controls for speaker and HP outputs */
16937/* Based on ALC880 version. But ALC861VD has separate,
16938 * different NIDs for mute/unmute switch and volume control */
16939static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16940 hda_nid_t pin, const char *pfx)
16941{
16942 hda_nid_t nid_v, nid_s;
16943 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016944
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016945 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016946 return 0;
16947
16948 if (alc880_is_fixed_pin(pin)) {
16949 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16950 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016951 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016952 spec->multiout.hp_nid = nid_v;
16953 else
16954 spec->multiout.extra_out_nid[0] = nid_v;
16955 /* control HP volume/switch on the output mixer amp */
16956 nid_v = alc861vd_idx_to_mixer_vol(
16957 alc880_fixed_pin_idx(pin));
16958 nid_s = alc861vd_idx_to_mixer_switch(
16959 alc880_fixed_pin_idx(pin));
16960
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016961 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016962 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
16963 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016964 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016965 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016966 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
16967 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016968 return err;
16969 } else if (alc880_is_multi_pin(pin)) {
16970 /* set manual connection */
16971 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016972 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016973 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
16974 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016975 return err;
16976 }
16977 return 0;
16978}
16979
16980/* parse the BIOS configuration and set up the alc_spec
16981 * return 1 if successful, 0 if the proper config is not found,
16982 * or a negative error code
16983 * Based on ALC880 version - had to change it to override
16984 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
16985static int alc861vd_parse_auto_config(struct hda_codec *codec)
16986{
16987 struct alc_spec *spec = codec->spec;
16988 int err;
16989 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
16990
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016991 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16992 alc861vd_ignore);
16993 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016994 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016995 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016996 return 0; /* can't find valid BIOS pin config */
16997
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016998 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
16999 if (err < 0)
17000 return err;
17001 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17002 if (err < 0)
17003 return err;
17004 err = alc861vd_auto_create_extra_out(spec,
17005 spec->autocfg.speaker_pins[0],
17006 "Speaker");
17007 if (err < 0)
17008 return err;
17009 err = alc861vd_auto_create_extra_out(spec,
17010 spec->autocfg.hp_pins[0],
17011 "Headphone");
17012 if (err < 0)
17013 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017014 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017015 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017016 return err;
17017
17018 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17019
Takashi Iwai757899a2010-07-30 10:48:14 +020017020 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017021
Takashi Iwai603c4012008-07-30 15:01:44 +020017022 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017023 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017024
Takashi Iwaid88897e2008-10-31 15:01:37 +010017025 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017026
17027 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017028 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017029
Takashi Iwai776e1842007-08-29 15:07:11 +020017030 err = alc_auto_add_mic_boost(codec);
17031 if (err < 0)
17032 return err;
17033
Kailang Yang6227cdc2010-02-25 08:36:52 +010017034 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017035
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017036 return 1;
17037}
17038
17039/* additional initialization for auto-configuration model */
17040static void alc861vd_auto_init(struct hda_codec *codec)
17041{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017042 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017043 alc861vd_auto_init_multi_out(codec);
17044 alc861vd_auto_init_hp_out(codec);
17045 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017046 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017047 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017048 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017049 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017050}
17051
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017052enum {
17053 ALC660VD_FIX_ASUS_GPIO1
17054};
17055
17056/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017057static const struct alc_fixup alc861vd_fixups[] = {
17058 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020017059 .verbs = (const struct hda_verb[]) {
17060 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17061 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17062 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17063 { }
17064 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017065 },
17066};
17067
17068static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17069 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17070 {}
17071};
17072
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017073static int patch_alc861vd(struct hda_codec *codec)
17074{
17075 struct alc_spec *spec;
17076 int err, board_config;
17077
17078 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17079 if (spec == NULL)
17080 return -ENOMEM;
17081
17082 codec->spec = spec;
17083
17084 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17085 alc861vd_models,
17086 alc861vd_cfg_tbl);
17087
17088 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017089 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17090 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017091 board_config = ALC861VD_AUTO;
17092 }
17093
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017094 if (board_config == ALC861VD_AUTO)
17095 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017096
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017097 if (board_config == ALC861VD_AUTO) {
17098 /* automatic parse from the BIOS config */
17099 err = alc861vd_parse_auto_config(codec);
17100 if (err < 0) {
17101 alc_free(codec);
17102 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017103 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017104 printk(KERN_INFO
17105 "hda_codec: Cannot set up configuration "
17106 "from BIOS. Using base mode...\n");
17107 board_config = ALC861VD_3ST;
17108 }
17109 }
17110
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017111 err = snd_hda_attach_beep_device(codec, 0x23);
17112 if (err < 0) {
17113 alc_free(codec);
17114 return err;
17115 }
17116
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017117 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017118 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017119
Kailang Yang2f893282008-05-27 12:14:47 +020017120 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017121 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017122 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017123 }
17124
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017125 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17126 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17127
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017128 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17129 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17130
Takashi Iwaidd704692009-08-11 08:45:11 +020017131 if (!spec->adc_nids) {
17132 spec->adc_nids = alc861vd_adc_nids;
17133 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17134 }
17135 if (!spec->capsrc_nids)
17136 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017137
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017138 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017139 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017140
Takashi Iwai2134ea42008-01-10 16:53:55 +010017141 spec->vmaster_nid = 0x02;
17142
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017143 if (board_config == ALC861VD_AUTO)
17144 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
17145
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017146 codec->patch_ops = alc_patch_ops;
17147
17148 if (board_config == ALC861VD_AUTO)
17149 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017150#ifdef CONFIG_SND_HDA_POWER_SAVE
17151 if (!spec->loopback.amplist)
17152 spec->loopback.amplist = alc861vd_loopbacks;
17153#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017154
17155 return 0;
17156}
17157
17158/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017159 * ALC662 support
17160 *
17161 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17162 * configuration. Each pin widget can choose any input DACs and a mixer.
17163 * Each ADC is connected from a mixer of all inputs. This makes possible
17164 * 6-channel independent captures.
17165 *
17166 * In addition, an independent DAC for the multi-playback (not used in this
17167 * driver yet).
17168 */
17169#define ALC662_DIGOUT_NID 0x06
17170#define ALC662_DIGIN_NID 0x0a
17171
17172static hda_nid_t alc662_dac_nids[4] = {
17173 /* front, rear, clfe, rear_surr */
17174 0x02, 0x03, 0x04
17175};
17176
Kailang Yang622e84c2009-04-21 07:39:04 +020017177static hda_nid_t alc272_dac_nids[2] = {
17178 0x02, 0x03
17179};
17180
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017181static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017182 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017183 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017184};
Takashi Iwaie1406342008-02-11 18:32:32 +010017185
Kailang Yang622e84c2009-04-21 07:39:04 +020017186static hda_nid_t alc272_adc_nids[1] = {
17187 /* ADC1-2 */
17188 0x08,
17189};
17190
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017191static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017192static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17193
Takashi Iwaie1406342008-02-11 18:32:32 +010017194
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017195/* input MUX */
17196/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017197static struct hda_input_mux alc662_capture_source = {
17198 .num_items = 4,
17199 .items = {
17200 { "Mic", 0x0 },
17201 { "Front Mic", 0x1 },
17202 { "Line", 0x2 },
17203 { "CD", 0x4 },
17204 },
17205};
17206
17207static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17208 .num_items = 2,
17209 .items = {
17210 { "Mic", 0x1 },
17211 { "Line", 0x2 },
17212 },
17213};
Kailang Yang291702f2007-10-16 14:28:03 +020017214
Kailang Yang6dda9f42008-05-27 12:05:31 +020017215static struct hda_input_mux alc663_capture_source = {
17216 .num_items = 3,
17217 .items = {
17218 { "Mic", 0x0 },
17219 { "Front Mic", 0x1 },
17220 { "Line", 0x2 },
17221 },
17222};
17223
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017224#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017225static struct hda_input_mux alc272_nc10_capture_source = {
17226 .num_items = 16,
17227 .items = {
17228 { "Autoselect Mic", 0x0 },
17229 { "Internal Mic", 0x1 },
17230 { "In-0x02", 0x2 },
17231 { "In-0x03", 0x3 },
17232 { "In-0x04", 0x4 },
17233 { "In-0x05", 0x5 },
17234 { "In-0x06", 0x6 },
17235 { "In-0x07", 0x7 },
17236 { "In-0x08", 0x8 },
17237 { "In-0x09", 0x9 },
17238 { "In-0x0a", 0x0a },
17239 { "In-0x0b", 0x0b },
17240 { "In-0x0c", 0x0c },
17241 { "In-0x0d", 0x0d },
17242 { "In-0x0e", 0x0e },
17243 { "In-0x0f", 0x0f },
17244 },
17245};
17246#endif
17247
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017248/*
17249 * 2ch mode
17250 */
17251static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17252 { 2, NULL }
17253};
17254
17255/*
17256 * 2ch mode
17257 */
17258static struct hda_verb alc662_3ST_ch2_init[] = {
17259 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17260 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17261 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17262 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17263 { } /* end */
17264};
17265
17266/*
17267 * 6ch mode
17268 */
17269static struct hda_verb alc662_3ST_ch6_init[] = {
17270 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17271 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17272 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17273 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17274 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17275 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17276 { } /* end */
17277};
17278
17279static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17280 { 2, alc662_3ST_ch2_init },
17281 { 6, alc662_3ST_ch6_init },
17282};
17283
17284/*
17285 * 2ch mode
17286 */
17287static struct hda_verb alc662_sixstack_ch6_init[] = {
17288 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17289 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17290 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17291 { } /* end */
17292};
17293
17294/*
17295 * 6ch mode
17296 */
17297static struct hda_verb alc662_sixstack_ch8_init[] = {
17298 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17299 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17300 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17301 { } /* end */
17302};
17303
17304static struct hda_channel_mode alc662_5stack_modes[2] = {
17305 { 2, alc662_sixstack_ch6_init },
17306 { 6, alc662_sixstack_ch8_init },
17307};
17308
17309/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17310 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17311 */
17312
17313static struct snd_kcontrol_new alc662_base_mixer[] = {
17314 /* output mixer control */
17315 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017316 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017317 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017318 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017319 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17320 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017321 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17322 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017323 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17324
17325 /*Input mixer control */
17326 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17327 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17328 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17329 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17330 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17331 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17332 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17333 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017334 { } /* end */
17335};
17336
17337static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17338 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017339 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017340 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17341 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17342 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17343 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17344 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17345 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17346 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17347 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17348 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017349 { } /* end */
17350};
17351
17352static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17353 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017354 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017355 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017356 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017357 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17358 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017359 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17360 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017361 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17362 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17363 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17364 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17365 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17366 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17367 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17368 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17369 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017370 { } /* end */
17371};
17372
17373static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17374 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17375 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017376 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17377 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017378 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17379 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17380 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17382 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017383 { } /* end */
17384};
17385
Kailang Yang291702f2007-10-16 14:28:03 +020017386static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017387 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17388 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017389
17390 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17391 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17392 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17393
17394 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17395 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17396 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17397 { } /* end */
17398};
17399
Kailang Yang8c427222008-01-10 13:03:59 +010017400static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017401 ALC262_HIPPO_MASTER_SWITCH,
17402 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017403 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017404 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17405 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017406 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17407 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17408 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17409 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17410 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17411 { } /* end */
17412};
17413
Kailang Yangf1d4e282008-08-26 14:03:29 +020017414static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17415 .ops = &snd_hda_bind_vol,
17416 .values = {
17417 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17418 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17419 0
17420 },
17421};
17422
17423static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17424 .ops = &snd_hda_bind_sw,
17425 .values = {
17426 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17427 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17428 0
17429 },
17430};
17431
Kailang Yang6dda9f42008-05-27 12:05:31 +020017432static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017433 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17434 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17435 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17436 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17437 { } /* end */
17438};
17439
17440static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17441 .ops = &snd_hda_bind_sw,
17442 .values = {
17443 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17444 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17445 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17446 0
17447 },
17448};
17449
17450static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17451 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17452 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17455 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17456 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17457
17458 { } /* end */
17459};
17460
17461static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17462 .ops = &snd_hda_bind_sw,
17463 .values = {
17464 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17465 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17466 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17467 0
17468 },
17469};
17470
17471static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17472 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17473 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17474 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17475 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17476 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17477 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17478 { } /* end */
17479};
17480
17481static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017482 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17483 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017484 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17485 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17486 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17487 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17488 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17489 { } /* end */
17490};
17491
17492static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17493 .ops = &snd_hda_bind_vol,
17494 .values = {
17495 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17496 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17497 0
17498 },
17499};
17500
17501static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17502 .ops = &snd_hda_bind_sw,
17503 .values = {
17504 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17505 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17506 0
17507 },
17508};
17509
17510static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17511 HDA_BIND_VOL("Master Playback Volume",
17512 &alc663_asus_two_bind_master_vol),
17513 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17514 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017515 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17516 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17517 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017518 { } /* end */
17519};
17520
17521static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17522 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17523 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17524 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17525 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17526 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17527 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017528 { } /* end */
17529};
17530
17531static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17532 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17533 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17534 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17535 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17536 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17537
17538 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17539 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17540 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17541 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17542 { } /* end */
17543};
17544
17545static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17546 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17547 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17548 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17549
17550 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17551 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17552 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17553 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17554 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17555 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17556 { } /* end */
17557};
17558
Kailang Yangebb83ee2009-12-17 12:23:00 +010017559static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17560 .ops = &snd_hda_bind_sw,
17561 .values = {
17562 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17563 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17564 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17565 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17566 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17567 0
17568 },
17569};
17570
17571static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17572 .ops = &snd_hda_bind_sw,
17573 .values = {
17574 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17575 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17576 0
17577 },
17578};
17579
17580static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17581 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17582 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17583 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17584 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17585 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17586 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17587 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17588 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17589 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17590 { } /* end */
17591};
17592
17593static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17594 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17595 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17596 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17597 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17598 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17599 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17600 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17601 { } /* end */
17602};
17603
17604
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017605static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17606 {
17607 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17608 .name = "Channel Mode",
17609 .info = alc_ch_mode_info,
17610 .get = alc_ch_mode_get,
17611 .put = alc_ch_mode_put,
17612 },
17613 { } /* end */
17614};
17615
17616static struct hda_verb alc662_init_verbs[] = {
17617 /* ADC: mute amp left and right */
17618 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17619 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017620
Kailang Yangb60dd392007-09-20 12:50:29 +020017621 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17623 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17624 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17625 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17626 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017627
17628 /* Front Pin: output 0 (0x0c) */
17629 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17630 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17631
17632 /* Rear Pin: output 1 (0x0d) */
17633 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17634 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17635
17636 /* CLFE Pin: output 2 (0x0e) */
17637 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17638 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17639
17640 /* Mic (rear) pin: input vref at 80% */
17641 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17642 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17643 /* Front Mic pin: input vref at 80% */
17644 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17645 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17646 /* Line In pin: input */
17647 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17648 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17649 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17650 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17651 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17652 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17653 /* CD pin widget for input */
17654 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17655
17656 /* FIXME: use matrix-type input source selection */
17657 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17658 /* Input mixer */
17659 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017660 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017661
17662 /* always trun on EAPD */
17663 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17664 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17665
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017666 { }
17667};
17668
Kailang Yangcec27c82010-02-04 14:18:18 +010017669static struct hda_verb alc663_init_verbs[] = {
17670 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17671 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17672 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17673 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17674 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17675 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17676 { }
17677};
17678
17679static struct hda_verb alc272_init_verbs[] = {
17680 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17681 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17682 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17683 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17684 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17685 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17686 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17687 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17688 { }
17689};
17690
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017691static struct hda_verb alc662_sue_init_verbs[] = {
17692 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17693 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017694 {}
17695};
17696
17697static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17698 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17699 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17700 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017701};
17702
Kailang Yang8c427222008-01-10 13:03:59 +010017703/* Set Unsolicited Event*/
17704static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17705 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17706 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17707 {}
17708};
17709
Kailang Yang6dda9f42008-05-27 12:05:31 +020017710static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017711 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17712 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017713 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17714 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017715 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17716 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17717 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017718 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17719 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17720 {}
17721};
17722
Kailang Yangf1d4e282008-08-26 14:03:29 +020017723static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17724 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17725 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17726 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17727 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17728 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17729 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17730 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17731 {}
17732};
17733
17734static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17735 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17736 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17737 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17738 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17739 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17740 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17741 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17742 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17743 {}
17744};
17745
17746static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17747 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17748 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17749 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17752 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17753 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17754 {}
17755};
17756
17757static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17758 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17759 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17760 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17761 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17762 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17763 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17764 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17765 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17766 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17767 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17768 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17769 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17770 {}
17771};
17772
17773static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17774 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17775 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17776 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17777 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17778 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17779 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17780 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17781 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17782 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17783 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17784 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17785 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17786 {}
17787};
17788
Kailang Yang6dda9f42008-05-27 12:05:31 +020017789static struct hda_verb alc663_g71v_init_verbs[] = {
17790 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17791 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17792 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17793
17794 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17795 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17796 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17797
17798 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17799 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17800 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17801 {}
17802};
17803
17804static struct hda_verb alc663_g50v_init_verbs[] = {
17805 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17806 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17807 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17808
17809 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17810 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17811 {}
17812};
17813
Kailang Yangf1d4e282008-08-26 14:03:29 +020017814static struct hda_verb alc662_ecs_init_verbs[] = {
17815 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17816 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17817 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17818 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17819 {}
17820};
17821
Kailang Yang622e84c2009-04-21 07:39:04 +020017822static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17823 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17824 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17825 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17826 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17827 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17828 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17829 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17830 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17831 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17832 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17833 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17834 {}
17835};
17836
17837static struct hda_verb alc272_dell_init_verbs[] = {
17838 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17839 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17840 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17841 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17842 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17843 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17844 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17845 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17846 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17847 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17848 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17849 {}
17850};
17851
Kailang Yangebb83ee2009-12-17 12:23:00 +010017852static struct hda_verb alc663_mode7_init_verbs[] = {
17853 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17854 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17855 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17856 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17857 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17858 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17859 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17860 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17861 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17862 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17863 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17864 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17865 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17866 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17867 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17868 {}
17869};
17870
17871static struct hda_verb alc663_mode8_init_verbs[] = {
17872 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17873 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17874 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17875 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17876 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17877 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17878 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17879 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17880 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17881 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17882 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17883 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17884 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17885 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17886 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17887 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17888 {}
17889};
17890
Kailang Yangf1d4e282008-08-26 14:03:29 +020017891static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17892 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17893 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17894 { } /* end */
17895};
17896
Kailang Yang622e84c2009-04-21 07:39:04 +020017897static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17898 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17899 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17900 { } /* end */
17901};
17902
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017903static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17904{
17905 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017906 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017907
Wu Fengguang864f92b2009-11-18 12:38:02 +080017908 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017909 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017910
Takashi Iwai47fd8302007-08-10 17:11:07 +020017911 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17912 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017913}
17914
17915static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17916{
17917 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017918 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017919
Wu Fengguang864f92b2009-11-18 12:38:02 +080017920 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017921 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017922
Takashi Iwai47fd8302007-08-10 17:11:07 +020017923 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17924 HDA_AMP_MUTE, bits);
17925 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17926 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017927}
17928
17929static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17930 unsigned int res)
17931{
17932 if ((res >> 26) == ALC880_HP_EVENT)
17933 alc662_lenovo_101e_all_automute(codec);
17934 if ((res >> 26) == ALC880_FRONT_EVENT)
17935 alc662_lenovo_101e_ispeaker_automute(codec);
17936}
17937
Kailang Yang291702f2007-10-16 14:28:03 +020017938/* unsolicited event for HP jack sensing */
17939static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17940 unsigned int res)
17941{
Kailang Yang291702f2007-10-16 14:28:03 +020017942 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017943 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017944 else
17945 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017946}
17947
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017948static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017949{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017950 struct alc_spec *spec = codec->spec;
17951
17952 alc262_hippo1_setup(codec);
17953 spec->ext_mic.pin = 0x18;
17954 spec->ext_mic.mux_idx = 0;
17955 spec->int_mic.pin = 0x19;
17956 spec->int_mic.mux_idx = 1;
17957 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017958}
17959
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017960static void alc662_eeepc_inithook(struct hda_codec *codec)
17961{
17962 alc262_hippo_automute(codec);
17963 alc_mic_automute(codec);
17964}
17965
17966static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010017967{
Takashi Iwai42171c12009-05-08 14:11:43 +020017968 struct alc_spec *spec = codec->spec;
17969
17970 spec->autocfg.hp_pins[0] = 0x14;
17971 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010017972}
17973
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017974#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
17975
Kailang Yang6dda9f42008-05-27 12:05:31 +020017976static void alc663_m51va_speaker_automute(struct hda_codec *codec)
17977{
17978 unsigned int present;
17979 unsigned char bits;
17980
Wu Fengguang864f92b2009-11-18 12:38:02 +080017981 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020017982 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020017983 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017984 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017985 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017986 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017987}
17988
17989static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
17990{
17991 unsigned int present;
17992 unsigned char bits;
17993
Wu Fengguang864f92b2009-11-18 12:38:02 +080017994 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017995 bits = present ? HDA_AMP_MUTE : 0;
17996 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017997 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020017998 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020017999 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018000 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018001 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018002 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018003 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018004}
18005
18006static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18007{
18008 unsigned int present;
18009 unsigned char bits;
18010
Wu Fengguang864f92b2009-11-18 12:38:02 +080018011 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018012 bits = present ? HDA_AMP_MUTE : 0;
18013 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018014 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018015 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018016 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018017 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018018 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018019 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018020 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018021}
18022
18023static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18024{
18025 unsigned int present;
18026 unsigned char bits;
18027
Wu Fengguang864f92b2009-11-18 12:38:02 +080018028 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018029 bits = present ? 0 : PIN_OUT;
18030 snd_hda_codec_write(codec, 0x14, 0,
18031 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18032}
18033
18034static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18035{
18036 unsigned int present1, present2;
18037
Wu Fengguang864f92b2009-11-18 12:38:02 +080018038 present1 = snd_hda_jack_detect(codec, 0x21);
18039 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018040
18041 if (present1 || present2) {
18042 snd_hda_codec_write_cache(codec, 0x14, 0,
18043 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18044 } else {
18045 snd_hda_codec_write_cache(codec, 0x14, 0,
18046 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18047 }
18048}
18049
18050static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18051{
18052 unsigned int present1, present2;
18053
Wu Fengguang864f92b2009-11-18 12:38:02 +080018054 present1 = snd_hda_jack_detect(codec, 0x1b);
18055 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018056
18057 if (present1 || present2) {
18058 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018059 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018060 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018061 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018062 } else {
18063 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018064 HDA_AMP_MUTE, 0);
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, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018067 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018068}
18069
Kailang Yangebb83ee2009-12-17 12:23:00 +010018070static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18071{
18072 unsigned int present1, present2;
18073
18074 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18075 AC_VERB_GET_PIN_SENSE, 0)
18076 & AC_PINSENSE_PRESENCE;
18077 present2 = snd_hda_codec_read(codec, 0x21, 0,
18078 AC_VERB_GET_PIN_SENSE, 0)
18079 & AC_PINSENSE_PRESENCE;
18080
18081 if (present1 || present2) {
18082 snd_hda_codec_write_cache(codec, 0x14, 0,
18083 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18084 snd_hda_codec_write_cache(codec, 0x17, 0,
18085 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18086 } else {
18087 snd_hda_codec_write_cache(codec, 0x14, 0,
18088 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18089 snd_hda_codec_write_cache(codec, 0x17, 0,
18090 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18091 }
18092}
18093
18094static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18095{
18096 unsigned int present1, present2;
18097
18098 present1 = snd_hda_codec_read(codec, 0x21, 0,
18099 AC_VERB_GET_PIN_SENSE, 0)
18100 & AC_PINSENSE_PRESENCE;
18101 present2 = snd_hda_codec_read(codec, 0x15, 0,
18102 AC_VERB_GET_PIN_SENSE, 0)
18103 & AC_PINSENSE_PRESENCE;
18104
18105 if (present1 || present2) {
18106 snd_hda_codec_write_cache(codec, 0x14, 0,
18107 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18108 snd_hda_codec_write_cache(codec, 0x17, 0,
18109 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18110 } else {
18111 snd_hda_codec_write_cache(codec, 0x14, 0,
18112 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18113 snd_hda_codec_write_cache(codec, 0x17, 0,
18114 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18115 }
18116}
18117
Kailang Yang6dda9f42008-05-27 12:05:31 +020018118static void alc663_m51va_unsol_event(struct hda_codec *codec,
18119 unsigned int res)
18120{
18121 switch (res >> 26) {
18122 case ALC880_HP_EVENT:
18123 alc663_m51va_speaker_automute(codec);
18124 break;
18125 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018126 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018127 break;
18128 }
18129}
18130
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018131static void alc663_m51va_setup(struct hda_codec *codec)
18132{
18133 struct alc_spec *spec = codec->spec;
18134 spec->ext_mic.pin = 0x18;
18135 spec->ext_mic.mux_idx = 0;
18136 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018137 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018138 spec->auto_mic = 1;
18139}
18140
Kailang Yang6dda9f42008-05-27 12:05:31 +020018141static void alc663_m51va_inithook(struct hda_codec *codec)
18142{
18143 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018144 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018145}
18146
Kailang Yangf1d4e282008-08-26 14:03:29 +020018147/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018148#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018149
18150static void alc663_mode1_setup(struct hda_codec *codec)
18151{
18152 struct alc_spec *spec = codec->spec;
18153 spec->ext_mic.pin = 0x18;
18154 spec->ext_mic.mux_idx = 0;
18155 spec->int_mic.pin = 0x19;
18156 spec->int_mic.mux_idx = 1;
18157 spec->auto_mic = 1;
18158}
18159
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018160#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018161
Kailang Yangf1d4e282008-08-26 14:03:29 +020018162/* ***************** Mode2 ******************************/
18163static void alc662_mode2_unsol_event(struct hda_codec *codec,
18164 unsigned int res)
18165{
18166 switch (res >> 26) {
18167 case ALC880_HP_EVENT:
18168 alc662_f5z_speaker_automute(codec);
18169 break;
18170 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018171 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018172 break;
18173 }
18174}
18175
Kailang Yangebb83ee2009-12-17 12:23:00 +010018176#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018177
Kailang Yangf1d4e282008-08-26 14:03:29 +020018178static void alc662_mode2_inithook(struct hda_codec *codec)
18179{
18180 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018181 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018182}
18183/* ***************** Mode3 ******************************/
18184static void alc663_mode3_unsol_event(struct hda_codec *codec,
18185 unsigned int res)
18186{
18187 switch (res >> 26) {
18188 case ALC880_HP_EVENT:
18189 alc663_two_hp_m1_speaker_automute(codec);
18190 break;
18191 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018192 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018193 break;
18194 }
18195}
18196
Kailang Yangebb83ee2009-12-17 12:23:00 +010018197#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018198
Kailang Yangf1d4e282008-08-26 14:03:29 +020018199static void alc663_mode3_inithook(struct hda_codec *codec)
18200{
18201 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018202 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018203}
18204/* ***************** Mode4 ******************************/
18205static void alc663_mode4_unsol_event(struct hda_codec *codec,
18206 unsigned int res)
18207{
18208 switch (res >> 26) {
18209 case ALC880_HP_EVENT:
18210 alc663_21jd_two_speaker_automute(codec);
18211 break;
18212 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018213 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018214 break;
18215 }
18216}
18217
Kailang Yangebb83ee2009-12-17 12:23:00 +010018218#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018219
Kailang Yangf1d4e282008-08-26 14:03:29 +020018220static void alc663_mode4_inithook(struct hda_codec *codec)
18221{
18222 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018223 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018224}
18225/* ***************** Mode5 ******************************/
18226static void alc663_mode5_unsol_event(struct hda_codec *codec,
18227 unsigned int res)
18228{
18229 switch (res >> 26) {
18230 case ALC880_HP_EVENT:
18231 alc663_15jd_two_speaker_automute(codec);
18232 break;
18233 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018234 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018235 break;
18236 }
18237}
18238
Kailang Yangebb83ee2009-12-17 12:23:00 +010018239#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018240
Kailang Yangf1d4e282008-08-26 14:03:29 +020018241static void alc663_mode5_inithook(struct hda_codec *codec)
18242{
18243 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018244 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018245}
18246/* ***************** Mode6 ******************************/
18247static void alc663_mode6_unsol_event(struct hda_codec *codec,
18248 unsigned int res)
18249{
18250 switch (res >> 26) {
18251 case ALC880_HP_EVENT:
18252 alc663_two_hp_m2_speaker_automute(codec);
18253 break;
18254 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018255 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018256 break;
18257 }
18258}
18259
Kailang Yangebb83ee2009-12-17 12:23:00 +010018260#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018261
Kailang Yangf1d4e282008-08-26 14:03:29 +020018262static void alc663_mode6_inithook(struct hda_codec *codec)
18263{
18264 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018265 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018266}
18267
Kailang Yangebb83ee2009-12-17 12:23:00 +010018268/* ***************** Mode7 ******************************/
18269static void alc663_mode7_unsol_event(struct hda_codec *codec,
18270 unsigned int res)
18271{
18272 switch (res >> 26) {
18273 case ALC880_HP_EVENT:
18274 alc663_two_hp_m7_speaker_automute(codec);
18275 break;
18276 case ALC880_MIC_EVENT:
18277 alc_mic_automute(codec);
18278 break;
18279 }
18280}
18281
18282#define alc663_mode7_setup alc663_mode1_setup
18283
18284static void alc663_mode7_inithook(struct hda_codec *codec)
18285{
18286 alc663_two_hp_m7_speaker_automute(codec);
18287 alc_mic_automute(codec);
18288}
18289
18290/* ***************** Mode8 ******************************/
18291static void alc663_mode8_unsol_event(struct hda_codec *codec,
18292 unsigned int res)
18293{
18294 switch (res >> 26) {
18295 case ALC880_HP_EVENT:
18296 alc663_two_hp_m8_speaker_automute(codec);
18297 break;
18298 case ALC880_MIC_EVENT:
18299 alc_mic_automute(codec);
18300 break;
18301 }
18302}
18303
18304#define alc663_mode8_setup alc663_m51va_setup
18305
18306static void alc663_mode8_inithook(struct hda_codec *codec)
18307{
18308 alc663_two_hp_m8_speaker_automute(codec);
18309 alc_mic_automute(codec);
18310}
18311
Kailang Yang6dda9f42008-05-27 12:05:31 +020018312static void alc663_g71v_hp_automute(struct hda_codec *codec)
18313{
18314 unsigned int present;
18315 unsigned char bits;
18316
Wu Fengguang864f92b2009-11-18 12:38:02 +080018317 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018318 bits = present ? HDA_AMP_MUTE : 0;
18319 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18320 HDA_AMP_MUTE, bits);
18321 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18322 HDA_AMP_MUTE, bits);
18323}
18324
18325static void alc663_g71v_front_automute(struct hda_codec *codec)
18326{
18327 unsigned int present;
18328 unsigned char bits;
18329
Wu Fengguang864f92b2009-11-18 12:38:02 +080018330 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018331 bits = present ? HDA_AMP_MUTE : 0;
18332 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18333 HDA_AMP_MUTE, bits);
18334}
18335
18336static void alc663_g71v_unsol_event(struct hda_codec *codec,
18337 unsigned int res)
18338{
18339 switch (res >> 26) {
18340 case ALC880_HP_EVENT:
18341 alc663_g71v_hp_automute(codec);
18342 break;
18343 case ALC880_FRONT_EVENT:
18344 alc663_g71v_front_automute(codec);
18345 break;
18346 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018347 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018348 break;
18349 }
18350}
18351
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018352#define alc663_g71v_setup alc663_m51va_setup
18353
Kailang Yang6dda9f42008-05-27 12:05:31 +020018354static void alc663_g71v_inithook(struct hda_codec *codec)
18355{
18356 alc663_g71v_front_automute(codec);
18357 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018358 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018359}
18360
18361static void alc663_g50v_unsol_event(struct hda_codec *codec,
18362 unsigned int res)
18363{
18364 switch (res >> 26) {
18365 case ALC880_HP_EVENT:
18366 alc663_m51va_speaker_automute(codec);
18367 break;
18368 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018369 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018370 break;
18371 }
18372}
18373
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018374#define alc663_g50v_setup alc663_m51va_setup
18375
Kailang Yang6dda9f42008-05-27 12:05:31 +020018376static void alc663_g50v_inithook(struct hda_codec *codec)
18377{
18378 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018379 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018380}
18381
Kailang Yangf1d4e282008-08-26 14:03:29 +020018382static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18383 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018384 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018385
18386 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18387 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18388 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18389
18390 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18391 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18392 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18393 { } /* end */
18394};
18395
Chris Pockelé9541ba12009-05-12 08:08:53 +020018396static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18397 /* Master Playback automatically created from Speaker and Headphone */
18398 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18399 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18400 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18401 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18402
18403 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18404 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18405 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18406
18407 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18408 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18409 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18410 { } /* end */
18411};
18412
Takashi Iwaicb53c622007-08-10 17:21:45 +020018413#ifdef CONFIG_SND_HDA_POWER_SAVE
18414#define alc662_loopbacks alc880_loopbacks
18415#endif
18416
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018417
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018418/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018419#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18420#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18421#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18422#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18423
18424/*
18425 * configuration and preset
18426 */
18427static const char *alc662_models[ALC662_MODEL_LAST] = {
18428 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18429 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18430 [ALC662_3ST_6ch] = "3stack-6ch",
18431 [ALC662_5ST_DIG] = "6stack-dig",
18432 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018433 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018434 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018435 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018436 [ALC663_ASUS_M51VA] = "m51va",
18437 [ALC663_ASUS_G71V] = "g71v",
18438 [ALC663_ASUS_H13] = "h13",
18439 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018440 [ALC663_ASUS_MODE1] = "asus-mode1",
18441 [ALC662_ASUS_MODE2] = "asus-mode2",
18442 [ALC663_ASUS_MODE3] = "asus-mode3",
18443 [ALC663_ASUS_MODE4] = "asus-mode4",
18444 [ALC663_ASUS_MODE5] = "asus-mode5",
18445 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018446 [ALC663_ASUS_MODE7] = "asus-mode7",
18447 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018448 [ALC272_DELL] = "dell",
18449 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018450 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018451 [ALC662_AUTO] = "auto",
18452};
18453
18454static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018455 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018456 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18457 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018458 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18459 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018460 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018461 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18462 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18463 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18464 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018465 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18466 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018467 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018468 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18469 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18470 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18471 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18472 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018473 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018474 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18475 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018476 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18477 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18478 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18479 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018480 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018481 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18482 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18483 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018484 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18485 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18486 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18487 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018488 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018489 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18490 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018491 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018492 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18493 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18494 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018495 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018496 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018497 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18498 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018499 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18500 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18501 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018502 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018503 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18504 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018505 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018506 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018507 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018508 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18509 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18510 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018511 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018512 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18513 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018514 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018515 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018516 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018517 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018518 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18519 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018520 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018521 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018522 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18523 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018524 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018525 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018526 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018527 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018528 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018529 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018530 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18531 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018532 {}
18533};
18534
18535static struct alc_config_preset alc662_presets[] = {
18536 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018537 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018538 .init_verbs = { alc662_init_verbs },
18539 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18540 .dac_nids = alc662_dac_nids,
18541 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018542 .dig_in_nid = ALC662_DIGIN_NID,
18543 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18544 .channel_mode = alc662_3ST_2ch_modes,
18545 .input_mux = &alc662_capture_source,
18546 },
18547 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018548 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018549 .init_verbs = { alc662_init_verbs },
18550 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18551 .dac_nids = alc662_dac_nids,
18552 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018553 .dig_in_nid = ALC662_DIGIN_NID,
18554 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18555 .channel_mode = alc662_3ST_6ch_modes,
18556 .need_dac_fix = 1,
18557 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018558 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018559 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018560 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018561 .init_verbs = { alc662_init_verbs },
18562 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18563 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018564 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18565 .channel_mode = alc662_3ST_6ch_modes,
18566 .need_dac_fix = 1,
18567 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018568 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018569 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018570 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018571 .init_verbs = { alc662_init_verbs },
18572 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18573 .dac_nids = alc662_dac_nids,
18574 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018575 .dig_in_nid = ALC662_DIGIN_NID,
18576 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18577 .channel_mode = alc662_5stack_modes,
18578 .input_mux = &alc662_capture_source,
18579 },
18580 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018581 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018582 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18583 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18584 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018585 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18586 .channel_mode = alc662_3ST_2ch_modes,
18587 .input_mux = &alc662_lenovo_101e_capture_source,
18588 .unsol_event = alc662_lenovo_101e_unsol_event,
18589 .init_hook = alc662_lenovo_101e_all_automute,
18590 },
Kailang Yang291702f2007-10-16 14:28:03 +020018591 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018592 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018593 .init_verbs = { alc662_init_verbs,
18594 alc662_eeepc_sue_init_verbs },
18595 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18596 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018597 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18598 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018599 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018600 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018601 .init_hook = alc662_eeepc_inithook,
18602 },
Kailang Yang8c427222008-01-10 13:03:59 +010018603 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018604 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018605 alc662_chmode_mixer },
18606 .init_verbs = { alc662_init_verbs,
18607 alc662_eeepc_ep20_sue_init_verbs },
18608 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18609 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018610 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18611 .channel_mode = alc662_3ST_6ch_modes,
18612 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018613 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018614 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018615 .init_hook = alc662_eeepc_ep20_inithook,
18616 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018617 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018618 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018619 .init_verbs = { alc662_init_verbs,
18620 alc662_ecs_init_verbs },
18621 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18622 .dac_nids = alc662_dac_nids,
18623 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18624 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018625 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018626 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018627 .init_hook = alc662_eeepc_inithook,
18628 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018629 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018630 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018631 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18632 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18633 .dac_nids = alc662_dac_nids,
18634 .dig_out_nid = ALC662_DIGOUT_NID,
18635 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18636 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018637 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018638 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018639 .init_hook = alc663_m51va_inithook,
18640 },
18641 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018642 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018643 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18644 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18645 .dac_nids = alc662_dac_nids,
18646 .dig_out_nid = ALC662_DIGOUT_NID,
18647 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18648 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018649 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018650 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018651 .init_hook = alc663_g71v_inithook,
18652 },
18653 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018654 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018655 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18656 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18657 .dac_nids = alc662_dac_nids,
18658 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18659 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018660 .unsol_event = alc663_m51va_unsol_event,
18661 .init_hook = alc663_m51va_inithook,
18662 },
18663 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018664 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018665 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18666 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18667 .dac_nids = alc662_dac_nids,
18668 .dig_out_nid = ALC662_DIGOUT_NID,
18669 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18670 .channel_mode = alc662_3ST_6ch_modes,
18671 .input_mux = &alc663_capture_source,
18672 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018673 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018674 .init_hook = alc663_g50v_inithook,
18675 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018676 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018677 .mixers = { alc663_m51va_mixer },
18678 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018679 .init_verbs = { alc662_init_verbs,
18680 alc663_21jd_amic_init_verbs },
18681 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18682 .hp_nid = 0x03,
18683 .dac_nids = alc662_dac_nids,
18684 .dig_out_nid = ALC662_DIGOUT_NID,
18685 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18686 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018687 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018688 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018689 .init_hook = alc663_mode1_inithook,
18690 },
18691 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018692 .mixers = { alc662_1bjd_mixer },
18693 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018694 .init_verbs = { alc662_init_verbs,
18695 alc662_1bjd_amic_init_verbs },
18696 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18697 .dac_nids = alc662_dac_nids,
18698 .dig_out_nid = ALC662_DIGOUT_NID,
18699 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18700 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018701 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018702 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018703 .init_hook = alc662_mode2_inithook,
18704 },
18705 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018706 .mixers = { alc663_two_hp_m1_mixer },
18707 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018708 .init_verbs = { alc662_init_verbs,
18709 alc663_two_hp_amic_m1_init_verbs },
18710 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18711 .hp_nid = 0x03,
18712 .dac_nids = alc662_dac_nids,
18713 .dig_out_nid = ALC662_DIGOUT_NID,
18714 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18715 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018716 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018717 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018718 .init_hook = alc663_mode3_inithook,
18719 },
18720 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018721 .mixers = { alc663_asus_21jd_clfe_mixer },
18722 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018723 .init_verbs = { alc662_init_verbs,
18724 alc663_21jd_amic_init_verbs},
18725 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18726 .hp_nid = 0x03,
18727 .dac_nids = alc662_dac_nids,
18728 .dig_out_nid = ALC662_DIGOUT_NID,
18729 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18730 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018731 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018732 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018733 .init_hook = alc663_mode4_inithook,
18734 },
18735 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018736 .mixers = { alc663_asus_15jd_clfe_mixer },
18737 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018738 .init_verbs = { alc662_init_verbs,
18739 alc663_15jd_amic_init_verbs },
18740 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18741 .hp_nid = 0x03,
18742 .dac_nids = alc662_dac_nids,
18743 .dig_out_nid = ALC662_DIGOUT_NID,
18744 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18745 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018746 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018747 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018748 .init_hook = alc663_mode5_inithook,
18749 },
18750 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018751 .mixers = { alc663_two_hp_m2_mixer },
18752 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018753 .init_verbs = { alc662_init_verbs,
18754 alc663_two_hp_amic_m2_init_verbs },
18755 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18756 .hp_nid = 0x03,
18757 .dac_nids = alc662_dac_nids,
18758 .dig_out_nid = ALC662_DIGOUT_NID,
18759 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18760 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018761 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018762 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018763 .init_hook = alc663_mode6_inithook,
18764 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018765 [ALC663_ASUS_MODE7] = {
18766 .mixers = { alc663_mode7_mixer },
18767 .cap_mixer = alc662_auto_capture_mixer,
18768 .init_verbs = { alc662_init_verbs,
18769 alc663_mode7_init_verbs },
18770 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18771 .hp_nid = 0x03,
18772 .dac_nids = alc662_dac_nids,
18773 .dig_out_nid = ALC662_DIGOUT_NID,
18774 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18775 .channel_mode = alc662_3ST_2ch_modes,
18776 .unsol_event = alc663_mode7_unsol_event,
18777 .setup = alc663_mode7_setup,
18778 .init_hook = alc663_mode7_inithook,
18779 },
18780 [ALC663_ASUS_MODE8] = {
18781 .mixers = { alc663_mode8_mixer },
18782 .cap_mixer = alc662_auto_capture_mixer,
18783 .init_verbs = { alc662_init_verbs,
18784 alc663_mode8_init_verbs },
18785 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18786 .hp_nid = 0x03,
18787 .dac_nids = alc662_dac_nids,
18788 .dig_out_nid = ALC662_DIGOUT_NID,
18789 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18790 .channel_mode = alc662_3ST_2ch_modes,
18791 .unsol_event = alc663_mode8_unsol_event,
18792 .setup = alc663_mode8_setup,
18793 .init_hook = alc663_mode8_inithook,
18794 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018795 [ALC272_DELL] = {
18796 .mixers = { alc663_m51va_mixer },
18797 .cap_mixer = alc272_auto_capture_mixer,
18798 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18799 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18800 .dac_nids = alc662_dac_nids,
18801 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18802 .adc_nids = alc272_adc_nids,
18803 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18804 .capsrc_nids = alc272_capsrc_nids,
18805 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018806 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018807 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018808 .init_hook = alc663_m51va_inithook,
18809 },
18810 [ALC272_DELL_ZM1] = {
18811 .mixers = { alc663_m51va_mixer },
18812 .cap_mixer = alc662_auto_capture_mixer,
18813 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18814 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18815 .dac_nids = alc662_dac_nids,
18816 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18817 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018818 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018819 .capsrc_nids = alc662_capsrc_nids,
18820 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018821 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018822 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018823 .init_hook = alc663_m51va_inithook,
18824 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018825 [ALC272_SAMSUNG_NC10] = {
18826 .mixers = { alc272_nc10_mixer },
18827 .init_verbs = { alc662_init_verbs,
18828 alc663_21jd_amic_init_verbs },
18829 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18830 .dac_nids = alc272_dac_nids,
18831 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18832 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018833 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018834 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018835 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018836 .init_hook = alc663_mode4_inithook,
18837 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018838};
18839
18840
18841/*
18842 * BIOS auto configuration
18843 */
18844
Takashi Iwai7085ec12009-10-02 09:03:58 +020018845/* convert from MIX nid to DAC */
18846static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18847{
18848 if (nid == 0x0f)
18849 return 0x02;
18850 else if (nid >= 0x0c && nid <= 0x0e)
18851 return nid - 0x0c + 0x02;
18852 else
18853 return 0;
18854}
18855
18856/* get MIX nid connected to the given pin targeted to DAC */
18857static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18858 hda_nid_t dac)
18859{
18860 hda_nid_t mix[4];
18861 int i, num;
18862
18863 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18864 for (i = 0; i < num; i++) {
18865 if (alc662_mix_to_dac(mix[i]) == dac)
18866 return mix[i];
18867 }
18868 return 0;
18869}
18870
18871/* look for an empty DAC slot */
18872static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18873{
18874 struct alc_spec *spec = codec->spec;
18875 hda_nid_t srcs[5];
18876 int i, j, num;
18877
18878 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18879 if (num < 0)
18880 return 0;
18881 for (i = 0; i < num; i++) {
18882 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18883 if (!nid)
18884 continue;
18885 for (j = 0; j < spec->multiout.num_dacs; j++)
18886 if (spec->multiout.dac_nids[j] == nid)
18887 break;
18888 if (j >= spec->multiout.num_dacs)
18889 return nid;
18890 }
18891 return 0;
18892}
18893
18894/* fill in the dac_nids table from the parsed pin configuration */
18895static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18896 const struct auto_pin_cfg *cfg)
18897{
18898 struct alc_spec *spec = codec->spec;
18899 int i;
18900 hda_nid_t dac;
18901
18902 spec->multiout.dac_nids = spec->private_dac_nids;
18903 for (i = 0; i < cfg->line_outs; i++) {
18904 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18905 if (!dac)
18906 continue;
18907 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18908 }
18909 return 0;
18910}
18911
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018912static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018913 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018914{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018915 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018916 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18917}
18918
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018919static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018920 hda_nid_t nid, unsigned int chs)
18921{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018922 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018923 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18924}
18925
18926#define alc662_add_stereo_vol(spec, pfx, nid) \
18927 alc662_add_vol_ctl(spec, pfx, nid, 3)
18928#define alc662_add_stereo_sw(spec, pfx, nid) \
18929 alc662_add_sw_ctl(spec, pfx, nid, 3)
18930
18931/* add playback controls from the parsed DAC table */
18932static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18933 const struct auto_pin_cfg *cfg)
18934{
18935 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018936 static const char *chname[4] = {
18937 "Front", "Surround", NULL /*CLFE*/, "Side"
18938 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018939 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018940 int i, err;
18941
18942 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018943 nid = spec->multiout.dac_nids[i];
18944 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018945 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018946 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18947 if (!mix)
18948 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018949 if (i == 2) {
18950 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018951 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018952 if (err < 0)
18953 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018954 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018955 if (err < 0)
18956 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018957 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018958 if (err < 0)
18959 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018960 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018961 if (err < 0)
18962 return err;
18963 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018964 const char *pfx;
18965 if (cfg->line_outs == 1 &&
18966 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018967 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018968 pfx = "Speaker";
18969 else
18970 pfx = "PCM";
18971 } else
18972 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018973 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018974 if (err < 0)
18975 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020018976 if (cfg->line_outs == 1 &&
18977 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
18978 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020018979 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018980 if (err < 0)
18981 return err;
18982 }
18983 }
18984 return 0;
18985}
18986
18987/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018988/* return DAC nid if any new DAC is assigned */
18989static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018990 const char *pfx)
18991{
Takashi Iwai7085ec12009-10-02 09:03:58 +020018992 struct alc_spec *spec = codec->spec;
18993 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018994 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018995
18996 if (!pin)
18997 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018998 nid = alc662_look_for_dac(codec, pin);
18999 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019000 /* the corresponding DAC is already occupied */
19001 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19002 return 0; /* no way */
19003 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019004 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019005 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19006 }
19007
19008 mix = alc662_dac_to_mix(codec, pin, nid);
19009 if (!mix)
19010 return 0;
19011 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19012 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019013 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019014 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19015 if (err < 0)
19016 return err;
19017 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019018}
19019
19020/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019021#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019022 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019023
19024static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19025 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019026 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019027{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019028 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019029 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019030
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019031 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019032 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019033 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19034 if (num <= 1)
19035 return;
19036 for (i = 0; i < num; i++) {
19037 if (alc662_mix_to_dac(srcs[i]) != dac)
19038 continue;
19039 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19040 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019041 }
19042}
19043
19044static void alc662_auto_init_multi_out(struct hda_codec *codec)
19045{
19046 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019047 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019048 int i;
19049
19050 for (i = 0; i <= HDA_SIDE; i++) {
19051 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19052 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019053 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019054 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019055 }
19056}
19057
19058static void alc662_auto_init_hp_out(struct hda_codec *codec)
19059{
19060 struct alc_spec *spec = codec->spec;
19061 hda_nid_t pin;
19062
19063 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019064 if (pin)
19065 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19066 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019067 pin = spec->autocfg.speaker_pins[0];
19068 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019069 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19070 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019071}
19072
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019073#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19074
19075static void alc662_auto_init_analog_input(struct hda_codec *codec)
19076{
19077 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019078 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019079 int i;
19080
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019081 for (i = 0; i < cfg->num_inputs; i++) {
19082 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019083 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai23f0c042009-02-26 13:03:58 +010019084 alc_set_input_pin(codec, nid, i);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019085 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019086 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019087 snd_hda_codec_write(codec, nid, 0,
19088 AC_VERB_SET_AMP_GAIN_MUTE,
19089 AMP_OUT_MUTE);
19090 }
19091 }
19092}
19093
Takashi Iwaif511b012008-08-15 16:46:42 +020019094#define alc662_auto_init_input_src alc882_auto_init_input_src
19095
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019096static int alc662_parse_auto_config(struct hda_codec *codec)
19097{
19098 struct alc_spec *spec = codec->spec;
19099 int err;
19100 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19101
19102 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19103 alc662_ignore);
19104 if (err < 0)
19105 return err;
19106 if (!spec->autocfg.line_outs)
19107 return 0; /* can't find valid BIOS pin config */
19108
Takashi Iwai7085ec12009-10-02 09:03:58 +020019109 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019110 if (err < 0)
19111 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019112 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019113 if (err < 0)
19114 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019115 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019116 spec->autocfg.speaker_pins[0],
19117 "Speaker");
19118 if (err < 0)
19119 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019120 if (err)
19121 spec->multiout.extra_out_nid[0] = err;
19122 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019123 "Headphone");
19124 if (err < 0)
19125 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019126 if (err)
19127 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019128 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019129 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019130 return err;
19131
19132 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19133
Takashi Iwai757899a2010-07-30 10:48:14 +020019134 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019135
Takashi Iwai603c4012008-07-30 15:01:44 +020019136 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019137 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019138
19139 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019140 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019141
Kailang Yangcec27c82010-02-04 14:18:18 +010019142 add_verb(spec, alc662_init_verbs);
19143 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019144 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019145 add_verb(spec, alc663_init_verbs);
19146
19147 if (codec->vendor_id == 0x10ec0272)
19148 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019149
19150 err = alc_auto_add_mic_boost(codec);
19151 if (err < 0)
19152 return err;
19153
Kailang Yang6227cdc2010-02-25 08:36:52 +010019154 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19155 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19156 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19157 else
19158 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019159
Takashi Iwai8c872862007-06-19 12:11:16 +020019160 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019161}
19162
19163/* additional initialization for auto-configuration model */
19164static void alc662_auto_init(struct hda_codec *codec)
19165{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019166 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019167 alc662_auto_init_multi_out(codec);
19168 alc662_auto_init_hp_out(codec);
19169 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019170 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019171 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019172 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019173 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019174}
19175
David Henningsson6cb3b702010-09-09 08:51:44 +020019176enum {
19177 ALC662_FIXUP_IDEAPAD,
19178};
19179
19180static const struct alc_fixup alc662_fixups[] = {
19181 [ALC662_FIXUP_IDEAPAD] = {
19182 .pins = (const struct alc_pincfg[]) {
19183 { 0x17, 0x99130112 }, /* subwoofer */
19184 { }
19185 }
19186 },
19187};
19188
19189static struct snd_pci_quirk alc662_fixup_tbl[] = {
19190 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19191 {}
19192};
19193
19194
19195
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019196static int patch_alc662(struct hda_codec *codec)
19197{
19198 struct alc_spec *spec;
19199 int err, board_config;
19200
19201 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19202 if (!spec)
19203 return -ENOMEM;
19204
19205 codec->spec = spec;
19206
Kailang Yangda00c242010-03-19 11:23:45 +010019207 alc_auto_parse_customize_define(codec);
19208
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019209 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19210
Kailang Yangc027ddc2010-03-19 11:33:06 +010019211 if (alc_read_coef_idx(codec, 0) == 0x8020)
19212 alc_codec_rename(codec, "ALC661");
19213 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
19214 codec->bus->pci->subsystem_vendor == 0x1025 &&
19215 spec->cdefine.platform_type == 1)
19216 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010019217
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019218 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19219 alc662_models,
19220 alc662_cfg_tbl);
19221 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019222 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19223 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019224 board_config = ALC662_AUTO;
19225 }
19226
19227 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019228 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019229 /* automatic parse from the BIOS config */
19230 err = alc662_parse_auto_config(codec);
19231 if (err < 0) {
19232 alc_free(codec);
19233 return err;
Takashi Iwai8c872862007-06-19 12:11:16 +020019234 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019235 printk(KERN_INFO
19236 "hda_codec: Cannot set up configuration "
19237 "from BIOS. Using base mode...\n");
19238 board_config = ALC662_3ST_2ch_DIG;
19239 }
19240 }
19241
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019242 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019243 err = snd_hda_attach_beep_device(codec, 0x1);
19244 if (err < 0) {
19245 alc_free(codec);
19246 return err;
19247 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019248 }
19249
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019250 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019251 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019252
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019253 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19254 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19255
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019256 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19257 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19258
Takashi Iwaidd704692009-08-11 08:45:11 +020019259 if (!spec->adc_nids) {
19260 spec->adc_nids = alc662_adc_nids;
19261 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19262 }
19263 if (!spec->capsrc_nids)
19264 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019265
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019266 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019267 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019268
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019269 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019270 switch (codec->vendor_id) {
19271 case 0x10ec0662:
19272 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19273 break;
19274 case 0x10ec0272:
19275 case 0x10ec0663:
19276 case 0x10ec0665:
19277 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19278 break;
19279 case 0x10ec0273:
19280 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19281 break;
19282 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019283 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019284 spec->vmaster_nid = 0x02;
19285
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019286 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019287 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019288 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019289 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0);
19290 }
19291
Takashi Iwaicb53c622007-08-10 17:21:45 +020019292#ifdef CONFIG_SND_HDA_POWER_SAVE
19293 if (!spec->loopback.amplist)
19294 spec->loopback.amplist = alc662_loopbacks;
19295#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019296
19297 return 0;
19298}
19299
Kailang Yang274693f2009-12-03 10:07:50 +010019300static int patch_alc888(struct hda_codec *codec)
19301{
19302 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19303 kfree(codec->chip_name);
19304 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019305 if (!codec->chip_name) {
19306 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019307 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019308 }
19309 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019310 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019311 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019312}
19313
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019314/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019315 * ALC680 support
19316 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019317#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019318#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19319#define alc680_modes alc260_modes
19320
19321static hda_nid_t alc680_dac_nids[3] = {
19322 /* Lout1, Lout2, hp */
19323 0x02, 0x03, 0x04
19324};
19325
19326static hda_nid_t alc680_adc_nids[3] = {
19327 /* ADC0-2 */
19328 /* DMIC, MIC, Line-in*/
19329 0x07, 0x08, 0x09
19330};
19331
Kailang Yangc69aefa2010-08-17 10:39:22 +020019332/*
19333 * Analog capture ADC cgange
19334 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019335static void alc680_rec_autoswitch(struct hda_codec *codec)
19336{
19337 struct alc_spec *spec = codec->spec;
19338 struct auto_pin_cfg *cfg = &spec->autocfg;
19339 int pin_found = 0;
19340 int type_found = AUTO_PIN_LAST;
19341 hda_nid_t nid;
19342 int i;
19343
19344 for (i = 0; i < cfg->num_inputs; i++) {
19345 nid = cfg->inputs[i].pin;
19346 if (!(snd_hda_query_pin_caps(codec, nid) &
19347 AC_PINCAP_PRES_DETECT))
19348 continue;
19349 if (snd_hda_jack_detect(codec, nid)) {
19350 if (cfg->inputs[i].type < type_found) {
19351 type_found = cfg->inputs[i].type;
19352 pin_found = nid;
19353 }
19354 }
19355 }
19356
19357 nid = 0x07;
19358 if (pin_found)
19359 snd_hda_get_connections(codec, pin_found, &nid, 1);
19360
19361 if (nid != spec->cur_adc)
19362 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19363 spec->cur_adc = nid;
19364 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19365 spec->cur_adc_format);
19366}
19367
Kailang Yangc69aefa2010-08-17 10:39:22 +020019368static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19369 struct hda_codec *codec,
19370 unsigned int stream_tag,
19371 unsigned int format,
19372 struct snd_pcm_substream *substream)
19373{
19374 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019375
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019376 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019377 spec->cur_adc_stream_tag = stream_tag;
19378 spec->cur_adc_format = format;
19379
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019380 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019381 return 0;
19382}
19383
19384static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19385 struct hda_codec *codec,
19386 struct snd_pcm_substream *substream)
19387{
19388 snd_hda_codec_cleanup_stream(codec, 0x07);
19389 snd_hda_codec_cleanup_stream(codec, 0x08);
19390 snd_hda_codec_cleanup_stream(codec, 0x09);
19391 return 0;
19392}
19393
19394static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19395 .substreams = 1, /* can be overridden */
19396 .channels_min = 2,
19397 .channels_max = 2,
19398 /* NID is set in alc_build_pcms */
19399 .ops = {
19400 .prepare = alc680_capture_pcm_prepare,
19401 .cleanup = alc680_capture_pcm_cleanup
19402 },
19403};
19404
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019405static struct snd_kcontrol_new alc680_base_mixer[] = {
19406 /* output mixer control */
19407 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19408 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19409 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19410 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019411 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019412 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019413 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019414 { }
19415};
19416
Kailang Yangc69aefa2010-08-17 10:39:22 +020019417static struct hda_bind_ctls alc680_bind_cap_vol = {
19418 .ops = &snd_hda_bind_vol,
19419 .values = {
19420 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19421 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19422 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19423 0
19424 },
19425};
19426
19427static struct hda_bind_ctls alc680_bind_cap_switch = {
19428 .ops = &snd_hda_bind_sw,
19429 .values = {
19430 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19431 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19432 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19433 0
19434 },
19435};
19436
19437static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19438 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19439 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019440 { } /* end */
19441};
19442
19443/*
19444 * generic initialization of ADC, input mixers and output mixers
19445 */
19446static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019447 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19448 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19449 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019450
Kailang Yangc69aefa2010-08-17 10:39:22 +020019451 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19452 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19453 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19454 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19455 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19456 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019457
19458 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19459 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19460 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19461 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19462 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019463
19464 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19465 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019466 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019467
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019468 { }
19469};
19470
Kailang Yangc69aefa2010-08-17 10:39:22 +020019471/* toggle speaker-output according to the hp-jack state */
19472static void alc680_base_setup(struct hda_codec *codec)
19473{
19474 struct alc_spec *spec = codec->spec;
19475
19476 spec->autocfg.hp_pins[0] = 0x16;
19477 spec->autocfg.speaker_pins[0] = 0x14;
19478 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019479 spec->autocfg.num_inputs = 2;
19480 spec->autocfg.inputs[0].pin = 0x18;
19481 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19482 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019483 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019484}
19485
19486static void alc680_unsol_event(struct hda_codec *codec,
19487 unsigned int res)
19488{
19489 if ((res >> 26) == ALC880_HP_EVENT)
19490 alc_automute_amp(codec);
19491 if ((res >> 26) == ALC880_MIC_EVENT)
19492 alc680_rec_autoswitch(codec);
19493}
19494
19495static void alc680_inithook(struct hda_codec *codec)
19496{
19497 alc_automute_amp(codec);
19498 alc680_rec_autoswitch(codec);
19499}
19500
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019501/* create input playback/capture controls for the given pin */
19502static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19503 const char *ctlname, int idx)
19504{
19505 hda_nid_t dac;
19506 int err;
19507
19508 switch (nid) {
19509 case 0x14:
19510 dac = 0x02;
19511 break;
19512 case 0x15:
19513 dac = 0x03;
19514 break;
19515 case 0x16:
19516 dac = 0x04;
19517 break;
19518 default:
19519 return 0;
19520 }
19521 if (spec->multiout.dac_nids[0] != dac &&
19522 spec->multiout.dac_nids[1] != dac) {
19523 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19524 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19525 HDA_OUTPUT));
19526 if (err < 0)
19527 return err;
19528
19529 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19530 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19531
19532 if (err < 0)
19533 return err;
19534 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19535 }
19536
19537 return 0;
19538}
19539
19540/* add playback controls from the parsed DAC table */
19541static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19542 const struct auto_pin_cfg *cfg)
19543{
19544 hda_nid_t nid;
19545 int err;
19546
19547 spec->multiout.dac_nids = spec->private_dac_nids;
19548
19549 nid = cfg->line_out_pins[0];
19550 if (nid) {
19551 const char *name;
19552 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19553 name = "Speaker";
19554 else
19555 name = "Front";
19556 err = alc680_new_analog_output(spec, nid, name, 0);
19557 if (err < 0)
19558 return err;
19559 }
19560
19561 nid = cfg->speaker_pins[0];
19562 if (nid) {
19563 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19564 if (err < 0)
19565 return err;
19566 }
19567 nid = cfg->hp_pins[0];
19568 if (nid) {
19569 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19570 if (err < 0)
19571 return err;
19572 }
19573
19574 return 0;
19575}
19576
19577static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19578 hda_nid_t nid, int pin_type)
19579{
19580 alc_set_pin_output(codec, nid, pin_type);
19581}
19582
19583static void alc680_auto_init_multi_out(struct hda_codec *codec)
19584{
19585 struct alc_spec *spec = codec->spec;
19586 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19587 if (nid) {
19588 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19589 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19590 }
19591}
19592
19593static void alc680_auto_init_hp_out(struct hda_codec *codec)
19594{
19595 struct alc_spec *spec = codec->spec;
19596 hda_nid_t pin;
19597
19598 pin = spec->autocfg.hp_pins[0];
19599 if (pin)
19600 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19601 pin = spec->autocfg.speaker_pins[0];
19602 if (pin)
19603 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19604}
19605
19606/* pcm configuration: identical with ALC880 */
19607#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19608#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19609#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19610#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019611#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019612
19613/*
19614 * BIOS auto configuration
19615 */
19616static int alc680_parse_auto_config(struct hda_codec *codec)
19617{
19618 struct alc_spec *spec = codec->spec;
19619 int err;
19620 static hda_nid_t alc680_ignore[] = { 0 };
19621
19622 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19623 alc680_ignore);
19624 if (err < 0)
19625 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019626
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019627 if (!spec->autocfg.line_outs) {
19628 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19629 spec->multiout.max_channels = 2;
19630 spec->no_analog = 1;
19631 goto dig_only;
19632 }
19633 return 0; /* can't find valid BIOS pin config */
19634 }
19635 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19636 if (err < 0)
19637 return err;
19638
19639 spec->multiout.max_channels = 2;
19640
19641 dig_only:
19642 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019643 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019644 if (spec->kctls.list)
19645 add_mixer(spec, spec->kctls.list);
19646
19647 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019648
19649 err = alc_auto_add_mic_boost(codec);
19650 if (err < 0)
19651 return err;
19652
19653 return 1;
19654}
19655
19656#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19657
19658/* init callback for auto-configuration model -- overriding the default init */
19659static void alc680_auto_init(struct hda_codec *codec)
19660{
19661 struct alc_spec *spec = codec->spec;
19662 alc680_auto_init_multi_out(codec);
19663 alc680_auto_init_hp_out(codec);
19664 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019665 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019666 if (spec->unsol_event)
19667 alc_inithook(codec);
19668}
19669
19670/*
19671 * configuration and preset
19672 */
19673static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019674 [ALC680_BASE] = "base",
19675 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019676};
19677
19678static struct snd_pci_quirk alc680_cfg_tbl[] = {
19679 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19680 {}
19681};
19682
19683static struct alc_config_preset alc680_presets[] = {
19684 [ALC680_BASE] = {
19685 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019686 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019687 .init_verbs = { alc680_init_verbs },
19688 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19689 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019690 .dig_out_nid = ALC680_DIGOUT_NID,
19691 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19692 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019693 .unsol_event = alc680_unsol_event,
19694 .setup = alc680_base_setup,
19695 .init_hook = alc680_inithook,
19696
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019697 },
19698};
19699
19700static int patch_alc680(struct hda_codec *codec)
19701{
19702 struct alc_spec *spec;
19703 int board_config;
19704 int err;
19705
19706 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19707 if (spec == NULL)
19708 return -ENOMEM;
19709
19710 codec->spec = spec;
19711
19712 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19713 alc680_models,
19714 alc680_cfg_tbl);
19715
19716 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19717 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19718 codec->chip_name);
19719 board_config = ALC680_AUTO;
19720 }
19721
19722 if (board_config == ALC680_AUTO) {
19723 /* automatic parse from the BIOS config */
19724 err = alc680_parse_auto_config(codec);
19725 if (err < 0) {
19726 alc_free(codec);
19727 return err;
19728 } else if (!err) {
19729 printk(KERN_INFO
19730 "hda_codec: Cannot set up configuration "
19731 "from BIOS. Using base mode...\n");
19732 board_config = ALC680_BASE;
19733 }
19734 }
19735
19736 if (board_config != ALC680_AUTO)
19737 setup_preset(codec, &alc680_presets[board_config]);
19738
19739 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019740 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019741 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019742 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019743
19744 if (!spec->adc_nids) {
19745 spec->adc_nids = alc680_adc_nids;
19746 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19747 }
19748
19749 if (!spec->cap_mixer)
19750 set_capture_mixer(codec);
19751
19752 spec->vmaster_nid = 0x02;
19753
19754 codec->patch_ops = alc_patch_ops;
19755 if (board_config == ALC680_AUTO)
19756 spec->init_hook = alc680_auto_init;
19757
19758 return 0;
19759}
19760
19761/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019762 * patch entries
19763 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019764static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019765 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019766 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019767 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019768 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019769 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019770 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019771 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019772 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019773 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019774 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019775 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19776 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19777 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019778 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai49535502009-06-30 15:28:30 +020019779 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019780 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19781 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019782 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019783 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019784 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019785 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019786 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019787 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai49535502009-06-30 15:28:30 +020019788 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019789 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai49535502009-06-30 15:28:30 +020019790 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019791 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai49535502009-06-30 15:28:30 +020019792 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019793 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai49535502009-06-30 15:28:30 +020019794 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020019795 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai49535502009-06-30 15:28:30 +020019796 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019797 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai49535502009-06-30 15:28:30 +020019798 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019799 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019800 {} /* terminator */
19801};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019802
19803MODULE_ALIAS("snd-hda-codec-id:10ec*");
19804
19805MODULE_LICENSE("GPL");
19806MODULE_DESCRIPTION("Realtek HD-audio codec");
19807
19808static struct hda_codec_preset_list realtek_list = {
19809 .preset = snd_hda_preset_realtek,
19810 .owner = THIS_MODULE,
19811};
19812
19813static int __init patch_realtek_init(void)
19814{
19815 return snd_hda_add_codec_preset(&realtek_list);
19816}
19817
19818static void __exit patch_realtek_exit(void)
19819{
19820 snd_hda_delete_codec_preset(&realtek_list);
19821}
19822
19823module_init(patch_realtek_init)
19824module_exit(patch_realtek_exit)