blob: c4d9ad70fde7015bba2847c23843cb0a0af2b614 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Universal Interface for Intel High Definition Audio Codec
3 *
4 * HD audio interface patch for ALC 260/880/882 codecs
5 *
Kailang Yangdf694da2005-12-05 19:42:22 +01006 * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
7 * PeiSen Hou <pshou@realtek.com.tw>
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * Takashi Iwai <tiwai@suse.de>
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01009 * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * This driver is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This driver is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/init.h>
27#include <linux/delay.h>
28#include <linux/slab.h>
29#include <linux/pci.h>
30#include <sound/core.h>
Kailang Yang9ad0e492010-09-14 23:22:00 +020031#include <sound/jack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "hda_codec.h"
33#include "hda_local.h"
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090034#include "hda_beep.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Kailang Yangccc656c2006-10-17 12:32:26 +020036#define ALC880_FRONT_EVENT 0x01
37#define ALC880_DCVOL_EVENT 0x02
38#define ALC880_HP_EVENT 0x04
39#define ALC880_MIC_EVENT 0x08
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
41/* ALC880 board config type */
42enum {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 ALC880_3ST,
44 ALC880_3ST_DIG,
45 ALC880_5ST,
46 ALC880_5ST_DIG,
47 ALC880_W810,
Takashi Iwaidfc0ff62005-05-12 14:31:49 +020048 ALC880_Z71V,
Takashi Iwaib6482d42005-06-27 15:32:43 +020049 ALC880_6ST,
Takashi Iwai16ded522005-06-10 19:58:24 +020050 ALC880_6ST_DIG,
51 ALC880_F1734,
52 ALC880_ASUS,
53 ALC880_ASUS_DIG,
54 ALC880_ASUS_W1V,
Kailang Yangdf694da2005-12-05 19:42:22 +010055 ALC880_ASUS_DIG2,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +010056 ALC880_FUJITSU,
Takashi Iwai16ded522005-06-10 19:58:24 +020057 ALC880_UNIWILL_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +020058 ALC880_UNIWILL,
59 ALC880_UNIWILL_P53,
Kailang Yangdf694da2005-12-05 19:42:22 +010060 ALC880_CLEVO,
61 ALC880_TCL_S700,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010062 ALC880_LG,
Takashi Iwaid6815182006-03-23 16:06:23 +010063 ALC880_LG_LW,
Takashi Iwaidf99cd32008-04-25 15:25:04 +020064 ALC880_MEDION_RIM,
Takashi Iwaie9edcee2005-06-13 14:16:38 +020065#ifdef CONFIG_SND_DEBUG
66 ALC880_TEST,
67#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010068 ALC880_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020069 ALC880_MODEL_LAST /* last tag */
70};
71
72/* ALC260 models */
73enum {
74 ALC260_BASIC,
75 ALC260_HP,
Kailang Yang3f878302008-08-26 13:02:23 +020076 ALC260_HP_DC7600,
Kailang Yangdf694da2005-12-05 19:42:22 +010077 ALC260_HP_3013,
78 ALC260_FUJITSU_S702X,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +010079 ALC260_ACER,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020080 ALC260_WILL,
81 ALC260_REPLACER_672V,
Michael Schwingencc959482009-02-22 18:58:45 +010082 ALC260_FAVORIT100,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +010083#ifdef CONFIG_SND_DEBUG
84 ALC260_TEST,
85#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010086 ALC260_AUTO,
Takashi Iwai16ded522005-06-10 19:58:24 +020087 ALC260_MODEL_LAST /* last tag */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088};
89
Kailang Yangdf694da2005-12-05 19:42:22 +010090/* ALC262 models */
91enum {
92 ALC262_BASIC,
Kailang Yangccc656c2006-10-17 12:32:26 +020093 ALC262_HIPPO,
94 ALC262_HIPPO_1,
Takashi Iwai834be882006-03-01 14:16:17 +010095 ALC262_FUJITSU,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020096 ALC262_HP_BPC,
Kailang Yangcd7509a2007-01-26 18:33:17 +010097 ALC262_HP_BPC_D7000_WL,
98 ALC262_HP_BPC_D7000_WF,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010099 ALC262_HP_TC_T5735,
Kailang Yang8c427222008-01-10 13:03:59 +0100100 ALC262_HP_RP5700,
Takashi Iwai304dcaa2006-07-25 14:51:16 +0200101 ALC262_BENQ_ED8,
Kailang Yang272a5272007-05-14 11:00:38 +0200102 ALC262_SONY_ASSAMD,
Kailang Yang83c34212007-07-05 11:43:05 +0200103 ALC262_BENQ_T31,
Tobin Davisf651b502007-10-26 12:40:47 +0200104 ALC262_ULTRA,
Jiang zhe0e31daf2008-03-20 12:12:39 +0100105 ALC262_LENOVO_3000,
Pascal Terjane8f9ae22008-08-04 14:36:05 +0200106 ALC262_NEC,
Kailang Yang4e555fe2008-08-26 13:05:55 +0200107 ALC262_TOSHIBA_S06,
Hiroshi Miura9f99a632008-08-28 16:09:06 +0200108 ALC262_TOSHIBA_RX1,
Tony Vroonba340e82009-02-02 19:01:30 +0000109 ALC262_TYAN,
Kailang Yangdf694da2005-12-05 19:42:22 +0100110 ALC262_AUTO,
111 ALC262_MODEL_LAST /* last tag */
112};
113
Kailang Yanga361d842007-06-05 12:30:55 +0200114/* ALC268 models */
115enum {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +0200116 ALC267_QUANTA_IL1,
Kailang Yanga361d842007-06-05 12:30:55 +0200117 ALC268_3ST,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200118 ALC268_TOSHIBA,
Takashi Iwaid2738092007-08-16 14:59:45 +0200119 ALC268_ACER,
Takashi Iwaic238b4f2008-11-05 14:57:20 +0100120 ALC268_ACER_DMIC,
Kailang Yang8ef355d2008-08-26 13:10:22 +0200121 ALC268_ACER_ASPIRE_ONE,
Takashi Iwai3866f0b2008-01-15 12:37:42 +0100122 ALC268_DELL,
Mirco Tischlerf12462c2008-02-04 12:33:59 +0100123 ALC268_ZEPTO,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +0100124#ifdef CONFIG_SND_DEBUG
125 ALC268_TEST,
126#endif
Kailang Yanga361d842007-06-05 12:30:55 +0200127 ALC268_AUTO,
128 ALC268_MODEL_LAST /* last tag */
129};
130
Kailang Yangf6a92242007-12-13 16:52:54 +0100131/* ALC269 models */
132enum {
133 ALC269_BASIC,
Kailang Yang60db6b52008-08-26 13:13:00 +0200134 ALC269_QUANTA_FL1,
Kailang Yang84898e82010-02-04 14:16:14 +0100135 ALC269_AMIC,
136 ALC269_DMIC,
137 ALC269VB_AMIC,
138 ALC269VB_DMIC,
Takashi Iwai26f5df22008-11-03 17:39:46 +0100139 ALC269_FUJITSU,
Tony Vroon64154832008-11-06 15:08:49 +0000140 ALC269_LIFEBOOK,
Kailang Yangfe3eb0a2010-08-06 10:02:57 +0200141 ALC271_ACER,
Kailang Yangf6a92242007-12-13 16:52:54 +0100142 ALC269_AUTO,
143 ALC269_MODEL_LAST /* last tag */
144};
145
Kailang Yangdf694da2005-12-05 19:42:22 +0100146/* ALC861 models */
147enum {
148 ALC861_3ST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200149 ALC660_3ST,
Kailang Yangdf694da2005-12-05 19:42:22 +0100150 ALC861_3ST_DIG,
151 ALC861_6ST_DIG,
Takashi Iwai22309c32006-08-09 16:57:28 +0200152 ALC861_UNIWILL_M31,
Tobin Davisa53d1ae2006-10-17 12:00:28 +0200153 ALC861_TOSHIBA,
Mariusz Domanski7cdbff92006-10-23 13:42:56 +0200154 ALC861_ASUS,
Takashi Iwai56bb0ca2006-11-22 11:52:52 +0100155 ALC861_ASUS_LAPTOP,
Kailang Yangdf694da2005-12-05 19:42:22 +0100156 ALC861_AUTO,
157 ALC861_MODEL_LAST,
158};
159
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100160/* ALC861-VD models */
161enum {
162 ALC660VD_3ST,
Mike Crash6963f842007-06-25 12:12:51 +0200163 ALC660VD_3ST_DIG,
Takashi Iwai13c94742008-11-05 08:06:08 +0100164 ALC660VD_ASUS_V1S,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100165 ALC861VD_3ST,
166 ALC861VD_3ST_DIG,
167 ALC861VD_6ST_DIG,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200168 ALC861VD_LENOVO,
Kailang Yang272a5272007-05-14 11:00:38 +0200169 ALC861VD_DALLAS,
Kailang Yangd1a991a2007-08-15 16:21:59 +0200170 ALC861VD_HP,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +0100171 ALC861VD_AUTO,
172 ALC861VD_MODEL_LAST,
173};
174
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200175/* ALC662 models */
176enum {
177 ALC662_3ST_2ch_DIG,
178 ALC662_3ST_6ch_DIG,
179 ALC662_3ST_6ch,
180 ALC662_5ST_DIG,
181 ALC662_LENOVO_101E,
Kailang Yang291702f2007-10-16 14:28:03 +0200182 ALC662_ASUS_EEEPC_P701,
Kailang Yang8c427222008-01-10 13:03:59 +0100183 ALC662_ASUS_EEEPC_EP20,
Kailang Yang6dda9f42008-05-27 12:05:31 +0200184 ALC663_ASUS_M51VA,
185 ALC663_ASUS_G71V,
186 ALC663_ASUS_H13,
187 ALC663_ASUS_G50V,
Kailang Yangf1d4e282008-08-26 14:03:29 +0200188 ALC662_ECS,
189 ALC663_ASUS_MODE1,
190 ALC662_ASUS_MODE2,
191 ALC663_ASUS_MODE3,
192 ALC663_ASUS_MODE4,
193 ALC663_ASUS_MODE5,
194 ALC663_ASUS_MODE6,
Kailang Yangebb83ee2009-12-17 12:23:00 +0100195 ALC663_ASUS_MODE7,
196 ALC663_ASUS_MODE8,
Kailang Yang622e84c2009-04-21 07:39:04 +0200197 ALC272_DELL,
198 ALC272_DELL_ZM1,
Chris Pockelé9541ba12009-05-12 08:08:53 +0200199 ALC272_SAMSUNG_NC10,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200200 ALC662_AUTO,
201 ALC662_MODEL_LAST,
202};
203
Kailang Yangdf694da2005-12-05 19:42:22 +0100204/* ALC882 models */
205enum {
206 ALC882_3ST_DIG,
207 ALC882_6ST_DIG,
Takashi Iwai4b146cb2006-07-28 14:42:36 +0200208 ALC882_ARIMA,
Kailang Yangbdd148a2007-05-08 15:19:08 +0200209 ALC882_W2JC,
Kailang Yang272a5272007-05-14 11:00:38 +0200210 ALC882_TARGA,
211 ALC882_ASUS_A7J,
Takashi Iwai914759b2007-09-06 14:52:04 +0200212 ALC882_ASUS_A7M,
Tobin Davis9102cd12006-12-15 10:02:12 +0100213 ALC885_MACPRO,
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -0800214 ALC885_MBA21,
Takashi Iwai87350ad2007-08-16 18:19:38 +0200215 ALC885_MBP3,
Kacper Szczesniak41d55452009-05-07 12:47:43 +0200216 ALC885_MB5,
Luke Yelaviche458b1f2010-02-12 16:28:29 +1100217 ALC885_MACMINI3,
Nicola Fagnanic54728d2007-07-19 23:28:52 +0200218 ALC885_IMAC24,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -0800219 ALC885_IMAC91,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200220 ALC883_3ST_2ch_DIG,
221 ALC883_3ST_6ch_DIG,
222 ALC883_3ST_6ch,
223 ALC883_6ST_DIG,
Kailang Yangccc656c2006-10-17 12:32:26 +0200224 ALC883_TARGA_DIG,
225 ALC883_TARGA_2ch_DIG,
David Heidelberger64a8be72009-06-08 16:15:18 +0200226 ALC883_TARGA_8ch_DIG,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +0200227 ALC883_ACER,
Tobin Davis2880a862007-08-07 11:50:26 +0200228 ALC883_ACER_ASPIRE,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +0800229 ALC888_ACER_ASPIRE_4930G,
Tony Vroond2fd4b02009-06-21 00:40:10 +0100230 ALC888_ACER_ASPIRE_6530G,
Hector Martin3b315d72009-06-02 10:54:19 +0200231 ALC888_ACER_ASPIRE_8930G,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +0200232 ALC888_ACER_ASPIRE_7730G,
Tobin Davisc07584c2006-10-13 12:32:16 +0200233 ALC883_MEDION,
Kailang Yangea1fb292008-08-26 12:58:38 +0200234 ALC883_MEDION_MD2,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200235 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100236 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200237 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200238 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200239 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200240 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200241 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200242 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100243 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100244 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430245 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100246 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100247 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800248 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200249 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200250 ALC889A_INTEL,
251 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200252 ALC888_ASUS_M90V,
253 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200254 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100255 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200256 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200257 ALC882_AUTO,
258 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200259};
260
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200261/* ALC680 models */
262enum {
263 ALC680_BASE,
264 ALC680_AUTO,
265 ALC680_MODEL_LAST,
266};
267
Kailang Yangdf694da2005-12-05 19:42:22 +0100268/* for GPIO Poll */
269#define GPIO_MASK 0x03
270
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200271/* extra amp-initialization sequence types */
272enum {
273 ALC_INIT_NONE,
274 ALC_INIT_DEFAULT,
275 ALC_INIT_GPIO1,
276 ALC_INIT_GPIO2,
277 ALC_INIT_GPIO3,
278};
279
Takashi Iwai6c819492009-08-10 18:47:44 +0200280struct alc_mic_route {
281 hda_nid_t pin;
282 unsigned char mux_idx;
283 unsigned char amix_idx;
284};
285
Kailang Yang9ad0e492010-09-14 23:22:00 +0200286struct alc_jack {
287 hda_nid_t nid;
288 int type;
289 struct snd_jack *jack;
290};
291
Takashi Iwai6c819492009-08-10 18:47:44 +0200292#define MUX_IDX_UNDEF ((unsigned char)-1)
293
Kailang Yangda00c242010-03-19 11:23:45 +0100294struct alc_customize_define {
295 unsigned int sku_cfg;
296 unsigned char port_connectivity;
297 unsigned char check_sum;
298 unsigned char customization;
299 unsigned char external_amp;
300 unsigned int enable_pcbeep:1;
301 unsigned int platform_type:1;
302 unsigned int swap:1;
303 unsigned int override:1;
304};
305
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306struct alc_spec {
307 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100308 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100310 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100311 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200313 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200314 * don't forget NULL
315 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200316 */
317 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200319 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 struct hda_pcm_stream *stream_analog_playback;
321 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100322 struct hda_pcm_stream *stream_analog_alt_playback;
323 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200325 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 struct hda_pcm_stream *stream_digital_playback;
327 struct hda_pcm_stream *stream_digital_capture;
328
329 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200330 struct hda_multi_out multiout; /* playback set-up
331 * max_channels, dacs must be set
332 * dig_out_nid and hp_nid are optional
333 */
Takashi Iwai63300792008-01-24 15:31:36 +0100334 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100335 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100336 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337
338 /* capture */
339 unsigned int num_adc_nids;
340 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100341 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200342 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Takashi Iwai840b64c2010-07-13 22:49:01 +0200344 /* capture setup for dynamic dual-adc switch */
345 unsigned int cur_adc_idx;
346 hda_nid_t cur_adc;
347 unsigned int cur_adc_stream_tag;
348 unsigned int cur_adc_format;
349
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200351 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 const struct hda_input_mux *input_mux;
353 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200354 struct alc_mic_route ext_mic;
355 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
357 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100358 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200360 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200361 int const_channel_count;
362 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363
364 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100365 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200366
Kailang Yang9ad0e492010-09-14 23:22:00 +0200367 /* jack detection */
368 struct snd_array jacks;
369
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200370 /* dynamic controls, init_verbs and input_mux */
371 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100372 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200373 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200374 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200375 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200376 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
377 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100378
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100379 /* hooks */
380 void (*init_hook)(struct hda_codec *codec);
381 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100382#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500383 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100384#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100385
Takashi Iwai834be882006-03-01 14:16:17 +0100386 /* for pin sensing */
387 unsigned int sense_updated: 1;
388 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100389 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200390 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200391
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100392 /* other flags */
393 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200394 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200395 int init_amp;
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100396
Takashi Iwai2134ea42008-01-10 16:53:55 +0100397 /* for virtual master */
398 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200399#ifdef CONFIG_SND_HDA_POWER_SAVE
400 struct hda_loopback_check loopback;
401#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200402
403 /* for PLL fix */
404 hda_nid_t pll_nid;
405 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100406};
407
408/*
409 * configuration template - to be copied to the spec instance
410 */
411struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200412 struct snd_kcontrol_new *mixers[5]; /* should be identical size
413 * with spec
414 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100415 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100416 const struct hda_verb *init_verbs[5];
417 unsigned int num_dacs;
418 hda_nid_t *dac_nids;
419 hda_nid_t dig_out_nid; /* optional */
420 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800421 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100422 unsigned int num_adc_nids;
423 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100424 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100425 hda_nid_t dig_in_nid;
426 unsigned int num_channel_mode;
427 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200428 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200429 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200430 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100431 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100432 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200433 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100434 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200435#ifdef CONFIG_SND_HDA_POWER_SAVE
436 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500437 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200438#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439};
440
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
442/*
443 * input MUX handling
444 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200445static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
446 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447{
448 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
449 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200450 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
451 if (mux_idx >= spec->num_mux_defs)
452 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100453 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
454 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200455 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456}
457
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200458static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
459 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
461 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
462 struct alc_spec *spec = codec->spec;
463 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
464
465 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
466 return 0;
467}
468
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200469static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
470 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471{
472 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
473 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100474 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100476 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100477 hda_nid_t nid = spec->capsrc_nids ?
478 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200479 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480
Takashi Iwaicd896c32008-11-18 12:36:33 +0100481 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
482 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100483 if (!imux->num_items && mux_idx > 0)
484 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100485
Takashi Iwaia22d5432009-07-27 12:54:26 +0200486 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200487 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100488 /* Matrix-mixer style (e.g. ALC882) */
489 unsigned int *cur_val = &spec->cur_mux[adc_idx];
490 unsigned int i, idx;
491
492 idx = ucontrol->value.enumerated.item[0];
493 if (idx >= imux->num_items)
494 idx = imux->num_items - 1;
495 if (*cur_val == idx)
496 return 0;
497 for (i = 0; i < imux->num_items; i++) {
498 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
499 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
500 imux->items[i].index,
501 HDA_AMP_MUTE, v);
502 }
503 *cur_val = idx;
504 return 1;
505 } else {
506 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100507 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100508 &spec->cur_mux[adc_idx]);
509 }
510}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200511
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512/*
513 * channel mode setting
514 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200515static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
516 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517{
518 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
519 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100520 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
521 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522}
523
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200524static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
525 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526{
527 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
528 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100529 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200530 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200531 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532}
533
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200534static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
535 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536{
537 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
538 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200539 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
540 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200541 &spec->ext_channel_count);
542 if (err >= 0 && !spec->const_channel_count) {
543 spec->multiout.max_channels = spec->ext_channel_count;
544 if (spec->need_dac_fix)
545 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
546 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200547 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548}
549
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100551 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200552 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100553 * being part of a format specifier. Maximum allowed length of a value is
554 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100555 *
556 * Note: some retasking pin complexes seem to ignore requests for input
557 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
558 * are requested. Therefore order this list so that this behaviour will not
559 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200560 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
561 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200562 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100563static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100564 "Mic 50pc bias", "Mic 80pc bias",
565 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100566};
567static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100568 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100569};
570/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200571 * in the pin being assumed to be exclusively an input or an output pin. In
572 * addition, "input" pins may or may not process the mic bias option
573 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
574 * accept requests for bias as of chip versions up to March 2006) and/or
575 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100576 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200577#define ALC_PIN_DIR_IN 0x00
578#define ALC_PIN_DIR_OUT 0x01
579#define ALC_PIN_DIR_INOUT 0x02
580#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
581#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100582
Kailang Yangea1fb292008-08-26 12:58:38 +0200583/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100584 * For each direction the minimum and maximum values are given.
585 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200586static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100587 { 0, 2 }, /* ALC_PIN_DIR_IN */
588 { 3, 4 }, /* ALC_PIN_DIR_OUT */
589 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200590 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
591 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100592};
593#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
594#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
595#define alc_pin_mode_n_items(_dir) \
596 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
597
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200598static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
599 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200600{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100601 unsigned int item_num = uinfo->value.enumerated.item;
602 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
603
604 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200605 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100606 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
607
608 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
609 item_num = alc_pin_mode_min(dir);
610 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200611 return 0;
612}
613
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200614static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
615 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200616{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100617 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200618 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
619 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100620 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200621 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200622 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
623 AC_VERB_GET_PIN_WIDGET_CONTROL,
624 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200625
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100626 /* Find enumerated value for current pinctl setting */
627 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200628 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100629 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200630 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100631 return 0;
632}
633
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200634static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
635 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100636{
637 signed int change;
638 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
639 hda_nid_t nid = kcontrol->private_value & 0xffff;
640 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
641 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200642 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
643 AC_VERB_GET_PIN_WIDGET_CONTROL,
644 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100645
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200646 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100647 val = alc_pin_mode_min(dir);
648
649 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100650 if (change) {
651 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200652 snd_hda_codec_write_cache(codec, nid, 0,
653 AC_VERB_SET_PIN_WIDGET_CONTROL,
654 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100655
Kailang Yangea1fb292008-08-26 12:58:38 +0200656 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100657 * for the requested pin mode. Enum values of 2 or less are
658 * input modes.
659 *
660 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200661 * reduces noise slightly (particularly on input) so we'll
662 * do it. However, having both input and output buffers
663 * enabled simultaneously doesn't seem to be problematic if
664 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100665 */
666 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200667 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
668 HDA_AMP_MUTE, HDA_AMP_MUTE);
669 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
670 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100671 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200672 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
673 HDA_AMP_MUTE, HDA_AMP_MUTE);
674 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
675 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100676 }
677 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200678 return change;
679}
680
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100681#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200682 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100683 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100684 .info = alc_pin_mode_info, \
685 .get = alc_pin_mode_get, \
686 .put = alc_pin_mode_put, \
687 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100688
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100689/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
690 * together using a mask with more than one bit set. This control is
691 * currently used only by the ALC260 test model. At this stage they are not
692 * needed for any "production" models.
693 */
694#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200695#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200696
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200697static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
698 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100699{
700 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
701 hda_nid_t nid = kcontrol->private_value & 0xffff;
702 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
703 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200704 unsigned int val = snd_hda_codec_read(codec, nid, 0,
705 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100706
707 *valp = (val & mask) != 0;
708 return 0;
709}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200710static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
711 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100712{
713 signed int change;
714 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
715 hda_nid_t nid = kcontrol->private_value & 0xffff;
716 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
717 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200718 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
719 AC_VERB_GET_GPIO_DATA,
720 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100721
722 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200723 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
724 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100725 gpio_data &= ~mask;
726 else
727 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200728 snd_hda_codec_write_cache(codec, nid, 0,
729 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100730
731 return change;
732}
733#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
734 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100735 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100736 .info = alc_gpio_data_info, \
737 .get = alc_gpio_data_get, \
738 .put = alc_gpio_data_put, \
739 .private_value = nid | (mask<<16) }
740#endif /* CONFIG_SND_DEBUG */
741
Jonathan Woithe92621f12006-02-28 11:47:47 +0100742/* A switch control to allow the enabling of the digital IO pins on the
743 * ALC260. This is incredibly simplistic; the intention of this control is
744 * to provide something in the test model allowing digital outputs to be
745 * identified if present. If models are found which can utilise these
746 * outputs a more complete mixer control can be devised for those models if
747 * necessary.
748 */
749#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200750#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200751
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200752static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
753 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100754{
755 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
756 hda_nid_t nid = kcontrol->private_value & 0xffff;
757 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
758 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200759 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100760 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100761
762 *valp = (val & mask) != 0;
763 return 0;
764}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200765static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
766 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100767{
768 signed int change;
769 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
770 hda_nid_t nid = kcontrol->private_value & 0xffff;
771 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
772 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200773 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100774 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200775 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100776
777 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200778 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100779 if (val==0)
780 ctrl_data &= ~mask;
781 else
782 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200783 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
784 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100785
786 return change;
787}
788#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
789 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100790 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100791 .info = alc_spdif_ctrl_info, \
792 .get = alc_spdif_ctrl_get, \
793 .put = alc_spdif_ctrl_put, \
794 .private_value = nid | (mask<<16) }
795#endif /* CONFIG_SND_DEBUG */
796
Jonathan Woithef8225f62008-01-08 12:16:54 +0100797/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
798 * Again, this is only used in the ALC26x test models to help identify when
799 * the EAPD line must be asserted for features to work.
800 */
801#ifdef CONFIG_SND_DEBUG
802#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
803
804static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
805 struct snd_ctl_elem_value *ucontrol)
806{
807 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
808 hda_nid_t nid = kcontrol->private_value & 0xffff;
809 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
810 long *valp = ucontrol->value.integer.value;
811 unsigned int val = snd_hda_codec_read(codec, nid, 0,
812 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
813
814 *valp = (val & mask) != 0;
815 return 0;
816}
817
818static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
819 struct snd_ctl_elem_value *ucontrol)
820{
821 int change;
822 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
823 hda_nid_t nid = kcontrol->private_value & 0xffff;
824 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
825 long val = *ucontrol->value.integer.value;
826 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
827 AC_VERB_GET_EAPD_BTLENABLE,
828 0x00);
829
830 /* Set/unset the masked control bit(s) as needed */
831 change = (!val ? 0 : mask) != (ctrl_data & mask);
832 if (!val)
833 ctrl_data &= ~mask;
834 else
835 ctrl_data |= mask;
836 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
837 ctrl_data);
838
839 return change;
840}
841
842#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
843 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100844 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100845 .info = alc_eapd_ctrl_info, \
846 .get = alc_eapd_ctrl_get, \
847 .put = alc_eapd_ctrl_put, \
848 .private_value = nid | (mask<<16) }
849#endif /* CONFIG_SND_DEBUG */
850
Kailang Yangdf694da2005-12-05 19:42:22 +0100851/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100852 * set up the input pin config (depending on the given auto-pin type)
853 */
854static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
855 int auto_pin_type)
856{
857 unsigned int val = PIN_IN;
858
Takashi Iwai86e29592010-09-09 14:50:17 +0200859 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100860 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200861 unsigned int oldval;
862 oldval = snd_hda_codec_read(codec, nid, 0,
863 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100864 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100865 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200866 /* if the default pin setup is vref50, we give it priority */
867 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100868 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200869 else if (pincap & AC_PINCAP_VREF_50)
870 val = PIN_VREF50;
871 else if (pincap & AC_PINCAP_VREF_100)
872 val = PIN_VREF100;
873 else if (pincap & AC_PINCAP_VREF_GRD)
874 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100875 }
876 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
877}
878
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200879static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
880{
881 struct alc_spec *spec = codec->spec;
882 struct auto_pin_cfg *cfg = &spec->autocfg;
883
884 if (!cfg->line_outs) {
885 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
886 cfg->line_out_pins[cfg->line_outs])
887 cfg->line_outs++;
888 }
889 if (!cfg->speaker_outs) {
890 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
891 cfg->speaker_pins[cfg->speaker_outs])
892 cfg->speaker_outs++;
893 }
894 if (!cfg->hp_outs) {
895 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
896 cfg->hp_pins[cfg->hp_outs])
897 cfg->hp_outs++;
898 }
899}
900
Takashi Iwai23f0c042009-02-26 13:03:58 +0100901/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100902 */
903static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
904{
905 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
906 return;
907 spec->mixers[spec->num_mixers++] = mix;
908}
909
910static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
911{
912 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
913 return;
914 spec->init_verbs[spec->num_init_verbs++] = verb;
915}
916
917/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100918 * set up from the preset table
919 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200920static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200921 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100922{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200923 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100924 int i;
925
926 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100927 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100928 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200929 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
930 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100931 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200932
Kailang Yangdf694da2005-12-05 19:42:22 +0100933 spec->channel_mode = preset->channel_mode;
934 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200935 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200936 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100937
Hector Martin3b315d72009-06-02 10:54:19 +0200938 if (preset->const_channel_count)
939 spec->multiout.max_channels = preset->const_channel_count;
940 else
941 spec->multiout.max_channels = spec->channel_mode[0].channels;
942 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100943
944 spec->multiout.num_dacs = preset->num_dacs;
945 spec->multiout.dac_nids = preset->dac_nids;
946 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800947 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100948 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200949
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200950 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200951 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200952 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100953 spec->input_mux = preset->input_mux;
954
955 spec->num_adc_nids = preset->num_adc_nids;
956 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100957 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100958 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100959
960 spec->unsol_event = preset->unsol_event;
961 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200962#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100963 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200964 spec->loopback.amplist = preset->loopbacks;
965#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200966
967 if (preset->setup)
968 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200969
970 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100971}
972
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200973/* Enable GPIO mask and set output */
974static struct hda_verb alc_gpio1_init_verbs[] = {
975 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
976 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
977 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
978 { }
979};
980
981static struct hda_verb alc_gpio2_init_verbs[] = {
982 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
983 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
984 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
985 { }
986};
987
Kailang Yangbdd148a2007-05-08 15:19:08 +0200988static struct hda_verb alc_gpio3_init_verbs[] = {
989 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
990 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
991 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
992 { }
993};
994
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200995/*
996 * Fix hardware PLL issue
997 * On some codecs, the analog PLL gating control must be off while
998 * the default value is 1.
999 */
1000static void alc_fix_pll(struct hda_codec *codec)
1001{
1002 struct alc_spec *spec = codec->spec;
1003 unsigned int val;
1004
1005 if (!spec->pll_nid)
1006 return;
1007 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1008 spec->pll_coef_idx);
1009 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1010 AC_VERB_GET_PROC_COEF, 0);
1011 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1012 spec->pll_coef_idx);
1013 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1014 val & ~(1 << spec->pll_coef_bit));
1015}
1016
1017static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1018 unsigned int coef_idx, unsigned int coef_bit)
1019{
1020 struct alc_spec *spec = codec->spec;
1021 spec->pll_nid = nid;
1022 spec->pll_coef_idx = coef_idx;
1023 spec->pll_coef_bit = coef_bit;
1024 alc_fix_pll(codec);
1025}
1026
Kailang Yang9ad0e492010-09-14 23:22:00 +02001027#ifdef CONFIG_SND_HDA_INPUT_JACK
1028static void alc_free_jack_priv(struct snd_jack *jack)
1029{
1030 struct alc_jack *jacks = jack->private_data;
1031 jacks->nid = 0;
1032 jacks->jack = NULL;
1033}
1034
1035static int alc_add_jack(struct hda_codec *codec,
1036 hda_nid_t nid, int type)
1037{
1038 struct alc_spec *spec;
1039 struct alc_jack *jack;
1040 const char *name;
1041 int err;
1042
1043 spec = codec->spec;
1044 snd_array_init(&spec->jacks, sizeof(*jack), 32);
1045 jack = snd_array_new(&spec->jacks);
1046 if (!jack)
1047 return -ENOMEM;
1048
1049 jack->nid = nid;
1050 jack->type = type;
1051 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
1052
1053 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
1054 if (err < 0)
1055 return err;
1056 jack->jack->private_data = jack;
1057 jack->jack->private_free = alc_free_jack_priv;
1058 return 0;
1059}
1060
1061static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1062{
1063 struct alc_spec *spec = codec->spec;
1064 struct alc_jack *jacks = spec->jacks.list;
1065
1066 if (jacks) {
1067 int i;
1068 for (i = 0; i < spec->jacks.used; i++) {
1069 if (jacks->nid == nid) {
1070 unsigned int present;
1071 present = snd_hda_jack_detect(codec, nid);
1072
1073 present = (present) ? jacks->type : 0;
1074
1075 snd_jack_report(jacks->jack, present);
1076 }
1077 jacks++;
1078 }
1079 }
1080}
1081
1082static int alc_init_jacks(struct hda_codec *codec)
1083{
1084 struct alc_spec *spec = codec->spec;
1085 int err;
1086 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1087 unsigned int mic_nid = spec->ext_mic.pin;
1088
1089 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1090 if (err < 0)
1091 return err;
1092 alc_report_jack(codec, hp_nid);
1093
1094 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1095 if (err < 0)
1096 return err;
1097 alc_report_jack(codec, mic_nid);
1098
1099 return 0;
1100}
1101#else
1102static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1103{
1104}
1105
1106static inline int alc_init_jacks(struct hda_codec *codec)
1107{
1108 return 0;
1109}
1110#endif
1111
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001112static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001113{
1114 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001115 unsigned int mute;
1116 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001117 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001118
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001119 spec->jack_present = 0;
1120 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1121 nid = spec->autocfg.hp_pins[i];
1122 if (!nid)
1123 break;
1124 if (snd_hda_jack_detect(codec, nid)) {
1125 spec->jack_present = 1;
1126 break;
1127 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001128 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001129 }
1130
1131 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1132 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001133 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1134 nid = spec->autocfg.speaker_pins[i];
1135 if (!nid)
1136 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001137 if (pinctl) {
1138 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001139 AC_VERB_SET_PIN_WIDGET_CONTROL,
1140 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001141 } else {
1142 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1143 HDA_AMP_MUTE, mute);
1144 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001145 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001146}
1147
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001148static void alc_automute_pin(struct hda_codec *codec)
1149{
1150 alc_automute_speaker(codec, 1);
1151}
1152
Takashi Iwai6c819492009-08-10 18:47:44 +02001153static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1154 hda_nid_t nid)
1155{
1156 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1157 int i, nums;
1158
1159 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1160 for (i = 0; i < nums; i++)
1161 if (conn[i] == nid)
1162 return i;
1163 return -1;
1164}
1165
Takashi Iwai840b64c2010-07-13 22:49:01 +02001166/* switch the current ADC according to the jack state */
1167static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1168{
1169 struct alc_spec *spec = codec->spec;
1170 unsigned int present;
1171 hda_nid_t new_adc;
1172
1173 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1174 if (present)
1175 spec->cur_adc_idx = 1;
1176 else
1177 spec->cur_adc_idx = 0;
1178 new_adc = spec->adc_nids[spec->cur_adc_idx];
1179 if (spec->cur_adc && spec->cur_adc != new_adc) {
1180 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001181 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001182 spec->cur_adc = new_adc;
1183 snd_hda_codec_setup_stream(codec, new_adc,
1184 spec->cur_adc_stream_tag, 0,
1185 spec->cur_adc_format);
1186 }
1187}
1188
Kailang Yang7fb0d782008-10-15 11:12:35 +02001189static void alc_mic_automute(struct hda_codec *codec)
1190{
1191 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001192 struct alc_mic_route *dead, *alive;
1193 unsigned int present, type;
1194 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001195
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001196 if (!spec->auto_mic)
1197 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001198 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1199 return;
1200 if (snd_BUG_ON(!spec->adc_nids))
1201 return;
1202
Takashi Iwai840b64c2010-07-13 22:49:01 +02001203 if (spec->dual_adc_switch) {
1204 alc_dual_mic_adc_auto_switch(codec);
1205 return;
1206 }
1207
Takashi Iwai6c819492009-08-10 18:47:44 +02001208 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1209
Wu Fengguang864f92b2009-11-18 12:38:02 +08001210 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001211 if (present) {
1212 alive = &spec->ext_mic;
1213 dead = &spec->int_mic;
1214 } else {
1215 alive = &spec->int_mic;
1216 dead = &spec->ext_mic;
1217 }
1218
Takashi Iwai6c819492009-08-10 18:47:44 +02001219 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1220 if (type == AC_WID_AUD_MIX) {
1221 /* Matrix-mixer style (e.g. ALC882) */
1222 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1223 alive->mux_idx,
1224 HDA_AMP_MUTE, 0);
1225 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1226 dead->mux_idx,
1227 HDA_AMP_MUTE, HDA_AMP_MUTE);
1228 } else {
1229 /* MUX style (e.g. ALC880) */
1230 snd_hda_codec_write_cache(codec, cap_nid, 0,
1231 AC_VERB_SET_CONNECT_SEL,
1232 alive->mux_idx);
1233 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001234 alc_report_jack(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001235
1236 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001237}
1238
Kailang Yangc9b58002007-10-16 14:30:01 +02001239/* unsolicited event for HP jack sensing */
1240static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1241{
1242 if (codec->vendor_id == 0x10ec0880)
1243 res >>= 28;
1244 else
1245 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001246 switch (res) {
1247 case ALC880_HP_EVENT:
1248 alc_automute_pin(codec);
1249 break;
1250 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001251 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001252 break;
1253 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001254}
1255
1256static void alc_inithook(struct hda_codec *codec)
1257{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001258 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001259 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001260}
1261
Kailang Yangf9423e72008-05-27 12:32:25 +02001262/* additional initialization for ALC888 variants */
1263static void alc888_coef_init(struct hda_codec *codec)
1264{
1265 unsigned int tmp;
1266
1267 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1268 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1269 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001270 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001271 /* alc888S-VC */
1272 snd_hda_codec_read(codec, 0x20, 0,
1273 AC_VERB_SET_PROC_COEF, 0x830);
1274 else
1275 /* alc888-VB */
1276 snd_hda_codec_read(codec, 0x20, 0,
1277 AC_VERB_SET_PROC_COEF, 0x3030);
1278}
1279
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001280static void alc889_coef_init(struct hda_codec *codec)
1281{
1282 unsigned int tmp;
1283
1284 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1285 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1286 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1287 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1288}
1289
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001290/* turn on/off EAPD control (only if available) */
1291static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1292{
1293 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1294 return;
1295 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1296 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1297 on ? 2 : 0);
1298}
1299
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001300static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001301{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001302 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001303
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001304 switch (type) {
1305 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001306 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1307 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001308 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001309 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1310 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001311 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001312 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1313 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001314 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001315 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001316 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001317 set_eapd(codec, 0x0f, 1);
1318 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001319 break;
1320 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001321 case 0x10ec0267:
1322 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001323 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001324 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001325 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001326 case 0x10ec0660:
1327 case 0x10ec0662:
1328 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001329 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001330 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001331 set_eapd(codec, 0x14, 1);
1332 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001333 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001334 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001335 switch (codec->vendor_id) {
1336 case 0x10ec0260:
1337 snd_hda_codec_write(codec, 0x1a, 0,
1338 AC_VERB_SET_COEF_INDEX, 7);
1339 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1340 AC_VERB_GET_PROC_COEF, 0);
1341 snd_hda_codec_write(codec, 0x1a, 0,
1342 AC_VERB_SET_COEF_INDEX, 7);
1343 snd_hda_codec_write(codec, 0x1a, 0,
1344 AC_VERB_SET_PROC_COEF,
1345 tmp | 0x2010);
1346 break;
1347 case 0x10ec0262:
1348 case 0x10ec0880:
1349 case 0x10ec0882:
1350 case 0x10ec0883:
1351 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001352 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001353 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001354 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001355 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001356 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001357 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001358 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001359#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001360 case 0x10ec0267:
1361 case 0x10ec0268:
1362 snd_hda_codec_write(codec, 0x20, 0,
1363 AC_VERB_SET_COEF_INDEX, 7);
1364 tmp = snd_hda_codec_read(codec, 0x20, 0,
1365 AC_VERB_GET_PROC_COEF, 0);
1366 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001367 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001368 snd_hda_codec_write(codec, 0x20, 0,
1369 AC_VERB_SET_PROC_COEF,
1370 tmp | 0x3000);
1371 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001372#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001373 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001374 break;
1375 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001376}
Kailang Yangea1fb292008-08-26 12:58:38 +02001377
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001378static void alc_init_auto_hp(struct hda_codec *codec)
1379{
1380 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001381 struct auto_pin_cfg *cfg = &spec->autocfg;
1382 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001383
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001384 if (!cfg->hp_pins[0]) {
1385 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001386 return;
1387 }
1388
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001389 if (!cfg->speaker_pins[0]) {
1390 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1391 return;
1392 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1393 sizeof(cfg->speaker_pins));
1394 cfg->speaker_outs = cfg->line_outs;
1395 }
1396
1397 if (!cfg->hp_pins[0]) {
1398 memcpy(cfg->hp_pins, cfg->line_out_pins,
1399 sizeof(cfg->hp_pins));
1400 cfg->hp_outs = cfg->line_outs;
1401 }
1402
1403 for (i = 0; i < cfg->hp_outs; i++) {
1404 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1405 cfg->hp_pins[i]);
1406 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001407 AC_VERB_SET_UNSOLICITED_ENABLE,
1408 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001409 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001410 spec->unsol_event = alc_sku_unsol_event;
1411}
1412
Takashi Iwai6c819492009-08-10 18:47:44 +02001413static void alc_init_auto_mic(struct hda_codec *codec)
1414{
1415 struct alc_spec *spec = codec->spec;
1416 struct auto_pin_cfg *cfg = &spec->autocfg;
1417 hda_nid_t fixed, ext;
1418 int i;
1419
1420 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001421 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001422 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001423 return;
1424
1425 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001426 for (i = 0; i < cfg->num_inputs; i++) {
1427 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001428 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001429 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001430 switch (snd_hda_get_input_pin_attr(defcfg)) {
1431 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001432 if (fixed)
1433 return; /* already occupied */
1434 fixed = nid;
1435 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001436 case INPUT_PIN_ATTR_UNUSED:
1437 return; /* invalid entry */
1438 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001439 if (ext)
1440 return; /* already occupied */
1441 ext = nid;
1442 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001443 }
1444 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001445 if (!ext || !fixed)
1446 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001447 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1448 return; /* no unsol support */
1449 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1450 ext, fixed);
1451 spec->ext_mic.pin = ext;
1452 spec->int_mic.pin = fixed;
1453 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1454 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1455 spec->auto_mic = 1;
1456 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1457 AC_VERB_SET_UNSOLICITED_ENABLE,
1458 AC_USRSP_EN | ALC880_MIC_EVENT);
1459 spec->unsol_event = alc_sku_unsol_event;
1460}
1461
Kailang Yangda00c242010-03-19 11:23:45 +01001462static int alc_auto_parse_customize_define(struct hda_codec *codec)
1463{
1464 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001465 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001466 struct alc_spec *spec = codec->spec;
1467
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001468 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1469
Kailang Yangda00c242010-03-19 11:23:45 +01001470 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001471 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001472 goto do_sku;
1473
1474 nid = 0x1d;
1475 if (codec->vendor_id == 0x10ec0260)
1476 nid = 0x17;
1477 ass = snd_hda_codec_get_pincfg(codec, nid);
1478
1479 if (!(ass & 1)) {
1480 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1481 codec->chip_name, ass);
1482 return -1;
1483 }
1484
1485 /* check sum */
1486 tmp = 0;
1487 for (i = 1; i < 16; i++) {
1488 if ((ass >> i) & 1)
1489 tmp++;
1490 }
1491 if (((ass >> 16) & 0xf) != tmp)
1492 return -1;
1493
1494 spec->cdefine.port_connectivity = ass >> 30;
1495 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1496 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1497 spec->cdefine.customization = ass >> 8;
1498do_sku:
1499 spec->cdefine.sku_cfg = ass;
1500 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1501 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1502 spec->cdefine.swap = (ass & 0x2) >> 1;
1503 spec->cdefine.override = ass & 0x1;
1504
1505 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1506 nid, spec->cdefine.sku_cfg);
1507 snd_printd("SKU: port_connectivity=0x%x\n",
1508 spec->cdefine.port_connectivity);
1509 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1510 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1511 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1512 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1513 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1514 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1515 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1516
1517 return 0;
1518}
1519
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001520/* check subsystem ID and set up device-specific initialization;
1521 * return 1 if initialized, 0 if invalid SSID
1522 */
1523/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1524 * 31 ~ 16 : Manufacture ID
1525 * 15 ~ 8 : SKU ID
1526 * 7 ~ 0 : Assembly ID
1527 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1528 */
1529static int alc_subsystem_id(struct hda_codec *codec,
1530 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001531 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001532{
1533 unsigned int ass, tmp, i;
1534 unsigned nid;
1535 struct alc_spec *spec = codec->spec;
1536
1537 ass = codec->subsystem_id & 0xffff;
1538 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1539 goto do_sku;
1540
1541 /* invalid SSID, check the special NID pin defcfg instead */
1542 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001543 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001544 * 29~21 : reserve
1545 * 20 : PCBEEP input
1546 * 19~16 : Check sum (15:1)
1547 * 15~1 : Custom
1548 * 0 : override
1549 */
1550 nid = 0x1d;
1551 if (codec->vendor_id == 0x10ec0260)
1552 nid = 0x17;
1553 ass = snd_hda_codec_get_pincfg(codec, nid);
1554 snd_printd("realtek: No valid SSID, "
1555 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001556 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001557 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001558 return 0;
1559 if ((ass >> 30) != 1) /* no physical connection */
1560 return 0;
1561
1562 /* check sum */
1563 tmp = 0;
1564 for (i = 1; i < 16; i++) {
1565 if ((ass >> i) & 1)
1566 tmp++;
1567 }
1568 if (((ass >> 16) & 0xf) != tmp)
1569 return 0;
1570do_sku:
1571 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1572 ass & 0xffff, codec->vendor_id);
1573 /*
1574 * 0 : override
1575 * 1 : Swap Jack
1576 * 2 : 0 --> Desktop, 1 --> Laptop
1577 * 3~5 : External Amplifier control
1578 * 7~6 : Reserved
1579 */
1580 tmp = (ass & 0x38) >> 3; /* external Amp control */
1581 switch (tmp) {
1582 case 1:
1583 spec->init_amp = ALC_INIT_GPIO1;
1584 break;
1585 case 3:
1586 spec->init_amp = ALC_INIT_GPIO2;
1587 break;
1588 case 7:
1589 spec->init_amp = ALC_INIT_GPIO3;
1590 break;
1591 case 5:
1592 spec->init_amp = ALC_INIT_DEFAULT;
1593 break;
1594 }
1595
1596 /* is laptop or Desktop and enable the function "Mute internal speaker
1597 * when the external headphone out jack is plugged"
1598 */
1599 if (!(ass & 0x8000))
1600 return 1;
1601 /*
1602 * 10~8 : Jack location
1603 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1604 * 14~13: Resvered
1605 * 15 : 1 --> enable the function "Mute internal speaker
1606 * when the external headphone out jack is plugged"
1607 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001608 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001609 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001610 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1611 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001612 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001613 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001614 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001615 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001616 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001617 else if (tmp == 3)
1618 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001619 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001620 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001621 for (i = 0; i < spec->autocfg.line_outs; i++)
1622 if (spec->autocfg.line_out_pins[i] == nid)
1623 return 1;
1624 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001625 }
1626
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001627 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001628 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001629 return 1;
1630}
Kailang Yangea1fb292008-08-26 12:58:38 +02001631
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001632static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001633 hda_nid_t porta, hda_nid_t porte,
1634 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001635{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001636 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001637 struct alc_spec *spec = codec->spec;
1638 snd_printd("realtek: "
1639 "Enable default setup for auto mode as fallback\n");
1640 spec->init_amp = ALC_INIT_DEFAULT;
1641 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001642 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001643 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001644}
1645
Takashi Iwai41e41f12005-06-08 14:48:49 +02001646/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001647 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001648 */
1649
1650struct alc_pincfg {
1651 hda_nid_t nid;
1652 u32 val;
1653};
1654
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001655struct alc_fixup {
1656 const struct alc_pincfg *pins;
1657 const struct hda_verb *verbs;
1658};
1659
1660static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaif95474e2007-07-10 00:47:43 +02001661 const struct snd_pci_quirk *quirk,
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001662 const struct alc_fixup *fix,
1663 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001664{
1665 const struct alc_pincfg *cfg;
1666
1667 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1668 if (!quirk)
1669 return;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001670 fix += quirk->value;
1671 cfg = fix->pins;
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001672 if (pre_init && cfg) {
1673#ifdef CONFIG_SND_DEBUG_VERBOSE
1674 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
1675 codec->chip_name, quirk->name);
1676#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001677 for (; cfg->nid; cfg++)
1678 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1679 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001680 if (!pre_init && fix->verbs) {
1681#ifdef CONFIG_SND_DEBUG_VERBOSE
1682 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
1683 codec->chip_name, quirk->name);
1684#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001685 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001686 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001687}
1688
Kailang Yang274693f2009-12-03 10:07:50 +01001689static int alc_read_coef_idx(struct hda_codec *codec,
1690 unsigned int coef_idx)
1691{
1692 unsigned int val;
1693 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1694 coef_idx);
1695 val = snd_hda_codec_read(codec, 0x20, 0,
1696 AC_VERB_GET_PROC_COEF, 0);
1697 return val;
1698}
1699
Kailang Yang977ddd62010-09-15 10:02:29 +02001700static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1701 unsigned int coef_val)
1702{
1703 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1704 coef_idx);
1705 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1706 coef_val);
1707}
1708
Takashi Iwai757899a2010-07-30 10:48:14 +02001709/* set right pin controls for digital I/O */
1710static void alc_auto_init_digital(struct hda_codec *codec)
1711{
1712 struct alc_spec *spec = codec->spec;
1713 int i;
1714 hda_nid_t pin;
1715
1716 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1717 pin = spec->autocfg.dig_out_pins[i];
1718 if (pin) {
1719 snd_hda_codec_write(codec, pin, 0,
1720 AC_VERB_SET_PIN_WIDGET_CONTROL,
1721 PIN_OUT);
1722 }
1723 }
1724 pin = spec->autocfg.dig_in_pin;
1725 if (pin)
1726 snd_hda_codec_write(codec, pin, 0,
1727 AC_VERB_SET_PIN_WIDGET_CONTROL,
1728 PIN_IN);
1729}
1730
1731/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1732static void alc_auto_parse_digital(struct hda_codec *codec)
1733{
1734 struct alc_spec *spec = codec->spec;
1735 int i, err;
1736 hda_nid_t dig_nid;
1737
1738 /* support multiple SPDIFs; the secondary is set up as a slave */
1739 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1740 err = snd_hda_get_connections(codec,
1741 spec->autocfg.dig_out_pins[i],
1742 &dig_nid, 1);
1743 if (err < 0)
1744 continue;
1745 if (!i) {
1746 spec->multiout.dig_out_nid = dig_nid;
1747 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1748 } else {
1749 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1750 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1751 break;
1752 spec->slave_dig_outs[i - 1] = dig_nid;
1753 }
1754 }
1755
1756 if (spec->autocfg.dig_in_pin) {
1757 hda_nid_t dig_nid;
1758 err = snd_hda_get_connections(codec,
1759 spec->autocfg.dig_in_pin,
1760 &dig_nid, 1);
1761 if (err > 0)
1762 spec->dig_in_nid = dig_nid;
1763 }
1764}
1765
Takashi Iwaif95474e2007-07-10 00:47:43 +02001766/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001767 * ALC888
1768 */
1769
1770/*
1771 * 2ch mode
1772 */
1773static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1774/* Mic-in jack as mic in */
1775 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1776 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1777/* Line-in jack as Line in */
1778 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1779 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1780/* Line-Out as Front */
1781 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1782 { } /* end */
1783};
1784
1785/*
1786 * 4ch mode
1787 */
1788static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1789/* Mic-in jack as mic in */
1790 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1791 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1792/* Line-in jack as Surround */
1793 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1794 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1795/* Line-Out as Front */
1796 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1797 { } /* end */
1798};
1799
1800/*
1801 * 6ch mode
1802 */
1803static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1804/* Mic-in jack as CLFE */
1805 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1806 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1807/* Line-in jack as Surround */
1808 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1809 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1810/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1811 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1812 { } /* end */
1813};
1814
1815/*
1816 * 8ch mode
1817 */
1818static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1819/* Mic-in jack as CLFE */
1820 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1821 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1822/* Line-in jack as Surround */
1823 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1824 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1825/* Line-Out as Side */
1826 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1827 { } /* end */
1828};
1829
1830static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1831 { 2, alc888_4ST_ch2_intel_init },
1832 { 4, alc888_4ST_ch4_intel_init },
1833 { 6, alc888_4ST_ch6_intel_init },
1834 { 8, alc888_4ST_ch8_intel_init },
1835};
1836
1837/*
1838 * ALC888 Fujitsu Siemens Amillo xa3530
1839 */
1840
1841static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1842/* Front Mic: set to PIN_IN (empty by default) */
1843 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1844/* Connect Internal HP to Front */
1845 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1846 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1847 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1848/* Connect Bass HP to Front */
1849 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1850 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1851 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1852/* Connect Line-Out side jack (SPDIF) to Side */
1853 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1854 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1855 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1856/* Connect Mic jack to CLFE */
1857 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1858 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1859 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1860/* Connect Line-in jack to Surround */
1861 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1862 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1863 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1864/* Connect HP out jack to Front */
1865 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1866 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1867 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1868/* Enable unsolicited event for HP jack and Line-out jack */
1869 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1870 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1871 {}
1872};
1873
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001874static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001875{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001876 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001877}
1878
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001879static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1880 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001881{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001882 if (codec->vendor_id == 0x10ec0880)
1883 res >>= 28;
1884 else
1885 res >>= 26;
1886 if (res == ALC880_HP_EVENT)
1887 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001888}
1889
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001890static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001891{
1892 struct alc_spec *spec = codec->spec;
1893
1894 spec->autocfg.hp_pins[0] = 0x15;
1895 spec->autocfg.speaker_pins[0] = 0x14;
1896 spec->autocfg.speaker_pins[1] = 0x16;
1897 spec->autocfg.speaker_pins[2] = 0x17;
1898 spec->autocfg.speaker_pins[3] = 0x19;
1899 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001900}
1901
1902static void alc889_intel_init_hook(struct hda_codec *codec)
1903{
1904 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001905 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001906}
1907
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001908static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001909{
1910 struct alc_spec *spec = codec->spec;
1911
1912 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1913 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1914 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1915 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001916}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001917
1918/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001919 * ALC888 Acer Aspire 4930G model
1920 */
1921
1922static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1923/* Front Mic: set to PIN_IN (empty by default) */
1924 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1925/* Unselect Front Mic by default in input mixer 3 */
1926 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001927/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001928 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1929/* Connect Internal HP to front */
1930 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1931 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1932 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1933/* Connect HP out to front */
1934 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1935 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1936 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1937 { }
1938};
1939
Hector Martin3b315d72009-06-02 10:54:19 +02001940/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01001941 * ALC888 Acer Aspire 6530G model
1942 */
1943
1944static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01001945/* Route to built-in subwoofer as well as speakers */
1946 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1947 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
1948 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
1949 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001950/* Bias voltage on for external mic port */
1951 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02001952/* Front Mic: set to PIN_IN (empty by default) */
1953 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1954/* Unselect Front Mic by default in input mixer 3 */
1955 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001956/* Enable unsolicited event for HP jack */
1957 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1958/* Enable speaker output */
1959 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1960 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01001961 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001962/* Enable headphone output */
1963 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
1964 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1965 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01001966 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01001967 { }
1968};
1969
1970/*
Hector Martin018df412009-06-04 00:13:40 +02001971 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02001972 */
1973
Hector Martin018df412009-06-04 00:13:40 +02001974static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02001975/* Front Mic: set to PIN_IN (empty by default) */
1976 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1977/* Unselect Front Mic by default in input mixer 3 */
1978 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
1979/* Enable unsolicited event for HP jack */
1980 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1981/* Connect Internal Front to Front */
1982 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1983 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1984 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1985/* Connect Internal Rear to Rear */
1986 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1987 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1988 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
1989/* Connect Internal CLFE to CLFE */
1990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1991 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1992 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
1993/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02001994 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02001995 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1996 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1997/* Enable all DACs */
1998/* DAC DISABLE/MUTE 1? */
1999/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2000 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2001 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2002/* DAC DISABLE/MUTE 2? */
2003/* some bit here disables the other DACs. Init=0x4900 */
2004 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2005 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002006/* DMIC fix
2007 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2008 * which makes the stereo useless. However, either the mic or the ALC889
2009 * makes the signal become a difference/sum signal instead of standard
2010 * stereo, which is annoying. So instead we flip this bit which makes the
2011 * codec replicate the sum signal to both channels, turning it into a
2012 * normal mono mic.
2013 */
2014/* DMIC_CONTROL? Init value = 0x0001 */
2015 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2016 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002017 { }
2018};
2019
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002020static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002021 /* Front mic only available on one ADC */
2022 {
2023 .num_items = 4,
2024 .items = {
2025 { "Mic", 0x0 },
2026 { "Line", 0x2 },
2027 { "CD", 0x4 },
2028 { "Front Mic", 0xb },
2029 },
2030 },
2031 {
2032 .num_items = 3,
2033 .items = {
2034 { "Mic", 0x0 },
2035 { "Line", 0x2 },
2036 { "CD", 0x4 },
2037 },
2038 }
2039};
2040
Tony Vroond2fd4b02009-06-21 00:40:10 +01002041static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2042 /* Interal mic only available on one ADC */
2043 {
Tony Vroon684a8842009-06-26 09:27:50 +01002044 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002045 .items = {
2046 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002047 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002048 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002049 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002050 { "Int Mic", 0xb },
2051 },
2052 },
2053 {
Tony Vroon684a8842009-06-26 09:27:50 +01002054 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002055 .items = {
2056 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002057 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002058 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002059 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002060 },
2061 }
2062};
2063
Hector Martin018df412009-06-04 00:13:40 +02002064static struct hda_input_mux alc889_capture_sources[3] = {
2065 /* Digital mic only available on first "ADC" */
2066 {
2067 .num_items = 5,
2068 .items = {
2069 { "Mic", 0x0 },
2070 { "Line", 0x2 },
2071 { "CD", 0x4 },
2072 { "Front Mic", 0xb },
2073 { "Input Mix", 0xa },
2074 },
2075 },
2076 {
2077 .num_items = 4,
2078 .items = {
2079 { "Mic", 0x0 },
2080 { "Line", 0x2 },
2081 { "CD", 0x4 },
2082 { "Input Mix", 0xa },
2083 },
2084 },
2085 {
2086 .num_items = 4,
2087 .items = {
2088 { "Mic", 0x0 },
2089 { "Line", 0x2 },
2090 { "CD", 0x4 },
2091 { "Input Mix", 0xa },
2092 },
2093 }
2094};
2095
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002096static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002097 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2098 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2099 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2100 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2101 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2102 HDA_OUTPUT),
2103 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2104 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2105 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2106 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2107 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2108 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2109 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2110 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2111 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2112 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2113 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2114 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002115 { } /* end */
2116};
2117
Hector Martin556eea92009-12-20 22:51:23 +01002118static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2119 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2120 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2121 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2122 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2123 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2124 HDA_OUTPUT),
2125 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2126 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2127 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2128 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2129 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2130 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2132 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2133 { } /* end */
2134};
2135
2136
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002137static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002138{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002139 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002140
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002141 spec->autocfg.hp_pins[0] = 0x15;
2142 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002143 spec->autocfg.speaker_pins[1] = 0x16;
2144 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002145}
2146
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002147static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002148{
2149 struct alc_spec *spec = codec->spec;
2150
2151 spec->autocfg.hp_pins[0] = 0x15;
2152 spec->autocfg.speaker_pins[0] = 0x14;
2153 spec->autocfg.speaker_pins[1] = 0x16;
2154 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002155}
2156
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002157static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002158{
2159 struct alc_spec *spec = codec->spec;
2160
2161 spec->autocfg.hp_pins[0] = 0x15;
2162 spec->autocfg.speaker_pins[0] = 0x14;
2163 spec->autocfg.speaker_pins[1] = 0x16;
2164 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002165}
2166
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002167/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002168 * ALC880 3-stack model
2169 *
2170 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002171 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2172 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002173 */
2174
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002175static hda_nid_t alc880_dac_nids[4] = {
2176 /* front, rear, clfe, rear_surr */
2177 0x02, 0x05, 0x04, 0x03
2178};
2179
2180static hda_nid_t alc880_adc_nids[3] = {
2181 /* ADC0-2 */
2182 0x07, 0x08, 0x09,
2183};
2184
2185/* The datasheet says the node 0x07 is connected from inputs,
2186 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002187 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002189static hda_nid_t alc880_adc_nids_alt[2] = {
2190 /* ADC1-2 */
2191 0x08, 0x09,
2192};
2193
2194#define ALC880_DIGOUT_NID 0x06
2195#define ALC880_DIGIN_NID 0x0a
2196
2197static struct hda_input_mux alc880_capture_source = {
2198 .num_items = 4,
2199 .items = {
2200 { "Mic", 0x0 },
2201 { "Front Mic", 0x3 },
2202 { "Line", 0x2 },
2203 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002205};
2206
2207/* channel source setting (2/6 channel selection for 3-stack) */
2208/* 2ch mode */
2209static struct hda_verb alc880_threestack_ch2_init[] = {
2210 /* set line-in to input, mute it */
2211 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2212 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2213 /* set mic-in to input vref 80%, mute it */
2214 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2215 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002216 { } /* end */
2217};
2218
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002219/* 6ch mode */
2220static struct hda_verb alc880_threestack_ch6_init[] = {
2221 /* set line-in to output, unmute it */
2222 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2223 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2224 /* set mic-in to output, unmute it */
2225 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2226 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2227 { } /* end */
2228};
2229
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002230static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002231 { 2, alc880_threestack_ch2_init },
2232 { 6, alc880_threestack_ch6_init },
2233};
2234
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002235static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002236 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002237 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002238 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002239 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002240 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2241 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002242 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2243 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002244 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2245 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2246 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2247 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2248 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2249 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2250 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2251 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002253 {
2254 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2255 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002256 .info = alc_ch_mode_info,
2257 .get = alc_ch_mode_get,
2258 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002259 },
2260 { } /* end */
2261};
2262
2263/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002264static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2265 struct snd_ctl_elem_info *uinfo)
2266{
2267 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2268 struct alc_spec *spec = codec->spec;
2269 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002270
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002271 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002272 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2273 HDA_INPUT);
2274 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002275 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002276 return err;
2277}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002279static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2280 unsigned int size, unsigned int __user *tlv)
2281{
2282 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2283 struct alc_spec *spec = codec->spec;
2284 int err;
2285
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002286 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002287 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2288 HDA_INPUT);
2289 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002290 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002291 return err;
2292}
2293
2294typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2295 struct snd_ctl_elem_value *ucontrol);
2296
2297static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2298 struct snd_ctl_elem_value *ucontrol,
2299 getput_call_t func)
2300{
2301 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2302 struct alc_spec *spec = codec->spec;
2303 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2304 int err;
2305
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002306 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002307 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2308 3, 0, HDA_INPUT);
2309 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002310 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002311 return err;
2312}
2313
2314static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2315 struct snd_ctl_elem_value *ucontrol)
2316{
2317 return alc_cap_getput_caller(kcontrol, ucontrol,
2318 snd_hda_mixer_amp_volume_get);
2319}
2320
2321static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2322 struct snd_ctl_elem_value *ucontrol)
2323{
2324 return alc_cap_getput_caller(kcontrol, ucontrol,
2325 snd_hda_mixer_amp_volume_put);
2326}
2327
2328/* capture mixer elements */
2329#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2330
2331static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2332 struct snd_ctl_elem_value *ucontrol)
2333{
2334 return alc_cap_getput_caller(kcontrol, ucontrol,
2335 snd_hda_mixer_amp_switch_get);
2336}
2337
2338static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2339 struct snd_ctl_elem_value *ucontrol)
2340{
2341 return alc_cap_getput_caller(kcontrol, ucontrol,
2342 snd_hda_mixer_amp_switch_put);
2343}
2344
Takashi Iwaia23b6882009-03-23 15:21:36 +01002345#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002346 { \
2347 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2348 .name = "Capture Switch", \
2349 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2350 .count = num, \
2351 .info = alc_cap_sw_info, \
2352 .get = alc_cap_sw_get, \
2353 .put = alc_cap_sw_put, \
2354 }, \
2355 { \
2356 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2357 .name = "Capture Volume", \
2358 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2359 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2360 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2361 .count = num, \
2362 .info = alc_cap_vol_info, \
2363 .get = alc_cap_vol_get, \
2364 .put = alc_cap_vol_put, \
2365 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002366 }
2367
2368#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002369 { \
2370 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2371 /* .name = "Capture Source", */ \
2372 .name = "Input Source", \
2373 .count = num, \
2374 .info = alc_mux_enum_info, \
2375 .get = alc_mux_enum_get, \
2376 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002377 }
2378
2379#define DEFINE_CAPMIX(num) \
2380static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2381 _DEFINE_CAPMIX(num), \
2382 _DEFINE_CAPSRC(num), \
2383 { } /* end */ \
2384}
2385
2386#define DEFINE_CAPMIX_NOSRC(num) \
2387static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2388 _DEFINE_CAPMIX(num), \
2389 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002390}
2391
2392/* up to three ADCs */
2393DEFINE_CAPMIX(1);
2394DEFINE_CAPMIX(2);
2395DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002396DEFINE_CAPMIX_NOSRC(1);
2397DEFINE_CAPMIX_NOSRC(2);
2398DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002399
2400/*
2401 * ALC880 5-stack model
2402 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002403 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2404 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002405 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2406 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2407 */
2408
2409/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002410static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002411 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002412 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413 { } /* end */
2414};
2415
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002416/* channel source setting (6/8 channel selection for 5-stack) */
2417/* 6ch mode */
2418static struct hda_verb alc880_fivestack_ch6_init[] = {
2419 /* set line-in to input, mute it */
2420 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2421 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002422 { } /* end */
2423};
2424
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002425/* 8ch mode */
2426static struct hda_verb alc880_fivestack_ch8_init[] = {
2427 /* set line-in to output, unmute it */
2428 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2429 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2430 { } /* end */
2431};
2432
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002433static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002434 { 6, alc880_fivestack_ch6_init },
2435 { 8, alc880_fivestack_ch8_init },
2436};
2437
2438
2439/*
2440 * ALC880 6-stack model
2441 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002442 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2443 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002444 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2445 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2446 */
2447
2448static hda_nid_t alc880_6st_dac_nids[4] = {
2449 /* front, rear, clfe, rear_surr */
2450 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002451};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002452
2453static struct hda_input_mux alc880_6stack_capture_source = {
2454 .num_items = 4,
2455 .items = {
2456 { "Mic", 0x0 },
2457 { "Front Mic", 0x1 },
2458 { "Line", 0x2 },
2459 { "CD", 0x4 },
2460 },
2461};
2462
2463/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002464static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002465 { 8, NULL },
2466};
2467
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002468static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002469 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002470 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002471 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002472 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002473 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2474 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002475 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2476 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002477 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002478 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002479 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2480 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2481 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2482 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2483 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2484 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2485 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2486 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002487 {
2488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2489 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002490 .info = alc_ch_mode_info,
2491 .get = alc_ch_mode_get,
2492 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002493 },
2494 { } /* end */
2495};
2496
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002497
2498/*
2499 * ALC880 W810 model
2500 *
2501 * W810 has rear IO for:
2502 * Front (DAC 02)
2503 * Surround (DAC 03)
2504 * Center/LFE (DAC 04)
2505 * Digital out (06)
2506 *
2507 * The system also has a pair of internal speakers, and a headphone jack.
2508 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002509 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002510 * There is a variable resistor to control the speaker or headphone
2511 * volume. This is a hardware-only device without a software API.
2512 *
2513 * Plugging headphones in will disable the internal speakers. This is
2514 * implemented in hardware, not via the driver using jack sense. In
2515 * a similar fashion, plugging into the rear socket marked "front" will
2516 * disable both the speakers and headphones.
2517 *
2518 * For input, there's a microphone jack, and an "audio in" jack.
2519 * These may not do anything useful with this driver yet, because I
2520 * haven't setup any initialization verbs for these yet...
2521 */
2522
2523static hda_nid_t alc880_w810_dac_nids[3] = {
2524 /* front, rear/surround, clfe */
2525 0x02, 0x03, 0x04
2526};
2527
2528/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002529static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002530 { 6, NULL }
2531};
2532
2533/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002534static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002535 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002536 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002537 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002538 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002539 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2540 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002541 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2542 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002543 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2544 { } /* end */
2545};
2546
2547
2548/*
2549 * Z710V model
2550 *
2551 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002552 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2553 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002554 */
2555
2556static hda_nid_t alc880_z71v_dac_nids[1] = {
2557 0x02
2558};
2559#define ALC880_Z71V_HP_DAC 0x03
2560
2561/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002562static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002563 { 2, NULL }
2564};
2565
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002566static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002567 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002568 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002569 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002570 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002571 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2572 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2573 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2574 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2575 { } /* end */
2576};
2577
2578
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002579/*
2580 * ALC880 F1734 model
2581 *
2582 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2583 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2584 */
2585
2586static hda_nid_t alc880_f1734_dac_nids[1] = {
2587 0x03
2588};
2589#define ALC880_F1734_HP_DAC 0x02
2590
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002591static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002592 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002593 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002594 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2595 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002596 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2597 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002598 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2599 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002600 { } /* end */
2601};
2602
Takashi Iwai937b4162008-02-11 14:52:36 +01002603static struct hda_input_mux alc880_f1734_capture_source = {
2604 .num_items = 2,
2605 .items = {
2606 { "Mic", 0x1 },
2607 { "CD", 0x4 },
2608 },
2609};
2610
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002611
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002612/*
2613 * ALC880 ASUS model
2614 *
2615 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2616 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2617 * Mic = 0x18, Line = 0x1a
2618 */
2619
2620#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2621#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2622
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002623static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002624 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002625 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002626 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002627 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002628 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2629 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002630 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2631 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002632 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2633 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2634 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2635 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002638 {
2639 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2640 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002641 .info = alc_ch_mode_info,
2642 .get = alc_ch_mode_get,
2643 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002644 },
2645 { } /* end */
2646};
2647
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002648/*
2649 * ALC880 ASUS W1V model
2650 *
2651 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2652 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2653 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2654 */
2655
2656/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002657static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002658 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2659 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002660 { } /* end */
2661};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662
Kailang Yangdf694da2005-12-05 19:42:22 +01002663/* TCL S700 */
2664static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2665 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2666 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2667 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2668 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2669 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2670 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2671 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2672 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2673 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002674 { } /* end */
2675};
2676
Kailang Yangccc656c2006-10-17 12:32:26 +02002677/* Uniwill */
2678static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002679 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2680 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2681 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2682 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002683 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2684 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2685 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2686 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2687 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2688 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2689 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2690 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2691 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2692 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2693 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2694 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002695 {
2696 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2697 .name = "Channel Mode",
2698 .info = alc_ch_mode_info,
2699 .get = alc_ch_mode_get,
2700 .put = alc_ch_mode_put,
2701 },
2702 { } /* end */
2703};
2704
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002705static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2706 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2707 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2708 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2709 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2710 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2711 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2712 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2713 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2714 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2715 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2716 { } /* end */
2717};
2718
Kailang Yangccc656c2006-10-17 12:32:26 +02002719static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002720 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2721 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2722 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2723 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2725 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2726 { } /* end */
2727};
2728
Linus Torvalds1da177e2005-04-16 15:20:36 -07002729/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002730 * virtual master controls
2731 */
2732
2733/*
2734 * slave controls for virtual master
2735 */
2736static const char *alc_slave_vols[] = {
2737 "Front Playback Volume",
2738 "Surround Playback Volume",
2739 "Center Playback Volume",
2740 "LFE Playback Volume",
2741 "Side Playback Volume",
2742 "Headphone Playback Volume",
2743 "Speaker Playback Volume",
2744 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002745 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002746 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002747 NULL,
2748};
2749
2750static const char *alc_slave_sws[] = {
2751 "Front Playback Switch",
2752 "Surround Playback Switch",
2753 "Center Playback Switch",
2754 "LFE Playback Switch",
2755 "Side Playback Switch",
2756 "Headphone Playback Switch",
2757 "Speaker Playback Switch",
2758 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002759 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002760 "Line-Out Playback Switch",
2761 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002762 NULL,
2763};
2764
2765/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002766 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002767 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002768
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002769#define NID_MAPPING (-1)
2770
2771#define SUBDEV_SPEAKER_ (0 << 6)
2772#define SUBDEV_HP_ (1 << 6)
2773#define SUBDEV_LINE_ (2 << 6)
2774#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2775#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2776#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2777
Takashi Iwai603c4012008-07-30 15:01:44 +02002778static void alc_free_kctls(struct hda_codec *codec);
2779
Takashi Iwai67d634c2009-11-16 15:35:59 +01002780#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002781/* additional beep mixers; the actual parameters are overwritten at build */
2782static struct snd_kcontrol_new alc_beep_mixer[] = {
2783 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002784 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002785 { } /* end */
2786};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002787#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002788
Linus Torvalds1da177e2005-04-16 15:20:36 -07002789static int alc_build_controls(struct hda_codec *codec)
2790{
2791 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002792 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002793 struct snd_kcontrol_new *knew;
2794 int i, j, err;
2795 unsigned int u;
2796 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002797
2798 for (i = 0; i < spec->num_mixers; i++) {
2799 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2800 if (err < 0)
2801 return err;
2802 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002803 if (spec->cap_mixer) {
2804 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2805 if (err < 0)
2806 return err;
2807 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002808 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002809 err = snd_hda_create_spdif_out_ctls(codec,
2810 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002811 if (err < 0)
2812 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002813 if (!spec->no_analog) {
2814 err = snd_hda_create_spdif_share_sw(codec,
2815 &spec->multiout);
2816 if (err < 0)
2817 return err;
2818 spec->multiout.share_spdif = 1;
2819 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002820 }
2821 if (spec->dig_in_nid) {
2822 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2823 if (err < 0)
2824 return err;
2825 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002826
Takashi Iwai67d634c2009-11-16 15:35:59 +01002827#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002828 /* create beep controls if needed */
2829 if (spec->beep_amp) {
2830 struct snd_kcontrol_new *knew;
2831 for (knew = alc_beep_mixer; knew->name; knew++) {
2832 struct snd_kcontrol *kctl;
2833 kctl = snd_ctl_new1(knew, codec);
2834 if (!kctl)
2835 return -ENOMEM;
2836 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002837 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002838 if (err < 0)
2839 return err;
2840 }
2841 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002842#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002843
Takashi Iwai2134ea42008-01-10 16:53:55 +01002844 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002845 if (!spec->no_analog &&
2846 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002847 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002848 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002849 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002850 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002851 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002852 if (err < 0)
2853 return err;
2854 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002855 if (!spec->no_analog &&
2856 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002857 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2858 NULL, alc_slave_sws);
2859 if (err < 0)
2860 return err;
2861 }
2862
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002863 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002864 if (spec->capsrc_nids || spec->adc_nids) {
2865 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2866 if (!kctl)
2867 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
2868 for (i = 0; kctl && i < kctl->count; i++) {
2869 hda_nid_t *nids = spec->capsrc_nids;
2870 if (!nids)
2871 nids = spec->adc_nids;
2872 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
2873 if (err < 0)
2874 return err;
2875 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002876 }
2877 if (spec->cap_mixer) {
2878 const char *kname = kctl ? kctl->id.name : NULL;
2879 for (knew = spec->cap_mixer; knew->name; knew++) {
2880 if (kname && strcmp(knew->name, kname) == 0)
2881 continue;
2882 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2883 for (i = 0; kctl && i < kctl->count; i++) {
2884 err = snd_hda_add_nid(codec, kctl, i,
2885 spec->adc_nids[i]);
2886 if (err < 0)
2887 return err;
2888 }
2889 }
2890 }
2891
2892 /* other nid->control mapping */
2893 for (i = 0; i < spec->num_mixers; i++) {
2894 for (knew = spec->mixers[i]; knew->name; knew++) {
2895 if (knew->iface != NID_MAPPING)
2896 continue;
2897 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
2898 if (kctl == NULL)
2899 continue;
2900 u = knew->subdevice;
2901 for (j = 0; j < 4; j++, u >>= 8) {
2902 nid = u & 0x3f;
2903 if (nid == 0)
2904 continue;
2905 switch (u & 0xc0) {
2906 case SUBDEV_SPEAKER_:
2907 nid = spec->autocfg.speaker_pins[nid];
2908 break;
2909 case SUBDEV_LINE_:
2910 nid = spec->autocfg.line_out_pins[nid];
2911 break;
2912 case SUBDEV_HP_:
2913 nid = spec->autocfg.hp_pins[nid];
2914 break;
2915 default:
2916 continue;
2917 }
2918 err = snd_hda_add_nid(codec, kctl, 0, nid);
2919 if (err < 0)
2920 return err;
2921 }
2922 u = knew->private_value;
2923 for (j = 0; j < 4; j++, u >>= 8) {
2924 nid = u & 0xff;
2925 if (nid == 0)
2926 continue;
2927 err = snd_hda_add_nid(codec, kctl, 0, nid);
2928 if (err < 0)
2929 return err;
2930 }
2931 }
2932 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01002933
2934 alc_free_kctls(codec); /* no longer needed */
2935
Linus Torvalds1da177e2005-04-16 15:20:36 -07002936 return 0;
2937}
2938
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002939
Linus Torvalds1da177e2005-04-16 15:20:36 -07002940/*
2941 * initialize the codec volumes, etc
2942 */
2943
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002944/*
2945 * generic initialization of ADC, input mixers and output mixers
2946 */
2947static struct hda_verb alc880_volume_init_verbs[] = {
2948 /*
2949 * Unmute ADC0-2 and set the default input to mic-in
2950 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002951 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002952 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002953 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002954 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02002955 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002956 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002957
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002958 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
2959 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002960 * Note: PASD motherboards uses the Line In 2 as the input for front
2961 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002962 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002963 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02002964 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2965 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
2966 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
2967 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
2968 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
2969 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
2970 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002971
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002972 /*
2973 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002974 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002975 /* set vol=0 to output mixers */
2976 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2977 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2978 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2979 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
2980 /* set up input amps for analog loopback */
2981 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02002982 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2983 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002984 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2985 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002986 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2987 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02002988 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
2989 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07002990
2991 { }
2992};
2993
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002994/*
2995 * 3-stack pin configuration:
2996 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
2997 */
2998static struct hda_verb alc880_pin_3stack_init_verbs[] = {
2999 /*
3000 * preset connection lists of input pins
3001 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3002 */
3003 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3004 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3005 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3006
3007 /*
3008 * Set pin mode and muting
3009 */
3010 /* set front pin widgets 0x14 for output */
3011 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3012 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3013 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3014 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3015 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3016 /* Mic2 (as headphone out) for HP output */
3017 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3018 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3019 /* Line In pin widget for input */
3020 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3021 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3022 /* Line2 (as front mic) pin widget for input and vref at 80% */
3023 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3024 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3025 /* CD pin widget for input */
3026 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3027
3028 { }
3029};
3030
3031/*
3032 * 5-stack pin configuration:
3033 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3034 * line-in/side = 0x1a, f-mic = 0x1b
3035 */
3036static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3037 /*
3038 * preset connection lists of input pins
3039 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3040 */
3041 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3042 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3043
3044 /*
3045 * Set pin mode and muting
3046 */
3047 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003048 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3049 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3050 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3051 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003052 /* unmute pins for output (no gain on this amp) */
3053 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3054 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3055 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3056 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3057
Linus Torvalds1da177e2005-04-16 15:20:36 -07003058 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003059 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003060 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3061 /* Mic2 (as headphone out) for HP output */
3062 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003063 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003064 /* Line In pin widget for input */
3065 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3066 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3067 /* Line2 (as front mic) pin widget for input and vref at 80% */
3068 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3069 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3070 /* CD pin widget for input */
3071 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003072
3073 { }
3074};
3075
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003076/*
3077 * W810 pin configuration:
3078 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3079 */
3080static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003081 /* hphone/speaker input selector: front DAC */
3082 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3083
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003084 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3085 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3086 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3087 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3088 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3089 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3090
3091 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003092 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003093
Linus Torvalds1da177e2005-04-16 15:20:36 -07003094 { }
3095};
3096
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003097/*
3098 * Z71V pin configuration:
3099 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3100 */
3101static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003102 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003103 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003104 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003105 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003106
Takashi Iwai16ded522005-06-10 19:58:24 +02003107 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003109 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003110 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003111
3112 { }
3113};
3114
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003115/*
3116 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003117 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3118 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003119 */
3120static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3121 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3122
Takashi Iwai16ded522005-06-10 19:58:24 +02003123 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003124 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003125 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003126 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003127 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003128 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003129 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003130 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3131
Takashi Iwai16ded522005-06-10 19:58:24 +02003132 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003133 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003134 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003135 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003136 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003137 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003138 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003139 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003140 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003141
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003142 { }
3143};
Takashi Iwai16ded522005-06-10 19:58:24 +02003144
Kailang Yangccc656c2006-10-17 12:32:26 +02003145/*
3146 * Uniwill pin configuration:
3147 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3148 * line = 0x1a
3149 */
3150static struct hda_verb alc880_uniwill_init_verbs[] = {
3151 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3152
3153 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3154 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3155 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3156 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3157 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3158 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3159 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3160 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3161 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3163 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3164 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3165 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3166 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3167
3168 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3169 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3170 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3171 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3172 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3173 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3174 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3175 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3176 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3177
3178 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3179 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3180
3181 { }
3182};
3183
3184/*
3185* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003186* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003187 */
3188static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3189 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3190
3191 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3192 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3193 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3194 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3195 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3196 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3197 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3198 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3199 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3200 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3201 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3202 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3203
3204 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3205 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3206 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3207 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3208 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3209 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3210
3211 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3212 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3213
3214 { }
3215};
3216
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003217static struct hda_verb alc880_beep_init_verbs[] = {
3218 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3219 { }
3220};
3221
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003222/* auto-toggle front mic */
3223static void alc880_uniwill_mic_automute(struct hda_codec *codec)
3224{
3225 unsigned int present;
3226 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003227
Wu Fengguang864f92b2009-11-18 12:38:02 +08003228 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003229 bits = present ? HDA_AMP_MUTE : 0;
3230 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003231}
3232
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003233static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003234{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003235 struct alc_spec *spec = codec->spec;
3236
3237 spec->autocfg.hp_pins[0] = 0x14;
3238 spec->autocfg.speaker_pins[0] = 0x15;
3239 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003240}
3241
3242static void alc880_uniwill_init_hook(struct hda_codec *codec)
3243{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003244 alc_automute_amp(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003245 alc880_uniwill_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003246}
3247
3248static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3249 unsigned int res)
3250{
3251 /* Looks like the unsol event is incompatible with the standard
3252 * definition. 4bit tag is placed at 28 bit!
3253 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003254 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003255 case ALC880_MIC_EVENT:
3256 alc880_uniwill_mic_automute(codec);
3257 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003258 default:
3259 alc_automute_amp_unsol_event(codec, res);
3260 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003261 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003262}
3263
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003264static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003265{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003266 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003267
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003268 spec->autocfg.hp_pins[0] = 0x14;
3269 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003270}
3271
3272static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3273{
3274 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003275
Kailang Yangccc656c2006-10-17 12:32:26 +02003276 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003277 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3278 present &= HDA_AMP_VOLMASK;
3279 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3280 HDA_AMP_VOLMASK, present);
3281 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3282 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003283}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003284
Kailang Yangccc656c2006-10-17 12:32:26 +02003285static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3286 unsigned int res)
3287{
3288 /* Looks like the unsol event is incompatible with the standard
3289 * definition. 4bit tag is placed at 28 bit!
3290 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003291 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003292 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003293 else
3294 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003295}
3296
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003297/*
3298 * F1734 pin configuration:
3299 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3300 */
3301static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003302 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003303 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3304 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3305 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3306 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3307
3308 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3309 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3310 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3311 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3312
3313 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3314 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003315 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003316 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3317 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3318 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3319 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3320 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3321 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003322
Takashi Iwai937b4162008-02-11 14:52:36 +01003323 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3324 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3325
Takashi Iwai16ded522005-06-10 19:58:24 +02003326 { }
3327};
3328
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003329/*
3330 * ASUS pin configuration:
3331 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3332 */
3333static struct hda_verb alc880_pin_asus_init_verbs[] = {
3334 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3335 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3336 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3337 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3338
3339 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3340 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3341 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3342 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3343 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3344 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3345 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3346 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3347
3348 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3349 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3350 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3351 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3352 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3353 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3354 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3355 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3356 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003357
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003358 { }
3359};
3360
3361/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003362#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3363#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003364#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003365
Kailang Yangdf694da2005-12-05 19:42:22 +01003366/* Clevo m520g init */
3367static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3368 /* headphone output */
3369 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3370 /* line-out */
3371 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3372 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3373 /* Line-in */
3374 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3375 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3376 /* CD */
3377 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3378 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3379 /* Mic1 (rear panel) */
3380 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3381 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3382 /* Mic2 (front panel) */
3383 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3384 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3385 /* headphone */
3386 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3387 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3388 /* change to EAPD mode */
3389 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3390 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3391
3392 { }
3393};
3394
3395static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003396 /* change to EAPD mode */
3397 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3398 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3399
Kailang Yangdf694da2005-12-05 19:42:22 +01003400 /* Headphone output */
3401 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3402 /* Front output*/
3403 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3404 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3405
3406 /* Line In pin widget for input */
3407 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3408 /* CD pin widget for input */
3409 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3410 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3411 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3412
3413 /* change to EAPD mode */
3414 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3415 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3416
3417 { }
3418};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003419
3420/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003421 * LG m1 express dual
3422 *
3423 * Pin assignment:
3424 * Rear Line-In/Out (blue): 0x14
3425 * Build-in Mic-In: 0x15
3426 * Speaker-out: 0x17
3427 * HP-Out (green): 0x1b
3428 * Mic-In/Out (red): 0x19
3429 * SPDIF-Out: 0x1e
3430 */
3431
3432/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3433static hda_nid_t alc880_lg_dac_nids[3] = {
3434 0x05, 0x02, 0x03
3435};
3436
3437/* seems analog CD is not working */
3438static struct hda_input_mux alc880_lg_capture_source = {
3439 .num_items = 3,
3440 .items = {
3441 { "Mic", 0x1 },
3442 { "Line", 0x5 },
3443 { "Internal Mic", 0x6 },
3444 },
3445};
3446
3447/* 2,4,6 channel modes */
3448static struct hda_verb alc880_lg_ch2_init[] = {
3449 /* set line-in and mic-in to input */
3450 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3451 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3452 { }
3453};
3454
3455static struct hda_verb alc880_lg_ch4_init[] = {
3456 /* set line-in to out and mic-in to input */
3457 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3458 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3459 { }
3460};
3461
3462static struct hda_verb alc880_lg_ch6_init[] = {
3463 /* set line-in and mic-in to output */
3464 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3465 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3466 { }
3467};
3468
3469static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3470 { 2, alc880_lg_ch2_init },
3471 { 4, alc880_lg_ch4_init },
3472 { 6, alc880_lg_ch6_init },
3473};
3474
3475static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003476 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3477 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003478 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3479 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3480 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3481 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3482 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3483 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3484 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3485 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3486 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3487 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3488 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3489 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3490 {
3491 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3492 .name = "Channel Mode",
3493 .info = alc_ch_mode_info,
3494 .get = alc_ch_mode_get,
3495 .put = alc_ch_mode_put,
3496 },
3497 { } /* end */
3498};
3499
3500static struct hda_verb alc880_lg_init_verbs[] = {
3501 /* set capture source to mic-in */
3502 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3503 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3504 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3505 /* mute all amp mixer inputs */
3506 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003507 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3508 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003509 /* line-in to input */
3510 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3511 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3512 /* built-in mic */
3513 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3514 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3515 /* speaker-out */
3516 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3517 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3518 /* mic-in to input */
3519 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3520 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3521 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3522 /* HP-out */
3523 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3524 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3525 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3526 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003527 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003528 { }
3529};
3530
3531/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003532static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003533{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003534 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003535
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003536 spec->autocfg.hp_pins[0] = 0x1b;
3537 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003538}
3539
3540/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003541 * LG LW20
3542 *
3543 * Pin assignment:
3544 * Speaker-out: 0x14
3545 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003546 * Built-in Mic-In: 0x19
3547 * Line-In: 0x1b
3548 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003549 * SPDIF-Out: 0x1e
3550 */
3551
Takashi Iwaid6815182006-03-23 16:06:23 +01003552static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003553 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003554 .items = {
3555 { "Mic", 0x0 },
3556 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003557 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003558 },
3559};
3560
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003561#define alc880_lg_lw_modes alc880_threestack_modes
3562
Takashi Iwaid6815182006-03-23 16:06:23 +01003563static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003564 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3565 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3566 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3567 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3568 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3569 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3570 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3571 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3572 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3573 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003574 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3575 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3576 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3577 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003578 {
3579 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3580 .name = "Channel Mode",
3581 .info = alc_ch_mode_info,
3582 .get = alc_ch_mode_get,
3583 .put = alc_ch_mode_put,
3584 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003585 { } /* end */
3586};
3587
3588static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003589 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3590 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3591 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3592
Takashi Iwaid6815182006-03-23 16:06:23 +01003593 /* set capture source to mic-in */
3594 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3595 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3596 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003597 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003598 /* speaker-out */
3599 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3600 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3601 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003602 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3603 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3604 /* mic-in to input */
3605 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3606 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3607 /* built-in mic */
3608 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3609 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3610 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003611 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003612 { }
3613};
3614
3615/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003616static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003617{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003618 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003619
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003620 spec->autocfg.hp_pins[0] = 0x1b;
3621 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003622}
3623
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003624static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3625 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3626 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3627 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3628 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3629 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3630 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3631 { } /* end */
3632};
3633
3634static struct hda_input_mux alc880_medion_rim_capture_source = {
3635 .num_items = 2,
3636 .items = {
3637 { "Mic", 0x0 },
3638 { "Internal Mic", 0x1 },
3639 },
3640};
3641
3642static struct hda_verb alc880_medion_rim_init_verbs[] = {
3643 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3644
3645 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3646 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3647
3648 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3649 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3650 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3651 /* Mic2 (as headphone out) for HP output */
3652 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3653 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3654 /* Internal Speaker */
3655 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3656 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3657
3658 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3659 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3660
3661 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3662 { }
3663};
3664
3665/* toggle speaker-output according to the hp-jack state */
3666static void alc880_medion_rim_automute(struct hda_codec *codec)
3667{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003668 struct alc_spec *spec = codec->spec;
3669 alc_automute_amp(codec);
3670 /* toggle EAPD */
3671 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003672 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3673 else
3674 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3675}
3676
3677static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3678 unsigned int res)
3679{
3680 /* Looks like the unsol event is incompatible with the standard
3681 * definition. 4bit tag is placed at 28 bit!
3682 */
3683 if ((res >> 28) == ALC880_HP_EVENT)
3684 alc880_medion_rim_automute(codec);
3685}
3686
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003687static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003688{
3689 struct alc_spec *spec = codec->spec;
3690
3691 spec->autocfg.hp_pins[0] = 0x14;
3692 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003693}
3694
Takashi Iwaicb53c622007-08-10 17:21:45 +02003695#ifdef CONFIG_SND_HDA_POWER_SAVE
3696static struct hda_amp_list alc880_loopbacks[] = {
3697 { 0x0b, HDA_INPUT, 0 },
3698 { 0x0b, HDA_INPUT, 1 },
3699 { 0x0b, HDA_INPUT, 2 },
3700 { 0x0b, HDA_INPUT, 3 },
3701 { 0x0b, HDA_INPUT, 4 },
3702 { } /* end */
3703};
3704
3705static struct hda_amp_list alc880_lg_loopbacks[] = {
3706 { 0x0b, HDA_INPUT, 1 },
3707 { 0x0b, HDA_INPUT, 6 },
3708 { 0x0b, HDA_INPUT, 7 },
3709 { } /* end */
3710};
3711#endif
3712
Takashi Iwaid6815182006-03-23 16:06:23 +01003713/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003714 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003715 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003716
Linus Torvalds1da177e2005-04-16 15:20:36 -07003717static int alc_init(struct hda_codec *codec)
3718{
3719 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003720 unsigned int i;
3721
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003722 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003723 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003724
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003725 for (i = 0; i < spec->num_init_verbs; i++)
3726 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003727
3728 if (spec->init_hook)
3729 spec->init_hook(codec);
3730
Takashi Iwaiad358792010-03-30 18:00:59 +02003731#ifdef CONFIG_SND_HDA_POWER_SAVE
3732 if (codec->patch_ops.check_power_status)
3733 codec->patch_ops.check_power_status(codec, 0x01);
3734#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003735 return 0;
3736}
3737
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003738static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3739{
3740 struct alc_spec *spec = codec->spec;
3741
3742 if (spec->unsol_event)
3743 spec->unsol_event(codec, res);
3744}
3745
Takashi Iwaicb53c622007-08-10 17:21:45 +02003746#ifdef CONFIG_SND_HDA_POWER_SAVE
3747static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3748{
3749 struct alc_spec *spec = codec->spec;
3750 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3751}
3752#endif
3753
Linus Torvalds1da177e2005-04-16 15:20:36 -07003754/*
3755 * Analog playback callbacks
3756 */
3757static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3758 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003759 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003760{
3761 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003762 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3763 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003764}
3765
3766static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3767 struct hda_codec *codec,
3768 unsigned int stream_tag,
3769 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003770 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003771{
3772 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003773 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3774 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003775}
3776
3777static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3778 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003779 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003780{
3781 struct alc_spec *spec = codec->spec;
3782 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3783}
3784
3785/*
3786 * Digital out
3787 */
3788static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3789 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003790 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003791{
3792 struct alc_spec *spec = codec->spec;
3793 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3794}
3795
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003796static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3797 struct hda_codec *codec,
3798 unsigned int stream_tag,
3799 unsigned int format,
3800 struct snd_pcm_substream *substream)
3801{
3802 struct alc_spec *spec = codec->spec;
3803 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3804 stream_tag, format, substream);
3805}
3806
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003807static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3808 struct hda_codec *codec,
3809 struct snd_pcm_substream *substream)
3810{
3811 struct alc_spec *spec = codec->spec;
3812 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3813}
3814
Linus Torvalds1da177e2005-04-16 15:20:36 -07003815static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3816 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003817 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003818{
3819 struct alc_spec *spec = codec->spec;
3820 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3821}
3822
3823/*
3824 * Analog capture
3825 */
Takashi Iwai63300792008-01-24 15:31:36 +01003826static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003827 struct hda_codec *codec,
3828 unsigned int stream_tag,
3829 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003830 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003831{
3832 struct alc_spec *spec = codec->spec;
3833
Takashi Iwai63300792008-01-24 15:31:36 +01003834 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003835 stream_tag, 0, format);
3836 return 0;
3837}
3838
Takashi Iwai63300792008-01-24 15:31:36 +01003839static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003840 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003841 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003842{
3843 struct alc_spec *spec = codec->spec;
3844
Takashi Iwai888afa12008-03-18 09:57:50 +01003845 snd_hda_codec_cleanup_stream(codec,
3846 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003847 return 0;
3848}
3849
Takashi Iwai840b64c2010-07-13 22:49:01 +02003850/* analog capture with dynamic dual-adc changes */
3851static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3852 struct hda_codec *codec,
3853 unsigned int stream_tag,
3854 unsigned int format,
3855 struct snd_pcm_substream *substream)
3856{
3857 struct alc_spec *spec = codec->spec;
3858 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3859 spec->cur_adc_stream_tag = stream_tag;
3860 spec->cur_adc_format = format;
3861 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3862 return 0;
3863}
3864
3865static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3866 struct hda_codec *codec,
3867 struct snd_pcm_substream *substream)
3868{
3869 struct alc_spec *spec = codec->spec;
3870 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
3871 spec->cur_adc = 0;
3872 return 0;
3873}
3874
3875static struct hda_pcm_stream dualmic_pcm_analog_capture = {
3876 .substreams = 1,
3877 .channels_min = 2,
3878 .channels_max = 2,
3879 .nid = 0, /* fill later */
3880 .ops = {
3881 .prepare = dualmic_capture_pcm_prepare,
3882 .cleanup = dualmic_capture_pcm_cleanup
3883 },
3884};
Linus Torvalds1da177e2005-04-16 15:20:36 -07003885
3886/*
3887 */
3888static struct hda_pcm_stream alc880_pcm_analog_playback = {
3889 .substreams = 1,
3890 .channels_min = 2,
3891 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003892 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003893 .ops = {
3894 .open = alc880_playback_pcm_open,
3895 .prepare = alc880_playback_pcm_prepare,
3896 .cleanup = alc880_playback_pcm_cleanup
3897 },
3898};
3899
3900static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01003901 .substreams = 1,
3902 .channels_min = 2,
3903 .channels_max = 2,
3904 /* NID is set in alc_build_pcms */
3905};
3906
3907static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
3908 .substreams = 1,
3909 .channels_min = 2,
3910 .channels_max = 2,
3911 /* NID is set in alc_build_pcms */
3912};
3913
3914static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
3915 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003916 .channels_min = 2,
3917 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003918 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003919 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01003920 .prepare = alc880_alt_capture_pcm_prepare,
3921 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003922 },
3923};
3924
3925static struct hda_pcm_stream alc880_pcm_digital_playback = {
3926 .substreams = 1,
3927 .channels_min = 2,
3928 .channels_max = 2,
3929 /* NID is set in alc_build_pcms */
3930 .ops = {
3931 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003932 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003933 .prepare = alc880_dig_playback_pcm_prepare,
3934 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07003935 },
3936};
3937
3938static struct hda_pcm_stream alc880_pcm_digital_capture = {
3939 .substreams = 1,
3940 .channels_min = 2,
3941 .channels_max = 2,
3942 /* NID is set in alc_build_pcms */
3943};
3944
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003945/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01003946static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01003947 .substreams = 0,
3948 .channels_min = 0,
3949 .channels_max = 0,
3950};
3951
Linus Torvalds1da177e2005-04-16 15:20:36 -07003952static int alc_build_pcms(struct hda_codec *codec)
3953{
3954 struct alc_spec *spec = codec->spec;
3955 struct hda_pcm *info = spec->pcm_rec;
3956 int i;
3957
3958 codec->num_pcms = 1;
3959 codec->pcm_info = info;
3960
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003961 if (spec->no_analog)
3962 goto skip_analog;
3963
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003964 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
3965 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003966 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01003967
Takashi Iwai4a471b72005-12-07 13:56:29 +01003968 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003969 if (snd_BUG_ON(!spec->multiout.dac_nids))
3970 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003971 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
3972 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
3973 }
3974 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02003975 if (snd_BUG_ON(!spec->adc_nids))
3976 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01003977 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
3978 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
3979 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003980
Takashi Iwai4a471b72005-12-07 13:56:29 +01003981 if (spec->channel_mode) {
3982 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
3983 for (i = 0; i < spec->num_channel_mode; i++) {
3984 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
3985 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
3986 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003987 }
3988 }
3989
Takashi Iwaie64f14f2009-01-20 18:32:55 +01003990 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02003991 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003992 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02003993 snprintf(spec->stream_name_digital,
3994 sizeof(spec->stream_name_digital),
3995 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02003996 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08003997 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02003998 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003999 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004000 if (spec->dig_out_type)
4001 info->pcm_type = spec->dig_out_type;
4002 else
4003 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004004 if (spec->multiout.dig_out_nid &&
4005 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004006 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4007 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4008 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004009 if (spec->dig_in_nid &&
4010 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004011 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4012 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4013 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004014 /* FIXME: do we need this for all Realtek codec models? */
4015 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004016 }
4017
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004018 if (spec->no_analog)
4019 return 0;
4020
Takashi Iwaie08a0072006-09-07 17:52:14 +02004021 /* If the use of more than one ADC is requested for the current
4022 * model, configure a second analog capture-only PCM.
4023 */
4024 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004025 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4026 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004027 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004028 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004029 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004030 if (spec->alt_dac_nid) {
4031 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4032 *spec->stream_analog_alt_playback;
4033 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4034 spec->alt_dac_nid;
4035 } else {
4036 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4037 alc_pcm_null_stream;
4038 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4039 }
4040 if (spec->num_adc_nids > 1) {
4041 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4042 *spec->stream_analog_alt_capture;
4043 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4044 spec->adc_nids[1];
4045 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4046 spec->num_adc_nids - 1;
4047 } else {
4048 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4049 alc_pcm_null_stream;
4050 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004051 }
4052 }
4053
Linus Torvalds1da177e2005-04-16 15:20:36 -07004054 return 0;
4055}
4056
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004057static inline void alc_shutup(struct hda_codec *codec)
4058{
4059 snd_hda_shutup_pins(codec);
4060}
4061
Takashi Iwai603c4012008-07-30 15:01:44 +02004062static void alc_free_kctls(struct hda_codec *codec)
4063{
4064 struct alc_spec *spec = codec->spec;
4065
4066 if (spec->kctls.list) {
4067 struct snd_kcontrol_new *kctl = spec->kctls.list;
4068 int i;
4069 for (i = 0; i < spec->kctls.used; i++)
4070 kfree(kctl[i].name);
4071 }
4072 snd_array_free(&spec->kctls);
4073}
4074
Linus Torvalds1da177e2005-04-16 15:20:36 -07004075static void alc_free(struct hda_codec *codec)
4076{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004077 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004078
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004079 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004080 return;
4081
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004082 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004083 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004084 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004085 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004086}
4087
Hector Martinf5de24b2009-12-20 22:51:31 +01004088#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004089static void alc_power_eapd(struct hda_codec *codec)
4090{
4091 /* We currently only handle front, HP */
4092 switch (codec->vendor_id) {
4093 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004094 set_eapd(codec, 0x0f, 0);
4095 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004096 break;
4097 case 0x10ec0262:
4098 case 0x10ec0267:
4099 case 0x10ec0268:
4100 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004101 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004102 case 0x10ec0272:
4103 case 0x10ec0660:
4104 case 0x10ec0662:
4105 case 0x10ec0663:
4106 case 0x10ec0862:
4107 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004108 set_eapd(codec, 0x14, 0);
4109 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004110 break;
4111 }
4112}
4113
Hector Martinf5de24b2009-12-20 22:51:31 +01004114static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4115{
4116 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004117 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004118 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004119 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004120 return 0;
4121}
4122#endif
4123
Takashi Iwaie044c392008-10-27 16:56:24 +01004124#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004125static int alc_resume(struct hda_codec *codec)
4126{
Takashi Iwaie044c392008-10-27 16:56:24 +01004127 codec->patch_ops.init(codec);
4128 snd_hda_codec_resume_amp(codec);
4129 snd_hda_codec_resume_cache(codec);
Takashi Iwaiad358792010-03-30 18:00:59 +02004130#ifdef CONFIG_SND_HDA_POWER_SAVE
4131 if (codec->patch_ops.check_power_status)
4132 codec->patch_ops.check_power_status(codec, 0x01);
4133#endif
Takashi Iwaie044c392008-10-27 16:56:24 +01004134 return 0;
4135}
Takashi Iwaie044c392008-10-27 16:56:24 +01004136#endif
4137
Linus Torvalds1da177e2005-04-16 15:20:36 -07004138/*
4139 */
4140static struct hda_codec_ops alc_patch_ops = {
4141 .build_controls = alc_build_controls,
4142 .build_pcms = alc_build_pcms,
4143 .init = alc_init,
4144 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004145 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004146#ifdef SND_HDA_NEEDS_RESUME
4147 .resume = alc_resume,
4148#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004149#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004150 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004151 .check_power_status = alc_check_power_status,
4152#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004153 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004154};
4155
Kailang Yangc027ddc2010-03-19 11:33:06 +01004156/* replace the codec chip_name with the given string */
4157static int alc_codec_rename(struct hda_codec *codec, const char *name)
4158{
4159 kfree(codec->chip_name);
4160 codec->chip_name = kstrdup(name, GFP_KERNEL);
4161 if (!codec->chip_name) {
4162 alc_free(codec);
4163 return -ENOMEM;
4164 }
4165 return 0;
4166}
4167
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004168/*
4169 * Test configuration for debugging
4170 *
4171 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4172 * enum controls.
4173 */
4174#ifdef CONFIG_SND_DEBUG
4175static hda_nid_t alc880_test_dac_nids[4] = {
4176 0x02, 0x03, 0x04, 0x05
4177};
4178
4179static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004180 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004181 .items = {
4182 { "In-1", 0x0 },
4183 { "In-2", 0x1 },
4184 { "In-3", 0x2 },
4185 { "In-4", 0x3 },
4186 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004187 { "Front", 0x5 },
4188 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004189 },
4190};
4191
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004192static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004193 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004194 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004195 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004196 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004197};
4198
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004199static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4200 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004201{
4202 static char *texts[] = {
4203 "N/A", "Line Out", "HP Out",
4204 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4205 };
4206 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4207 uinfo->count = 1;
4208 uinfo->value.enumerated.items = 8;
4209 if (uinfo->value.enumerated.item >= 8)
4210 uinfo->value.enumerated.item = 7;
4211 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4212 return 0;
4213}
4214
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004215static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4216 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004217{
4218 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4219 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4220 unsigned int pin_ctl, item = 0;
4221
4222 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4223 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4224 if (pin_ctl & AC_PINCTL_OUT_EN) {
4225 if (pin_ctl & AC_PINCTL_HP_EN)
4226 item = 2;
4227 else
4228 item = 1;
4229 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4230 switch (pin_ctl & AC_PINCTL_VREFEN) {
4231 case AC_PINCTL_VREF_HIZ: item = 3; break;
4232 case AC_PINCTL_VREF_50: item = 4; break;
4233 case AC_PINCTL_VREF_GRD: item = 5; break;
4234 case AC_PINCTL_VREF_80: item = 6; break;
4235 case AC_PINCTL_VREF_100: item = 7; break;
4236 }
4237 }
4238 ucontrol->value.enumerated.item[0] = item;
4239 return 0;
4240}
4241
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004242static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4243 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004244{
4245 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4246 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4247 static unsigned int ctls[] = {
4248 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4249 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4250 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4251 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4252 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4253 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4254 };
4255 unsigned int old_ctl, new_ctl;
4256
4257 old_ctl = snd_hda_codec_read(codec, nid, 0,
4258 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4259 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4260 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004261 int val;
4262 snd_hda_codec_write_cache(codec, nid, 0,
4263 AC_VERB_SET_PIN_WIDGET_CONTROL,
4264 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004265 val = ucontrol->value.enumerated.item[0] >= 3 ?
4266 HDA_AMP_MUTE : 0;
4267 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4268 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004269 return 1;
4270 }
4271 return 0;
4272}
4273
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004274static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4275 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004276{
4277 static char *texts[] = {
4278 "Front", "Surround", "CLFE", "Side"
4279 };
4280 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4281 uinfo->count = 1;
4282 uinfo->value.enumerated.items = 4;
4283 if (uinfo->value.enumerated.item >= 4)
4284 uinfo->value.enumerated.item = 3;
4285 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4286 return 0;
4287}
4288
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004289static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4290 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004291{
4292 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4293 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4294 unsigned int sel;
4295
4296 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4297 ucontrol->value.enumerated.item[0] = sel & 3;
4298 return 0;
4299}
4300
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004301static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4302 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004303{
4304 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4305 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4306 unsigned int sel;
4307
4308 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4309 if (ucontrol->value.enumerated.item[0] != sel) {
4310 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004311 snd_hda_codec_write_cache(codec, nid, 0,
4312 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004313 return 1;
4314 }
4315 return 0;
4316}
4317
4318#define PIN_CTL_TEST(xname,nid) { \
4319 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4320 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004321 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004322 .info = alc_test_pin_ctl_info, \
4323 .get = alc_test_pin_ctl_get, \
4324 .put = alc_test_pin_ctl_put, \
4325 .private_value = nid \
4326 }
4327
4328#define PIN_SRC_TEST(xname,nid) { \
4329 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4330 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004331 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004332 .info = alc_test_pin_src_info, \
4333 .get = alc_test_pin_src_get, \
4334 .put = alc_test_pin_src_put, \
4335 .private_value = nid \
4336 }
4337
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004338static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004339 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4340 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4341 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4342 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004343 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4344 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4345 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4346 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004347 PIN_CTL_TEST("Front Pin Mode", 0x14),
4348 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4349 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4350 PIN_CTL_TEST("Side Pin Mode", 0x17),
4351 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4352 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4353 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4354 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4355 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4356 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4357 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4358 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4359 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4360 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4361 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4362 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4363 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4364 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4365 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4366 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4367 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4368 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004369 {
4370 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4371 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004372 .info = alc_ch_mode_info,
4373 .get = alc_ch_mode_get,
4374 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004375 },
4376 { } /* end */
4377};
4378
4379static struct hda_verb alc880_test_init_verbs[] = {
4380 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4383 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4384 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4385 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4386 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4387 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4388 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004389 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004390 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4391 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4392 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4393 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004394 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004395 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4396 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4397 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4398 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004399 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004400 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4401 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4402 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4403 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004404 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004405 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4406 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004407 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4408 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4409 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004410 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004411 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4412 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4413 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4414 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004415 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004417 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004418 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004419 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004420 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004421 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004422 /* Analog input/passthru */
4423 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4424 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4425 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4426 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4427 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004428 { }
4429};
4430#endif
4431
Linus Torvalds1da177e2005-04-16 15:20:36 -07004432/*
4433 */
4434
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004435static const char *alc880_models[ALC880_MODEL_LAST] = {
4436 [ALC880_3ST] = "3stack",
4437 [ALC880_TCL_S700] = "tcl",
4438 [ALC880_3ST_DIG] = "3stack-digout",
4439 [ALC880_CLEVO] = "clevo",
4440 [ALC880_5ST] = "5stack",
4441 [ALC880_5ST_DIG] = "5stack-digout",
4442 [ALC880_W810] = "w810",
4443 [ALC880_Z71V] = "z71v",
4444 [ALC880_6ST] = "6stack",
4445 [ALC880_6ST_DIG] = "6stack-digout",
4446 [ALC880_ASUS] = "asus",
4447 [ALC880_ASUS_W1V] = "asus-w1v",
4448 [ALC880_ASUS_DIG] = "asus-dig",
4449 [ALC880_ASUS_DIG2] = "asus-dig2",
4450 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004451 [ALC880_UNIWILL_P53] = "uniwill-p53",
4452 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004453 [ALC880_F1734] = "F1734",
4454 [ALC880_LG] = "lg",
4455 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004456 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004457#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004458 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004459#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004460 [ALC880_AUTO] = "auto",
4461};
4462
4463static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004464 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004465 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4466 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4467 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4468 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4469 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4470 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4471 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4472 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004473 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4474 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004475 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4476 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4477 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4478 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4479 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4480 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4481 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4482 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4483 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4484 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004485 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004486 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4487 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4488 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004489 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004490 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004491 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4492 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004493 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4494 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004495 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4496 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4497 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4498 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004499 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4500 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004501 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004502 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004503 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004504 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004505 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4506 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004507 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004508 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004509 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004510 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004511 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004512 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004513 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004514 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004515 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004516 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
4517 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004518 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004519 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4520 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4521 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4522 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004523 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4524 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004525 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004526 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004527 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4528 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004529 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4530 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4531 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004532 /* default Intel */
4533 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004534 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4535 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004536 {}
4537};
4538
Takashi Iwai16ded522005-06-10 19:58:24 +02004539/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004540 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004541 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004542static struct alc_config_preset alc880_presets[] = {
4543 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004544 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004545 .init_verbs = { alc880_volume_init_verbs,
4546 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004547 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004548 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004549 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4550 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004551 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004552 .input_mux = &alc880_capture_source,
4553 },
4554 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004555 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004556 .init_verbs = { alc880_volume_init_verbs,
4557 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004558 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004559 .dac_nids = alc880_dac_nids,
4560 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004561 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4562 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004563 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004564 .input_mux = &alc880_capture_source,
4565 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004566 [ALC880_TCL_S700] = {
4567 .mixers = { alc880_tcl_s700_mixer },
4568 .init_verbs = { alc880_volume_init_verbs,
4569 alc880_pin_tcl_S700_init_verbs,
4570 alc880_gpio2_init_verbs },
4571 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4572 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004573 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4574 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004575 .hp_nid = 0x03,
4576 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4577 .channel_mode = alc880_2_jack_modes,
4578 .input_mux = &alc880_capture_source,
4579 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004580 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004581 .mixers = { alc880_three_stack_mixer,
4582 alc880_five_stack_mixer},
4583 .init_verbs = { alc880_volume_init_verbs,
4584 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004585 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4586 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004587 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4588 .channel_mode = alc880_fivestack_modes,
4589 .input_mux = &alc880_capture_source,
4590 },
4591 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004592 .mixers = { alc880_three_stack_mixer,
4593 alc880_five_stack_mixer },
4594 .init_verbs = { alc880_volume_init_verbs,
4595 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004596 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4597 .dac_nids = alc880_dac_nids,
4598 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004599 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4600 .channel_mode = alc880_fivestack_modes,
4601 .input_mux = &alc880_capture_source,
4602 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004603 [ALC880_6ST] = {
4604 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004605 .init_verbs = { alc880_volume_init_verbs,
4606 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004607 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4608 .dac_nids = alc880_6st_dac_nids,
4609 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4610 .channel_mode = alc880_sixstack_modes,
4611 .input_mux = &alc880_6stack_capture_source,
4612 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004613 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004614 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004615 .init_verbs = { alc880_volume_init_verbs,
4616 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004617 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4618 .dac_nids = alc880_6st_dac_nids,
4619 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004620 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4621 .channel_mode = alc880_sixstack_modes,
4622 .input_mux = &alc880_6stack_capture_source,
4623 },
4624 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004625 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004626 .init_verbs = { alc880_volume_init_verbs,
4627 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004628 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004629 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4630 .dac_nids = alc880_w810_dac_nids,
4631 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004632 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4633 .channel_mode = alc880_w810_modes,
4634 .input_mux = &alc880_capture_source,
4635 },
4636 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004637 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004638 .init_verbs = { alc880_volume_init_verbs,
4639 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004640 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4641 .dac_nids = alc880_z71v_dac_nids,
4642 .dig_out_nid = ALC880_DIGOUT_NID,
4643 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004644 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4645 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004646 .input_mux = &alc880_capture_source,
4647 },
4648 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004649 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004650 .init_verbs = { alc880_volume_init_verbs,
4651 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004652 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4653 .dac_nids = alc880_f1734_dac_nids,
4654 .hp_nid = 0x02,
4655 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4656 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004657 .input_mux = &alc880_f1734_capture_source,
4658 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004659 .setup = alc880_uniwill_p53_setup,
4660 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004661 },
4662 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004663 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004664 .init_verbs = { alc880_volume_init_verbs,
4665 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004666 alc880_gpio1_init_verbs },
4667 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4668 .dac_nids = alc880_asus_dac_nids,
4669 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4670 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004671 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004672 .input_mux = &alc880_capture_source,
4673 },
4674 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004675 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004676 .init_verbs = { alc880_volume_init_verbs,
4677 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004678 alc880_gpio1_init_verbs },
4679 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4680 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004681 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004682 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4683 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004684 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004685 .input_mux = &alc880_capture_source,
4686 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004687 [ALC880_ASUS_DIG2] = {
4688 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004689 .init_verbs = { alc880_volume_init_verbs,
4690 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004691 alc880_gpio2_init_verbs }, /* use GPIO2 */
4692 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4693 .dac_nids = alc880_asus_dac_nids,
4694 .dig_out_nid = ALC880_DIGOUT_NID,
4695 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4696 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004697 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004698 .input_mux = &alc880_capture_source,
4699 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004700 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004701 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004702 .init_verbs = { alc880_volume_init_verbs,
4703 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004704 alc880_gpio1_init_verbs },
4705 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4706 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004707 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004708 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4709 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004710 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004711 .input_mux = &alc880_capture_source,
4712 },
4713 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004714 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004715 .init_verbs = { alc880_volume_init_verbs,
4716 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004717 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4718 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004719 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004720 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4721 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004722 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004723 .input_mux = &alc880_capture_source,
4724 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004725 [ALC880_UNIWILL] = {
4726 .mixers = { alc880_uniwill_mixer },
4727 .init_verbs = { alc880_volume_init_verbs,
4728 alc880_uniwill_init_verbs },
4729 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4730 .dac_nids = alc880_asus_dac_nids,
4731 .dig_out_nid = ALC880_DIGOUT_NID,
4732 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4733 .channel_mode = alc880_threestack_modes,
4734 .need_dac_fix = 1,
4735 .input_mux = &alc880_capture_source,
4736 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004737 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004738 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004739 },
4740 [ALC880_UNIWILL_P53] = {
4741 .mixers = { alc880_uniwill_p53_mixer },
4742 .init_verbs = { alc880_volume_init_verbs,
4743 alc880_uniwill_p53_init_verbs },
4744 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4745 .dac_nids = alc880_asus_dac_nids,
4746 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004747 .channel_mode = alc880_threestack_modes,
4748 .input_mux = &alc880_capture_source,
4749 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004750 .setup = alc880_uniwill_p53_setup,
4751 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004752 },
4753 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004754 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004755 .init_verbs = { alc880_volume_init_verbs,
4756 alc880_uniwill_p53_init_verbs,
4757 alc880_beep_init_verbs },
4758 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4759 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004760 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004761 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4762 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004763 .input_mux = &alc880_capture_source,
4764 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004765 .setup = alc880_uniwill_p53_setup,
4766 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004767 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004768 [ALC880_CLEVO] = {
4769 .mixers = { alc880_three_stack_mixer },
4770 .init_verbs = { alc880_volume_init_verbs,
4771 alc880_pin_clevo_init_verbs },
4772 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4773 .dac_nids = alc880_dac_nids,
4774 .hp_nid = 0x03,
4775 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4776 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004777 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004778 .input_mux = &alc880_capture_source,
4779 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004780 [ALC880_LG] = {
4781 .mixers = { alc880_lg_mixer },
4782 .init_verbs = { alc880_volume_init_verbs,
4783 alc880_lg_init_verbs },
4784 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4785 .dac_nids = alc880_lg_dac_nids,
4786 .dig_out_nid = ALC880_DIGOUT_NID,
4787 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4788 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004789 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004790 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004791 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004792 .setup = alc880_lg_setup,
4793 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004794#ifdef CONFIG_SND_HDA_POWER_SAVE
4795 .loopbacks = alc880_lg_loopbacks,
4796#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004797 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004798 [ALC880_LG_LW] = {
4799 .mixers = { alc880_lg_lw_mixer },
4800 .init_verbs = { alc880_volume_init_verbs,
4801 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004802 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004803 .dac_nids = alc880_dac_nids,
4804 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004805 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4806 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004807 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004808 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004809 .setup = alc880_lg_lw_setup,
4810 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004811 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004812 [ALC880_MEDION_RIM] = {
4813 .mixers = { alc880_medion_rim_mixer },
4814 .init_verbs = { alc880_volume_init_verbs,
4815 alc880_medion_rim_init_verbs,
4816 alc_gpio2_init_verbs },
4817 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4818 .dac_nids = alc880_dac_nids,
4819 .dig_out_nid = ALC880_DIGOUT_NID,
4820 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4821 .channel_mode = alc880_2_jack_modes,
4822 .input_mux = &alc880_medion_rim_capture_source,
4823 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004824 .setup = alc880_medion_rim_setup,
4825 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004826 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004827#ifdef CONFIG_SND_DEBUG
4828 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004829 .mixers = { alc880_test_mixer },
4830 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004831 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4832 .dac_nids = alc880_test_dac_nids,
4833 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004834 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4835 .channel_mode = alc880_test_modes,
4836 .input_mux = &alc880_test_capture_source,
4837 },
4838#endif
4839};
4840
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004841/*
4842 * Automatic parse of I/O pins from the BIOS configuration
4843 */
4844
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004845enum {
4846 ALC_CTL_WIDGET_VOL,
4847 ALC_CTL_WIDGET_MUTE,
4848 ALC_CTL_BIND_MUTE,
4849};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004850static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004851 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4852 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004853 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004854};
4855
4856/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004857static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004858 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004859{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004860 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004861
Takashi Iwai603c4012008-07-30 15:01:44 +02004862 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4863 knew = snd_array_new(&spec->kctls);
4864 if (!knew)
4865 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004866 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004867 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004868 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004869 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004870 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004871 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004872 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004873 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004874 return 0;
4875}
4876
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004877static int add_control_with_pfx(struct alc_spec *spec, int type,
4878 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004879 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004880{
4881 char name[32];
4882 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004883 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004884}
4885
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004886#define add_pb_vol_ctrl(spec, type, pfx, val) \
4887 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
4888#define add_pb_sw_ctrl(spec, type, pfx, val) \
4889 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
4890#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
4891 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
4892#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
4893 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004894
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004895#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
4896#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
4897#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
4898#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004899#define alc880_idx_to_dac(nid) ((nid) + 0x02)
4900#define alc880_dac_to_idx(nid) ((nid) - 0x02)
4901#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
4902#define alc880_idx_to_selector(nid) ((nid) + 0x10)
4903#define ALC880_PIN_CD_NID 0x1c
4904
4905/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004906static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
4907 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004908{
4909 hda_nid_t nid;
4910 int assigned[4];
4911 int i, j;
4912
4913 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004914 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004915
4916 /* check the pins hardwired to audio widget */
4917 for (i = 0; i < cfg->line_outs; i++) {
4918 nid = cfg->line_out_pins[i];
4919 if (alc880_is_fixed_pin(nid)) {
4920 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01004921 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004922 assigned[idx] = 1;
4923 }
4924 }
4925 /* left pins can be connect to any audio widget */
4926 for (i = 0; i < cfg->line_outs; i++) {
4927 nid = cfg->line_out_pins[i];
4928 if (alc880_is_fixed_pin(nid))
4929 continue;
4930 /* search for an empty channel */
4931 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004932 if (!assigned[j]) {
4933 spec->multiout.dac_nids[i] =
4934 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004935 assigned[j] = 1;
4936 break;
4937 }
4938 }
4939 }
4940 spec->multiout.num_dacs = cfg->line_outs;
4941 return 0;
4942}
4943
4944/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01004945static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
4946 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004947{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004948 static const char *chname[4] = {
4949 "Front", "Surround", NULL /*CLFE*/, "Side"
4950 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004951 hda_nid_t nid;
4952 int i, err;
4953
4954 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004955 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004956 continue;
4957 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
4958 if (i == 2) {
4959 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004960 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4961 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004962 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
4963 HDA_OUTPUT));
4964 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004965 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004966 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
4967 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004968 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
4969 HDA_OUTPUT));
4970 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004971 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004972 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4973 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004974 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
4975 HDA_INPUT));
4976 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004977 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004978 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
4979 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004980 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
4981 HDA_INPUT));
4982 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004983 return err;
4984 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02004985 const char *pfx;
4986 if (cfg->line_outs == 1 &&
4987 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
4988 pfx = "Speaker";
4989 else
4990 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004991 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004992 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
4993 HDA_OUTPUT));
4994 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004995 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02004996 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004997 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
4998 HDA_INPUT));
4999 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005000 return err;
5001 }
5002 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005003 return 0;
5004}
5005
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005006/* add playback controls for speaker and HP outputs */
5007static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5008 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005009{
5010 hda_nid_t nid;
5011 int err;
5012
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005013 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005014 return 0;
5015
5016 if (alc880_is_fixed_pin(pin)) {
5017 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005018 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005019 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005020 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005021 else
5022 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005023 /* control HP volume/switch on the output mixer amp */
5024 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005025 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005026 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5027 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005028 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005029 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005030 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5031 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005032 return err;
5033 } else if (alc880_is_multi_pin(pin)) {
5034 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005035 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005036 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5038 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005039 return err;
5040 }
5041 return 0;
5042}
5043
5044/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005045static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005046 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005047 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005048{
Kailang Yangdf694da2005-12-05 19:42:22 +01005049 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005050
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005051 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005052 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5053 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005054 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005055 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005056 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5057 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005058 return err;
5059 return 0;
5060}
5061
Takashi Iwai05f5f472009-08-25 13:10:18 +02005062static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005063{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005064 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5065 return (pincap & AC_PINCAP_IN) != 0;
5066}
5067
5068/* create playback/capture controls for input pins */
5069static int alc_auto_create_input_ctls(struct hda_codec *codec,
5070 const struct auto_pin_cfg *cfg,
5071 hda_nid_t mixer,
5072 hda_nid_t cap1, hda_nid_t cap2)
5073{
5074 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005075 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005076 int i, err, idx, type, type_idx = 0;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005077
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005078 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005079 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005080 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005081
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005082 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005083 if (!alc_is_input_pin(codec, pin))
5084 continue;
5085
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005086 type = cfg->inputs[i].type;
5087 if (i > 0 && type == cfg->inputs[i - 1].type)
5088 type_idx++;
5089 else
5090 type_idx = 0;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005091 label = hda_get_autocfg_input_label(codec, cfg, i);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005092 if (mixer) {
5093 idx = get_connection_index(codec, mixer, pin);
5094 if (idx >= 0) {
5095 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005096 label, type_idx,
5097 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005098 if (err < 0)
5099 return err;
5100 }
5101 }
5102
5103 if (!cap1)
5104 continue;
5105 idx = get_connection_index(codec, cap1, pin);
5106 if (idx < 0 && cap2)
5107 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005108 if (idx >= 0)
5109 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005110 }
5111 return 0;
5112}
5113
Takashi Iwai05f5f472009-08-25 13:10:18 +02005114static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5115 const struct auto_pin_cfg *cfg)
5116{
5117 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5118}
5119
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005120static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5121 unsigned int pin_type)
5122{
5123 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5124 pin_type);
5125 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005126 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5127 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005128}
5129
Kailang Yangdf694da2005-12-05 19:42:22 +01005130static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5131 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005132 int dac_idx)
5133{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005134 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005135 /* need the manual connection? */
5136 if (alc880_is_multi_pin(nid)) {
5137 struct alc_spec *spec = codec->spec;
5138 int idx = alc880_multi_pin_idx(nid);
5139 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5140 AC_VERB_SET_CONNECT_SEL,
5141 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5142 }
5143}
5144
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005145static int get_pin_type(int line_out_type)
5146{
5147 if (line_out_type == AUTO_PIN_HP_OUT)
5148 return PIN_HP;
5149 else
5150 return PIN_OUT;
5151}
5152
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005153static void alc880_auto_init_multi_out(struct hda_codec *codec)
5154{
5155 struct alc_spec *spec = codec->spec;
5156 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005157
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005158 for (i = 0; i < spec->autocfg.line_outs; i++) {
5159 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005160 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5161 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005162 }
5163}
5164
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005165static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005166{
5167 struct alc_spec *spec = codec->spec;
5168 hda_nid_t pin;
5169
Takashi Iwai82bc9552006-03-21 11:24:42 +01005170 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005171 if (pin) /* connect to front */
5172 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005173 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005174 if (pin) /* connect to front */
5175 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5176}
5177
5178static void alc880_auto_init_analog_input(struct hda_codec *codec)
5179{
5180 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005181 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005182 int i;
5183
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005184 for (i = 0; i < cfg->num_inputs; i++) {
5185 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005186 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005187 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005188 if (nid != ALC880_PIN_CD_NID &&
5189 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005190 snd_hda_codec_write(codec, nid, 0,
5191 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005192 AMP_OUT_MUTE);
5193 }
5194 }
5195}
5196
Takashi Iwai7f311a42010-04-09 17:32:23 +02005197static void alc880_auto_init_input_src(struct hda_codec *codec)
5198{
5199 struct alc_spec *spec = codec->spec;
5200 int c;
5201
5202 for (c = 0; c < spec->num_adc_nids; c++) {
5203 unsigned int mux_idx;
5204 const struct hda_input_mux *imux;
5205 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5206 imux = &spec->input_mux[mux_idx];
5207 if (!imux->num_items && mux_idx > 0)
5208 imux = &spec->input_mux[0];
5209 if (imux)
5210 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5211 AC_VERB_SET_CONNECT_SEL,
5212 imux->items[0].index);
5213 }
5214}
5215
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005216/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005217/* return 1 if successful, 0 if the proper config is not found,
5218 * or a negative error code
5219 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005220static int alc880_parse_auto_config(struct hda_codec *codec)
5221{
5222 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005223 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005224 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005225
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005226 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5227 alc880_ignore);
5228 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005229 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005230 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005231 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005232
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005233 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5234 if (err < 0)
5235 return err;
5236 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5237 if (err < 0)
5238 return err;
5239 err = alc880_auto_create_extra_out(spec,
5240 spec->autocfg.speaker_pins[0],
5241 "Speaker");
5242 if (err < 0)
5243 return err;
5244 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5245 "Headphone");
5246 if (err < 0)
5247 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005248 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005249 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005250 return err;
5251
5252 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5253
Takashi Iwai757899a2010-07-30 10:48:14 +02005254 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005255
Takashi Iwai603c4012008-07-30 15:01:44 +02005256 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005257 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005258
Takashi Iwaid88897e2008-10-31 15:01:37 +01005259 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005260
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005261 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005262 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005263
Kailang Yang6227cdc2010-02-25 08:36:52 +01005264 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005265
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005266 return 1;
5267}
5268
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005269/* additional initialization for auto-configuration model */
5270static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005271{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005272 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005273 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005274 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005275 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005276 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005277 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005278 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005279 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005280}
5281
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005282/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5283 * one of two digital mic pins, e.g. on ALC272
5284 */
5285static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005286{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005287 struct alc_spec *spec = codec->spec;
5288 int i;
5289
5290 for (i = 0; i < spec->num_adc_nids; i++) {
5291 hda_nid_t cap = spec->capsrc_nids ?
5292 spec->capsrc_nids[i] : spec->adc_nids[i];
5293 int iidx, eidx;
5294
5295 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5296 if (iidx < 0)
5297 continue;
5298 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5299 if (eidx < 0)
5300 continue;
5301 spec->int_mic.mux_idx = iidx;
5302 spec->ext_mic.mux_idx = eidx;
5303 if (spec->capsrc_nids)
5304 spec->capsrc_nids += i;
5305 spec->adc_nids += i;
5306 spec->num_adc_nids = 1;
5307 return;
5308 }
5309 snd_printd(KERN_INFO "hda_codec: %s: "
5310 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5311 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5312 spec->auto_mic = 0; /* disable auto-mic to be sure */
5313}
5314
Takashi Iwai748cce42010-08-04 07:37:39 +02005315/* select or unmute the given capsrc route */
5316static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5317 int idx)
5318{
5319 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5320 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5321 HDA_AMP_MUTE, 0);
5322 } else {
5323 snd_hda_codec_write_cache(codec, cap, 0,
5324 AC_VERB_SET_CONNECT_SEL, idx);
5325 }
5326}
5327
Takashi Iwai840b64c2010-07-13 22:49:01 +02005328/* set the default connection to that pin */
5329static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5330{
5331 struct alc_spec *spec = codec->spec;
5332 int i;
5333
5334 for (i = 0; i < spec->num_adc_nids; i++) {
5335 hda_nid_t cap = spec->capsrc_nids ?
5336 spec->capsrc_nids[i] : spec->adc_nids[i];
5337 int idx;
5338
5339 idx = get_connection_index(codec, cap, pin);
5340 if (idx < 0)
5341 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005342 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005343 return i; /* return the found index */
5344 }
5345 return -1; /* not found */
5346}
5347
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005348/* choose the ADC/MUX containing the input pin and initialize the setup */
5349static void fixup_single_adc(struct hda_codec *codec)
5350{
5351 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005352 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005353 int i;
5354
5355 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005356 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005357 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005358 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005359 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005360 /* use only this ADC */
5361 if (spec->capsrc_nids)
5362 spec->capsrc_nids += i;
5363 spec->adc_nids += i;
5364 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005365 }
5366}
5367
Takashi Iwai840b64c2010-07-13 22:49:01 +02005368/* initialize dual adcs */
5369static void fixup_dual_adc_switch(struct hda_codec *codec)
5370{
5371 struct alc_spec *spec = codec->spec;
5372 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5373 init_capsrc_for_pin(codec, spec->int_mic.pin);
5374}
5375
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005376static void set_capture_mixer(struct hda_codec *codec)
5377{
5378 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005379 static struct snd_kcontrol_new *caps[2][3] = {
5380 { alc_capture_mixer_nosrc1,
5381 alc_capture_mixer_nosrc2,
5382 alc_capture_mixer_nosrc3 },
5383 { alc_capture_mixer1,
5384 alc_capture_mixer2,
5385 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005386 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005387 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005388 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005389 int num_adcs = spec->num_adc_nids;
5390 if (spec->dual_adc_switch)
5391 fixup_dual_adc_switch(codec);
5392 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005393 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005394 else if (spec->input_mux) {
5395 if (spec->input_mux->num_items > 1)
5396 mux = 1;
5397 else if (spec->input_mux->num_items == 1)
5398 fixup_single_adc(codec);
5399 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005400 if (spec->dual_adc_switch)
5401 num_adcs = 1;
5402 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005403 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005404}
5405
Takashi Iwai66946352010-03-29 17:21:45 +02005406/* fill adc_nids (and capsrc_nids) containing all active input pins */
5407static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5408 int num_nids)
5409{
5410 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005411 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005412 int n;
5413 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5414
5415 for (n = 0; n < num_nids; n++) {
5416 hda_nid_t adc, cap;
5417 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5418 int nconns, i, j;
5419
5420 adc = nids[n];
5421 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5422 continue;
5423 cap = adc;
5424 nconns = snd_hda_get_connections(codec, cap, conn,
5425 ARRAY_SIZE(conn));
5426 if (nconns == 1) {
5427 cap = conn[0];
5428 nconns = snd_hda_get_connections(codec, cap, conn,
5429 ARRAY_SIZE(conn));
5430 }
5431 if (nconns <= 0)
5432 continue;
5433 if (!fallback_adc) {
5434 fallback_adc = adc;
5435 fallback_cap = cap;
5436 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005437 for (i = 0; i < cfg->num_inputs; i++) {
5438 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005439 for (j = 0; j < nconns; j++) {
5440 if (conn[j] == nid)
5441 break;
5442 }
5443 if (j >= nconns)
5444 break;
5445 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005446 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005447 int num_adcs = spec->num_adc_nids;
5448 spec->private_adc_nids[num_adcs] = adc;
5449 spec->private_capsrc_nids[num_adcs] = cap;
5450 spec->num_adc_nids++;
5451 spec->adc_nids = spec->private_adc_nids;
5452 if (adc != cap)
5453 spec->capsrc_nids = spec->private_capsrc_nids;
5454 }
5455 }
5456 if (!spec->num_adc_nids) {
5457 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005458 " using fallback 0x%x\n",
5459 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005460 spec->private_adc_nids[0] = fallback_adc;
5461 spec->adc_nids = spec->private_adc_nids;
5462 if (fallback_adc != fallback_cap) {
5463 spec->private_capsrc_nids[0] = fallback_cap;
5464 spec->capsrc_nids = spec->private_adc_nids;
5465 }
5466 }
5467}
5468
Takashi Iwai67d634c2009-11-16 15:35:59 +01005469#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005470#define set_beep_amp(spec, nid, idx, dir) \
5471 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005472
5473static struct snd_pci_quirk beep_white_list[] = {
5474 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005475 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005476 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005477 {}
5478};
5479
5480static inline int has_cdefine_beep(struct hda_codec *codec)
5481{
5482 struct alc_spec *spec = codec->spec;
5483 const struct snd_pci_quirk *q;
5484 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5485 if (q)
5486 return q->value;
5487 return spec->cdefine.enable_pcbeep;
5488}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005489#else
5490#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005491#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005492#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005493
5494/*
5495 * OK, here we have finally the patch for ALC880
5496 */
5497
Linus Torvalds1da177e2005-04-16 15:20:36 -07005498static int patch_alc880(struct hda_codec *codec)
5499{
5500 struct alc_spec *spec;
5501 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005502 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005503
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005504 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005505 if (spec == NULL)
5506 return -ENOMEM;
5507
5508 codec->spec = spec;
5509
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005510 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5511 alc880_models,
5512 alc880_cfg_tbl);
5513 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005514 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5515 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005516 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005517 }
5518
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005519 if (board_config == ALC880_AUTO) {
5520 /* automatic parse from the BIOS config */
5521 err = alc880_parse_auto_config(codec);
5522 if (err < 0) {
5523 alc_free(codec);
5524 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005525 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005526 printk(KERN_INFO
5527 "hda_codec: Cannot set up configuration "
5528 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005529 board_config = ALC880_3ST;
5530 }
5531 }
5532
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005533 err = snd_hda_attach_beep_device(codec, 0x1);
5534 if (err < 0) {
5535 alc_free(codec);
5536 return err;
5537 }
5538
Kailang Yangdf694da2005-12-05 19:42:22 +01005539 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005540 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005541
Linus Torvalds1da177e2005-04-16 15:20:36 -07005542 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5543 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005544 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005545
Linus Torvalds1da177e2005-04-16 15:20:36 -07005546 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5547 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5548
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005549 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005550 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005551 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005552 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005553 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005554 if (wcap != AC_WID_AUD_IN) {
5555 spec->adc_nids = alc880_adc_nids_alt;
5556 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005557 } else {
5558 spec->adc_nids = alc880_adc_nids;
5559 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005560 }
5561 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005562 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005563 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005564
Takashi Iwai2134ea42008-01-10 16:53:55 +01005565 spec->vmaster_nid = 0x0c;
5566
Linus Torvalds1da177e2005-04-16 15:20:36 -07005567 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005568 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005569 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005570#ifdef CONFIG_SND_HDA_POWER_SAVE
5571 if (!spec->loopback.amplist)
5572 spec->loopback.amplist = alc880_loopbacks;
5573#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005574
5575 return 0;
5576}
5577
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005578
Linus Torvalds1da177e2005-04-16 15:20:36 -07005579/*
5580 * ALC260 support
5581 */
5582
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005583static hda_nid_t alc260_dac_nids[1] = {
5584 /* front */
5585 0x02,
5586};
5587
5588static hda_nid_t alc260_adc_nids[1] = {
5589 /* ADC0 */
5590 0x04,
5591};
5592
Kailang Yangdf694da2005-12-05 19:42:22 +01005593static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005594 /* ADC1 */
5595 0x05,
5596};
5597
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005598/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5599 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5600 */
5601static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005602 /* ADC0, ADC1 */
5603 0x04, 0x05
5604};
5605
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005606#define ALC260_DIGOUT_NID 0x03
5607#define ALC260_DIGIN_NID 0x06
5608
5609static struct hda_input_mux alc260_capture_source = {
5610 .num_items = 4,
5611 .items = {
5612 { "Mic", 0x0 },
5613 { "Front Mic", 0x1 },
5614 { "Line", 0x2 },
5615 { "CD", 0x4 },
5616 },
5617};
5618
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005619/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005620 * headphone jack and the internal CD lines since these are the only pins at
5621 * which audio can appear. For flexibility, also allow the option of
5622 * recording the mixer output on the second ADC (ADC0 doesn't have a
5623 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005624 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005625static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5626 {
5627 .num_items = 3,
5628 .items = {
5629 { "Mic/Line", 0x0 },
5630 { "CD", 0x4 },
5631 { "Headphone", 0x2 },
5632 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005633 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005634 {
5635 .num_items = 4,
5636 .items = {
5637 { "Mic/Line", 0x0 },
5638 { "CD", 0x4 },
5639 { "Headphone", 0x2 },
5640 { "Mixer", 0x5 },
5641 },
5642 },
5643
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005644};
5645
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005646/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5647 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005648 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005649static struct hda_input_mux alc260_acer_capture_sources[2] = {
5650 {
5651 .num_items = 4,
5652 .items = {
5653 { "Mic", 0x0 },
5654 { "Line", 0x2 },
5655 { "CD", 0x4 },
5656 { "Headphone", 0x5 },
5657 },
5658 },
5659 {
5660 .num_items = 5,
5661 .items = {
5662 { "Mic", 0x0 },
5663 { "Line", 0x2 },
5664 { "CD", 0x4 },
5665 { "Headphone", 0x6 },
5666 { "Mixer", 0x5 },
5667 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005668 },
5669};
Michael Schwingencc959482009-02-22 18:58:45 +01005670
5671/* Maxdata Favorit 100XS */
5672static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5673 {
5674 .num_items = 2,
5675 .items = {
5676 { "Line/Mic", 0x0 },
5677 { "CD", 0x4 },
5678 },
5679 },
5680 {
5681 .num_items = 3,
5682 .items = {
5683 { "Line/Mic", 0x0 },
5684 { "CD", 0x4 },
5685 { "Mixer", 0x5 },
5686 },
5687 },
5688};
5689
Linus Torvalds1da177e2005-04-16 15:20:36 -07005690/*
5691 * This is just place-holder, so there's something for alc_build_pcms to look
5692 * at when it calculates the maximum number of channels. ALC260 has no mixer
5693 * element which allows changing the channel mode, so the verb list is
5694 * never used.
5695 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005696static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005697 { 2, NULL },
5698};
5699
Kailang Yangdf694da2005-12-05 19:42:22 +01005700
5701/* Mixer combinations
5702 *
5703 * basic: base_output + input + pc_beep + capture
5704 * HP: base_output + input + capture_alt
5705 * HP_3013: hp_3013 + input + capture
5706 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005707 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005708 */
5709
5710static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005711 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005712 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005713 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5714 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5715 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5716 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5717 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005718};
Kailang Yangdf694da2005-12-05 19:42:22 +01005719
5720static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005721 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5722 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5723 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5724 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5725 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5726 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5727 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5728 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005729 { } /* end */
5730};
5731
Takashi Iwaibec15c32008-01-28 18:16:30 +01005732/* update HP, line and mono out pins according to the master switch */
5733static void alc260_hp_master_update(struct hda_codec *codec,
5734 hda_nid_t hp, hda_nid_t line,
5735 hda_nid_t mono)
5736{
5737 struct alc_spec *spec = codec->spec;
5738 unsigned int val = spec->master_sw ? PIN_HP : 0;
5739 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005740 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005741 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005742 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005743 val);
5744 /* mono (speaker) depending on the HP jack sense */
5745 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005746 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005747 val);
5748}
5749
5750static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5751 struct snd_ctl_elem_value *ucontrol)
5752{
5753 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5754 struct alc_spec *spec = codec->spec;
5755 *ucontrol->value.integer.value = spec->master_sw;
5756 return 0;
5757}
5758
5759static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5760 struct snd_ctl_elem_value *ucontrol)
5761{
5762 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5763 struct alc_spec *spec = codec->spec;
5764 int val = !!*ucontrol->value.integer.value;
5765 hda_nid_t hp, line, mono;
5766
5767 if (val == spec->master_sw)
5768 return 0;
5769 spec->master_sw = val;
5770 hp = (kcontrol->private_value >> 16) & 0xff;
5771 line = (kcontrol->private_value >> 8) & 0xff;
5772 mono = kcontrol->private_value & 0xff;
5773 alc260_hp_master_update(codec, hp, line, mono);
5774 return 1;
5775}
5776
5777static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5778 {
5779 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5780 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005781 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005782 .info = snd_ctl_boolean_mono_info,
5783 .get = alc260_hp_master_sw_get,
5784 .put = alc260_hp_master_sw_put,
5785 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5786 },
5787 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5788 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5789 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5790 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5791 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5792 HDA_OUTPUT),
5793 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5794 { } /* end */
5795};
5796
5797static struct hda_verb alc260_hp_unsol_verbs[] = {
5798 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5799 {},
5800};
5801
5802static void alc260_hp_automute(struct hda_codec *codec)
5803{
5804 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005805
Wu Fengguang864f92b2009-11-18 12:38:02 +08005806 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005807 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5808}
5809
5810static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5811{
5812 if ((res >> 26) == ALC880_HP_EVENT)
5813 alc260_hp_automute(codec);
5814}
5815
Kailang Yangdf694da2005-12-05 19:42:22 +01005816static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005817 {
5818 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5819 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005820 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005821 .info = snd_ctl_boolean_mono_info,
5822 .get = alc260_hp_master_sw_get,
5823 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005824 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005825 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005826 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5827 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5828 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5829 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5830 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5831 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005832 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5833 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005834 { } /* end */
5835};
5836
Kailang Yang3f878302008-08-26 13:02:23 +02005837static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5838 .ops = &snd_hda_bind_vol,
5839 .values = {
5840 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5841 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5842 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5843 0
5844 },
5845};
5846
5847static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5848 .ops = &snd_hda_bind_sw,
5849 .values = {
5850 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5851 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5852 0
5853 },
5854};
5855
5856static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5857 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5858 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5859 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5860 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5861 { } /* end */
5862};
5863
Takashi Iwaibec15c32008-01-28 18:16:30 +01005864static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5865 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5866 {},
5867};
5868
5869static void alc260_hp_3013_automute(struct hda_codec *codec)
5870{
5871 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005872
Wu Fengguang864f92b2009-11-18 12:38:02 +08005873 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005874 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005875}
5876
5877static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
5878 unsigned int res)
5879{
5880 if ((res >> 26) == ALC880_HP_EVENT)
5881 alc260_hp_3013_automute(codec);
5882}
5883
Kailang Yang3f878302008-08-26 13:02:23 +02005884static void alc260_hp_3012_automute(struct hda_codec *codec)
5885{
Wu Fengguang864f92b2009-11-18 12:38:02 +08005886 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02005887
Kailang Yang3f878302008-08-26 13:02:23 +02005888 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5889 bits);
5890 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5891 bits);
5892 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5893 bits);
5894}
5895
5896static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
5897 unsigned int res)
5898{
5899 if ((res >> 26) == ALC880_HP_EVENT)
5900 alc260_hp_3012_automute(codec);
5901}
5902
5903/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005904 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
5905 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01005906static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005907 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005908 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005909 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005910 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5911 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5912 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
5913 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005914 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005915 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5916 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005917 { } /* end */
5918};
5919
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005920/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
5921 * versions of the ALC260 don't act on requests to enable mic bias from NID
5922 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
5923 * datasheet doesn't mention this restriction. At this stage it's not clear
5924 * whether this behaviour is intentional or is a hardware bug in chip
5925 * revisions available in early 2006. Therefore for now allow the
5926 * "Headphone Jack Mode" control to span all choices, but if it turns out
5927 * that the lack of mic bias for this NID is intentional we could change the
5928 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
5929 *
5930 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
5931 * don't appear to make the mic bias available from the "line" jack, even
5932 * though the NID used for this jack (0x14) can supply it. The theory is
5933 * that perhaps Acer have included blocking capacitors between the ALC260
5934 * and the output jack. If this turns out to be the case for all such
5935 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
5936 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01005937 *
5938 * The C20x Tablet series have a mono internal speaker which is controlled
5939 * via the chip's Mono sum widget and pin complex, so include the necessary
5940 * controls for such models. On models without a "mono speaker" the control
5941 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005942 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005943static struct snd_kcontrol_new alc260_acer_mixer[] = {
5944 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5945 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005946 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005947 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01005948 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01005949 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01005950 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005951 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5952 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5953 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5954 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5955 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5956 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5957 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5958 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005959 { } /* end */
5960};
5961
Michael Schwingencc959482009-02-22 18:58:45 +01005962/* Maxdata Favorit 100XS: one output and one input (0x12) jack
5963 */
5964static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
5965 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5966 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
5967 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
5968 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5969 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5970 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5971 { } /* end */
5972};
5973
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005974/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
5975 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
5976 */
5977static struct snd_kcontrol_new alc260_will_mixer[] = {
5978 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5979 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5980 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5981 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5982 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
5983 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5984 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5985 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
5986 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5987 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02005988 { } /* end */
5989};
5990
5991/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
5992 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
5993 */
5994static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
5995 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5996 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
5997 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5998 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5999 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6000 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6001 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6002 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6003 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6004 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6005 { } /* end */
6006};
6007
Kailang Yangdf694da2005-12-05 19:42:22 +01006008/*
6009 * initialization verbs
6010 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006011static struct hda_verb alc260_init_verbs[] = {
6012 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006013 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006014 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006015 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006016 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006017 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006018 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006019 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006020 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006021 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006022 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006023 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006024 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006025 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006026 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006027 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006028 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006029 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6030 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006031 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006032 /* set connection select to line in (default select for this ADC) */
6033 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006034 /* mute capture amp left and right */
6035 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6036 /* set connection select to line in (default select for this ADC) */
6037 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006038 /* set vol=0 Line-Out mixer amp left and right */
6039 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6040 /* unmute pin widget amp left and right (no gain on this amp) */
6041 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6042 /* set vol=0 HP mixer amp left and right */
6043 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6044 /* unmute pin widget amp left and right (no gain on this amp) */
6045 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6046 /* set vol=0 Mono mixer amp left and right */
6047 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6048 /* unmute pin widget amp left and right (no gain on this amp) */
6049 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6050 /* unmute LINE-2 out pin */
6051 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006052 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6053 * Line In 2 = 0x03
6054 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006055 /* mute analog inputs */
6056 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6057 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6058 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6059 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6060 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006061 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006062 /* mute Front out path */
6063 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6064 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6065 /* mute Headphone out path */
6066 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6067 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6068 /* mute Mono out path */
6069 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6070 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006071 { }
6072};
6073
Takashi Iwai474167d2006-05-17 17:17:43 +02006074#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006075static struct hda_verb alc260_hp_init_verbs[] = {
6076 /* Headphone and output */
6077 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6078 /* mono output */
6079 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6080 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6081 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6082 /* Mic2 (front panel) pin widget for input and vref at 80% */
6083 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6084 /* Line In pin widget for input */
6085 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6086 /* Line-2 pin widget for output */
6087 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6088 /* CD pin widget for input */
6089 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6090 /* unmute amp left and right */
6091 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6092 /* set connection select to line in (default select for this ADC) */
6093 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6094 /* unmute Line-Out mixer amp left and right (volume = 0) */
6095 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6096 /* mute pin widget amp left and right (no gain on this amp) */
6097 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6098 /* unmute HP mixer amp left and right (volume = 0) */
6099 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6100 /* mute pin widget amp left and right (no gain on this amp) */
6101 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006102 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6103 * Line In 2 = 0x03
6104 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006105 /* mute analog inputs */
6106 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6107 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6108 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6109 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6110 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006111 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6112 /* Unmute Front out path */
6113 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6114 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6115 /* Unmute Headphone out path */
6116 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6117 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6118 /* Unmute Mono out path */
6119 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6120 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6121 { }
6122};
Takashi Iwai474167d2006-05-17 17:17:43 +02006123#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006124
6125static struct hda_verb alc260_hp_3013_init_verbs[] = {
6126 /* Line out and output */
6127 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6128 /* mono output */
6129 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6130 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6131 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6132 /* Mic2 (front panel) pin widget for input and vref at 80% */
6133 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6134 /* Line In pin widget for input */
6135 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6136 /* Headphone pin widget for output */
6137 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6138 /* CD pin widget for input */
6139 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6140 /* unmute amp left and right */
6141 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6142 /* set connection select to line in (default select for this ADC) */
6143 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6144 /* unmute Line-Out mixer amp left and right (volume = 0) */
6145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6146 /* mute pin widget amp left and right (no gain on this amp) */
6147 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6148 /* unmute HP mixer amp left and right (volume = 0) */
6149 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6150 /* mute pin widget amp left and right (no gain on this amp) */
6151 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006152 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6153 * Line In 2 = 0x03
6154 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006155 /* mute analog inputs */
6156 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6157 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6158 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6159 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6160 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006161 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6162 /* Unmute Front out path */
6163 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6164 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6165 /* Unmute Headphone out path */
6166 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6167 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6168 /* Unmute Mono out path */
6169 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6170 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6171 { }
6172};
6173
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006174/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006175 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6176 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006177 */
6178static struct hda_verb alc260_fujitsu_init_verbs[] = {
6179 /* Disable all GPIOs */
6180 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6181 /* Internal speaker is connected to headphone pin */
6182 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6183 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6184 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006185 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6186 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6187 /* Ensure all other unused pins are disabled and muted. */
6188 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6189 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006190 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006191 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006192 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006193 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6194 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6195 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006196
Jonathan Woithef7ace402006-02-28 11:46:14 +01006197 /* Disable digital (SPDIF) pins */
6198 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6199 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006200
Kailang Yangea1fb292008-08-26 12:58:38 +02006201 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006202 * when acting as an output.
6203 */
6204 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6205
6206 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006207 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6208 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6209 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6210 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6211 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6212 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6213 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6214 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6215 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006216
Jonathan Woithef7ace402006-02-28 11:46:14 +01006217 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6218 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6219 /* Unmute Line1 pin widget output buffer since it starts as an output.
6220 * If the pin mode is changed by the user the pin mode control will
6221 * take care of enabling the pin's input/output buffers as needed.
6222 * Therefore there's no need to enable the input buffer at this
6223 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006224 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006225 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006226 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006227 * mixer ctrl)
6228 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006229 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006230
Jonathan Woithef7ace402006-02-28 11:46:14 +01006231 /* Mute capture amp left and right */
6232 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006233 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006234 * in (on mic1 pin)
6235 */
6236 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006237
Jonathan Woithef7ace402006-02-28 11:46:14 +01006238 /* Do the same for the second ADC: mute capture input amp and
6239 * set ADC connection to line in (on mic1 pin)
6240 */
6241 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6242 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006243
Jonathan Woithef7ace402006-02-28 11:46:14 +01006244 /* Mute all inputs to mixer widget (even unconnected ones) */
6245 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6246 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6247 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6248 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6249 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6250 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6251 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006253
6254 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006255};
6256
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006257/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6258 * similar laptops (adapted from Fujitsu init verbs).
6259 */
6260static struct hda_verb alc260_acer_init_verbs[] = {
6261 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6262 * the headphone jack. Turn this on and rely on the standard mute
6263 * methods whenever the user wants to turn these outputs off.
6264 */
6265 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6266 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6267 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6268 /* Internal speaker/Headphone jack is connected to Line-out pin */
6269 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6270 /* Internal microphone/Mic jack is connected to Mic1 pin */
6271 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6272 /* Line In jack is connected to Line1 pin */
6273 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006274 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6275 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006276 /* Ensure all other unused pins are disabled and muted. */
6277 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6278 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006279 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6280 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6281 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6282 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6283 /* Disable digital (SPDIF) pins */
6284 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6285 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6286
Kailang Yangea1fb292008-08-26 12:58:38 +02006287 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006288 * bus when acting as outputs.
6289 */
6290 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6291 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6292
6293 /* Start with output sum widgets muted and their output gains at min */
6294 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6295 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6296 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6297 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6298 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6299 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6300 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6301 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6302 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6303
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006304 /* Unmute Line-out pin widget amp left and right
6305 * (no equiv mixer ctrl)
6306 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006307 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006308 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6309 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006310 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6311 * inputs. If the pin mode is changed by the user the pin mode control
6312 * will take care of enabling the pin's input/output buffers as needed.
6313 * Therefore there's no need to enable the input buffer at this
6314 * stage.
6315 */
6316 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6317 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6318
6319 /* Mute capture amp left and right */
6320 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6321 /* Set ADC connection select to match default mixer setting - mic
6322 * (on mic1 pin)
6323 */
6324 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6325
6326 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006327 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006328 */
6329 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006330 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006331
6332 /* Mute all inputs to mixer widget (even unconnected ones) */
6333 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6334 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6335 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6336 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6337 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6338 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6339 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6340 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6341
6342 { }
6343};
6344
Michael Schwingencc959482009-02-22 18:58:45 +01006345/* Initialisation sequence for Maxdata Favorit 100XS
6346 * (adapted from Acer init verbs).
6347 */
6348static struct hda_verb alc260_favorit100_init_verbs[] = {
6349 /* GPIO 0 enables the output jack.
6350 * Turn this on and rely on the standard mute
6351 * methods whenever the user wants to turn these outputs off.
6352 */
6353 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6354 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6355 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6356 /* Line/Mic input jack is connected to Mic1 pin */
6357 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6358 /* Ensure all other unused pins are disabled and muted. */
6359 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6360 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6361 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6362 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6363 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6364 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6365 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6366 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6369 /* Disable digital (SPDIF) pins */
6370 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6371 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6372
6373 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6374 * bus when acting as outputs.
6375 */
6376 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6377 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6378
6379 /* Start with output sum widgets muted and their output gains at min */
6380 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6381 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6382 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6383 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6384 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6385 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6386 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6387 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6388 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6389
6390 /* Unmute Line-out pin widget amp left and right
6391 * (no equiv mixer ctrl)
6392 */
6393 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6394 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6395 * inputs. If the pin mode is changed by the user the pin mode control
6396 * will take care of enabling the pin's input/output buffers as needed.
6397 * Therefore there's no need to enable the input buffer at this
6398 * stage.
6399 */
6400 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6401
6402 /* Mute capture amp left and right */
6403 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6404 /* Set ADC connection select to match default mixer setting - mic
6405 * (on mic1 pin)
6406 */
6407 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6408
6409 /* Do similar with the second ADC: mute capture input amp and
6410 * set ADC connection to mic to match ALSA's default state.
6411 */
6412 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6413 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6414
6415 /* Mute all inputs to mixer widget (even unconnected ones) */
6416 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6417 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6418 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6419 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6420 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6421 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6422 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6423 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6424
6425 { }
6426};
6427
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006428static struct hda_verb alc260_will_verbs[] = {
6429 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6430 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6431 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6432 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6433 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6434 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6435 {}
6436};
6437
6438static struct hda_verb alc260_replacer_672v_verbs[] = {
6439 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6440 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6441 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6442
6443 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6444 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6445 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6446
6447 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6448 {}
6449};
6450
6451/* toggle speaker-output according to the hp-jack state */
6452static void alc260_replacer_672v_automute(struct hda_codec *codec)
6453{
6454 unsigned int present;
6455
6456 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006457 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006458 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006459 snd_hda_codec_write_cache(codec, 0x01, 0,
6460 AC_VERB_SET_GPIO_DATA, 1);
6461 snd_hda_codec_write_cache(codec, 0x0f, 0,
6462 AC_VERB_SET_PIN_WIDGET_CONTROL,
6463 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006464 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006465 snd_hda_codec_write_cache(codec, 0x01, 0,
6466 AC_VERB_SET_GPIO_DATA, 0);
6467 snd_hda_codec_write_cache(codec, 0x0f, 0,
6468 AC_VERB_SET_PIN_WIDGET_CONTROL,
6469 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006470 }
6471}
6472
6473static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6474 unsigned int res)
6475{
6476 if ((res >> 26) == ALC880_HP_EVENT)
6477 alc260_replacer_672v_automute(codec);
6478}
6479
Kailang Yang3f878302008-08-26 13:02:23 +02006480static struct hda_verb alc260_hp_dc7600_verbs[] = {
6481 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6482 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6483 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6484 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6485 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6486 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6487 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6488 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6489 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6490 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6491 {}
6492};
6493
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006494/* Test configuration for debugging, modelled after the ALC880 test
6495 * configuration.
6496 */
6497#ifdef CONFIG_SND_DEBUG
6498static hda_nid_t alc260_test_dac_nids[1] = {
6499 0x02,
6500};
6501static hda_nid_t alc260_test_adc_nids[2] = {
6502 0x04, 0x05,
6503};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006504/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006505 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006506 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006507 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006508static struct hda_input_mux alc260_test_capture_sources[2] = {
6509 {
6510 .num_items = 7,
6511 .items = {
6512 { "MIC1 pin", 0x0 },
6513 { "MIC2 pin", 0x1 },
6514 { "LINE1 pin", 0x2 },
6515 { "LINE2 pin", 0x3 },
6516 { "CD pin", 0x4 },
6517 { "LINE-OUT pin", 0x5 },
6518 { "HP-OUT pin", 0x6 },
6519 },
6520 },
6521 {
6522 .num_items = 8,
6523 .items = {
6524 { "MIC1 pin", 0x0 },
6525 { "MIC2 pin", 0x1 },
6526 { "LINE1 pin", 0x2 },
6527 { "LINE2 pin", 0x3 },
6528 { "CD pin", 0x4 },
6529 { "Mixer", 0x5 },
6530 { "LINE-OUT pin", 0x6 },
6531 { "HP-OUT pin", 0x7 },
6532 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006533 },
6534};
6535static struct snd_kcontrol_new alc260_test_mixer[] = {
6536 /* Output driver widgets */
6537 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6538 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6539 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6540 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6541 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6542 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6543
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006544 /* Modes for retasking pin widgets
6545 * Note: the ALC260 doesn't seem to act on requests to enable mic
6546 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6547 * mention this restriction. At this stage it's not clear whether
6548 * this behaviour is intentional or is a hardware bug in chip
6549 * revisions available at least up until early 2006. Therefore for
6550 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6551 * choices, but if it turns out that the lack of mic bias for these
6552 * NIDs is intentional we could change their modes from
6553 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6554 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006555 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6556 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6557 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6558 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6559 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6560 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6561
6562 /* Loopback mixer controls */
6563 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6564 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6565 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6566 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6567 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6568 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6569 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6570 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6571 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6572 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006573 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6574 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6575 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6576 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006577
6578 /* Controls for GPIO pins, assuming they are configured as outputs */
6579 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6580 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6581 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6582 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6583
Jonathan Woithe92621f12006-02-28 11:47:47 +01006584 /* Switches to allow the digital IO pins to be enabled. The datasheet
6585 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006586 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006587 */
6588 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6589 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6590
Jonathan Woithef8225f62008-01-08 12:16:54 +01006591 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6592 * this output to turn on an external amplifier.
6593 */
6594 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6595 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6596
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006597 { } /* end */
6598};
6599static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006600 /* Enable all GPIOs as outputs with an initial value of 0 */
6601 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6602 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6603 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6604
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006605 /* Enable retasking pins as output, initially without power amp */
6606 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6607 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6608 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6609 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6610 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6611 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6612
Jonathan Woithe92621f12006-02-28 11:47:47 +01006613 /* Disable digital (SPDIF) pins initially, but users can enable
6614 * them via a mixer switch. In the case of SPDIF-out, this initverb
6615 * payload also sets the generation to 0, output to be in "consumer"
6616 * PCM format, copyright asserted, no pre-emphasis and no validity
6617 * control.
6618 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006619 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6620 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6621
Kailang Yangea1fb292008-08-26 12:58:38 +02006622 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006623 * OUT1 sum bus when acting as an output.
6624 */
6625 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6626 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6627 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6628 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6629
6630 /* Start with output sum widgets muted and their output gains at min */
6631 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6632 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6633 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6634 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6635 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6637 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6638 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6639 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6640
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006641 /* Unmute retasking pin widget output buffers since the default
6642 * state appears to be output. As the pin mode is changed by the
6643 * user the pin mode control will take care of enabling the pin's
6644 * input/output buffers as needed.
6645 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006646 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6647 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6648 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6649 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6650 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6651 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6652 /* Also unmute the mono-out pin widget */
6653 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6654
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006655 /* Mute capture amp left and right */
6656 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006657 /* Set ADC connection select to match default mixer setting (mic1
6658 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006659 */
6660 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6661
6662 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006663 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006664 */
6665 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6666 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6667
6668 /* Mute all inputs to mixer widget (even unconnected ones) */
6669 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6670 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6671 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6672 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6673 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6674 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6675 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6676 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6677
6678 { }
6679};
6680#endif
6681
Takashi Iwai63300792008-01-24 15:31:36 +01006682#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6683#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006684
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006685#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6686#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6687
Kailang Yangdf694da2005-12-05 19:42:22 +01006688/*
6689 * for BIOS auto-configuration
6690 */
6691
6692static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006693 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006694{
6695 hda_nid_t nid_vol;
6696 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006697 int err;
6698
6699 if (nid >= 0x0f && nid < 0x11) {
6700 nid_vol = nid - 0x7;
6701 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6702 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6703 } else if (nid == 0x11) {
6704 nid_vol = nid - 0x7;
6705 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6706 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6707 } else if (nid >= 0x12 && nid <= 0x15) {
6708 nid_vol = 0x08;
6709 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6710 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6711 } else
6712 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006713
Takashi Iwai863b4512008-10-21 17:01:47 +02006714 if (!(*vol_bits & (1 << nid_vol))) {
6715 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006716 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006717 if (err < 0)
6718 return err;
6719 *vol_bits |= (1 << nid_vol);
6720 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006721 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006722 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006723 return err;
6724 return 1;
6725}
6726
6727/* add playback controls from the parsed DAC table */
6728static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6729 const struct auto_pin_cfg *cfg)
6730{
6731 hda_nid_t nid;
6732 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006733 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006734
6735 spec->multiout.num_dacs = 1;
6736 spec->multiout.dac_nids = spec->private_dac_nids;
6737 spec->multiout.dac_nids[0] = 0x02;
6738
6739 nid = cfg->line_out_pins[0];
6740 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006741 const char *pfx;
6742 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6743 pfx = "Master";
6744 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6745 pfx = "Speaker";
6746 else
6747 pfx = "Front";
6748 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006749 if (err < 0)
6750 return err;
6751 }
6752
Takashi Iwai82bc9552006-03-21 11:24:42 +01006753 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006754 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006755 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006756 if (err < 0)
6757 return err;
6758 }
6759
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006760 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006761 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006762 err = alc260_add_playback_controls(spec, nid, "Headphone",
6763 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006764 if (err < 0)
6765 return err;
6766 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006767 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006768}
6769
6770/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006771static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006772 const struct auto_pin_cfg *cfg)
6773{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006774 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006775}
6776
6777static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6778 hda_nid_t nid, int pin_type,
6779 int sel_idx)
6780{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006781 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006782 /* need the manual connection? */
6783 if (nid >= 0x12) {
6784 int idx = nid - 0x12;
6785 snd_hda_codec_write(codec, idx + 0x0b, 0,
6786 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006787 }
6788}
6789
6790static void alc260_auto_init_multi_out(struct hda_codec *codec)
6791{
6792 struct alc_spec *spec = codec->spec;
6793 hda_nid_t nid;
6794
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006795 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006796 if (nid) {
6797 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6798 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6799 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006800
Takashi Iwai82bc9552006-03-21 11:24:42 +01006801 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006802 if (nid)
6803 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6804
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006805 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006806 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006807 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006808}
Kailang Yangdf694da2005-12-05 19:42:22 +01006809
6810#define ALC260_PIN_CD_NID 0x16
6811static void alc260_auto_init_analog_input(struct hda_codec *codec)
6812{
6813 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006814 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006815 int i;
6816
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006817 for (i = 0; i < cfg->num_inputs; i++) {
6818 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006819 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006820 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006821 if (nid != ALC260_PIN_CD_NID &&
6822 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006823 snd_hda_codec_write(codec, nid, 0,
6824 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006825 AMP_OUT_MUTE);
6826 }
6827 }
6828}
6829
Takashi Iwai7f311a42010-04-09 17:32:23 +02006830#define alc260_auto_init_input_src alc880_auto_init_input_src
6831
Kailang Yangdf694da2005-12-05 19:42:22 +01006832/*
6833 * generic initialization of ADC, input mixers and output mixers
6834 */
6835static struct hda_verb alc260_volume_init_verbs[] = {
6836 /*
6837 * Unmute ADC0-1 and set the default input to mic-in
6838 */
6839 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6840 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6841 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6842 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006843
Kailang Yangdf694da2005-12-05 19:42:22 +01006844 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6845 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006846 * Note: PASD motherboards uses the Line In 2 as the input for
6847 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006848 */
6849 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006850 /* mute analog inputs */
6851 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6852 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6853 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6854 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6855 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006856
6857 /*
6858 * Set up output mixers (0x08 - 0x0a)
6859 */
6860 /* set vol=0 to output mixers */
6861 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6862 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6863 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6864 /* set up input amps for analog loopback */
6865 /* Amp Indices: DAC = 0, mixer = 1 */
6866 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6867 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6868 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6869 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6870 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6871 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006872
Kailang Yangdf694da2005-12-05 19:42:22 +01006873 { }
6874};
6875
6876static int alc260_parse_auto_config(struct hda_codec *codec)
6877{
6878 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006879 int err;
6880 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
6881
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006882 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
6883 alc260_ignore);
6884 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006885 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006886 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
6887 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01006888 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02006889 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01006890 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006891 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006892 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006893 return err;
6894
6895 spec->multiout.max_channels = 2;
6896
Takashi Iwai0852d7a2009-02-11 11:35:15 +01006897 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01006898 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02006899 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01006900 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01006901
Takashi Iwaid88897e2008-10-31 15:01:37 +01006902 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01006903
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006904 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02006905 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006906
Kailang Yang6227cdc2010-02-25 08:36:52 +01006907 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02006908
Kailang Yangdf694da2005-12-05 19:42:22 +01006909 return 1;
6910}
6911
Takashi Iwaiae6b8132006-03-03 16:47:17 +01006912/* additional initialization for auto-configuration model */
6913static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01006914{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006915 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01006916 alc260_auto_init_multi_out(codec);
6917 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02006918 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02006919 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006920 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02006921 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01006922}
6923
Takashi Iwaicb53c622007-08-10 17:21:45 +02006924#ifdef CONFIG_SND_HDA_POWER_SAVE
6925static struct hda_amp_list alc260_loopbacks[] = {
6926 { 0x07, HDA_INPUT, 0 },
6927 { 0x07, HDA_INPUT, 1 },
6928 { 0x07, HDA_INPUT, 2 },
6929 { 0x07, HDA_INPUT, 3 },
6930 { 0x07, HDA_INPUT, 4 },
6931 { } /* end */
6932};
6933#endif
6934
Kailang Yangdf694da2005-12-05 19:42:22 +01006935/*
Takashi Iwaifc091762010-08-04 23:53:36 +02006936 * Pin config fixes
6937 */
6938enum {
6939 PINFIX_HP_DC5750,
6940};
6941
Takashi Iwaifc091762010-08-04 23:53:36 +02006942static const struct alc_fixup alc260_fixups[] = {
6943 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02006944 .pins = (const struct alc_pincfg[]) {
6945 { 0x11, 0x90130110 }, /* speaker */
6946 { }
6947 }
Takashi Iwaifc091762010-08-04 23:53:36 +02006948 },
6949};
6950
6951static struct snd_pci_quirk alc260_fixup_tbl[] = {
6952 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
6953 {}
6954};
6955
6956/*
Kailang Yangdf694da2005-12-05 19:42:22 +01006957 * ALC260 configurations
6958 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006959static const char *alc260_models[ALC260_MODEL_LAST] = {
6960 [ALC260_BASIC] = "basic",
6961 [ALC260_HP] = "hp",
6962 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02006963 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006964 [ALC260_FUJITSU_S702X] = "fujitsu",
6965 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006966 [ALC260_WILL] = "will",
6967 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01006968 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006969#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006970 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006971#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006972 [ALC260_AUTO] = "auto",
6973};
6974
6975static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01006976 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05006977 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006978 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01006979 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01006980 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01006981 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006982 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02006983 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02006984 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01006985 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
6986 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
6987 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
6988 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
6989 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
6990 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
6991 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
6992 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
6993 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006994 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01006995 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02006996 {}
6997};
6998
Kailang Yangdf694da2005-12-05 19:42:22 +01006999static struct alc_config_preset alc260_presets[] = {
7000 [ALC260_BASIC] = {
7001 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007002 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007003 .init_verbs = { alc260_init_verbs },
7004 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7005 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007006 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007007 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007008 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7009 .channel_mode = alc260_modes,
7010 .input_mux = &alc260_capture_source,
7011 },
7012 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007013 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007014 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007015 .init_verbs = { alc260_init_verbs,
7016 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007017 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7018 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007019 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7020 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007021 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7022 .channel_mode = alc260_modes,
7023 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007024 .unsol_event = alc260_hp_unsol_event,
7025 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007026 },
Kailang Yang3f878302008-08-26 13:02:23 +02007027 [ALC260_HP_DC7600] = {
7028 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007029 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007030 .init_verbs = { alc260_init_verbs,
7031 alc260_hp_dc7600_verbs },
7032 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7033 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007034 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7035 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007036 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7037 .channel_mode = alc260_modes,
7038 .input_mux = &alc260_capture_source,
7039 .unsol_event = alc260_hp_3012_unsol_event,
7040 .init_hook = alc260_hp_3012_automute,
7041 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007042 [ALC260_HP_3013] = {
7043 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007044 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007045 .init_verbs = { alc260_hp_3013_init_verbs,
7046 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007047 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7048 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007049 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7050 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007051 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7052 .channel_mode = alc260_modes,
7053 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007054 .unsol_event = alc260_hp_3013_unsol_event,
7055 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007056 },
7057 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007058 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007059 .init_verbs = { alc260_fujitsu_init_verbs },
7060 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7061 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007062 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7063 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007064 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7065 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007066 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7067 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007068 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007069 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007070 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007071 .init_verbs = { alc260_acer_init_verbs },
7072 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7073 .dac_nids = alc260_dac_nids,
7074 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7075 .adc_nids = alc260_dual_adc_nids,
7076 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7077 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007078 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7079 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007080 },
Michael Schwingencc959482009-02-22 18:58:45 +01007081 [ALC260_FAVORIT100] = {
7082 .mixers = { alc260_favorit100_mixer },
7083 .init_verbs = { alc260_favorit100_init_verbs },
7084 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7085 .dac_nids = alc260_dac_nids,
7086 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7087 .adc_nids = alc260_dual_adc_nids,
7088 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7089 .channel_mode = alc260_modes,
7090 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7091 .input_mux = alc260_favorit100_capture_sources,
7092 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007093 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007094 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007095 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7096 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7097 .dac_nids = alc260_dac_nids,
7098 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7099 .adc_nids = alc260_adc_nids,
7100 .dig_out_nid = ALC260_DIGOUT_NID,
7101 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7102 .channel_mode = alc260_modes,
7103 .input_mux = &alc260_capture_source,
7104 },
7105 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007106 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007107 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7108 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7109 .dac_nids = alc260_dac_nids,
7110 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7111 .adc_nids = alc260_adc_nids,
7112 .dig_out_nid = ALC260_DIGOUT_NID,
7113 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7114 .channel_mode = alc260_modes,
7115 .input_mux = &alc260_capture_source,
7116 .unsol_event = alc260_replacer_672v_unsol_event,
7117 .init_hook = alc260_replacer_672v_automute,
7118 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007119#ifdef CONFIG_SND_DEBUG
7120 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007121 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007122 .init_verbs = { alc260_test_init_verbs },
7123 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7124 .dac_nids = alc260_test_dac_nids,
7125 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7126 .adc_nids = alc260_test_adc_nids,
7127 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7128 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007129 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7130 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007131 },
7132#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007133};
7134
Linus Torvalds1da177e2005-04-16 15:20:36 -07007135static int patch_alc260(struct hda_codec *codec)
7136{
7137 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007138 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007139
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007140 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007141 if (spec == NULL)
7142 return -ENOMEM;
7143
7144 codec->spec = spec;
7145
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007146 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7147 alc260_models,
7148 alc260_cfg_tbl);
7149 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007150 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007151 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007152 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007153 }
7154
Takashi Iwaifc091762010-08-04 23:53:36 +02007155 if (board_config == ALC260_AUTO)
7156 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7157
Kailang Yangdf694da2005-12-05 19:42:22 +01007158 if (board_config == ALC260_AUTO) {
7159 /* automatic parse from the BIOS config */
7160 err = alc260_parse_auto_config(codec);
7161 if (err < 0) {
7162 alc_free(codec);
7163 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007164 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007165 printk(KERN_INFO
7166 "hda_codec: Cannot set up configuration "
7167 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007168 board_config = ALC260_BASIC;
7169 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007170 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007171
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007172 err = snd_hda_attach_beep_device(codec, 0x1);
7173 if (err < 0) {
7174 alc_free(codec);
7175 return err;
7176 }
7177
Kailang Yangdf694da2005-12-05 19:42:22 +01007178 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007179 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007180
Linus Torvalds1da177e2005-04-16 15:20:36 -07007181 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7182 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307183 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007184
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007185 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7186 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7187
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007188 if (!spec->adc_nids && spec->input_mux) {
7189 /* check whether NID 0x04 is valid */
7190 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007191 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007192 /* get type */
7193 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7194 spec->adc_nids = alc260_adc_nids_alt;
7195 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7196 } else {
7197 spec->adc_nids = alc260_adc_nids;
7198 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7199 }
7200 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007201 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007202 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007203
Takashi Iwaifc091762010-08-04 23:53:36 +02007204 if (board_config == ALC260_AUTO)
7205 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7206
Takashi Iwai2134ea42008-01-10 16:53:55 +01007207 spec->vmaster_nid = 0x08;
7208
Linus Torvalds1da177e2005-04-16 15:20:36 -07007209 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007210 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007211 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007212#ifdef CONFIG_SND_HDA_POWER_SAVE
7213 if (!spec->loopback.amplist)
7214 spec->loopback.amplist = alc260_loopbacks;
7215#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007216
7217 return 0;
7218}
7219
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007220
Linus Torvalds1da177e2005-04-16 15:20:36 -07007221/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007222 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007223 *
7224 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7225 * configuration. Each pin widget can choose any input DACs and a mixer.
7226 * Each ADC is connected from a mixer of all inputs. This makes possible
7227 * 6-channel independent captures.
7228 *
7229 * In addition, an independent DAC for the multi-playback (not used in this
7230 * driver yet).
7231 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007232#define ALC882_DIGOUT_NID 0x06
7233#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007234#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7235#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7236#define ALC1200_DIGOUT_NID 0x10
7237
Linus Torvalds1da177e2005-04-16 15:20:36 -07007238
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007239static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007240 { 8, NULL }
7241};
7242
Takashi Iwai4953550a2009-06-30 15:28:30 +02007243/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007244static hda_nid_t alc882_dac_nids[4] = {
7245 /* front, rear, clfe, rear_surr */
7246 0x02, 0x03, 0x04, 0x05
7247};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007248#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007249
Takashi Iwai4953550a2009-06-30 15:28:30 +02007250/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007251#define alc882_adc_nids alc880_adc_nids
7252#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007253#define alc883_adc_nids alc882_adc_nids_alt
7254static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7255static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7256#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007257
Takashi Iwaie1406342008-02-11 18:32:32 +01007258static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7259static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007260#define alc883_capsrc_nids alc882_capsrc_nids_alt
7261static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7262#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007263
Linus Torvalds1da177e2005-04-16 15:20:36 -07007264/* input MUX */
7265/* FIXME: should be a matrix-type input source selection */
7266
7267static struct hda_input_mux alc882_capture_source = {
7268 .num_items = 4,
7269 .items = {
7270 { "Mic", 0x0 },
7271 { "Front Mic", 0x1 },
7272 { "Line", 0x2 },
7273 { "CD", 0x4 },
7274 },
7275};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007276
Takashi Iwai4953550a2009-06-30 15:28:30 +02007277#define alc883_capture_source alc882_capture_source
7278
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007279static struct hda_input_mux alc889_capture_source = {
7280 .num_items = 3,
7281 .items = {
7282 { "Front Mic", 0x0 },
7283 { "Mic", 0x3 },
7284 { "Line", 0x2 },
7285 },
7286};
7287
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007288static struct hda_input_mux mb5_capture_source = {
7289 .num_items = 3,
7290 .items = {
7291 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307292 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007293 { "CD", 0x4 },
7294 },
7295};
7296
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007297static struct hda_input_mux macmini3_capture_source = {
7298 .num_items = 2,
7299 .items = {
7300 { "Line", 0x2 },
7301 { "CD", 0x4 },
7302 },
7303};
7304
Takashi Iwai4953550a2009-06-30 15:28:30 +02007305static struct hda_input_mux alc883_3stack_6ch_intel = {
7306 .num_items = 4,
7307 .items = {
7308 { "Mic", 0x1 },
7309 { "Front Mic", 0x0 },
7310 { "Line", 0x2 },
7311 { "CD", 0x4 },
7312 },
7313};
7314
7315static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7316 .num_items = 2,
7317 .items = {
7318 { "Mic", 0x1 },
7319 { "Line", 0x2 },
7320 },
7321};
7322
7323static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7324 .num_items = 4,
7325 .items = {
7326 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007327 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007328 { "Line", 0x2 },
7329 { "CD", 0x4 },
7330 },
7331};
7332
7333static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7334 .num_items = 2,
7335 .items = {
7336 { "Mic", 0x0 },
7337 { "Int Mic", 0x1 },
7338 },
7339};
7340
7341static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7342 .num_items = 3,
7343 .items = {
7344 { "Mic", 0x0 },
7345 { "Front Mic", 0x1 },
7346 { "Line", 0x4 },
7347 },
7348};
7349
7350static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7351 .num_items = 2,
7352 .items = {
7353 { "Mic", 0x0 },
7354 { "Line", 0x2 },
7355 },
7356};
7357
7358static struct hda_input_mux alc889A_mb31_capture_source = {
7359 .num_items = 2,
7360 .items = {
7361 { "Mic", 0x0 },
7362 /* Front Mic (0x01) unused */
7363 { "Line", 0x2 },
7364 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007365 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007366 },
7367};
7368
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007369static struct hda_input_mux alc889A_imac91_capture_source = {
7370 .num_items = 2,
7371 .items = {
7372 { "Mic", 0x01 },
7373 { "Line", 0x2 }, /* Not sure! */
7374 },
7375};
7376
Takashi Iwai4953550a2009-06-30 15:28:30 +02007377/*
7378 * 2ch mode
7379 */
7380static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7381 { 2, NULL }
7382};
7383
Kailang Yangdf694da2005-12-05 19:42:22 +01007384/*
Kailang Yang272a5272007-05-14 11:00:38 +02007385 * 2ch mode
7386 */
7387static struct hda_verb alc882_3ST_ch2_init[] = {
7388 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7389 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7390 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7391 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7392 { } /* end */
7393};
7394
7395/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007396 * 4ch mode
7397 */
7398static struct hda_verb alc882_3ST_ch4_init[] = {
7399 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7400 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7401 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7402 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7403 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7404 { } /* end */
7405};
7406
7407/*
Kailang Yang272a5272007-05-14 11:00:38 +02007408 * 6ch mode
7409 */
7410static struct hda_verb alc882_3ST_ch6_init[] = {
7411 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7412 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7413 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7414 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7415 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7416 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7417 { } /* end */
7418};
7419
Takashi Iwai4953550a2009-06-30 15:28:30 +02007420static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007421 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007422 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007423 { 6, alc882_3ST_ch6_init },
7424};
7425
Takashi Iwai4953550a2009-06-30 15:28:30 +02007426#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7427
Kailang Yang272a5272007-05-14 11:00:38 +02007428/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307429 * 2ch mode
7430 */
7431static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7432 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7433 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7434 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7435 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7436 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7437 { } /* end */
7438};
7439
7440/*
7441 * 4ch mode
7442 */
7443static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7444 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7445 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7446 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7447 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7448 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7449 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7450 { } /* end */
7451};
7452
7453/*
7454 * 6ch mode
7455 */
7456static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7457 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7458 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7459 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7460 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7461 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7462 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7463 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7464 { } /* end */
7465};
7466
7467static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7468 { 2, alc883_3ST_ch2_clevo_init },
7469 { 4, alc883_3ST_ch4_clevo_init },
7470 { 6, alc883_3ST_ch6_clevo_init },
7471};
7472
7473
7474/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007475 * 6ch mode
7476 */
7477static struct hda_verb alc882_sixstack_ch6_init[] = {
7478 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7479 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7480 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7481 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7482 { } /* end */
7483};
7484
7485/*
7486 * 8ch mode
7487 */
7488static struct hda_verb alc882_sixstack_ch8_init[] = {
7489 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7490 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7491 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7492 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7493 { } /* end */
7494};
7495
7496static struct hda_channel_mode alc882_sixstack_modes[2] = {
7497 { 6, alc882_sixstack_ch6_init },
7498 { 8, alc882_sixstack_ch8_init },
7499};
7500
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007501
7502/* Macbook Air 2,1 */
7503
7504static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7505 { 2, NULL },
7506};
7507
Takashi Iwai87350ad2007-08-16 18:19:38 +02007508/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007509 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007510 */
7511
7512/*
7513 * 2ch mode
7514 */
7515static struct hda_verb alc885_mbp_ch2_init[] = {
7516 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7517 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7518 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7519 { } /* end */
7520};
7521
7522/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007523 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007524 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007525static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007526 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7527 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7528 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7529 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7530 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7531 { } /* end */
7532};
7533
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007534static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007535 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007536 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007537};
7538
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007539/*
7540 * 2ch
7541 * Speakers/Woofer/HP = Front
7542 * LineIn = Input
7543 */
7544static struct hda_verb alc885_mb5_ch2_init[] = {
7545 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7546 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7547 { } /* end */
7548};
7549
7550/*
7551 * 6ch mode
7552 * Speakers/HP = Front
7553 * Woofer = LFE
7554 * LineIn = Surround
7555 */
7556static struct hda_verb alc885_mb5_ch6_init[] = {
7557 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7558 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7559 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7560 { } /* end */
7561};
7562
7563static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7564 { 2, alc885_mb5_ch2_init },
7565 { 6, alc885_mb5_ch6_init },
7566};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007567
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007568#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007569
7570/*
7571 * 2ch mode
7572 */
7573static struct hda_verb alc883_4ST_ch2_init[] = {
7574 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7575 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7576 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7577 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7578 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7579 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7580 { } /* end */
7581};
7582
7583/*
7584 * 4ch mode
7585 */
7586static struct hda_verb alc883_4ST_ch4_init[] = {
7587 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7588 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7589 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7590 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7591 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7592 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7593 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7594 { } /* end */
7595};
7596
7597/*
7598 * 6ch mode
7599 */
7600static struct hda_verb alc883_4ST_ch6_init[] = {
7601 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7602 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7603 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7604 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7605 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7606 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7607 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7608 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7609 { } /* end */
7610};
7611
7612/*
7613 * 8ch mode
7614 */
7615static struct hda_verb alc883_4ST_ch8_init[] = {
7616 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7617 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7618 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7619 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7620 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7621 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7622 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7623 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7624 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7625 { } /* end */
7626};
7627
7628static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7629 { 2, alc883_4ST_ch2_init },
7630 { 4, alc883_4ST_ch4_init },
7631 { 6, alc883_4ST_ch6_init },
7632 { 8, alc883_4ST_ch8_init },
7633};
7634
7635
7636/*
7637 * 2ch mode
7638 */
7639static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7640 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7641 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7642 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7643 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7644 { } /* end */
7645};
7646
7647/*
7648 * 4ch mode
7649 */
7650static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7651 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7652 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7653 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7654 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7655 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7656 { } /* end */
7657};
7658
7659/*
7660 * 6ch mode
7661 */
7662static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7663 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7664 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7665 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7666 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7667 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7668 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7669 { } /* end */
7670};
7671
7672static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7673 { 2, alc883_3ST_ch2_intel_init },
7674 { 4, alc883_3ST_ch4_intel_init },
7675 { 6, alc883_3ST_ch6_intel_init },
7676};
7677
7678/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007679 * 2ch mode
7680 */
7681static struct hda_verb alc889_ch2_intel_init[] = {
7682 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7683 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7684 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7685 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7686 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7687 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7688 { } /* end */
7689};
7690
7691/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007692 * 6ch mode
7693 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007694static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007695 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7696 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7697 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7698 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7699 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007700 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7701 { } /* end */
7702};
7703
7704/*
7705 * 8ch mode
7706 */
7707static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007708 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7709 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7710 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7711 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7712 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007713 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7714 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007715 { } /* end */
7716};
7717
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007718static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7719 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007720 { 6, alc889_ch6_intel_init },
7721 { 8, alc889_ch8_intel_init },
7722};
7723
7724/*
7725 * 6ch mode
7726 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007727static struct hda_verb alc883_sixstack_ch6_init[] = {
7728 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7729 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7730 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7731 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7732 { } /* end */
7733};
7734
7735/*
7736 * 8ch mode
7737 */
7738static struct hda_verb alc883_sixstack_ch8_init[] = {
7739 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7740 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7741 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7742 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7743 { } /* end */
7744};
7745
7746static struct hda_channel_mode alc883_sixstack_modes[2] = {
7747 { 6, alc883_sixstack_ch6_init },
7748 { 8, alc883_sixstack_ch8_init },
7749};
7750
7751
Linus Torvalds1da177e2005-04-16 15:20:36 -07007752/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7753 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7754 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007755static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007756 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007757 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007758 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007759 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007760 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7761 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007762 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7763 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007764 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007765 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007766 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7767 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7768 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7769 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7770 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7771 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007772 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007773 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7774 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007775 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007776 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007777 { } /* end */
7778};
7779
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007780/* Macbook Air 2,1 same control for HP and internal Speaker */
7781
7782static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7783 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7784 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7785 { }
7786};
7787
7788
Takashi Iwai87350ad2007-08-16 18:19:38 +02007789static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007790 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7791 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7792 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7793 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7794 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007795 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7796 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007797 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7798 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007799 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007800 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7801 { } /* end */
7802};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007803
7804static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007805 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7806 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7807 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7808 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7809 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7810 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307811 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7812 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307813 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7814 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007815 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7816 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7817 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7818 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7819 { } /* end */
7820};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007821
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007822static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7823 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7824 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7825 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7826 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7827 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7828 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7829 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7830 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7831 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7832 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7833 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7834 { } /* end */
7835};
7836
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007837static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007838 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7839 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007840 { } /* end */
7841};
7842
7843
Kailang Yangbdd148a2007-05-08 15:19:08 +02007844static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7845 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7846 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7847 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7848 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7849 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7850 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7851 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7852 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7853 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007854 { } /* end */
7855};
7856
Kailang Yang272a5272007-05-14 11:00:38 +02007857static struct snd_kcontrol_new alc882_targa_mixer[] = {
7858 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7859 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7860 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7861 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7862 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7863 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7864 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7865 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7866 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007867 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007868 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7869 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007870 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007871 { } /* end */
7872};
7873
7874/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
7875 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
7876 */
7877static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
7878 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7879 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
7880 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7881 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
7882 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7883 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7884 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7885 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7886 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
7887 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
7888 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007890 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007891 { } /* end */
7892};
7893
Takashi Iwai914759b2007-09-06 14:52:04 +02007894static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
7895 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7896 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
7898 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7899 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7900 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7901 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7903 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02007905 { } /* end */
7906};
7907
Kailang Yangdf694da2005-12-05 19:42:22 +01007908static struct snd_kcontrol_new alc882_chmode_mixer[] = {
7909 {
7910 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
7911 .name = "Channel Mode",
7912 .info = alc_ch_mode_info,
7913 .get = alc_ch_mode_get,
7914 .put = alc_ch_mode_put,
7915 },
7916 { } /* end */
7917};
7918
Takashi Iwai4953550a2009-06-30 15:28:30 +02007919static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007920 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007921 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007923 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007924 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7925 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007926 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007927 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7928 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007929 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02007930 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7931 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007932
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007933 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007934 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007935 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007936 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007937 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007938 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007939 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007940 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007941 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007942 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007943 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007944 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007945 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02007946 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02007947 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007948 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007949 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007950 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007951 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7952 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02007953 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007954 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7955 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007956 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007957 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7958 /* Line-2 In: Headphone output (output 0 - 0x0c) */
7959 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
7960 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7961 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007962 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02007963 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007964
7965 /* FIXME: use matrix-type input source selection */
7966 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007967 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007968 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007969 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02007970 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02007971 /* ADC2: mute amp left and right */
7972 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007973 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02007974 /* ADC3: mute amp left and right */
7975 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02007976 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07007977
7978 { }
7979};
7980
Takashi Iwai4953550a2009-06-30 15:28:30 +02007981static struct hda_verb alc882_adc1_init_verbs[] = {
7982 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
7983 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7984 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7985 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7986 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
7987 /* ADC1: mute amp left and right */
7988 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7989 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
7990 { }
7991};
7992
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007993static struct hda_verb alc882_eapd_verbs[] = {
7994 /* change to EAPD mode */
7995 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01007996 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007997 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02007998};
7999
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008000static struct hda_verb alc889_eapd_verbs[] = {
8001 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8002 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8003 { }
8004};
8005
Wu Fengguang6732bd02009-07-30 09:19:14 +02008006static struct hda_verb alc_hp15_unsol_verbs[] = {
8007 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8008 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8009 {}
8010};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008011
8012static struct hda_verb alc885_init_verbs[] = {
8013 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008014 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8015 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008016 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008017 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8018 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008019 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008020 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8021 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008022 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008023 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8024 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008025
8026 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008027 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008028 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8029 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8030 /* Front Pin: output 0 (0x0c) */
8031 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8032 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8033 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8034 /* Rear Pin: output 1 (0x0d) */
8035 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8036 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8037 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8038 /* CLFE Pin: output 2 (0x0e) */
8039 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8040 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8041 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8042 /* Side Pin: output 3 (0x0f) */
8043 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8044 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8045 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8046 /* Mic (rear) pin: input vref at 80% */
8047 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8048 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8049 /* Front Mic pin: input vref at 80% */
8050 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8051 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8052 /* Line In pin: input */
8053 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8054 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8055
8056 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8057 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008058 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008059 /* Input mixer2 */
8060 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008061 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008062 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008063 /* ADC2: mute amp left and right */
8064 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8065 /* ADC3: mute amp left and right */
8066 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8067
8068 { }
8069};
8070
8071static struct hda_verb alc885_init_input_verbs[] = {
8072 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8073 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8074 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8075 { }
8076};
8077
8078
8079/* Unmute Selector 24h and set the default input to front mic */
8080static struct hda_verb alc889_init_input_verbs[] = {
8081 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8082 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8083 { }
8084};
8085
8086
Takashi Iwai4953550a2009-06-30 15:28:30 +02008087#define alc883_init_verbs alc882_base_init_verbs
8088
Tobin Davis9102cd12006-12-15 10:02:12 +01008089/* Mac Pro test */
8090static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8092 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8093 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8094 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8095 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008096 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008097 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8098 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008099 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008100 { } /* end */
8101};
8102
8103static struct hda_verb alc882_macpro_init_verbs[] = {
8104 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8105 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8106 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8107 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8108 /* Front Pin: output 0 (0x0c) */
8109 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8110 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8111 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8112 /* Front Mic pin: input vref at 80% */
8113 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8114 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8115 /* Speaker: output */
8116 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8117 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8118 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8119 /* Headphone output (output 0 - 0x0c) */
8120 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8121 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8122 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8123
8124 /* FIXME: use matrix-type input source selection */
8125 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8126 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8127 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8128 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8129 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8130 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8131 /* Input mixer2 */
8132 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8133 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8134 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8135 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8136 /* Input mixer3 */
8137 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8138 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8139 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8140 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8141 /* ADC1: mute amp left and right */
8142 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8143 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8144 /* ADC2: mute amp left and right */
8145 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8146 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8147 /* ADC3: mute amp left and right */
8148 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8149 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8150
8151 { }
8152};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008153
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008154/* Macbook 5,1 */
8155static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008156 /* DACs */
8157 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8158 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8159 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8160 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008161 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008162 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8163 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8164 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008165 /* Surround mixer */
8166 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8167 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8168 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8169 /* LFE mixer */
8170 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8171 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8172 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8173 /* HP mixer */
8174 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8175 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8176 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8177 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008178 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8179 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008180 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8181 /* LFE Pin (0x0e) */
8182 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8183 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8184 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8185 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008186 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8187 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008188 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308189 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008190 /* Front Mic pin: input vref at 80% */
8191 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8192 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8193 /* Line In pin */
8194 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8195 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8196
Alex Murrayb8f171e2010-06-14 12:08:43 +09308197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008200 { }
8201};
8202
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008203/* Macmini 3,1 */
8204static struct hda_verb alc885_macmini3_init_verbs[] = {
8205 /* DACs */
8206 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8207 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8208 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8209 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8210 /* Front mixer */
8211 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8212 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8214 /* Surround mixer */
8215 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8216 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8217 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8218 /* LFE mixer */
8219 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8220 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8221 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8222 /* HP mixer */
8223 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8224 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8225 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8226 /* Front Pin (0x0c) */
8227 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8228 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8229 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8230 /* LFE Pin (0x0e) */
8231 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8232 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8233 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8234 /* HP Pin (0x0f) */
8235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8237 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8238 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8239 /* Line In pin */
8240 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8241 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8242
8243 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8244 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8245 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8246 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8247 { }
8248};
8249
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008250
8251static struct hda_verb alc885_mba21_init_verbs[] = {
8252 /*Internal and HP Speaker Mixer*/
8253 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8254 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8255 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8256 /*Internal Speaker Pin (0x0c)*/
8257 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8258 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8259 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8260 /* HP Pin: output 0 (0x0e) */
8261 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8262 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8263 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8264 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8265 /* Line in (is hp when jack connected)*/
8266 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8267 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8268
8269 { }
8270 };
8271
8272
Takashi Iwai87350ad2007-08-16 18:19:38 +02008273/* Macbook Pro rev3 */
8274static struct hda_verb alc885_mbp3_init_verbs[] = {
8275 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8276 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8277 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8278 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8279 /* Rear mixer */
8280 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8281 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8282 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008283 /* HP mixer */
8284 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8285 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008287 /* Front Pin: output 0 (0x0c) */
8288 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8289 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8290 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008291 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008292 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008293 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8294 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008295 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8296 /* Mic (rear) pin: input vref at 80% */
8297 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8298 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8299 /* Front Mic pin: input vref at 80% */
8300 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8301 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8302 /* Line In pin: use output 1 when in LineOut mode */
8303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8305 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8306
8307 /* FIXME: use matrix-type input source selection */
8308 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8309 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8310 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8311 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8312 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8313 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8314 /* Input mixer2 */
8315 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8316 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8318 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8319 /* Input mixer3 */
8320 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8321 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8322 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8323 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8324 /* ADC1: mute amp left and right */
8325 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8326 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8327 /* ADC2: mute amp left and right */
8328 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8329 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8330 /* ADC3: mute amp left and right */
8331 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8332 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8333
8334 { }
8335};
8336
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008337/* iMac 9,1 */
8338static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008339 /* Internal Speaker Pin (0x0c) */
8340 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8341 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8342 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8343 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8344 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8345 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8346 /* HP Pin: Rear */
8347 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8348 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8349 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8350 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8351 /* Line in Rear */
8352 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8353 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8354 /* Front Mic pin: input vref at 80% */
8355 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8356 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008357 /* Rear mixer */
8358 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8359 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8360 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008361 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8362 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8365 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008366 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8367 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8368 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8369 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008370 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008371 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8372 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8373 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8374 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008375 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008376 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8377 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8378 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8379 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008380 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008381 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8382 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008383 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008384 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8385 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008386 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008387 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8388 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008389 { }
8390};
8391
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008392/* iMac 24 mixer. */
8393static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8394 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8395 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8396 { } /* end */
8397};
8398
8399/* iMac 24 init verbs. */
8400static struct hda_verb alc885_imac24_init_verbs[] = {
8401 /* Internal speakers: output 0 (0x0c) */
8402 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8403 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8404 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8405 /* Internal speakers: output 0 (0x0c) */
8406 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8407 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8408 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8409 /* Headphone: output 0 (0x0c) */
8410 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8411 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8412 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8413 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8414 /* Front Mic: input vref at 80% */
8415 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8416 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8417 { }
8418};
8419
8420/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008421static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008422{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008423 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008424
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008425 spec->autocfg.hp_pins[0] = 0x14;
8426 spec->autocfg.speaker_pins[0] = 0x18;
8427 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008428}
8429
Takashi Iwai9d54f082010-02-22 08:34:40 +01008430#define alc885_mb5_setup alc885_imac24_setup
8431#define alc885_macmini3_setup alc885_imac24_setup
8432
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008433/* Macbook Air 2,1 */
8434static void alc885_mba21_setup(struct hda_codec *codec)
8435{
8436 struct alc_spec *spec = codec->spec;
8437
8438 spec->autocfg.hp_pins[0] = 0x14;
8439 spec->autocfg.speaker_pins[0] = 0x18;
8440}
8441
8442
8443
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008444static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008445{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008446 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008447
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008448 spec->autocfg.hp_pins[0] = 0x15;
8449 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008450}
8451
Takashi Iwai9d54f082010-02-22 08:34:40 +01008452static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308453{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008454 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308455
Takashi Iwai9d54f082010-02-22 08:34:40 +01008456 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008457 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008458 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008459}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008460
Kailang Yang272a5272007-05-14 11:00:38 +02008461static struct hda_verb alc882_targa_verbs[] = {
8462 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8463 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8464
8465 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8466 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008467
Kailang Yang272a5272007-05-14 11:00:38 +02008468 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8469 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8470 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8471
8472 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008473 { } /* end */
8474};
8475
8476/* toggle speaker-output according to the hp-jack state */
8477static void alc882_targa_automute(struct hda_codec *codec)
8478{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008479 struct alc_spec *spec = codec->spec;
8480 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008481 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008482 spec->jack_present ? 1 : 3);
8483}
8484
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008485static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008486{
8487 struct alc_spec *spec = codec->spec;
8488
8489 spec->autocfg.hp_pins[0] = 0x14;
8490 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008491}
8492
8493static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8494{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008495 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008496 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008497}
8498
8499static struct hda_verb alc882_asus_a7j_verbs[] = {
8500 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8501 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8502
8503 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8505 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008506
Kailang Yang272a5272007-05-14 11:00:38 +02008507 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8508 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8509 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8510
8511 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8512 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8513 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8514 { } /* end */
8515};
8516
Takashi Iwai914759b2007-09-06 14:52:04 +02008517static struct hda_verb alc882_asus_a7m_verbs[] = {
8518 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8519 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8520
8521 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8522 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8523 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008524
Takashi Iwai914759b2007-09-06 14:52:04 +02008525 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8526 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8527 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8528
8529 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8530 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8531 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8532 { } /* end */
8533};
8534
Tobin Davis9102cd12006-12-15 10:02:12 +01008535static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8536{
8537 unsigned int gpiostate, gpiomask, gpiodir;
8538
8539 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8540 AC_VERB_GET_GPIO_DATA, 0);
8541
8542 if (!muted)
8543 gpiostate |= (1 << pin);
8544 else
8545 gpiostate &= ~(1 << pin);
8546
8547 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8548 AC_VERB_GET_GPIO_MASK, 0);
8549 gpiomask |= (1 << pin);
8550
8551 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8552 AC_VERB_GET_GPIO_DIRECTION, 0);
8553 gpiodir |= (1 << pin);
8554
8555
8556 snd_hda_codec_write(codec, codec->afg, 0,
8557 AC_VERB_SET_GPIO_MASK, gpiomask);
8558 snd_hda_codec_write(codec, codec->afg, 0,
8559 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8560
8561 msleep(1);
8562
8563 snd_hda_codec_write(codec, codec->afg, 0,
8564 AC_VERB_SET_GPIO_DATA, gpiostate);
8565}
8566
Takashi Iwai7debbe52007-08-16 15:01:03 +02008567/* set up GPIO at initialization */
8568static void alc885_macpro_init_hook(struct hda_codec *codec)
8569{
8570 alc882_gpio_mute(codec, 0, 0);
8571 alc882_gpio_mute(codec, 1, 0);
8572}
8573
8574/* set up GPIO and update auto-muting at initialization */
8575static void alc885_imac24_init_hook(struct hda_codec *codec)
8576{
8577 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008578 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008579}
8580
Kailang Yangdf694da2005-12-05 19:42:22 +01008581/*
8582 * generic initialization of ADC, input mixers and output mixers
8583 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008584static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008585 /*
8586 * Unmute ADC0-2 and set the default input to mic-in
8587 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008588 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8589 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8590 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8591 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8592
Kailang Yangdf694da2005-12-05 19:42:22 +01008593 /*
8594 * Set up output mixers (0x0c - 0x0f)
8595 */
8596 /* set vol=0 to output mixers */
8597 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8598 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8599 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8600 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8601 /* set up input amps for analog loopback */
8602 /* Amp Indices: DAC = 0, mixer = 1 */
8603 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8604 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8605 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8606 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8607 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8608 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8609 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8610 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8611 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8612 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8613
8614 /* FIXME: use matrix-type input source selection */
8615 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008616 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008618 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008619 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008620 { }
8621};
8622
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008623/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8624static struct hda_verb alc889A_mb31_ch2_init[] = {
8625 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8626 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8627 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8628 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8629 { } /* end */
8630};
8631
8632/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8633static struct hda_verb alc889A_mb31_ch4_init[] = {
8634 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8635 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8636 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8637 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8638 { } /* end */
8639};
8640
8641/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8642static struct hda_verb alc889A_mb31_ch5_init[] = {
8643 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8644 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8645 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8646 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8647 { } /* end */
8648};
8649
8650/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8651static struct hda_verb alc889A_mb31_ch6_init[] = {
8652 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8653 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8654 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8655 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8656 { } /* end */
8657};
8658
8659static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8660 { 2, alc889A_mb31_ch2_init },
8661 { 4, alc889A_mb31_ch4_init },
8662 { 5, alc889A_mb31_ch5_init },
8663 { 6, alc889A_mb31_ch6_init },
8664};
8665
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008666static struct hda_verb alc883_medion_eapd_verbs[] = {
8667 /* eanable EAPD on medion laptop */
8668 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8669 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8670 { }
8671};
8672
Takashi Iwai4953550a2009-06-30 15:28:30 +02008673#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008674
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008675static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8676 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8677 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8678 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8679 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8680 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8681 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8682 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8683 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8684 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8685 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8686 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8687 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8688 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008689 { } /* end */
8690};
8691
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008692static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008693 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8694 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8695 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8696 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8697 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8698 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8699 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8700 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8701 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8702 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008703 { } /* end */
8704};
8705
Jiang zhefb97dc62008-03-06 11:07:11 +01008706static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8707 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8708 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8709 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8710 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8711 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8712 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8713 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8714 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8715 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8716 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008717 { } /* end */
8718};
8719
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008720static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8721 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8722 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8723 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8724 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8725 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8726 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8727 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8728 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008729 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008730 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8731 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008732 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008733 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008734 { } /* end */
8735};
8736
8737static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8738 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8739 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8740 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8741 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8742 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8743 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8744 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8745 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8746 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8747 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8748 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8749 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8750 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8751 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008752 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008753 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8754 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008755 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008756 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008757 { } /* end */
8758};
8759
Jiang zhe17bba1b2008-06-04 12:11:07 +02008760static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8761 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8762 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8763 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8764 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8765 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8766 HDA_OUTPUT),
8767 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8768 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8769 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8770 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8771 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8772 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8773 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8774 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8776 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8777 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8778 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8779 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8780 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008781 { } /* end */
8782};
8783
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008784static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8785 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8786 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8787 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8788 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8789 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8790 HDA_OUTPUT),
8791 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8792 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8793 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8794 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8795 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8796 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8797 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8798 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8799 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8800 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8801 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8802 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8803 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8804 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8805 { } /* end */
8806};
8807
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008808static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008809 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008810 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008811 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008812 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008813 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8814 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008815 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8816 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008817 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8818 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8819 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8820 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8821 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8822 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008823 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008824 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8825 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008826 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008827 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008828 { } /* end */
8829};
8830
Sasha Alexandrc2592492009-06-16 14:52:54 -04008831static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008832 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008833 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008834 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008835 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008836 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8837 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8838 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8839 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8840 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8841 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8842 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8843 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8844 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8845 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8846 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008847 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008848 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008849 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008850};
Kailang Yangccc656c2006-10-17 12:32:26 +02008851
Sasha Alexandrc2592492009-06-16 14:52:54 -04008852static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008853 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008854 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008855 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008856 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008857 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8858 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8859 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008860 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008861 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008862 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8863 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8864 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008865 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008866};
Kailang Yangccc656c2006-10-17 12:32:26 +02008867
Takashi Iwaib99dba32009-09-17 18:23:00 +02008868static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8869 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8870 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8871 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8872 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8873 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8874 { } /* end */
8875};
8876
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008877static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
8878 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8879 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01008880 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8881 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8883 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8884 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8885 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008886 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008887};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02008888
Kailang Yang272a5272007-05-14 11:00:38 +02008889static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
8890 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8891 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
8892 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8893 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8894 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8895 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8896 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02008897 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8898 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008899 { } /* end */
8900};
8901
8902static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
8903 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8904 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8905 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8906 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8907 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8908 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8909 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8910 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8911 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008912 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02008913};
Kailang Yang272a5272007-05-14 11:00:38 +02008914
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02008915static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
8916 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8917 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8918 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8919 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
8920 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
8921 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
8922 { } /* end */
8923};
8924
8925static struct hda_verb alc883_medion_wim2160_verbs[] = {
8926 /* Unmute front mixer */
8927 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8928 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8929
8930 /* Set speaker pin to front mixer */
8931 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8932
8933 /* Init headphone pin */
8934 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8935 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8936 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8937 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8938
8939 { } /* end */
8940};
8941
8942/* toggle speaker-output according to the hp-jack state */
8943static void alc883_medion_wim2160_setup(struct hda_codec *codec)
8944{
8945 struct alc_spec *spec = codec->spec;
8946
8947 spec->autocfg.hp_pins[0] = 0x1a;
8948 spec->autocfg.speaker_pins[0] = 0x15;
8949}
8950
Tobin Davis2880a862007-08-07 11:50:26 +02008951static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02008952 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8953 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008954 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008955 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8956 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02008957 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8958 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8959 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02008960 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02008961};
Tobin Davis2880a862007-08-07 11:50:26 +02008962
Tony Vroond2fd4b02009-06-21 00:40:10 +01008963static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
8964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008965 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01008966 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8967 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01008968 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8969 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8970 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8971 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8972 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8973 { } /* end */
8974};
8975
Kailang Yange2757d52008-08-26 13:17:46 +02008976static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
8977 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8978 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8979 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
8980 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
8981 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
8982 0x0d, 1, 0x0, HDA_OUTPUT),
8983 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
8984 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
8985 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
8986 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8987 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8993 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8994 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8996 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8997 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02008998 { } /* end */
8999};
9000
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009001static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9002 /* Output mixers */
9003 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9004 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9005 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9006 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9007 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9008 HDA_OUTPUT),
9009 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9010 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9011 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9012 /* Output switches */
9013 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9014 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9015 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9016 /* Boost mixers */
9017 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
9018 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
9019 /* Input mixers */
9020 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9021 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9024 { } /* end */
9025};
9026
Guido Günther3e1647c2009-06-05 00:47:26 +02009027static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9028 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9029 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9030 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9031 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9032 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
9033 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9034 { } /* end */
9035};
9036
Kailang Yange2757d52008-08-26 13:17:46 +02009037static struct hda_bind_ctls alc883_bind_cap_vol = {
9038 .ops = &snd_hda_bind_vol,
9039 .values = {
9040 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9041 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9042 0
9043 },
9044};
9045
9046static struct hda_bind_ctls alc883_bind_cap_switch = {
9047 .ops = &snd_hda_bind_sw,
9048 .values = {
9049 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9050 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9051 0
9052 },
9053};
9054
9055static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9056 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9057 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9058 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9060 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9062 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009064 { } /* end */
9065};
9066
9067static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009068 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9069 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9070 {
9071 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9072 /* .name = "Capture Source", */
9073 .name = "Input Source",
9074 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009075 .info = alc_mux_enum_info,
9076 .get = alc_mux_enum_get,
9077 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009078 },
9079 { } /* end */
9080};
9081
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009082static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9083 {
9084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9085 .name = "Channel Mode",
9086 .info = alc_ch_mode_info,
9087 .get = alc_ch_mode_get,
9088 .put = alc_ch_mode_put,
9089 },
9090 { } /* end */
9091};
9092
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009093/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009094static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009095{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009096 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009097
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009098 spec->autocfg.hp_pins[0] = 0x15;
9099 spec->autocfg.speaker_pins[0] = 0x14;
9100 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009101}
9102
9103/* auto-toggle front mic */
9104/*
9105static void alc883_mitac_mic_automute(struct hda_codec *codec)
9106{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009107 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009108
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009109 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
9110}
9111*/
9112
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009113static struct hda_verb alc883_mitac_verbs[] = {
9114 /* HP */
9115 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9116 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9117 /* Subwoofer */
9118 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9119 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9120
9121 /* enable unsolicited event */
9122 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9123 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9124
9125 { } /* end */
9126};
9127
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309128static struct hda_verb alc883_clevo_m540r_verbs[] = {
9129 /* HP */
9130 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9131 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9132 /* Int speaker */
9133 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9134
9135 /* enable unsolicited event */
9136 /*
9137 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9138 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9139 */
9140
9141 { } /* end */
9142};
9143
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009144static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009145 /* HP */
9146 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9147 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9148 /* Int speaker */
9149 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9150 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9151
9152 /* enable unsolicited event */
9153 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009154 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009155
9156 { } /* end */
9157};
9158
Jiang zhefb97dc62008-03-06 11:07:11 +01009159static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9160 /* HP */
9161 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9162 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9163 /* Subwoofer */
9164 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9165 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9166
9167 /* enable unsolicited event */
9168 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9169
9170 { } /* end */
9171};
9172
Sasha Alexandrc2592492009-06-16 14:52:54 -04009173static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009174 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9175 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9176
9177 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9178 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009179
David Heidelberger64a8be72009-06-08 16:15:18 +02009180/* Connect Line-Out side jack (SPDIF) to Side */
9181 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9182 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9183 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9184/* Connect Mic jack to CLFE */
9185 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9186 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9187 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9188/* Connect Line-in jack to Surround */
9189 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9190 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9191 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9192/* Connect HP out jack to Front */
9193 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9194 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9195 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009196
9197 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009198
9199 { } /* end */
9200};
9201
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009202static struct hda_verb alc883_lenovo_101e_verbs[] = {
9203 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9204 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9205 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9206 { } /* end */
9207};
9208
Kailang Yang272a5272007-05-14 11:00:38 +02009209static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9210 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9211 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9212 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9213 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9214 { } /* end */
9215};
9216
9217static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9218 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9220 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9221 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9222 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9223 { } /* end */
9224};
9225
Kailang Yang189609a2007-08-20 11:31:23 +02009226static struct hda_verb alc883_haier_w66_verbs[] = {
9227 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9228 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9229
9230 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9231
9232 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9233 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9234 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9235 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9236 { } /* end */
9237};
9238
Kailang Yange2757d52008-08-26 13:17:46 +02009239static struct hda_verb alc888_lenovo_sky_verbs[] = {
9240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9241 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9242 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9243 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9244 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9245 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9246 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9247 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9248 { } /* end */
9249};
9250
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009251static struct hda_verb alc888_6st_dell_verbs[] = {
9252 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9253 { }
9254};
9255
Guido Günther3e1647c2009-06-05 00:47:26 +02009256static struct hda_verb alc883_vaiott_verbs[] = {
9257 /* HP */
9258 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9259 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9260
9261 /* enable unsolicited event */
9262 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9263
9264 { } /* end */
9265};
9266
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009267static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009268{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009269 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009270
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009271 spec->autocfg.hp_pins[0] = 0x1b;
9272 spec->autocfg.speaker_pins[0] = 0x14;
9273 spec->autocfg.speaker_pins[1] = 0x16;
9274 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009275}
9276
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009277static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009278 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009279 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9280 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009281 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009282 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009283};
9284
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009285/*
9286 * 2ch mode
9287 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009288static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009289 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9290 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9291 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9292 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009293 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009294};
9295
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009296/*
9297 * 4ch mode
9298 */
9299static struct hda_verb alc888_3st_hp_4ch_init[] = {
9300 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9301 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9302 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9303 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9304 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9305 { } /* end */
9306};
9307
9308/*
9309 * 6ch mode
9310 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009311static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009312 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9313 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009314 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009315 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9316 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009317 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9318 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009319};
9320
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009321static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009322 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009323 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009324 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009325};
9326
Kailang Yang272a5272007-05-14 11:00:38 +02009327/* toggle front-jack and RCA according to the hp-jack state */
9328static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9329{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009330 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009331
Takashi Iwai47fd8302007-08-10 17:11:07 +02009332 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9333 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9334 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9335 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009336}
9337
9338/* toggle RCA according to the front-jack state */
9339static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9340{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009341 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009342
Takashi Iwai47fd8302007-08-10 17:11:07 +02009343 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9344 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009345}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009346
Kailang Yang272a5272007-05-14 11:00:38 +02009347static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9348 unsigned int res)
9349{
9350 if ((res >> 26) == ALC880_HP_EVENT)
9351 alc888_lenovo_ms7195_front_automute(codec);
9352 if ((res >> 26) == ALC880_FRONT_EVENT)
9353 alc888_lenovo_ms7195_rca_automute(codec);
9354}
9355
9356static struct hda_verb alc883_medion_md2_verbs[] = {
9357 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9358 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9359
9360 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9361
9362 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9363 { } /* end */
9364};
9365
9366/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009367static void alc883_medion_md2_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009368{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009369 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009370
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009371 spec->autocfg.hp_pins[0] = 0x14;
9372 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009373}
9374
Kailang Yangccc656c2006-10-17 12:32:26 +02009375/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009376#define alc883_targa_init_hook alc882_targa_init_hook
9377#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009378
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009379static void alc883_clevo_m720_mic_automute(struct hda_codec *codec)
9380{
9381 unsigned int present;
9382
Takashi Iwaid56757a2009-11-18 08:00:14 +01009383 present = snd_hda_jack_detect(codec, 0x18);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009384 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
9385 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9386}
9387
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009388static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009389{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009390 struct alc_spec *spec = codec->spec;
9391
9392 spec->autocfg.hp_pins[0] = 0x15;
9393 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009394}
9395
9396static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9397{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009398 alc_automute_amp(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009399 alc883_clevo_m720_mic_automute(codec);
9400}
9401
9402static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009403 unsigned int res)
9404{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009405 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009406 case ALC880_MIC_EVENT:
9407 alc883_clevo_m720_mic_automute(codec);
9408 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009409 default:
9410 alc_automute_amp_unsol_event(codec, res);
9411 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009412 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009413}
9414
Jiang zhefb97dc62008-03-06 11:07:11 +01009415/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009416static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009417{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009418 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009419
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009420 spec->autocfg.hp_pins[0] = 0x14;
9421 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009422}
9423
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009424static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009425{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009426 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009427
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009428 spec->autocfg.hp_pins[0] = 0x1b;
9429 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009430}
9431
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009432static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9433{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009434 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009435
Takashi Iwai47fd8302007-08-10 17:11:07 +02009436 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9437 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009438}
9439
9440static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9441{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009442 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009443
Takashi Iwai47fd8302007-08-10 17:11:07 +02009444 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9445 HDA_AMP_MUTE, bits);
9446 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9447 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009448}
9449
9450static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9451 unsigned int res)
9452{
9453 if ((res >> 26) == ALC880_HP_EVENT)
9454 alc883_lenovo_101e_all_automute(codec);
9455 if ((res >> 26) == ALC880_FRONT_EVENT)
9456 alc883_lenovo_101e_ispeaker_automute(codec);
9457}
9458
Takashi Iwai676a9b52007-08-16 15:23:35 +02009459/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009460static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009461{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009462 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009463
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009464 spec->autocfg.hp_pins[0] = 0x14;
9465 spec->autocfg.speaker_pins[0] = 0x15;
9466 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009467}
9468
Kailang Yangd1a991a2007-08-15 16:21:59 +02009469static struct hda_verb alc883_acer_eapd_verbs[] = {
9470 /* HP Pin: output 0 (0x0c) */
9471 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9472 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9473 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9474 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009475 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9476 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009477 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009478 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9479 /* eanable EAPD on medion laptop */
9480 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9481 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009482 /* enable unsolicited event */
9483 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009484 { }
9485};
9486
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009487static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
9488 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9489 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9490 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9491 { } /* end */
9492};
9493
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009494static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009495{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009496 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009497
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009498 spec->autocfg.hp_pins[0] = 0x1b;
9499 spec->autocfg.speaker_pins[0] = 0x14;
9500 spec->autocfg.speaker_pins[1] = 0x15;
9501 spec->autocfg.speaker_pins[2] = 0x16;
9502 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009503}
9504
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009505static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009506{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009507 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009508
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009509 spec->autocfg.hp_pins[0] = 0x1b;
9510 spec->autocfg.speaker_pins[0] = 0x14;
9511 spec->autocfg.speaker_pins[1] = 0x15;
9512 spec->autocfg.speaker_pins[2] = 0x16;
9513 spec->autocfg.speaker_pins[3] = 0x17;
9514 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009515}
9516
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009517static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009518{
9519 struct alc_spec *spec = codec->spec;
9520
9521 spec->autocfg.hp_pins[0] = 0x15;
9522 spec->autocfg.speaker_pins[0] = 0x14;
9523 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009524}
9525
Kailang Yange2757d52008-08-26 13:17:46 +02009526static struct hda_verb alc888_asus_m90v_verbs[] = {
9527 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9528 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9529 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9530 /* enable unsolicited event */
9531 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9532 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9533 { } /* end */
9534};
9535
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009536static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009537{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009538 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009539
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009540 spec->autocfg.hp_pins[0] = 0x1b;
9541 spec->autocfg.speaker_pins[0] = 0x14;
9542 spec->autocfg.speaker_pins[1] = 0x15;
9543 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009544 spec->ext_mic.pin = 0x18;
9545 spec->int_mic.pin = 0x19;
9546 spec->ext_mic.mux_idx = 0;
9547 spec->int_mic.mux_idx = 1;
9548 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009549}
9550
9551static struct hda_verb alc888_asus_eee1601_verbs[] = {
9552 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9553 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9554 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9555 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9556 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9557 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9558 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9559 /* enable unsolicited event */
9560 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9561 { } /* end */
9562};
9563
Kailang Yange2757d52008-08-26 13:17:46 +02009564static void alc883_eee1601_inithook(struct hda_codec *codec)
9565{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009566 struct alc_spec *spec = codec->spec;
9567
9568 spec->autocfg.hp_pins[0] = 0x14;
9569 spec->autocfg.speaker_pins[0] = 0x1b;
9570 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009571}
9572
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009573static struct hda_verb alc889A_mb31_verbs[] = {
9574 /* Init rear pin (used as headphone output) */
9575 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9576 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9577 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9578 /* Init line pin (used as output in 4ch and 6ch mode) */
9579 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9580 /* Init line 2 pin (used as headphone out by default) */
9581 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9582 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9583 { } /* end */
9584};
9585
9586/* Mute speakers according to the headphone jack state */
9587static void alc889A_mb31_automute(struct hda_codec *codec)
9588{
9589 unsigned int present;
9590
9591 /* Mute only in 2ch or 4ch mode */
9592 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9593 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009594 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009595 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9596 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9597 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9598 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9599 }
9600}
9601
9602static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9603{
9604 if ((res >> 26) == ALC880_HP_EVENT)
9605 alc889A_mb31_automute(codec);
9606}
9607
Takashi Iwai4953550a2009-06-30 15:28:30 +02009608
Takashi Iwaicb53c622007-08-10 17:21:45 +02009609#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009610#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009611#endif
9612
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009613/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009614#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9615#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9616#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9617#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9618
9619static hda_nid_t alc883_slave_dig_outs[] = {
9620 ALC1200_DIGOUT_NID, 0,
9621};
9622
9623static hda_nid_t alc1200_slave_dig_outs[] = {
9624 ALC883_DIGOUT_NID, 0,
9625};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009626
9627/*
9628 * configuration and preset
9629 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009630static const char *alc882_models[ALC882_MODEL_LAST] = {
9631 [ALC882_3ST_DIG] = "3stack-dig",
9632 [ALC882_6ST_DIG] = "6stack-dig",
9633 [ALC882_ARIMA] = "arima",
9634 [ALC882_W2JC] = "w2jc",
9635 [ALC882_TARGA] = "targa",
9636 [ALC882_ASUS_A7J] = "asus-a7j",
9637 [ALC882_ASUS_A7M] = "asus-a7m",
9638 [ALC885_MACPRO] = "macpro",
9639 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009640 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009641 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009642 [ALC885_MBP3] = "mbp3",
9643 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009644 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009645 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009646 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9647 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009648 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009649 [ALC883_TARGA_DIG] = "targa-dig",
9650 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009651 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009652 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009653 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009654 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009655 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009656 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009657 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009658 [ALC883_MEDION] = "medion",
Kailang Yang272a5272007-05-14 11:00:38 +02009659 [ALC883_MEDION_MD2] = "medion-md2",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009660 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009661 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009662 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009663 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9664 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009665 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009666 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009667 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009668 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009669 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309670 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009671 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009672 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009673 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009674 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009675 [ALC889A_INTEL] = "intel-alc889a",
9676 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009677 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009678 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009679 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009680 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009681};
9682
Takashi Iwai4953550a2009-06-30 15:28:30 +02009683static struct snd_pci_quirk alc882_cfg_tbl[] = {
9684 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9685
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009686 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009687 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009688 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009689 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9690 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009691 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009692 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9693 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009694 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009695 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009696 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9697 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009698 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9699 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009700 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9701 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009702 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009703 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009704 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009705 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009706 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9707 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009708 /* default Acer -- disabled as it causes more problems.
9709 * model=auto should work fine now
9710 */
9711 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009712
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009713 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009714
Tobin Davisfebe3372007-06-12 11:27:46 +02009715 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009716 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9717 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009718 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009719 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009720 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009721
9722 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9723 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9724 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009725 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009726 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9727 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9728 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009729 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009730 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009731 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009732 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009733
9734 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009735 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009736 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009737 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009738 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9739 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009740 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009741 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009742 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9743
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009744 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9745 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9746 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009747 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009748 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009749 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009750 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009751 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009752 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9753 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9754 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9755 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9756 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9757 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009758 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009759 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9760 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9761 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009762 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009763 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009764 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9765 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009766 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009767 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009768 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009769 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009770 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009771 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009772 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009773 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009774 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009775
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009776 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009777 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009778 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9779 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309780 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009781 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009782 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009783 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009784 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009785 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009786 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009787 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009788 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009789 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009790 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009791 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9792 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009793 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Kailang Yang272a5272007-05-14 11:00:38 +02009794 SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
Takashi Iwai959973b2008-11-05 11:30:56 +01009795 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009796 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009797 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009798
Jiang zhe17bba1b2008-06-04 12:11:07 +02009799 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9800 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009801 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009802 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9803 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9804 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009805 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009806
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009807 {}
9808};
9809
Takashi Iwai4953550a2009-06-30 15:28:30 +02009810/* codec SSID table for Intel Mac */
9811static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9812 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9813 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9814 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9815 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9816 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9817 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9818 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009819 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009820 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009821 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009822 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009823 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9824 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9825 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009826 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009827 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009828 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009829 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9830 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009831 */
9832 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009833 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009834 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009835 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009836};
9837
Takashi Iwai4953550a2009-06-30 15:28:30 +02009838static struct alc_config_preset alc882_presets[] = {
9839 [ALC882_3ST_DIG] = {
9840 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009841 .init_verbs = { alc882_base_init_verbs,
9842 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009843 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9844 .dac_nids = alc882_dac_nids,
9845 .dig_out_nid = ALC882_DIGOUT_NID,
9846 .dig_in_nid = ALC882_DIGIN_NID,
9847 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9848 .channel_mode = alc882_ch_modes,
9849 .need_dac_fix = 1,
9850 .input_mux = &alc882_capture_source,
9851 },
9852 [ALC882_6ST_DIG] = {
9853 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009854 .init_verbs = { alc882_base_init_verbs,
9855 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009856 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9857 .dac_nids = alc882_dac_nids,
9858 .dig_out_nid = ALC882_DIGOUT_NID,
9859 .dig_in_nid = ALC882_DIGIN_NID,
9860 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9861 .channel_mode = alc882_sixstack_modes,
9862 .input_mux = &alc882_capture_source,
9863 },
9864 [ALC882_ARIMA] = {
9865 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009866 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9867 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009868 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9869 .dac_nids = alc882_dac_nids,
9870 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9871 .channel_mode = alc882_sixstack_modes,
9872 .input_mux = &alc882_capture_source,
9873 },
9874 [ALC882_W2JC] = {
9875 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009876 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9877 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009878 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9879 .dac_nids = alc882_dac_nids,
9880 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9881 .channel_mode = alc880_threestack_modes,
9882 .need_dac_fix = 1,
9883 .input_mux = &alc882_capture_source,
9884 .dig_out_nid = ALC882_DIGOUT_NID,
9885 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009886 [ALC885_MBA21] = {
9887 .mixers = { alc885_mba21_mixer },
9888 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9889 .num_dacs = 2,
9890 .dac_nids = alc882_dac_nids,
9891 .channel_mode = alc885_mba21_ch_modes,
9892 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9893 .input_mux = &alc882_capture_source,
9894 .unsol_event = alc_automute_amp_unsol_event,
9895 .setup = alc885_mba21_setup,
9896 .init_hook = alc_automute_amp,
9897 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009898 [ALC885_MBP3] = {
9899 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9900 .init_verbs = { alc885_mbp3_init_verbs,
9901 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009902 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009903 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009904 .hp_nid = 0x04,
9905 .channel_mode = alc885_mbp_4ch_modes,
9906 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009907 .input_mux = &alc882_capture_source,
9908 .dig_out_nid = ALC882_DIGOUT_NID,
9909 .dig_in_nid = ALC882_DIGIN_NID,
9910 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009911 .setup = alc885_mbp3_setup,
9912 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009913 },
9914 [ALC885_MB5] = {
9915 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
9916 .init_verbs = { alc885_mb5_init_verbs,
9917 alc880_gpio1_init_verbs },
9918 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9919 .dac_nids = alc882_dac_nids,
9920 .channel_mode = alc885_mb5_6ch_modes,
9921 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
9922 .input_mux = &mb5_capture_source,
9923 .dig_out_nid = ALC882_DIGOUT_NID,
9924 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009925 .unsol_event = alc_automute_amp_unsol_event,
9926 .setup = alc885_mb5_setup,
9927 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009928 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009929 [ALC885_MACMINI3] = {
9930 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
9931 .init_verbs = { alc885_macmini3_init_verbs,
9932 alc880_gpio1_init_verbs },
9933 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9934 .dac_nids = alc882_dac_nids,
9935 .channel_mode = alc885_macmini3_6ch_modes,
9936 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
9937 .input_mux = &macmini3_capture_source,
9938 .dig_out_nid = ALC882_DIGOUT_NID,
9939 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009940 .unsol_event = alc_automute_amp_unsol_event,
9941 .setup = alc885_macmini3_setup,
9942 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009943 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009944 [ALC885_MACPRO] = {
9945 .mixers = { alc882_macpro_mixer },
9946 .init_verbs = { alc882_macpro_init_verbs },
9947 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9948 .dac_nids = alc882_dac_nids,
9949 .dig_out_nid = ALC882_DIGOUT_NID,
9950 .dig_in_nid = ALC882_DIGIN_NID,
9951 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9952 .channel_mode = alc882_ch_modes,
9953 .input_mux = &alc882_capture_source,
9954 .init_hook = alc885_macpro_init_hook,
9955 },
9956 [ALC885_IMAC24] = {
9957 .mixers = { alc885_imac24_mixer },
9958 .init_verbs = { alc885_imac24_init_verbs },
9959 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9960 .dac_nids = alc882_dac_nids,
9961 .dig_out_nid = ALC882_DIGOUT_NID,
9962 .dig_in_nid = ALC882_DIGIN_NID,
9963 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9964 .channel_mode = alc882_ch_modes,
9965 .input_mux = &alc882_capture_source,
9966 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009967 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009968 .init_hook = alc885_imac24_init_hook,
9969 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009970 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009971 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009972 .init_verbs = { alc885_imac91_init_verbs,
9973 alc880_gpio1_init_verbs },
9974 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9975 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07009976 .channel_mode = alc885_mba21_ch_modes,
9977 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9978 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009979 .dig_out_nid = ALC882_DIGOUT_NID,
9980 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +01009981 .unsol_event = alc_automute_amp_unsol_event,
9982 .setup = alc885_imac91_setup,
9983 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009984 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009985 [ALC882_TARGA] = {
9986 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009987 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +02009988 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +02009989 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9990 .dac_nids = alc882_dac_nids,
9991 .dig_out_nid = ALC882_DIGOUT_NID,
9992 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
9993 .adc_nids = alc882_adc_nids,
9994 .capsrc_nids = alc882_capsrc_nids,
9995 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
9996 .channel_mode = alc882_3ST_6ch_modes,
9997 .need_dac_fix = 1,
9998 .input_mux = &alc882_capture_source,
9999 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010000 .setup = alc882_targa_setup,
10001 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010002 },
10003 [ALC882_ASUS_A7J] = {
10004 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010005 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10006 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010007 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10008 .dac_nids = alc882_dac_nids,
10009 .dig_out_nid = ALC882_DIGOUT_NID,
10010 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10011 .adc_nids = alc882_adc_nids,
10012 .capsrc_nids = alc882_capsrc_nids,
10013 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10014 .channel_mode = alc882_3ST_6ch_modes,
10015 .need_dac_fix = 1,
10016 .input_mux = &alc882_capture_source,
10017 },
10018 [ALC882_ASUS_A7M] = {
10019 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010020 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10021 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010022 alc882_asus_a7m_verbs },
10023 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10024 .dac_nids = alc882_dac_nids,
10025 .dig_out_nid = ALC882_DIGOUT_NID,
10026 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10027 .channel_mode = alc880_threestack_modes,
10028 .need_dac_fix = 1,
10029 .input_mux = &alc882_capture_source,
10030 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010031 [ALC883_3ST_2ch_DIG] = {
10032 .mixers = { alc883_3ST_2ch_mixer },
10033 .init_verbs = { alc883_init_verbs },
10034 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10035 .dac_nids = alc883_dac_nids,
10036 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010037 .dig_in_nid = ALC883_DIGIN_NID,
10038 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10039 .channel_mode = alc883_3ST_2ch_modes,
10040 .input_mux = &alc883_capture_source,
10041 },
10042 [ALC883_3ST_6ch_DIG] = {
10043 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10044 .init_verbs = { alc883_init_verbs },
10045 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10046 .dac_nids = alc883_dac_nids,
10047 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010048 .dig_in_nid = ALC883_DIGIN_NID,
10049 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10050 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010051 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010052 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010053 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010054 [ALC883_3ST_6ch] = {
10055 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10056 .init_verbs = { alc883_init_verbs },
10057 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10058 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010059 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10060 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010061 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010062 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010063 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010064 [ALC883_3ST_6ch_INTEL] = {
10065 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10066 .init_verbs = { alc883_init_verbs },
10067 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10068 .dac_nids = alc883_dac_nids,
10069 .dig_out_nid = ALC883_DIGOUT_NID,
10070 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010071 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010072 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10073 .channel_mode = alc883_3ST_6ch_intel_modes,
10074 .need_dac_fix = 1,
10075 .input_mux = &alc883_3stack_6ch_intel,
10076 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010077 [ALC889A_INTEL] = {
10078 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010079 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10080 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010081 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10082 .dac_nids = alc883_dac_nids,
10083 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10084 .adc_nids = alc889_adc_nids,
10085 .dig_out_nid = ALC883_DIGOUT_NID,
10086 .dig_in_nid = ALC883_DIGIN_NID,
10087 .slave_dig_outs = alc883_slave_dig_outs,
10088 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10089 .channel_mode = alc889_8ch_intel_modes,
10090 .capsrc_nids = alc889_capsrc_nids,
10091 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010092 .setup = alc889_automute_setup,
10093 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010094 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010095 .need_dac_fix = 1,
10096 },
10097 [ALC889_INTEL] = {
10098 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10099 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010100 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010101 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10102 .dac_nids = alc883_dac_nids,
10103 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10104 .adc_nids = alc889_adc_nids,
10105 .dig_out_nid = ALC883_DIGOUT_NID,
10106 .dig_in_nid = ALC883_DIGIN_NID,
10107 .slave_dig_outs = alc883_slave_dig_outs,
10108 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10109 .channel_mode = alc889_8ch_intel_modes,
10110 .capsrc_nids = alc889_capsrc_nids,
10111 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010112 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010113 .init_hook = alc889_intel_init_hook,
10114 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010115 .need_dac_fix = 1,
10116 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010117 [ALC883_6ST_DIG] = {
10118 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10119 .init_verbs = { alc883_init_verbs },
10120 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10121 .dac_nids = alc883_dac_nids,
10122 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010123 .dig_in_nid = ALC883_DIGIN_NID,
10124 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10125 .channel_mode = alc883_sixstack_modes,
10126 .input_mux = &alc883_capture_source,
10127 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010128 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010129 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010130 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10131 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010132 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10133 .dac_nids = alc883_dac_nids,
10134 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010135 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10136 .channel_mode = alc883_3ST_6ch_modes,
10137 .need_dac_fix = 1,
10138 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010139 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010140 .setup = alc882_targa_setup,
10141 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010142 },
10143 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010144 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010145 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10146 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010147 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10148 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010149 .adc_nids = alc883_adc_nids_alt,
10150 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010151 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010152 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010153 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10154 .channel_mode = alc883_3ST_2ch_modes,
10155 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010156 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010157 .setup = alc882_targa_setup,
10158 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010159 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010160 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010161 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10162 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010163 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010164 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010165 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10166 .dac_nids = alc883_dac_nids,
10167 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10168 .adc_nids = alc883_adc_nids_rev,
10169 .capsrc_nids = alc883_capsrc_nids_rev,
10170 .dig_out_nid = ALC883_DIGOUT_NID,
10171 .dig_in_nid = ALC883_DIGIN_NID,
10172 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10173 .channel_mode = alc883_4ST_8ch_modes,
10174 .need_dac_fix = 1,
10175 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010176 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010177 .setup = alc882_targa_setup,
10178 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010179 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010180 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010181 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010182 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10183 * and the headphone jack. Turn this on and rely on the
10184 * standard mute methods whenever the user wants to turn
10185 * these outputs off.
10186 */
10187 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10188 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10189 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010190 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10191 .channel_mode = alc883_3ST_2ch_modes,
10192 .input_mux = &alc883_capture_source,
10193 },
Tobin Davis2880a862007-08-07 11:50:26 +020010194 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010195 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010196 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010197 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10198 .dac_nids = alc883_dac_nids,
10199 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010200 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10201 .channel_mode = alc883_3ST_2ch_modes,
10202 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010203 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010204 .setup = alc883_acer_aspire_setup,
10205 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010206 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010207 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010208 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010209 alc883_chmode_mixer },
10210 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10211 alc888_acer_aspire_4930g_verbs },
10212 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10213 .dac_nids = alc883_dac_nids,
10214 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10215 .adc_nids = alc883_adc_nids_rev,
10216 .capsrc_nids = alc883_capsrc_nids_rev,
10217 .dig_out_nid = ALC883_DIGOUT_NID,
10218 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10219 .channel_mode = alc883_3ST_6ch_modes,
10220 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010221 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010222 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010223 ARRAY_SIZE(alc888_2_capture_sources),
10224 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010225 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010226 .setup = alc888_acer_aspire_4930g_setup,
10227 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010228 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010229 [ALC888_ACER_ASPIRE_6530G] = {
10230 .mixers = { alc888_acer_aspire_6530_mixer },
10231 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10232 alc888_acer_aspire_6530g_verbs },
10233 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10234 .dac_nids = alc883_dac_nids,
10235 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10236 .adc_nids = alc883_adc_nids_rev,
10237 .capsrc_nids = alc883_capsrc_nids_rev,
10238 .dig_out_nid = ALC883_DIGOUT_NID,
10239 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10240 .channel_mode = alc883_3ST_2ch_modes,
10241 .num_mux_defs =
10242 ARRAY_SIZE(alc888_2_capture_sources),
10243 .input_mux = alc888_acer_aspire_6530_sources,
10244 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010245 .setup = alc888_acer_aspire_6530g_setup,
10246 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010247 },
Hector Martin3b315d72009-06-02 10:54:19 +020010248 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010249 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010250 alc883_chmode_mixer },
10251 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010252 alc889_acer_aspire_8930g_verbs,
10253 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010254 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10255 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010256 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10257 .adc_nids = alc889_adc_nids,
10258 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010259 .dig_out_nid = ALC883_DIGOUT_NID,
10260 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10261 .channel_mode = alc883_3ST_6ch_modes,
10262 .need_dac_fix = 1,
10263 .const_channel_count = 6,
10264 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010265 ARRAY_SIZE(alc889_capture_sources),
10266 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010267 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010268 .setup = alc889_acer_aspire_8930g_setup,
10269 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010270#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010271 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010272#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010273 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010274 [ALC888_ACER_ASPIRE_7730G] = {
10275 .mixers = { alc883_3ST_6ch_mixer,
10276 alc883_chmode_mixer },
10277 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10278 alc888_acer_aspire_7730G_verbs },
10279 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10280 .dac_nids = alc883_dac_nids,
10281 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10282 .adc_nids = alc883_adc_nids_rev,
10283 .capsrc_nids = alc883_capsrc_nids_rev,
10284 .dig_out_nid = ALC883_DIGOUT_NID,
10285 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10286 .channel_mode = alc883_3ST_6ch_modes,
10287 .need_dac_fix = 1,
10288 .const_channel_count = 6,
10289 .input_mux = &alc883_capture_source,
10290 .unsol_event = alc_automute_amp_unsol_event,
10291 .setup = alc888_acer_aspire_6530g_setup,
10292 .init_hook = alc_automute_amp,
10293 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010294 [ALC883_MEDION] = {
10295 .mixers = { alc883_fivestack_mixer,
10296 alc883_chmode_mixer },
10297 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010298 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010299 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10300 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010301 .adc_nids = alc883_adc_nids_alt,
10302 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010303 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010304 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10305 .channel_mode = alc883_sixstack_modes,
10306 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010307 },
Kailang Yang272a5272007-05-14 11:00:38 +020010308 [ALC883_MEDION_MD2] = {
10309 .mixers = { alc883_medion_md2_mixer},
10310 .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
10311 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10312 .dac_nids = alc883_dac_nids,
10313 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010314 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10315 .channel_mode = alc883_3ST_2ch_modes,
10316 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010317 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010318 .setup = alc883_medion_md2_setup,
10319 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020010320 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010321 [ALC883_MEDION_WIM2160] = {
10322 .mixers = { alc883_medion_wim2160_mixer },
10323 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10324 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10325 .dac_nids = alc883_dac_nids,
10326 .dig_out_nid = ALC883_DIGOUT_NID,
10327 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10328 .adc_nids = alc883_adc_nids,
10329 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10330 .channel_mode = alc883_3ST_2ch_modes,
10331 .input_mux = &alc883_capture_source,
10332 .unsol_event = alc_automute_amp_unsol_event,
10333 .setup = alc883_medion_wim2160_setup,
10334 .init_hook = alc_automute_amp,
10335 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010336 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010337 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010338 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10339 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10340 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010341 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10342 .channel_mode = alc883_3ST_2ch_modes,
10343 .input_mux = &alc883_capture_source,
10344 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010345 [ALC883_CLEVO_M540R] = {
10346 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10347 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10348 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10349 .dac_nids = alc883_dac_nids,
10350 .dig_out_nid = ALC883_DIGOUT_NID,
10351 .dig_in_nid = ALC883_DIGIN_NID,
10352 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10353 .channel_mode = alc883_3ST_6ch_clevo_modes,
10354 .need_dac_fix = 1,
10355 .input_mux = &alc883_capture_source,
10356 /* This machine has the hardware HP auto-muting, thus
10357 * we need no software mute via unsol event
10358 */
10359 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010360 [ALC883_CLEVO_M720] = {
10361 .mixers = { alc883_clevo_m720_mixer },
10362 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010363 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10364 .dac_nids = alc883_dac_nids,
10365 .dig_out_nid = ALC883_DIGOUT_NID,
10366 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10367 .channel_mode = alc883_3ST_2ch_modes,
10368 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010369 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010370 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010371 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010372 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010373 [ALC883_LENOVO_101E_2ch] = {
10374 .mixers = { alc883_lenovo_101e_2ch_mixer},
10375 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10376 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10377 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010378 .adc_nids = alc883_adc_nids_alt,
10379 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010380 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010381 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10382 .channel_mode = alc883_3ST_2ch_modes,
10383 .input_mux = &alc883_lenovo_101e_capture_source,
10384 .unsol_event = alc883_lenovo_101e_unsol_event,
10385 .init_hook = alc883_lenovo_101e_all_automute,
10386 },
Kailang Yang272a5272007-05-14 11:00:38 +020010387 [ALC883_LENOVO_NB0763] = {
10388 .mixers = { alc883_lenovo_nb0763_mixer },
10389 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10390 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10391 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010392 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10393 .channel_mode = alc883_3ST_2ch_modes,
10394 .need_dac_fix = 1,
10395 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010396 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010397 .setup = alc883_medion_md2_setup,
10398 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010399 },
10400 [ALC888_LENOVO_MS7195_DIG] = {
10401 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10402 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10403 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10404 .dac_nids = alc883_dac_nids,
10405 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010406 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10407 .channel_mode = alc883_3ST_6ch_modes,
10408 .need_dac_fix = 1,
10409 .input_mux = &alc883_capture_source,
10410 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10411 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010412 },
10413 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010414 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010415 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10416 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10417 .dac_nids = alc883_dac_nids,
10418 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010419 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10420 .channel_mode = alc883_3ST_2ch_modes,
10421 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010422 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010423 .setup = alc883_haier_w66_setup,
10424 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010425 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010426 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010427 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010428 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010429 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10430 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010431 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10432 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010433 .need_dac_fix = 1,
10434 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010435 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010436 .setup = alc888_3st_hp_setup,
10437 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010438 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010439 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010440 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010441 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10442 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10443 .dac_nids = alc883_dac_nids,
10444 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010445 .dig_in_nid = ALC883_DIGIN_NID,
10446 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10447 .channel_mode = alc883_sixstack_modes,
10448 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010449 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010450 .setup = alc888_6st_dell_setup,
10451 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010452 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010453 [ALC883_MITAC] = {
10454 .mixers = { alc883_mitac_mixer },
10455 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10456 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10457 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010458 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10459 .channel_mode = alc883_3ST_2ch_modes,
10460 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010461 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010462 .setup = alc883_mitac_setup,
10463 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010464 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010465 [ALC883_FUJITSU_PI2515] = {
10466 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10467 .init_verbs = { alc883_init_verbs,
10468 alc883_2ch_fujitsu_pi2515_verbs},
10469 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10470 .dac_nids = alc883_dac_nids,
10471 .dig_out_nid = ALC883_DIGOUT_NID,
10472 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10473 .channel_mode = alc883_3ST_2ch_modes,
10474 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010475 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010476 .setup = alc883_2ch_fujitsu_pi2515_setup,
10477 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010478 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010479 [ALC888_FUJITSU_XA3530] = {
10480 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10481 .init_verbs = { alc883_init_verbs,
10482 alc888_fujitsu_xa3530_verbs },
10483 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10484 .dac_nids = alc883_dac_nids,
10485 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10486 .adc_nids = alc883_adc_nids_rev,
10487 .capsrc_nids = alc883_capsrc_nids_rev,
10488 .dig_out_nid = ALC883_DIGOUT_NID,
10489 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10490 .channel_mode = alc888_4ST_8ch_intel_modes,
10491 .num_mux_defs =
10492 ARRAY_SIZE(alc888_2_capture_sources),
10493 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010494 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010495 .setup = alc888_fujitsu_xa3530_setup,
10496 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010497 },
Kailang Yange2757d52008-08-26 13:17:46 +020010498 [ALC888_LENOVO_SKY] = {
10499 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10500 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10501 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10502 .dac_nids = alc883_dac_nids,
10503 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010504 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10505 .channel_mode = alc883_sixstack_modes,
10506 .need_dac_fix = 1,
10507 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010508 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010509 .setup = alc888_lenovo_sky_setup,
10510 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010511 },
10512 [ALC888_ASUS_M90V] = {
10513 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10514 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10515 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10516 .dac_nids = alc883_dac_nids,
10517 .dig_out_nid = ALC883_DIGOUT_NID,
10518 .dig_in_nid = ALC883_DIGIN_NID,
10519 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10520 .channel_mode = alc883_3ST_6ch_modes,
10521 .need_dac_fix = 1,
10522 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010523 .unsol_event = alc_sku_unsol_event,
10524 .setup = alc883_mode2_setup,
10525 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010526 },
10527 [ALC888_ASUS_EEE1601] = {
10528 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010529 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010530 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10531 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10532 .dac_nids = alc883_dac_nids,
10533 .dig_out_nid = ALC883_DIGOUT_NID,
10534 .dig_in_nid = ALC883_DIGIN_NID,
10535 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10536 .channel_mode = alc883_3ST_2ch_modes,
10537 .need_dac_fix = 1,
10538 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010539 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010540 .init_hook = alc883_eee1601_inithook,
10541 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010542 [ALC1200_ASUS_P5Q] = {
10543 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10544 .init_verbs = { alc883_init_verbs },
10545 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10546 .dac_nids = alc883_dac_nids,
10547 .dig_out_nid = ALC1200_DIGOUT_NID,
10548 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010549 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010550 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10551 .channel_mode = alc883_sixstack_modes,
10552 .input_mux = &alc883_capture_source,
10553 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010554 [ALC889A_MB31] = {
10555 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10556 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10557 alc880_gpio1_init_verbs },
10558 .adc_nids = alc883_adc_nids,
10559 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010560 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010561 .dac_nids = alc883_dac_nids,
10562 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10563 .channel_mode = alc889A_mb31_6ch_modes,
10564 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10565 .input_mux = &alc889A_mb31_capture_source,
10566 .dig_out_nid = ALC883_DIGOUT_NID,
10567 .unsol_event = alc889A_mb31_unsol_event,
10568 .init_hook = alc889A_mb31_automute,
10569 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010570 [ALC883_SONY_VAIO_TT] = {
10571 .mixers = { alc883_vaiott_mixer },
10572 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10573 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10574 .dac_nids = alc883_dac_nids,
10575 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10576 .channel_mode = alc883_3ST_2ch_modes,
10577 .input_mux = &alc883_capture_source,
10578 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010579 .setup = alc883_vaiott_setup,
10580 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010581 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010582};
10583
10584
10585/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010586 * Pin config fixes
10587 */
10588enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010589 PINFIX_ABIT_AW9D_MAX,
10590 PINFIX_PB_M5210,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010591};
10592
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010593static const struct alc_fixup alc882_fixups[] = {
10594 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010595 .pins = (const struct alc_pincfg[]) {
10596 { 0x15, 0x01080104 }, /* side */
10597 { 0x16, 0x01011012 }, /* rear */
10598 { 0x17, 0x01016011 }, /* clfe */
10599 { }
10600 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010601 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010602 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010603 .verbs = (const struct hda_verb[]) {
10604 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10605 {}
10606 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010607 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010608};
10609
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010610static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010611 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010612 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
10613 {}
10614};
10615
10616/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010617 * BIOS auto configuration
10618 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010619static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10620 const struct auto_pin_cfg *cfg)
10621{
10622 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10623}
10624
Takashi Iwai4953550a2009-06-30 15:28:30 +020010625static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010626 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010627 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010628{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010629 int idx;
10630
Takashi Iwai489008c2010-04-07 09:06:00 +020010631 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010632 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010633
Takashi Iwai489008c2010-04-07 09:06:00 +020010634 if (dac == 0x25)
10635 idx = 4;
10636 else if (dac >= 0x02 && dac <= 0x05)
10637 idx = dac - 2;
10638 else
10639 return;
10640 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010641}
10642
Takashi Iwai4953550a2009-06-30 15:28:30 +020010643static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010644{
10645 struct alc_spec *spec = codec->spec;
10646 int i;
10647
10648 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010649 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010650 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010651 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010652 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010653 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010654 }
10655}
10656
Takashi Iwai4953550a2009-06-30 15:28:30 +020010657static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010658{
10659 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010660 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010661 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010662
Takashi Iwai5855fb82010-09-16 18:24:02 +020010663 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10664 pin = spec->autocfg.hp_pins[i];
10665 if (!pin)
10666 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010667 dac = spec->multiout.hp_nid;
10668 if (!dac)
10669 dac = spec->multiout.dac_nids[0]; /* to front */
10670 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10671 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010672 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10673 pin = spec->autocfg.speaker_pins[i];
10674 if (!pin)
10675 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010676 dac = spec->multiout.extra_out_nid[0];
10677 if (!dac)
10678 dac = spec->multiout.dac_nids[0]; /* to front */
10679 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10680 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010681}
10682
Takashi Iwai4953550a2009-06-30 15:28:30 +020010683static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010684{
10685 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010686 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010687 int i;
10688
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010689 for (i = 0; i < cfg->num_inputs; i++) {
10690 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010691 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010692 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10693 snd_hda_codec_write(codec, nid, 0,
10694 AC_VERB_SET_AMP_GAIN_MUTE,
10695 AMP_OUT_MUTE);
10696 }
10697}
10698
10699static void alc882_auto_init_input_src(struct hda_codec *codec)
10700{
10701 struct alc_spec *spec = codec->spec;
10702 int c;
10703
10704 for (c = 0; c < spec->num_adc_nids; c++) {
10705 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10706 hda_nid_t nid = spec->capsrc_nids[c];
10707 unsigned int mux_idx;
10708 const struct hda_input_mux *imux;
10709 int conns, mute, idx, item;
10710
10711 conns = snd_hda_get_connections(codec, nid, conn_list,
10712 ARRAY_SIZE(conn_list));
10713 if (conns < 0)
10714 continue;
10715 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10716 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010717 if (!imux->num_items && mux_idx > 0)
10718 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010719 for (idx = 0; idx < conns; idx++) {
10720 /* if the current connection is the selected one,
10721 * unmute it as default - otherwise mute it
10722 */
10723 mute = AMP_IN_MUTE(idx);
10724 for (item = 0; item < imux->num_items; item++) {
10725 if (imux->items[item].index == idx) {
10726 if (spec->cur_mux[c] == item)
10727 mute = AMP_IN_UNMUTE(idx);
10728 break;
10729 }
10730 }
10731 /* check if we have a selector or mixer
10732 * we could check for the widget type instead, but
10733 * just check for Amp-In presence (in case of mixer
10734 * without amp-in there is something wrong, this
10735 * function shouldn't be used or capsrc nid is wrong)
10736 */
10737 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010738 snd_hda_codec_write(codec, nid, 0,
10739 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010740 mute);
10741 else if (mute != AMP_IN_MUTE(idx))
10742 snd_hda_codec_write(codec, nid, 0,
10743 AC_VERB_SET_CONNECT_SEL,
10744 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010745 }
10746 }
10747}
10748
Takashi Iwai4953550a2009-06-30 15:28:30 +020010749/* add mic boosts if needed */
10750static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010751{
10752 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010753 struct auto_pin_cfg *cfg = &spec->autocfg;
10754 int i, err;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010755 hda_nid_t nid;
10756
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010757 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010758 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010759 break;
10760 nid = cfg->inputs[i].pin;
10761 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +020010762 char label[32];
10763 snprintf(label, sizeof(label), "%s Boost",
10764 hda_get_autocfg_input_label(codec, cfg, i));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010765 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010766 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010767 if (err < 0)
10768 return err;
10769 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010770 }
10771 return 0;
10772}
10773
10774/* almost identical with ALC880 parser... */
10775static int alc882_parse_auto_config(struct hda_codec *codec)
10776{
10777 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010778 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010779 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010780
Takashi Iwai05f5f472009-08-25 13:10:18 +020010781 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10782 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010783 if (err < 0)
10784 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010785 if (!spec->autocfg.line_outs)
10786 return 0; /* can't find valid BIOS pin config */
10787
10788 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10789 if (err < 0)
10790 return err;
10791 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10792 if (err < 0)
10793 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010794 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10795 "Headphone");
10796 if (err < 0)
10797 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010798 err = alc880_auto_create_extra_out(spec,
10799 spec->autocfg.speaker_pins[0],
10800 "Speaker");
10801 if (err < 0)
10802 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010803 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10804 if (err < 0)
10805 return err;
10806
10807 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10808
Takashi Iwai757899a2010-07-30 10:48:14 +020010809 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010810
10811 if (spec->kctls.list)
10812 add_mixer(spec, spec->kctls.list);
10813
10814 add_verb(spec, alc883_auto_init_verbs);
10815 /* if ADC 0x07 is available, initialize it, too */
10816 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10817 add_verb(spec, alc882_adc1_init_verbs);
10818
10819 spec->num_mux_defs = 1;
10820 spec->input_mux = &spec->private_imux[0];
10821
Kailang Yang6227cdc2010-02-25 08:36:52 +010010822 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010823
10824 err = alc_auto_add_mic_boost(codec);
10825 if (err < 0)
10826 return err;
10827
Takashi Iwai776e1842007-08-29 15:07:11 +020010828 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010829}
10830
10831/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010832static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010833{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010834 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010835 alc882_auto_init_multi_out(codec);
10836 alc882_auto_init_hp_out(codec);
10837 alc882_auto_init_analog_input(codec);
10838 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010839 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010840 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010841 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010842}
10843
Takashi Iwai4953550a2009-06-30 15:28:30 +020010844static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010845{
10846 struct alc_spec *spec;
10847 int err, board_config;
10848
10849 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10850 if (spec == NULL)
10851 return -ENOMEM;
10852
10853 codec->spec = spec;
10854
Kailang Yangda00c242010-03-19 11:23:45 +010010855 alc_auto_parse_customize_define(codec);
10856
Takashi Iwai4953550a2009-06-30 15:28:30 +020010857 switch (codec->vendor_id) {
10858 case 0x10ec0882:
10859 case 0x10ec0885:
10860 break;
10861 default:
10862 /* ALC883 and variants */
10863 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10864 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010865 }
10866
Takashi Iwai4953550a2009-06-30 15:28:30 +020010867 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10868 alc882_models,
10869 alc882_cfg_tbl);
10870
10871 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10872 board_config = snd_hda_check_board_codec_sid_config(codec,
10873 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10874
10875 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010876 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010877 codec->chip_name);
10878 board_config = ALC882_AUTO;
10879 }
10880
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010881 if (board_config == ALC882_AUTO)
10882 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010883
10884 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010885 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010886 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010887 if (err < 0) {
10888 alc_free(codec);
10889 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010890 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010891 printk(KERN_INFO
10892 "hda_codec: Cannot set up configuration "
10893 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010894 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010895 }
10896 }
10897
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010898 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010899 err = snd_hda_attach_beep_device(codec, 0x1);
10900 if (err < 0) {
10901 alc_free(codec);
10902 return err;
10903 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010904 }
10905
Takashi Iwai4953550a2009-06-30 15:28:30 +020010906 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010907 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010908
Takashi Iwai4953550a2009-06-30 15:28:30 +020010909 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10910 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10911 /* FIXME: setup DAC5 */
10912 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10913 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10914
10915 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10916 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10917
Takashi Iwai4953550a2009-06-30 15:28:30 +020010918 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010919 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010920 spec->num_adc_nids = 0;
10921 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010922 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010923 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010924 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010925 hda_nid_t nid = alc882_adc_nids[i];
10926 unsigned int wcap = get_wcaps(codec, nid);
10927 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020010928 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010929 if (wcap != AC_WID_AUD_IN)
10930 continue;
10931 spec->private_adc_nids[spec->num_adc_nids] = nid;
10932 err = snd_hda_get_connections(codec, nid, &cap, 1);
10933 if (err < 0)
10934 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010935 err = snd_hda_get_connections(codec, cap, items,
10936 ARRAY_SIZE(items));
10937 if (err < 0)
10938 continue;
10939 for (j = 0; j < imux->num_items; j++)
10940 if (imux->items[j].index >= err)
10941 break;
10942 if (j < imux->num_items)
10943 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010944 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
10945 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020010946 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010947 spec->adc_nids = spec->private_adc_nids;
10948 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020010949 }
10950
Takashi Iwaib59bdf32009-08-11 09:47:30 +020010951 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010010952
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010953 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010010954 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010955
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010956 if (board_config == ALC882_AUTO)
10957 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
10958
Takashi Iwai2134ea42008-01-10 16:53:55 +010010959 spec->vmaster_nid = 0x0c;
10960
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010961 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010962 if (board_config == ALC882_AUTO)
10963 spec->init_hook = alc882_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010964#ifdef CONFIG_SND_HDA_POWER_SAVE
10965 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010966 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020010967#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010968
10969 return 0;
10970}
10971
Takashi Iwai4953550a2009-06-30 15:28:30 +020010972
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010973/*
Kailang Yangdf694da2005-12-05 19:42:22 +010010974 * ALC262 support
10975 */
10976
10977#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
10978#define ALC262_DIGIN_NID ALC880_DIGIN_NID
10979
10980#define alc262_dac_nids alc260_dac_nids
10981#define alc262_adc_nids alc882_adc_nids
10982#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010010983#define alc262_capsrc_nids alc882_capsrc_nids
10984#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010010985
10986#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010010987#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010010988
Kailang Yang4e555fe2008-08-26 13:05:55 +020010989static hda_nid_t alc262_dmic_adc_nids[1] = {
10990 /* ADC0 */
10991 0x09
10992};
10993
10994static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
10995
Kailang Yangdf694da2005-12-05 19:42:22 +010010996static struct snd_kcontrol_new alc262_base_mixer[] = {
10997 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
10998 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
10999 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11000 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11001 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11002 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11003 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11004 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011005 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011006 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11007 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011008 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011009 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11010 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11011 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11012 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011013 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011014};
11015
Takashi Iwaice875f02008-01-28 18:17:43 +010011016/* update HP, line and mono-out pins according to the master switch */
11017static void alc262_hp_master_update(struct hda_codec *codec)
11018{
11019 struct alc_spec *spec = codec->spec;
11020 int val = spec->master_sw;
11021
11022 /* HP & line-out */
11023 snd_hda_codec_write_cache(codec, 0x1b, 0,
11024 AC_VERB_SET_PIN_WIDGET_CONTROL,
11025 val ? PIN_HP : 0);
11026 snd_hda_codec_write_cache(codec, 0x15, 0,
11027 AC_VERB_SET_PIN_WIDGET_CONTROL,
11028 val ? PIN_HP : 0);
11029 /* mono (speaker) depending on the HP jack sense */
11030 val = val && !spec->jack_present;
11031 snd_hda_codec_write_cache(codec, 0x16, 0,
11032 AC_VERB_SET_PIN_WIDGET_CONTROL,
11033 val ? PIN_OUT : 0);
11034}
11035
11036static void alc262_hp_bpc_automute(struct hda_codec *codec)
11037{
11038 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011039
11040 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011041 alc262_hp_master_update(codec);
11042}
11043
11044static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11045{
11046 if ((res >> 26) != ALC880_HP_EVENT)
11047 return;
11048 alc262_hp_bpc_automute(codec);
11049}
11050
11051static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11052{
11053 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011054
11055 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011056 alc262_hp_master_update(codec);
11057}
11058
11059static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11060 unsigned int res)
11061{
11062 if ((res >> 26) != ALC880_HP_EVENT)
11063 return;
11064 alc262_hp_wildwest_automute(codec);
11065}
11066
Takashi Iwaib72519b2009-05-08 14:31:55 +020011067#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011068
11069static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11070 struct snd_ctl_elem_value *ucontrol)
11071{
11072 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11073 struct alc_spec *spec = codec->spec;
11074 int val = !!*ucontrol->value.integer.value;
11075
11076 if (val == spec->master_sw)
11077 return 0;
11078 spec->master_sw = val;
11079 alc262_hp_master_update(codec);
11080 return 1;
11081}
11082
Takashi Iwaib72519b2009-05-08 14:31:55 +020011083#define ALC262_HP_MASTER_SWITCH \
11084 { \
11085 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11086 .name = "Master Playback Switch", \
11087 .info = snd_ctl_boolean_mono_info, \
11088 .get = alc262_hp_master_sw_get, \
11089 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011090 }, \
11091 { \
11092 .iface = NID_MAPPING, \
11093 .name = "Master Playback Switch", \
11094 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011095 }
11096
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011097
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011098static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011099 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011100 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11101 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11102 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011103 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11104 HDA_OUTPUT),
11105 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11106 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011109 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011110 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11111 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011112 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011113 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11114 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11115 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11116 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011117 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11118 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11119 { } /* end */
11120};
11121
Kailang Yangcd7509a2007-01-26 18:33:17 +010011122static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011123 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011124 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11125 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11126 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11127 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011128 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11129 HDA_OUTPUT),
11130 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11131 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011132 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11133 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011134 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011135 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11136 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11137 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11138 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011139 { } /* end */
11140};
11141
11142static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11143 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11144 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011145 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011146 { } /* end */
11147};
11148
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011149/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011150static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011151{
11152 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011153
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011154 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011155 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011156}
11157
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011158static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011159 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11160 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011161 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11162 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11163 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11164 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11165 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11166 { } /* end */
11167};
11168
11169static struct hda_verb alc262_hp_t5735_verbs[] = {
11170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11171 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11172
11173 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11174 { }
11175};
11176
Kailang Yang8c427222008-01-10 13:03:59 +010011177static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011178 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11179 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011180 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11181 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011182 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11183 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11184 { } /* end */
11185};
11186
11187static struct hda_verb alc262_hp_rp5700_verbs[] = {
11188 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11189 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11190 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11191 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11192 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11193 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11194 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11196 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11198 {}
11199};
11200
11201static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11202 .num_items = 1,
11203 .items = {
11204 { "Line", 0x1 },
11205 },
11206};
11207
Takashi Iwai42171c12009-05-08 14:11:43 +020011208/* bind hp and internal speaker mute (with plug check) as master switch */
11209static void alc262_hippo_master_update(struct hda_codec *codec)
11210{
11211 struct alc_spec *spec = codec->spec;
11212 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11213 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11214 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11215 unsigned int mute;
11216
11217 /* HP */
11218 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11219 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11220 HDA_AMP_MUTE, mute);
11221 /* mute internal speaker per jack sense */
11222 if (spec->jack_present)
11223 mute = HDA_AMP_MUTE;
11224 if (line_nid)
11225 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11226 HDA_AMP_MUTE, mute);
11227 if (speaker_nid && speaker_nid != line_nid)
11228 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11229 HDA_AMP_MUTE, mute);
11230}
11231
11232#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11233
11234static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11235 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011236{
11237 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011238 struct alc_spec *spec = codec->spec;
11239 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011240
Takashi Iwai42171c12009-05-08 14:11:43 +020011241 if (val == spec->master_sw)
11242 return 0;
11243 spec->master_sw = val;
11244 alc262_hippo_master_update(codec);
11245 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011246}
Takashi Iwai5b319542007-07-26 11:49:22 +020011247
Takashi Iwai42171c12009-05-08 14:11:43 +020011248#define ALC262_HIPPO_MASTER_SWITCH \
11249 { \
11250 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11251 .name = "Master Playback Switch", \
11252 .info = snd_ctl_boolean_mono_info, \
11253 .get = alc262_hippo_master_sw_get, \
11254 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011255 }, \
11256 { \
11257 .iface = NID_MAPPING, \
11258 .name = "Master Playback Switch", \
11259 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11260 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011261 }
11262
11263static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11264 ALC262_HIPPO_MASTER_SWITCH,
11265 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11266 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11267 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11268 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11269 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11270 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11271 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11272 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11273 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11274 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11275 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11276 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11277 { } /* end */
11278};
11279
11280static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11281 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11282 ALC262_HIPPO_MASTER_SWITCH,
11283 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11284 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11285 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11286 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11287 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11288 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11289 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11290 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11291 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11292 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11293 { } /* end */
11294};
11295
11296/* mute/unmute internal speaker according to the hp jack and mute state */
11297static void alc262_hippo_automute(struct hda_codec *codec)
11298{
11299 struct alc_spec *spec = codec->spec;
11300 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011301
Wu Fengguang864f92b2009-11-18 12:38:02 +080011302 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011303 alc262_hippo_master_update(codec);
11304}
11305
11306static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11307{
11308 if ((res >> 26) != ALC880_HP_EVENT)
11309 return;
11310 alc262_hippo_automute(codec);
11311}
11312
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011313static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011314{
11315 struct alc_spec *spec = codec->spec;
11316
11317 spec->autocfg.hp_pins[0] = 0x15;
11318 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011319}
11320
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011321static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011322{
11323 struct alc_spec *spec = codec->spec;
11324
11325 spec->autocfg.hp_pins[0] = 0x1b;
11326 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011327}
11328
11329
Kailang Yang272a5272007-05-14 11:00:38 +020011330static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011331 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011332 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011333 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11334 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11335 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11336 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11337 { } /* end */
11338};
11339
Kailang Yang83c34212007-07-05 11:43:05 +020011340static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011341 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11342 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011343 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11344 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11345 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11346 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11347 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11348 { } /* end */
11349};
Kailang Yang272a5272007-05-14 11:00:38 +020011350
Tony Vroonba340e82009-02-02 19:01:30 +000011351static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11352 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11353 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11354 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11355 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11356 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11357 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11358 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11359 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11360 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11361 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11362 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11363 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11364 { } /* end */
11365};
11366
11367static struct hda_verb alc262_tyan_verbs[] = {
11368 /* Headphone automute */
11369 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11370 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11371 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11372
11373 /* P11 AUX_IN, white 4-pin connector */
11374 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11375 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11376 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11377 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11378
11379 {}
11380};
11381
11382/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011383static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011384{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011385 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011386
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011387 spec->autocfg.hp_pins[0] = 0x1b;
11388 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011389}
11390
Tony Vroonba340e82009-02-02 19:01:30 +000011391
Kailang Yangdf694da2005-12-05 19:42:22 +010011392#define alc262_capture_mixer alc882_capture_mixer
11393#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11394
11395/*
11396 * generic initialization of ADC, input mixers and output mixers
11397 */
11398static struct hda_verb alc262_init_verbs[] = {
11399 /*
11400 * Unmute ADC0-2 and set the default input to mic-in
11401 */
11402 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11404 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11405 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11406 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11407 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11408
Takashi Iwaicb53c622007-08-10 17:21:45 +020011409 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011410 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011411 * Note: PASD motherboards uses the Line In 2 as the input for
11412 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011413 */
11414 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011415 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11416 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11417 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11418 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11419 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011420
11421 /*
11422 * Set up output mixers (0x0c - 0x0e)
11423 */
11424 /* set vol=0 to output mixers */
11425 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11426 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11427 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11428 /* set up input amps for analog loopback */
11429 /* Amp Indices: DAC = 0, mixer = 1 */
11430 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11431 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11432 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11433 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11434 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11435 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11436
11437 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11439 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11440 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11441 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11442 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11443
11444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11445 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11446 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11447 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11448 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011449
Kailang Yangdf694da2005-12-05 19:42:22 +010011450 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11451 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011452
Kailang Yangdf694da2005-12-05 19:42:22 +010011453 /* FIXME: use matrix-type input source selection */
11454 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11455 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11456 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11457 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11458 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11459 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11460 /* Input mixer2 */
11461 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11462 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11463 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11464 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11465 /* Input mixer3 */
11466 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11467 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11468 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011469 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011470
11471 { }
11472};
11473
Kailang Yang4e555fe2008-08-26 13:05:55 +020011474static struct hda_verb alc262_eapd_verbs[] = {
11475 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11476 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11477 { }
11478};
11479
Kailang Yangccc656c2006-10-17 12:32:26 +020011480static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11481 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11482 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11483 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11484
11485 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11486 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11487 {}
11488};
11489
Kailang Yang272a5272007-05-14 11:00:38 +020011490static struct hda_verb alc262_sony_unsol_verbs[] = {
11491 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11492 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11493 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11494
11495 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11496 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011497 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011498};
11499
Kailang Yang4e555fe2008-08-26 13:05:55 +020011500static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11501 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11502 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11503 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11504 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11505 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011506 { } /* end */
11507};
11508
11509static struct hda_verb alc262_toshiba_s06_verbs[] = {
11510 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11511 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11512 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11513 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11514 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11515 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11516 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11517 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11518 {}
11519};
11520
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011521static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011522{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011523 struct alc_spec *spec = codec->spec;
11524
11525 spec->autocfg.hp_pins[0] = 0x15;
11526 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011527 spec->ext_mic.pin = 0x18;
11528 spec->ext_mic.mux_idx = 0;
11529 spec->int_mic.pin = 0x12;
11530 spec->int_mic.mux_idx = 9;
11531 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011532}
11533
Takashi Iwai834be882006-03-01 14:16:17 +010011534/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011535 * nec model
11536 * 0x15 = headphone
11537 * 0x16 = internal speaker
11538 * 0x18 = external mic
11539 */
11540
11541static struct snd_kcontrol_new alc262_nec_mixer[] = {
11542 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11543 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11544
11545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11547 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11548
11549 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11550 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11551 { } /* end */
11552};
11553
11554static struct hda_verb alc262_nec_verbs[] = {
11555 /* Unmute Speaker */
11556 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11557
11558 /* Headphone */
11559 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11560 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11561
11562 /* External mic to headphone */
11563 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11564 /* External mic to speaker */
11565 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11566 {}
11567};
11568
11569/*
Takashi Iwai834be882006-03-01 14:16:17 +010011570 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011571 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11572 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011573 */
11574
11575#define ALC_HP_EVENT 0x37
11576
11577static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11578 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11579 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011580 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11581 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011582 {}
11583};
11584
Jiang zhe0e31daf2008-03-20 12:12:39 +010011585static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11586 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11587 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11588 {}
11589};
11590
Daniel T Chene2595322009-12-19 18:19:02 -050011591static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11592 /* Front Mic pin: input vref at 50% */
11593 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11594 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11595 {}
11596};
11597
Takashi Iwai834be882006-03-01 14:16:17 +010011598static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011599 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011600 .items = {
11601 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011602 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011603 { "CD", 0x4 },
11604 },
11605};
11606
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011607static struct hda_input_mux alc262_HP_capture_source = {
11608 .num_items = 5,
11609 .items = {
11610 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011611 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011612 { "Line", 0x2 },
11613 { "CD", 0x4 },
11614 { "AUX IN", 0x6 },
11615 },
11616};
11617
zhejiangaccbe492007-08-31 12:36:05 +020011618static struct hda_input_mux alc262_HP_D7000_capture_source = {
11619 .num_items = 4,
11620 .items = {
11621 { "Mic", 0x0 },
11622 { "Front Mic", 0x2 },
11623 { "Line", 0x1 },
11624 { "CD", 0x4 },
11625 },
11626};
11627
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011628/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011629static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11630{
11631 struct alc_spec *spec = codec->spec;
11632 unsigned int mute;
11633
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011634 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011635 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11636 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011637 spec->sense_updated = 1;
11638 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011639 /* unmute internal speaker only if both HPs are unplugged and
11640 * master switch is on
11641 */
11642 if (spec->jack_present)
11643 mute = HDA_AMP_MUTE;
11644 else
Takashi Iwai834be882006-03-01 14:16:17 +010011645 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011646 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11647 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011648}
11649
11650/* unsolicited event for HP jack sensing */
11651static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11652 unsigned int res)
11653{
11654 if ((res >> 26) != ALC_HP_EVENT)
11655 return;
11656 alc262_fujitsu_automute(codec, 1);
11657}
11658
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011659static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11660{
11661 alc262_fujitsu_automute(codec, 1);
11662}
11663
Takashi Iwai834be882006-03-01 14:16:17 +010011664/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011665static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11666 .ops = &snd_hda_bind_vol,
11667 .values = {
11668 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11669 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11670 0
11671 },
11672};
Takashi Iwai834be882006-03-01 14:16:17 +010011673
Jiang zhe0e31daf2008-03-20 12:12:39 +010011674/* mute/unmute internal speaker according to the hp jack and mute state */
11675static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11676{
11677 struct alc_spec *spec = codec->spec;
11678 unsigned int mute;
11679
11680 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011681 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011682 spec->sense_updated = 1;
11683 }
11684 if (spec->jack_present) {
11685 /* mute internal speaker */
11686 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11687 HDA_AMP_MUTE, HDA_AMP_MUTE);
11688 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11689 HDA_AMP_MUTE, HDA_AMP_MUTE);
11690 } else {
11691 /* unmute internal speaker if necessary */
11692 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11693 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11694 HDA_AMP_MUTE, mute);
11695 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11696 HDA_AMP_MUTE, mute);
11697 }
11698}
11699
11700/* unsolicited event for HP jack sensing */
11701static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11702 unsigned int res)
11703{
11704 if ((res >> 26) != ALC_HP_EVENT)
11705 return;
11706 alc262_lenovo_3000_automute(codec, 1);
11707}
11708
Takashi Iwai8de56b72009-07-24 16:51:47 +020011709static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11710 int dir, int idx, long *valp)
11711{
11712 int i, change = 0;
11713
11714 for (i = 0; i < 2; i++, valp++)
11715 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11716 HDA_AMP_MUTE,
11717 *valp ? 0 : HDA_AMP_MUTE);
11718 return change;
11719}
11720
Takashi Iwai834be882006-03-01 14:16:17 +010011721/* bind hp and internal speaker mute (with plug check) */
11722static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11723 struct snd_ctl_elem_value *ucontrol)
11724{
11725 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11726 long *valp = ucontrol->value.integer.value;
11727 int change;
11728
Takashi Iwai8de56b72009-07-24 16:51:47 +020011729 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11730 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011731 if (change)
11732 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011733 return change;
11734}
11735
11736static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011737 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011738 {
11739 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11740 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011741 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011742 .info = snd_hda_mixer_amp_switch_info,
11743 .get = snd_hda_mixer_amp_switch_get,
11744 .put = alc262_fujitsu_master_sw_put,
11745 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11746 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011747 {
11748 .iface = NID_MAPPING,
11749 .name = "Master Playback Switch",
11750 .private_value = 0x1b,
11751 },
Takashi Iwai834be882006-03-01 14:16:17 +010011752 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11753 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11754 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11755 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11756 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011757 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11758 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11759 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011760 { } /* end */
11761};
11762
Jiang zhe0e31daf2008-03-20 12:12:39 +010011763/* bind hp and internal speaker mute (with plug check) */
11764static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11765 struct snd_ctl_elem_value *ucontrol)
11766{
11767 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11768 long *valp = ucontrol->value.integer.value;
11769 int change;
11770
Takashi Iwai8de56b72009-07-24 16:51:47 +020011771 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011772 if (change)
11773 alc262_lenovo_3000_automute(codec, 0);
11774 return change;
11775}
11776
11777static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11778 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11779 {
11780 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11781 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011782 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011783 .info = snd_hda_mixer_amp_switch_info,
11784 .get = snd_hda_mixer_amp_switch_get,
11785 .put = alc262_lenovo_3000_master_sw_put,
11786 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11787 },
11788 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11789 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11790 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11791 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11792 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11793 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11794 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11795 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11796 { } /* end */
11797};
11798
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011799static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11800 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011801 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11804 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11805 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11806 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11807 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11808 { } /* end */
11809};
11810
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011811/* additional init verbs for Benq laptops */
11812static struct hda_verb alc262_EAPD_verbs[] = {
11813 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11814 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11815 {}
11816};
11817
Kailang Yang83c34212007-07-05 11:43:05 +020011818static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11819 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11820 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11821
11822 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11823 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11824 {}
11825};
11826
Tobin Davisf651b502007-10-26 12:40:47 +020011827/* Samsung Q1 Ultra Vista model setup */
11828static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011829 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11830 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011831 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11832 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11833 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011834 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011835 { } /* end */
11836};
11837
11838static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011839 /* output mixer */
11840 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11841 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11842 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11843 /* speaker */
11844 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11845 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11846 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11847 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11848 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011849 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011850 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11851 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11852 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11853 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11854 /* internal mic */
11855 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11856 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11857 /* ADC, choose mic */
11858 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11859 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11860 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11861 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11862 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11863 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11864 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11865 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11866 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11867 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011868 {}
11869};
11870
Tobin Davisf651b502007-10-26 12:40:47 +020011871/* mute/unmute internal speaker according to the hp jack and mute state */
11872static void alc262_ultra_automute(struct hda_codec *codec)
11873{
11874 struct alc_spec *spec = codec->spec;
11875 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011876
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011877 mute = 0;
11878 /* auto-mute only when HP is used as HP */
11879 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011880 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011881 if (spec->jack_present)
11882 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011883 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011884 /* mute/unmute internal speaker */
11885 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11886 HDA_AMP_MUTE, mute);
11887 /* mute/unmute HP */
11888 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11889 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011890}
11891
11892/* unsolicited event for HP jack sensing */
11893static void alc262_ultra_unsol_event(struct hda_codec *codec,
11894 unsigned int res)
11895{
11896 if ((res >> 26) != ALC880_HP_EVENT)
11897 return;
11898 alc262_ultra_automute(codec);
11899}
11900
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011901static struct hda_input_mux alc262_ultra_capture_source = {
11902 .num_items = 2,
11903 .items = {
11904 { "Mic", 0x1 },
11905 { "Headphone", 0x7 },
11906 },
11907};
11908
11909static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11910 struct snd_ctl_elem_value *ucontrol)
11911{
11912 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11913 struct alc_spec *spec = codec->spec;
11914 int ret;
11915
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011916 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011917 if (!ret)
11918 return 0;
11919 /* reprogram the HP pin as mic or HP according to the input source */
11920 snd_hda_codec_write_cache(codec, 0x15, 0,
11921 AC_VERB_SET_PIN_WIDGET_CONTROL,
11922 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
11923 alc262_ultra_automute(codec); /* mute/unmute HP */
11924 return ret;
11925}
11926
11927static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
11928 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
11929 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
11930 {
11931 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11932 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011933 .info = alc_mux_enum_info,
11934 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011935 .put = alc262_ultra_mux_enum_put,
11936 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011937 {
11938 .iface = NID_MAPPING,
11939 .name = "Capture Source",
11940 .private_value = 0x15,
11941 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011942 { } /* end */
11943};
11944
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011945/* We use two mixers depending on the output pin; 0x16 is a mono output
11946 * and thus it's bound with a different mixer.
11947 * This function returns which mixer amp should be used.
11948 */
11949static int alc262_check_volbit(hda_nid_t nid)
11950{
11951 if (!nid)
11952 return 0;
11953 else if (nid == 0x16)
11954 return 2;
11955 else
11956 return 1;
11957}
11958
11959static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011960 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011961{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011962 unsigned long val;
11963 int vbit;
11964
11965 vbit = alc262_check_volbit(nid);
11966 if (!vbit)
11967 return 0;
11968 if (*vbits & vbit) /* a volume control for this mixer already there */
11969 return 0;
11970 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011971 if (vbit == 2)
11972 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
11973 else
11974 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011975 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011976}
11977
11978static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020011979 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011980{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011981 unsigned long val;
11982
11983 if (!nid)
11984 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011985 if (nid == 0x16)
11986 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
11987 else
11988 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020011989 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011990}
11991
Kailang Yangdf694da2005-12-05 19:42:22 +010011992/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011993static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
11994 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010011995{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020011996 const char *pfx;
11997 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020011998 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010011999
12000 spec->multiout.num_dacs = 1; /* only use one dac */
12001 spec->multiout.dac_nids = spec->private_dac_nids;
12002 spec->multiout.dac_nids[0] = 2;
12003
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012004 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
12005 pfx = "Master";
12006 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12007 pfx = "Speaker";
Takashi Iwai033688a2010-09-08 15:47:09 +020012008 else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
12009 pfx = "Headphone";
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012010 else
12011 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012012 for (i = 0; i < 2; i++) {
12013 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12014 if (err < 0)
12015 return err;
12016 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12017 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12018 "Speaker", i);
12019 if (err < 0)
12020 return err;
12021 }
12022 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12023 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12024 "Headphone", i);
12025 if (err < 0)
12026 return err;
12027 }
12028 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012029
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012030 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12031 alc262_check_volbit(cfg->speaker_pins[0]) |
12032 alc262_check_volbit(cfg->hp_pins[0]);
12033 if (vbits == 1 || vbits == 2)
12034 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012035 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012036 for (i = 0; i < 2; i++) {
12037 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12038 &vbits, i);
12039 if (err < 0)
12040 return err;
12041 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12042 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12043 "Speaker", &vbits, i);
12044 if (err < 0)
12045 return err;
12046 }
12047 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12048 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12049 "Headphone", &vbits, i);
12050 if (err < 0)
12051 return err;
12052 }
12053 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012054 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012055}
12056
Takashi Iwai05f5f472009-08-25 13:10:18 +020012057#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012058 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012059
12060/*
12061 * generic initialization of ADC, input mixers and output mixers
12062 */
12063static struct hda_verb alc262_volume_init_verbs[] = {
12064 /*
12065 * Unmute ADC0-2 and set the default input to mic-in
12066 */
12067 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12068 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12069 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12070 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12071 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12072 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12073
Takashi Iwaicb53c622007-08-10 17:21:45 +020012074 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012075 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012076 * Note: PASD motherboards uses the Line In 2 as the input for
12077 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012078 */
12079 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012080 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12081 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12082 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12083 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12084 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012085
12086 /*
12087 * Set up output mixers (0x0c - 0x0f)
12088 */
12089 /* set vol=0 to output mixers */
12090 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12091 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12092 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012093
Kailang Yangdf694da2005-12-05 19:42:22 +010012094 /* set up input amps for analog loopback */
12095 /* Amp Indices: DAC = 0, mixer = 1 */
12096 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12097 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12098 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12099 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12100 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12101 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12102
12103 /* FIXME: use matrix-type input source selection */
12104 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12105 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12106 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12107 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12108 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12109 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12110 /* Input mixer2 */
12111 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12112 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12113 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12114 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12115 /* Input mixer3 */
12116 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12117 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12118 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12119 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12120
12121 { }
12122};
12123
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012124static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12125 /*
12126 * Unmute ADC0-2 and set the default input to mic-in
12127 */
12128 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12129 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12130 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12131 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12132 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12133 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12134
Takashi Iwaicb53c622007-08-10 17:21:45 +020012135 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012136 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012137 * Note: PASD motherboards uses the Line In 2 as the input for
12138 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012139 */
12140 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012141 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12142 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12143 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12144 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12145 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12146 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12147 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012148
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012149 /*
12150 * Set up output mixers (0x0c - 0x0e)
12151 */
12152 /* set vol=0 to output mixers */
12153 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12154 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12155 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12156
12157 /* set up input amps for analog loopback */
12158 /* Amp Indices: DAC = 0, mixer = 1 */
12159 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12160 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12161 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12162 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12163 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12164 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12165
Takashi Iwaice875f02008-01-28 18:17:43 +010012166 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012167 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12168 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12169
12170 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12171 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12172
12173 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12174 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12175
12176 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12177 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12178 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12179 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12180 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12181
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012182 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012183 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12184 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012185 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012186 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12187 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12188
12189
12190 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012191 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12192 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012193 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012194 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12195 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12196 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12197 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12198 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012202 /* Input mixer2 */
12203 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012204 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12205 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12206 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12207 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12208 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12209 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12210 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12211 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012212 /* Input mixer3 */
12213 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012214 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12215 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12216 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12217 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12218 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12219 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12220 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012222
Takashi Iwaice875f02008-01-28 18:17:43 +010012223 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12224
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012225 { }
12226};
12227
Kailang Yangcd7509a2007-01-26 18:33:17 +010012228static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12229 /*
12230 * Unmute ADC0-2 and set the default input to mic-in
12231 */
12232 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12234 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12235 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12236 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12237 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12238
Takashi Iwaicb53c622007-08-10 17:21:45 +020012239 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012240 * mixer widget
12241 * Note: PASD motherboards uses the Line In 2 as the input for front
12242 * panel mic (mic 2)
12243 */
12244 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012245 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12246 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12247 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12248 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12249 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12250 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12251 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12252 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012253 /*
12254 * Set up output mixers (0x0c - 0x0e)
12255 */
12256 /* set vol=0 to output mixers */
12257 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12258 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12259 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12260
12261 /* set up input amps for analog loopback */
12262 /* Amp Indices: DAC = 0, mixer = 1 */
12263 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12265 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12266 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12267 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12268 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12269
12270
12271 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12272 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12273 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12274 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12275 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12276 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12277 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12278
12279 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12280 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12281
12282 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12283 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12284
12285 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12286 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12287 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12288 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12289 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12290 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12291
12292 /* FIXME: use matrix-type input source selection */
12293 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12294 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12295 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12296 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12297 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12298 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12299 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12300 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12301 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12302 /* Input mixer2 */
12303 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12304 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12305 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12306 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12307 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12308 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12309 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12310 /* Input mixer3 */
12311 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12312 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12313 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12314 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12315 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12316 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12317 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12318
Takashi Iwaice875f02008-01-28 18:17:43 +010012319 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12320
Kailang Yangcd7509a2007-01-26 18:33:17 +010012321 { }
12322};
12323
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012324static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12325
12326 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12327 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12328 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12329
12330 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12331 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12332 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12333 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12334
12335 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12336 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12337 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12338 {}
12339};
12340
Takashi Iwai18675e42010-09-08 15:55:44 +020012341/*
12342 * Pin config fixes
12343 */
12344enum {
12345 PINFIX_FSC_H270,
12346};
12347
12348static const struct alc_fixup alc262_fixups[] = {
12349 [PINFIX_FSC_H270] = {
12350 .pins = (const struct alc_pincfg[]) {
12351 { 0x14, 0x99130110 }, /* speaker */
12352 { 0x15, 0x0221142f }, /* front HP */
12353 { 0x1b, 0x0121141f }, /* rear HP */
12354 { }
12355 }
12356 },
12357 [PINFIX_PB_M5210] = {
12358 .verbs = (const struct hda_verb[]) {
12359 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12360 {}
12361 }
12362 },
12363};
12364
12365static struct snd_pci_quirk alc262_fixup_tbl[] = {
12366 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12367 {}
12368};
12369
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012370
Takashi Iwaicb53c622007-08-10 17:21:45 +020012371#ifdef CONFIG_SND_HDA_POWER_SAVE
12372#define alc262_loopbacks alc880_loopbacks
12373#endif
12374
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012375/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012376#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12377#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12378#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12379#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12380
12381/*
12382 * BIOS auto configuration
12383 */
12384static int alc262_parse_auto_config(struct hda_codec *codec)
12385{
12386 struct alc_spec *spec = codec->spec;
12387 int err;
12388 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12389
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012390 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12391 alc262_ignore);
12392 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012393 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012394 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012395 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012396 spec->multiout.max_channels = 2;
12397 spec->no_analog = 1;
12398 goto dig_only;
12399 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012400 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012401 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012402 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12403 if (err < 0)
12404 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012405 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012406 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012407 return err;
12408
12409 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12410
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012411 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012412 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012413
Takashi Iwai603c4012008-07-30 15:01:44 +020012414 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012415 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012416
Takashi Iwaid88897e2008-10-31 15:01:37 +010012417 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012418 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012419 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012420
Takashi Iwai776e1842007-08-29 15:07:11 +020012421 err = alc_auto_add_mic_boost(codec);
12422 if (err < 0)
12423 return err;
12424
Kailang Yang6227cdc2010-02-25 08:36:52 +010012425 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012426
Kailang Yangdf694da2005-12-05 19:42:22 +010012427 return 1;
12428}
12429
12430#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12431#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12432#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012433#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012434
12435
12436/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012437static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012438{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012439 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012440 alc262_auto_init_multi_out(codec);
12441 alc262_auto_init_hp_out(codec);
12442 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012443 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012444 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012445 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012446 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012447}
12448
12449/*
12450 * configuration and preset
12451 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012452static const char *alc262_models[ALC262_MODEL_LAST] = {
12453 [ALC262_BASIC] = "basic",
12454 [ALC262_HIPPO] = "hippo",
12455 [ALC262_HIPPO_1] = "hippo_1",
12456 [ALC262_FUJITSU] = "fujitsu",
12457 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012458 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012459 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012460 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012461 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012462 [ALC262_BENQ_T31] = "benq-t31",
12463 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012464 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012465 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012466 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012467 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012468 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012469 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012470 [ALC262_AUTO] = "auto",
12471};
12472
12473static struct snd_pci_quirk alc262_cfg_tbl[] = {
12474 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012475 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012476 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12477 ALC262_HP_BPC),
12478 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12479 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012480 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12481 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012482 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012483 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012484 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012485 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012486 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012487 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012488 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012489 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012490 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12491 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12492 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012493 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12494 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012495 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012496 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012497 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012498 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012499 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012500 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012501 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012502 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012503#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012504 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12505 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012506#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012507 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012508 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012509 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012510 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012511 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012512 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012513 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12514 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012515 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012516 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012517 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012518 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012519 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012520 {}
12521};
12522
12523static struct alc_config_preset alc262_presets[] = {
12524 [ALC262_BASIC] = {
12525 .mixers = { alc262_base_mixer },
12526 .init_verbs = { alc262_init_verbs },
12527 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12528 .dac_nids = alc262_dac_nids,
12529 .hp_nid = 0x03,
12530 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12531 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012532 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012533 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012534 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012535 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012536 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012537 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12538 .dac_nids = alc262_dac_nids,
12539 .hp_nid = 0x03,
12540 .dig_out_nid = ALC262_DIGOUT_NID,
12541 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12542 .channel_mode = alc262_modes,
12543 .input_mux = &alc262_capture_source,
12544 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012545 .setup = alc262_hippo_setup,
12546 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012547 },
12548 [ALC262_HIPPO_1] = {
12549 .mixers = { alc262_hippo1_mixer },
12550 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12551 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12552 .dac_nids = alc262_dac_nids,
12553 .hp_nid = 0x02,
12554 .dig_out_nid = ALC262_DIGOUT_NID,
12555 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12556 .channel_mode = alc262_modes,
12557 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012558 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012559 .setup = alc262_hippo1_setup,
12560 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012561 },
Takashi Iwai834be882006-03-01 14:16:17 +010012562 [ALC262_FUJITSU] = {
12563 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012564 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12565 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012566 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12567 .dac_nids = alc262_dac_nids,
12568 .hp_nid = 0x03,
12569 .dig_out_nid = ALC262_DIGOUT_NID,
12570 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12571 .channel_mode = alc262_modes,
12572 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012573 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012574 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012575 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012576 [ALC262_HP_BPC] = {
12577 .mixers = { alc262_HP_BPC_mixer },
12578 .init_verbs = { alc262_HP_BPC_init_verbs },
12579 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12580 .dac_nids = alc262_dac_nids,
12581 .hp_nid = 0x03,
12582 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12583 .channel_mode = alc262_modes,
12584 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012585 .unsol_event = alc262_hp_bpc_unsol_event,
12586 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012587 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012588 [ALC262_HP_BPC_D7000_WF] = {
12589 .mixers = { alc262_HP_BPC_WildWest_mixer },
12590 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12591 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12592 .dac_nids = alc262_dac_nids,
12593 .hp_nid = 0x03,
12594 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12595 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012596 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012597 .unsol_event = alc262_hp_wildwest_unsol_event,
12598 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012599 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012600 [ALC262_HP_BPC_D7000_WL] = {
12601 .mixers = { alc262_HP_BPC_WildWest_mixer,
12602 alc262_HP_BPC_WildWest_option_mixer },
12603 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12604 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12605 .dac_nids = alc262_dac_nids,
12606 .hp_nid = 0x03,
12607 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12608 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012609 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012610 .unsol_event = alc262_hp_wildwest_unsol_event,
12611 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012612 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012613 [ALC262_HP_TC_T5735] = {
12614 .mixers = { alc262_hp_t5735_mixer },
12615 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12616 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12617 .dac_nids = alc262_dac_nids,
12618 .hp_nid = 0x03,
12619 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12620 .channel_mode = alc262_modes,
12621 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012622 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012623 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012624 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012625 },
12626 [ALC262_HP_RP5700] = {
12627 .mixers = { alc262_hp_rp5700_mixer },
12628 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12629 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12630 .dac_nids = alc262_dac_nids,
12631 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12632 .channel_mode = alc262_modes,
12633 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012634 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012635 [ALC262_BENQ_ED8] = {
12636 .mixers = { alc262_base_mixer },
12637 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12638 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12639 .dac_nids = alc262_dac_nids,
12640 .hp_nid = 0x03,
12641 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12642 .channel_mode = alc262_modes,
12643 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012644 },
Kailang Yang272a5272007-05-14 11:00:38 +020012645 [ALC262_SONY_ASSAMD] = {
12646 .mixers = { alc262_sony_mixer },
12647 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12648 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12649 .dac_nids = alc262_dac_nids,
12650 .hp_nid = 0x02,
12651 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12652 .channel_mode = alc262_modes,
12653 .input_mux = &alc262_capture_source,
12654 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012655 .setup = alc262_hippo_setup,
12656 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012657 },
12658 [ALC262_BENQ_T31] = {
12659 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012660 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12661 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012662 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12663 .dac_nids = alc262_dac_nids,
12664 .hp_nid = 0x03,
12665 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12666 .channel_mode = alc262_modes,
12667 .input_mux = &alc262_capture_source,
12668 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012669 .setup = alc262_hippo_setup,
12670 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012671 },
Tobin Davisf651b502007-10-26 12:40:47 +020012672 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012673 .mixers = { alc262_ultra_mixer },
12674 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012675 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012676 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12677 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012678 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12679 .channel_mode = alc262_modes,
12680 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012681 .adc_nids = alc262_adc_nids, /* ADC0 */
12682 .capsrc_nids = alc262_capsrc_nids,
12683 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012684 .unsol_event = alc262_ultra_unsol_event,
12685 .init_hook = alc262_ultra_automute,
12686 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012687 [ALC262_LENOVO_3000] = {
12688 .mixers = { alc262_lenovo_3000_mixer },
12689 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012690 alc262_lenovo_3000_unsol_verbs,
12691 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012692 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12693 .dac_nids = alc262_dac_nids,
12694 .hp_nid = 0x03,
12695 .dig_out_nid = ALC262_DIGOUT_NID,
12696 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12697 .channel_mode = alc262_modes,
12698 .input_mux = &alc262_fujitsu_capture_source,
12699 .unsol_event = alc262_lenovo_3000_unsol_event,
12700 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012701 [ALC262_NEC] = {
12702 .mixers = { alc262_nec_mixer },
12703 .init_verbs = { alc262_nec_verbs },
12704 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12705 .dac_nids = alc262_dac_nids,
12706 .hp_nid = 0x03,
12707 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12708 .channel_mode = alc262_modes,
12709 .input_mux = &alc262_capture_source,
12710 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012711 [ALC262_TOSHIBA_S06] = {
12712 .mixers = { alc262_toshiba_s06_mixer },
12713 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12714 alc262_eapd_verbs },
12715 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12716 .capsrc_nids = alc262_dmic_capsrc_nids,
12717 .dac_nids = alc262_dac_nids,
12718 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012719 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012720 .dig_out_nid = ALC262_DIGOUT_NID,
12721 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12722 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012723 .unsol_event = alc_sku_unsol_event,
12724 .setup = alc262_toshiba_s06_setup,
12725 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012726 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012727 [ALC262_TOSHIBA_RX1] = {
12728 .mixers = { alc262_toshiba_rx1_mixer },
12729 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12730 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12731 .dac_nids = alc262_dac_nids,
12732 .hp_nid = 0x03,
12733 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12734 .channel_mode = alc262_modes,
12735 .input_mux = &alc262_capture_source,
12736 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012737 .setup = alc262_hippo_setup,
12738 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012739 },
Tony Vroonba340e82009-02-02 19:01:30 +000012740 [ALC262_TYAN] = {
12741 .mixers = { alc262_tyan_mixer },
12742 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12743 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12744 .dac_nids = alc262_dac_nids,
12745 .hp_nid = 0x02,
12746 .dig_out_nid = ALC262_DIGOUT_NID,
12747 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12748 .channel_mode = alc262_modes,
12749 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012750 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012751 .setup = alc262_tyan_setup,
12752 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012753 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012754};
12755
12756static int patch_alc262(struct hda_codec *codec)
12757{
12758 struct alc_spec *spec;
12759 int board_config;
12760 int err;
12761
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012762 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012763 if (spec == NULL)
12764 return -ENOMEM;
12765
12766 codec->spec = spec;
12767#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012768 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12769 * under-run
12770 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012771 {
12772 int tmp;
12773 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12774 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12775 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12776 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12777 }
12778#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012779 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012780
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012781 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12782
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012783 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12784 alc262_models,
12785 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012786
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012787 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012788 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12789 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012790 board_config = ALC262_AUTO;
12791 }
12792
Takashi Iwai18675e42010-09-08 15:55:44 +020012793 if (board_config == ALC262_AUTO)
12794 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12795
Kailang Yangdf694da2005-12-05 19:42:22 +010012796 if (board_config == ALC262_AUTO) {
12797 /* automatic parse from the BIOS config */
12798 err = alc262_parse_auto_config(codec);
12799 if (err < 0) {
12800 alc_free(codec);
12801 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012802 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012803 printk(KERN_INFO
12804 "hda_codec: Cannot set up configuration "
12805 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012806 board_config = ALC262_BASIC;
12807 }
12808 }
12809
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012810 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012811 err = snd_hda_attach_beep_device(codec, 0x1);
12812 if (err < 0) {
12813 alc_free(codec);
12814 return err;
12815 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012816 }
12817
Kailang Yangdf694da2005-12-05 19:42:22 +010012818 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012819 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012820
Kailang Yangdf694da2005-12-05 19:42:22 +010012821 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12822 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012823
Kailang Yangdf694da2005-12-05 19:42:22 +010012824 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12825 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12826
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012827 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012828 int i;
12829 /* check whether the digital-mic has to be supported */
12830 for (i = 0; i < spec->input_mux->num_items; i++) {
12831 if (spec->input_mux->items[i].index >= 9)
12832 break;
12833 }
12834 if (i < spec->input_mux->num_items) {
12835 /* use only ADC0 */
12836 spec->adc_nids = alc262_dmic_adc_nids;
12837 spec->num_adc_nids = 1;
12838 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012839 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012840 /* all analog inputs */
12841 /* check whether NID 0x07 is valid */
12842 unsigned int wcap = get_wcaps(codec, 0x07);
12843
12844 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012845 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012846 if (wcap != AC_WID_AUD_IN) {
12847 spec->adc_nids = alc262_adc_nids_alt;
12848 spec->num_adc_nids =
12849 ARRAY_SIZE(alc262_adc_nids_alt);
12850 spec->capsrc_nids = alc262_capsrc_nids_alt;
12851 } else {
12852 spec->adc_nids = alc262_adc_nids;
12853 spec->num_adc_nids =
12854 ARRAY_SIZE(alc262_adc_nids);
12855 spec->capsrc_nids = alc262_capsrc_nids;
12856 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012857 }
12858 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012859 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012860 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012861 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012862 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012863
Takashi Iwai18675e42010-09-08 15:55:44 +020012864 if (board_config == ALC262_AUTO)
12865 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12866
Takashi Iwai2134ea42008-01-10 16:53:55 +010012867 spec->vmaster_nid = 0x0c;
12868
Kailang Yangdf694da2005-12-05 19:42:22 +010012869 codec->patch_ops = alc_patch_ops;
12870 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012871 spec->init_hook = alc262_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020012872#ifdef CONFIG_SND_HDA_POWER_SAVE
12873 if (!spec->loopback.amplist)
12874 spec->loopback.amplist = alc262_loopbacks;
12875#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012876
Kailang Yangdf694da2005-12-05 19:42:22 +010012877 return 0;
12878}
12879
Kailang Yangdf694da2005-12-05 19:42:22 +010012880/*
Kailang Yanga361d842007-06-05 12:30:55 +020012881 * ALC268 channel source setting (2 channel)
12882 */
12883#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12884#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012885
Kailang Yanga361d842007-06-05 12:30:55 +020012886static hda_nid_t alc268_dac_nids[2] = {
12887 /* front, hp */
12888 0x02, 0x03
12889};
12890
12891static hda_nid_t alc268_adc_nids[2] = {
12892 /* ADC0-1 */
12893 0x08, 0x07
12894};
12895
12896static hda_nid_t alc268_adc_nids_alt[1] = {
12897 /* ADC0 */
12898 0x08
12899};
12900
Takashi Iwaie1406342008-02-11 18:32:32 +010012901static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12902
Kailang Yanga361d842007-06-05 12:30:55 +020012903static struct snd_kcontrol_new alc268_base_mixer[] = {
12904 /* output mixer control */
12905 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12906 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12907 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12908 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012909 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12910 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12911 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012912 { }
12913};
12914
Takashi Iwai42171c12009-05-08 14:11:43 +020012915static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12916 /* output mixer control */
12917 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12918 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12919 ALC262_HIPPO_MASTER_SWITCH,
12920 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12921 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12922 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
12923 { }
12924};
12925
Takashi Iwaiaef9d312008-02-19 13:16:41 +010012926/* bind Beep switches of both NID 0x0f and 0x10 */
12927static struct hda_bind_ctls alc268_bind_beep_sw = {
12928 .ops = &snd_hda_bind_sw,
12929 .values = {
12930 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
12931 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
12932 0
12933 },
12934};
12935
12936static struct snd_kcontrol_new alc268_beep_mixer[] = {
12937 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
12938 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
12939 { }
12940};
12941
Kailang Yangd1a991a2007-08-15 16:21:59 +020012942static struct hda_verb alc268_eapd_verbs[] = {
12943 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
12944 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
12945 { }
12946};
12947
Takashi Iwaid2738092007-08-16 14:59:45 +020012948/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020012949static struct hda_verb alc268_toshiba_verbs[] = {
12950 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12951 { } /* end */
12952};
12953
12954/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020012955/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020012956static struct hda_bind_ctls alc268_acer_bind_master_vol = {
12957 .ops = &snd_hda_bind_vol,
12958 .values = {
12959 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
12960 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
12961 0
12962 },
12963};
12964
Takashi Iwai889c4392007-08-23 18:56:52 +020012965/* mute/unmute internal speaker according to the hp jack and mute state */
12966static void alc268_acer_automute(struct hda_codec *codec, int force)
12967{
12968 struct alc_spec *spec = codec->spec;
12969 unsigned int mute;
12970
12971 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012972 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020012973 spec->sense_updated = 1;
12974 }
12975 if (spec->jack_present)
12976 mute = HDA_AMP_MUTE; /* mute internal speaker */
12977 else /* unmute internal speaker if necessary */
12978 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
12979 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12980 HDA_AMP_MUTE, mute);
12981}
12982
12983
12984/* bind hp and internal speaker mute (with plug check) */
12985static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
12986 struct snd_ctl_elem_value *ucontrol)
12987{
12988 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12989 long *valp = ucontrol->value.integer.value;
12990 int change;
12991
Takashi Iwai8de56b72009-07-24 16:51:47 +020012992 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020012993 if (change)
12994 alc268_acer_automute(codec, 0);
12995 return change;
12996}
Takashi Iwaid2738092007-08-16 14:59:45 +020012997
Kailang Yang8ef355d2008-08-26 13:10:22 +020012998static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
12999 /* output mixer control */
13000 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13001 {
13002 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13003 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013004 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013005 .info = snd_hda_mixer_amp_switch_info,
13006 .get = snd_hda_mixer_amp_switch_get,
13007 .put = alc268_acer_master_sw_put,
13008 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13009 },
13010 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13011 { }
13012};
13013
Takashi Iwaid2738092007-08-16 14:59:45 +020013014static struct snd_kcontrol_new alc268_acer_mixer[] = {
13015 /* output mixer control */
13016 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13017 {
13018 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13019 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013020 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013021 .info = snd_hda_mixer_amp_switch_info,
13022 .get = snd_hda_mixer_amp_switch_get,
13023 .put = alc268_acer_master_sw_put,
13024 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13025 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020013026 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13027 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13028 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013029 { }
13030};
13031
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013032static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13033 /* output mixer control */
13034 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13035 {
13036 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13037 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013038 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013039 .info = snd_hda_mixer_amp_switch_info,
13040 .get = snd_hda_mixer_amp_switch_get,
13041 .put = alc268_acer_master_sw_put,
13042 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13043 },
13044 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13045 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13046 { }
13047};
13048
Kailang Yang8ef355d2008-08-26 13:10:22 +020013049static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13050 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13051 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13052 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13053 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13054 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13055 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13056 { }
13057};
13058
Takashi Iwaid2738092007-08-16 14:59:45 +020013059static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013060 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13061 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013062 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13063 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013064 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13065 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013066 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13067 { }
13068};
13069
13070/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013071#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013072#define alc268_toshiba_setup alc262_hippo_setup
13073#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013074
13075static void alc268_acer_unsol_event(struct hda_codec *codec,
13076 unsigned int res)
13077{
Takashi Iwai889c4392007-08-23 18:56:52 +020013078 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013079 return;
13080 alc268_acer_automute(codec, 1);
13081}
13082
Takashi Iwai889c4392007-08-23 18:56:52 +020013083static void alc268_acer_init_hook(struct hda_codec *codec)
13084{
13085 alc268_acer_automute(codec, 1);
13086}
13087
Kailang Yang8ef355d2008-08-26 13:10:22 +020013088/* toggle speaker-output according to the hp-jack state */
13089static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13090{
13091 unsigned int present;
13092 unsigned char bits;
13093
Wu Fengguang864f92b2009-11-18 12:38:02 +080013094 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013095 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013096 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013097 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013098 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013099 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013100}
13101
Kailang Yang8ef355d2008-08-26 13:10:22 +020013102static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13103 unsigned int res)
13104{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013105 switch (res >> 26) {
13106 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013107 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013108 break;
13109 case ALC880_MIC_EVENT:
13110 alc_mic_automute(codec);
13111 break;
13112 }
13113}
13114
13115static void alc268_acer_lc_setup(struct hda_codec *codec)
13116{
13117 struct alc_spec *spec = codec->spec;
13118 spec->ext_mic.pin = 0x18;
13119 spec->ext_mic.mux_idx = 0;
13120 spec->int_mic.pin = 0x12;
13121 spec->int_mic.mux_idx = 6;
13122 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013123}
13124
13125static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13126{
13127 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013128 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013129}
13130
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013131static struct snd_kcontrol_new alc268_dell_mixer[] = {
13132 /* output mixer control */
13133 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13134 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13135 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13136 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13137 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13138 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13139 { }
13140};
13141
13142static struct hda_verb alc268_dell_verbs[] = {
13143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13144 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13145 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013146 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013147 { }
13148};
13149
13150/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013151static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013152{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013153 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013154
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013155 spec->autocfg.hp_pins[0] = 0x15;
13156 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013157 spec->ext_mic.pin = 0x18;
13158 spec->ext_mic.mux_idx = 0;
13159 spec->int_mic.pin = 0x19;
13160 spec->int_mic.mux_idx = 1;
13161 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013162}
13163
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013164static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13165 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13166 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13167 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13168 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13169 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13170 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13171 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13172 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13173 { }
13174};
13175
13176static struct hda_verb alc267_quanta_il1_verbs[] = {
13177 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13178 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13179 { }
13180};
13181
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013182static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013183{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013184 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013185 spec->autocfg.hp_pins[0] = 0x15;
13186 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013187 spec->ext_mic.pin = 0x18;
13188 spec->ext_mic.mux_idx = 0;
13189 spec->int_mic.pin = 0x19;
13190 spec->int_mic.mux_idx = 1;
13191 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013192}
13193
Kailang Yanga361d842007-06-05 12:30:55 +020013194/*
13195 * generic initialization of ADC, input mixers and output mixers
13196 */
13197static struct hda_verb alc268_base_init_verbs[] = {
13198 /* Unmute DAC0-1 and set vol = 0 */
13199 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013200 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013201
13202 /*
13203 * Set up output mixers (0x0c - 0x0e)
13204 */
13205 /* set vol=0 to output mixers */
13206 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013207 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13208
13209 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13210 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13211
13212 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13213 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13214 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13215 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13216 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13217 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13218 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13219 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13220
13221 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13222 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13223 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13224 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013225 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013226
13227 /* set PCBEEP vol = 0, mute connections */
13228 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13229 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13230 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013231
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013232 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013233
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013234 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13236 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13237 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013238
Kailang Yanga361d842007-06-05 12:30:55 +020013239 { }
13240};
13241
13242/*
13243 * generic initialization of ADC, input mixers and output mixers
13244 */
13245static struct hda_verb alc268_volume_init_verbs[] = {
13246 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013247 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13248 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013249
13250 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13251 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13252 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13253 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13254 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13255
Kailang Yanga361d842007-06-05 12:30:55 +020013256 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013257 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13258 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13259
13260 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013261 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013262
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013263 /* set PCBEEP vol = 0, mute connections */
13264 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13265 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13266 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013267
13268 { }
13269};
13270
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013271static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13272 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13273 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13274 { } /* end */
13275};
13276
Kailang Yanga361d842007-06-05 12:30:55 +020013277static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13278 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13279 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013280 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013281 { } /* end */
13282};
13283
13284static struct snd_kcontrol_new alc268_capture_mixer[] = {
13285 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13286 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13287 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13288 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013289 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013290 { } /* end */
13291};
13292
13293static struct hda_input_mux alc268_capture_source = {
13294 .num_items = 4,
13295 .items = {
13296 { "Mic", 0x0 },
13297 { "Front Mic", 0x1 },
13298 { "Line", 0x2 },
13299 { "CD", 0x3 },
13300 },
13301};
13302
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013303static struct hda_input_mux alc268_acer_capture_source = {
13304 .num_items = 3,
13305 .items = {
13306 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013307 { "Internal Mic", 0x1 },
13308 { "Line", 0x2 },
13309 },
13310};
13311
13312static struct hda_input_mux alc268_acer_dmic_capture_source = {
13313 .num_items = 3,
13314 .items = {
13315 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013316 { "Internal Mic", 0x6 },
13317 { "Line", 0x2 },
13318 },
13319};
13320
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013321#ifdef CONFIG_SND_DEBUG
13322static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013323 /* Volume widgets */
13324 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13325 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13326 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13327 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13328 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13329 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13330 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13331 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13332 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13333 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13334 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13335 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13336 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013337 /* The below appears problematic on some hardwares */
13338 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013339 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13340 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13341 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13342 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13343
13344 /* Modes for retasking pin widgets */
13345 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13346 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13347 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13348 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13349
13350 /* Controls for GPIO pins, assuming they are configured as outputs */
13351 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13352 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13353 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13354 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13355
13356 /* Switches to allow the digital SPDIF output pin to be enabled.
13357 * The ALC268 does not have an SPDIF input.
13358 */
13359 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13360
13361 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13362 * this output to turn on an external amplifier.
13363 */
13364 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13365 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13366
13367 { } /* end */
13368};
13369#endif
13370
Kailang Yanga361d842007-06-05 12:30:55 +020013371/* create input playback/capture controls for the given pin */
13372static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13373 const char *ctlname, int idx)
13374{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013375 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013376 int err;
13377
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013378 switch (nid) {
13379 case 0x14:
13380 case 0x16:
13381 dac = 0x02;
13382 break;
13383 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013384 case 0x1a: /* ALC259/269 only */
13385 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013386 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013387 dac = 0x03;
13388 break;
13389 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013390 snd_printd(KERN_WARNING "hda_codec: "
13391 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013392 return 0;
13393 }
13394 if (spec->multiout.dac_nids[0] != dac &&
13395 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013396 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013397 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013398 HDA_OUTPUT));
13399 if (err < 0)
13400 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013401 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13402 }
13403
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013404 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013405 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013406 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013407 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013408 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013409 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013410 if (err < 0)
13411 return err;
13412 return 0;
13413}
13414
13415/* add playback controls from the parsed DAC table */
13416static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13417 const struct auto_pin_cfg *cfg)
13418{
13419 hda_nid_t nid;
13420 int err;
13421
Kailang Yanga361d842007-06-05 12:30:55 +020013422 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013423
13424 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013425 if (nid) {
13426 const char *name;
13427 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13428 name = "Speaker";
13429 else
13430 name = "Front";
13431 err = alc268_new_analog_output(spec, nid, name, 0);
13432 if (err < 0)
13433 return err;
13434 }
Kailang Yanga361d842007-06-05 12:30:55 +020013435
13436 nid = cfg->speaker_pins[0];
13437 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013438 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013439 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13440 if (err < 0)
13441 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013442 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013443 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13444 if (err < 0)
13445 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013446 }
13447 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013448 if (nid) {
13449 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13450 if (err < 0)
13451 return err;
13452 }
Kailang Yanga361d842007-06-05 12:30:55 +020013453
13454 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13455 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013456 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013457 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013458 if (err < 0)
13459 return err;
13460 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013461 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013462}
13463
13464/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013465static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013466 const struct auto_pin_cfg *cfg)
13467{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013468 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013469}
13470
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013471static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13472 hda_nid_t nid, int pin_type)
13473{
13474 int idx;
13475
13476 alc_set_pin_output(codec, nid, pin_type);
13477 if (nid == 0x14 || nid == 0x16)
13478 idx = 0;
13479 else
13480 idx = 1;
13481 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13482}
13483
13484static void alc268_auto_init_multi_out(struct hda_codec *codec)
13485{
13486 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013487 int i;
13488
13489 for (i = 0; i < spec->autocfg.line_outs; i++) {
13490 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013491 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13492 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13493 }
13494}
13495
13496static void alc268_auto_init_hp_out(struct hda_codec *codec)
13497{
13498 struct alc_spec *spec = codec->spec;
13499 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013500 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013501
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013502 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13503 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013504 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013505 }
13506 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13507 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013508 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013509 }
13510 if (spec->autocfg.mono_out_pin)
13511 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13512 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013513}
13514
Kailang Yanga361d842007-06-05 12:30:55 +020013515static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13516{
13517 struct alc_spec *spec = codec->spec;
13518 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13519 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13520 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13521 unsigned int dac_vol1, dac_vol2;
13522
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013523 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013524 snd_hda_codec_write(codec, speaker_nid, 0,
13525 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013526 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013527 snd_hda_codec_write(codec, 0x0f, 0,
13528 AC_VERB_SET_AMP_GAIN_MUTE,
13529 AMP_IN_UNMUTE(1));
13530 snd_hda_codec_write(codec, 0x10, 0,
13531 AC_VERB_SET_AMP_GAIN_MUTE,
13532 AMP_IN_UNMUTE(1));
13533 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013534 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013535 snd_hda_codec_write(codec, 0x0f, 0,
13536 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13537 snd_hda_codec_write(codec, 0x10, 0,
13538 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13539 }
13540
13541 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013542 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013543 dac_vol2 = AMP_OUT_ZERO;
13544 else if (line_nid == 0x15)
13545 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013546 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013547 dac_vol2 = AMP_OUT_ZERO;
13548 else if (hp_nid == 0x15)
13549 dac_vol1 = AMP_OUT_ZERO;
13550 if (line_nid != 0x16 || hp_nid != 0x16 ||
13551 spec->autocfg.line_out_pins[1] != 0x16 ||
13552 spec->autocfg.line_out_pins[2] != 0x16)
13553 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13554
13555 snd_hda_codec_write(codec, 0x02, 0,
13556 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13557 snd_hda_codec_write(codec, 0x03, 0,
13558 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13559}
13560
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013561/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013562#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13563#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013564#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013565#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13566
13567/*
13568 * BIOS auto configuration
13569 */
13570static int alc268_parse_auto_config(struct hda_codec *codec)
13571{
13572 struct alc_spec *spec = codec->spec;
13573 int err;
13574 static hda_nid_t alc268_ignore[] = { 0 };
13575
13576 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13577 alc268_ignore);
13578 if (err < 0)
13579 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013580 if (!spec->autocfg.line_outs) {
13581 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13582 spec->multiout.max_channels = 2;
13583 spec->no_analog = 1;
13584 goto dig_only;
13585 }
Kailang Yanga361d842007-06-05 12:30:55 +020013586 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013587 }
Kailang Yanga361d842007-06-05 12:30:55 +020013588 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13589 if (err < 0)
13590 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013591 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013592 if (err < 0)
13593 return err;
13594
13595 spec->multiout.max_channels = 2;
13596
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013597 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013598 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013599 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013600 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013601 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013602
Takashi Iwai892981f2009-03-02 08:04:35 +010013603 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013604 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013605
Takashi Iwaid88897e2008-10-31 15:01:37 +010013606 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013607 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013608 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013609
Takashi Iwai776e1842007-08-29 15:07:11 +020013610 err = alc_auto_add_mic_boost(codec);
13611 if (err < 0)
13612 return err;
13613
Kailang Yang6227cdc2010-02-25 08:36:52 +010013614 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013615
Kailang Yanga361d842007-06-05 12:30:55 +020013616 return 1;
13617}
13618
Kailang Yanga361d842007-06-05 12:30:55 +020013619#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13620
13621/* init callback for auto-configuration model -- overriding the default init */
13622static void alc268_auto_init(struct hda_codec *codec)
13623{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013624 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013625 alc268_auto_init_multi_out(codec);
13626 alc268_auto_init_hp_out(codec);
13627 alc268_auto_init_mono_speaker_out(codec);
13628 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013629 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013630 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013631 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013632}
13633
13634/*
13635 * configuration and preset
13636 */
13637static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013638 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013639 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013640 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013641 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013642 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013643 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013644 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013645 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013646#ifdef CONFIG_SND_DEBUG
13647 [ALC268_TEST] = "test",
13648#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013649 [ALC268_AUTO] = "auto",
13650};
13651
13652static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013653 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013654 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013655 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013656 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013657 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013658 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13659 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013660 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013661 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13662 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013663 /* almost compatible with toshiba but with optional digital outs;
13664 * auto-probing seems working fine
13665 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013666 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013667 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013668 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013669 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013670 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013671 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013672 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013673 {}
13674};
13675
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013676/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13677static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13678 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13679 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13680 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13681 ALC268_TOSHIBA),
13682 {}
13683};
13684
Kailang Yanga361d842007-06-05 12:30:55 +020013685static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013686 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013687 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13688 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013689 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13690 alc267_quanta_il1_verbs },
13691 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13692 .dac_nids = alc268_dac_nids,
13693 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13694 .adc_nids = alc268_adc_nids_alt,
13695 .hp_nid = 0x03,
13696 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13697 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013698 .unsol_event = alc_sku_unsol_event,
13699 .setup = alc267_quanta_il1_setup,
13700 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013701 },
Kailang Yanga361d842007-06-05 12:30:55 +020013702 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013703 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13704 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013705 .init_verbs = { alc268_base_init_verbs },
13706 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13707 .dac_nids = alc268_dac_nids,
13708 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13709 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013710 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013711 .hp_nid = 0x03,
13712 .dig_out_nid = ALC268_DIGOUT_NID,
13713 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13714 .channel_mode = alc268_modes,
13715 .input_mux = &alc268_capture_source,
13716 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013717 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013718 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013719 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013720 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13721 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013722 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13723 .dac_nids = alc268_dac_nids,
13724 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13725 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013726 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013727 .hp_nid = 0x03,
13728 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13729 .channel_mode = alc268_modes,
13730 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013731 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013732 .setup = alc268_toshiba_setup,
13733 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013734 },
13735 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013736 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013737 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013738 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13739 alc268_acer_verbs },
13740 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13741 .dac_nids = alc268_dac_nids,
13742 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13743 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013744 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013745 .hp_nid = 0x02,
13746 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13747 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013748 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013749 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013750 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013751 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013752 [ALC268_ACER_DMIC] = {
13753 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13754 alc268_beep_mixer },
13755 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13756 alc268_acer_verbs },
13757 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13758 .dac_nids = alc268_dac_nids,
13759 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13760 .adc_nids = alc268_adc_nids_alt,
13761 .capsrc_nids = alc268_capsrc_nids,
13762 .hp_nid = 0x02,
13763 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13764 .channel_mode = alc268_modes,
13765 .input_mux = &alc268_acer_dmic_capture_source,
13766 .unsol_event = alc268_acer_unsol_event,
13767 .init_hook = alc268_acer_init_hook,
13768 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013769 [ALC268_ACER_ASPIRE_ONE] = {
13770 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013771 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013772 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013773 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13774 alc268_acer_aspire_one_verbs },
13775 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13776 .dac_nids = alc268_dac_nids,
13777 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13778 .adc_nids = alc268_adc_nids_alt,
13779 .capsrc_nids = alc268_capsrc_nids,
13780 .hp_nid = 0x03,
13781 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13782 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013783 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013784 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013785 .init_hook = alc268_acer_lc_init_hook,
13786 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013787 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013788 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13789 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013790 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13791 alc268_dell_verbs },
13792 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13793 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013794 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13795 .adc_nids = alc268_adc_nids_alt,
13796 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013797 .hp_nid = 0x02,
13798 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13799 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013800 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013801 .setup = alc268_dell_setup,
13802 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013803 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013804 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013805 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13806 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013807 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13808 alc268_toshiba_verbs },
13809 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13810 .dac_nids = alc268_dac_nids,
13811 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13812 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013813 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013814 .hp_nid = 0x03,
13815 .dig_out_nid = ALC268_DIGOUT_NID,
13816 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13817 .channel_mode = alc268_modes,
13818 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013819 .setup = alc268_toshiba_setup,
13820 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013821 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013822#ifdef CONFIG_SND_DEBUG
13823 [ALC268_TEST] = {
13824 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13825 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13826 alc268_volume_init_verbs },
13827 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13828 .dac_nids = alc268_dac_nids,
13829 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13830 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013831 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013832 .hp_nid = 0x03,
13833 .dig_out_nid = ALC268_DIGOUT_NID,
13834 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13835 .channel_mode = alc268_modes,
13836 .input_mux = &alc268_capture_source,
13837 },
13838#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013839};
13840
13841static int patch_alc268(struct hda_codec *codec)
13842{
13843 struct alc_spec *spec;
13844 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013845 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013846
Julia Lawallef86f582009-12-19 08:18:03 +010013847 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013848 if (spec == NULL)
13849 return -ENOMEM;
13850
13851 codec->spec = spec;
13852
13853 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13854 alc268_models,
13855 alc268_cfg_tbl);
13856
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013857 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13858 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013859 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013860
Kailang Yanga361d842007-06-05 12:30:55 +020013861 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013862 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13863 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013864 board_config = ALC268_AUTO;
13865 }
13866
13867 if (board_config == ALC268_AUTO) {
13868 /* automatic parse from the BIOS config */
13869 err = alc268_parse_auto_config(codec);
13870 if (err < 0) {
13871 alc_free(codec);
13872 return err;
13873 } else if (!err) {
13874 printk(KERN_INFO
13875 "hda_codec: Cannot set up configuration "
13876 "from BIOS. Using base mode...\n");
13877 board_config = ALC268_3ST;
13878 }
13879 }
13880
13881 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013882 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013883
Kailang Yanga361d842007-06-05 12:30:55 +020013884 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13885 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013886 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013887
Kailang Yanga361d842007-06-05 12:30:55 +020013888 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13889
Takashi Iwai22971e32009-02-10 11:56:44 +010013890 has_beep = 0;
13891 for (i = 0; i < spec->num_mixers; i++) {
13892 if (spec->mixers[i] == alc268_beep_mixer) {
13893 has_beep = 1;
13894 break;
13895 }
13896 }
13897
13898 if (has_beep) {
13899 err = snd_hda_attach_beep_device(codec, 0x1);
13900 if (err < 0) {
13901 alc_free(codec);
13902 return err;
13903 }
13904 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13905 /* override the amp caps for beep generator */
13906 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013907 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13908 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13909 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13910 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013911 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013912
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013913 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013914 /* check whether NID 0x07 is valid */
13915 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013916 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013917
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013918 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013919 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020013920 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013921 if (spec->auto_mic ||
13922 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013923 spec->adc_nids = alc268_adc_nids_alt;
13924 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020013925 if (spec->auto_mic)
13926 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013927 if (spec->auto_mic || spec->input_mux->num_items == 1)
13928 add_mixer(spec, alc268_capture_nosrc_mixer);
13929 else
13930 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013931 } else {
13932 spec->adc_nids = alc268_adc_nids;
13933 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010013934 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020013935 }
Takashi Iwai85860c02008-02-19 15:00:15 +010013936 /* set default input source */
13937 for (i = 0; i < spec->num_adc_nids; i++)
13938 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
13939 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013940 i < spec->num_mux_defs ?
13941 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010013942 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020013943 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010013944
13945 spec->vmaster_nid = 0x02;
13946
Kailang Yanga361d842007-06-05 12:30:55 +020013947 codec->patch_ops = alc_patch_ops;
13948 if (board_config == ALC268_AUTO)
13949 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020013950
Kailang Yanga361d842007-06-05 12:30:55 +020013951 return 0;
13952}
13953
13954/*
Kailang Yangf6a92242007-12-13 16:52:54 +010013955 * ALC269 channel source setting (2 channel)
13956 */
13957#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
13958
13959#define alc269_dac_nids alc260_dac_nids
13960
13961static hda_nid_t alc269_adc_nids[1] = {
13962 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020013963 0x08,
13964};
13965
Takashi Iwaie01bf502008-08-21 16:25:07 +020013966static hda_nid_t alc269_capsrc_nids[1] = {
13967 0x23,
13968};
13969
Kailang Yang84898e82010-02-04 14:16:14 +010013970static hda_nid_t alc269vb_adc_nids[1] = {
13971 /* ADC1 */
13972 0x09,
13973};
13974
13975static hda_nid_t alc269vb_capsrc_nids[1] = {
13976 0x22,
13977};
13978
Takashi Iwai66946352010-03-29 17:21:45 +020013979static hda_nid_t alc269_adc_candidates[] = {
13980 0x08, 0x09, 0x07,
13981};
Takashi Iwaie01bf502008-08-21 16:25:07 +020013982
Kailang Yangf6a92242007-12-13 16:52:54 +010013983#define alc269_modes alc260_modes
13984#define alc269_capture_source alc880_lg_lw_capture_source
13985
13986static struct snd_kcontrol_new alc269_base_mixer[] = {
13987 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13988 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13989 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
13990 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
13991 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
13992 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
13993 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13994 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
13995 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
13996 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13997 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13998 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
13999 { } /* end */
14000};
14001
Kailang Yang60db6b52008-08-26 13:13:00 +020014002static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14003 /* output mixer control */
14004 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14005 {
14006 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14007 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014008 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014009 .info = snd_hda_mixer_amp_switch_info,
14010 .get = snd_hda_mixer_amp_switch_get,
14011 .put = alc268_acer_master_sw_put,
14012 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14013 },
14014 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14015 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14016 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14017 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14018 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14019 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014020 { }
14021};
14022
Tony Vroon64154832008-11-06 15:08:49 +000014023static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14024 /* output mixer control */
14025 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14026 {
14027 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14028 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014029 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014030 .info = snd_hda_mixer_amp_switch_info,
14031 .get = snd_hda_mixer_amp_switch_get,
14032 .put = alc268_acer_master_sw_put,
14033 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14034 },
14035 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14036 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14037 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14038 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14039 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14040 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
14041 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14042 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
14043 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014044 { }
14045};
14046
Kailang Yang84898e82010-02-04 14:16:14 +010014047static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014048 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014049 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014050 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014051 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014052 { } /* end */
14053};
14054
Kailang Yang84898e82010-02-04 14:16:14 +010014055static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14056 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14057 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14058 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14059 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14060 { } /* end */
14061};
14062
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014063static struct snd_kcontrol_new alc269_asus_mixer[] = {
14064 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14065 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14066 { } /* end */
14067};
14068
Kailang Yangf6a92242007-12-13 16:52:54 +010014069/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014070static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14071 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14072 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14073 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14074 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14075 { } /* end */
14076};
14077
14078static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014079 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14080 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014081 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14082 { } /* end */
14083};
14084
Kailang Yang84898e82010-02-04 14:16:14 +010014085static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14086 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14087 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14088 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14089 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14090 { } /* end */
14091};
14092
14093static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14094 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14095 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14096 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14097 { } /* end */
14098};
14099
Takashi Iwai26f5df22008-11-03 17:39:46 +010014100/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014101#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014102
Kailang Yang60db6b52008-08-26 13:13:00 +020014103static struct hda_verb alc269_quanta_fl1_verbs[] = {
14104 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14105 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14106 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14107 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14108 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14109 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14110 { }
14111};
14112
Tony Vroon64154832008-11-06 15:08:49 +000014113static struct hda_verb alc269_lifebook_verbs[] = {
14114 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14115 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14116 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14117 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14118 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14119 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14120 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14121 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14122 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14123 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14124 { }
14125};
14126
Kailang Yang60db6b52008-08-26 13:13:00 +020014127/* toggle speaker-output according to the hp-jack state */
14128static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14129{
14130 unsigned int present;
14131 unsigned char bits;
14132
Wu Fengguang864f92b2009-11-18 12:38:02 +080014133 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014134 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014135 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014136 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014137 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014138 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014139
14140 snd_hda_codec_write(codec, 0x20, 0,
14141 AC_VERB_SET_COEF_INDEX, 0x0c);
14142 snd_hda_codec_write(codec, 0x20, 0,
14143 AC_VERB_SET_PROC_COEF, 0x680);
14144
14145 snd_hda_codec_write(codec, 0x20, 0,
14146 AC_VERB_SET_COEF_INDEX, 0x0c);
14147 snd_hda_codec_write(codec, 0x20, 0,
14148 AC_VERB_SET_PROC_COEF, 0x480);
14149}
14150
Tony Vroon64154832008-11-06 15:08:49 +000014151/* toggle speaker-output according to the hp-jacks state */
14152static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14153{
14154 unsigned int present;
14155 unsigned char bits;
14156
14157 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014158 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014159
14160 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014161 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014162
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014163 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014164 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014165 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014166 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014167 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014168
14169 snd_hda_codec_write(codec, 0x20, 0,
14170 AC_VERB_SET_COEF_INDEX, 0x0c);
14171 snd_hda_codec_write(codec, 0x20, 0,
14172 AC_VERB_SET_PROC_COEF, 0x680);
14173
14174 snd_hda_codec_write(codec, 0x20, 0,
14175 AC_VERB_SET_COEF_INDEX, 0x0c);
14176 snd_hda_codec_write(codec, 0x20, 0,
14177 AC_VERB_SET_PROC_COEF, 0x480);
14178}
14179
Tony Vroon64154832008-11-06 15:08:49 +000014180static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14181{
14182 unsigned int present_laptop;
14183 unsigned int present_dock;
14184
Wu Fengguang864f92b2009-11-18 12:38:02 +080014185 present_laptop = snd_hda_jack_detect(codec, 0x18);
14186 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014187
14188 /* Laptop mic port overrides dock mic port, design decision */
14189 if (present_dock)
14190 snd_hda_codec_write(codec, 0x23, 0,
14191 AC_VERB_SET_CONNECT_SEL, 0x3);
14192 if (present_laptop)
14193 snd_hda_codec_write(codec, 0x23, 0,
14194 AC_VERB_SET_CONNECT_SEL, 0x0);
14195 if (!present_dock && !present_laptop)
14196 snd_hda_codec_write(codec, 0x23, 0,
14197 AC_VERB_SET_CONNECT_SEL, 0x1);
14198}
14199
Kailang Yang60db6b52008-08-26 13:13:00 +020014200static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14201 unsigned int res)
14202{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014203 switch (res >> 26) {
14204 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014205 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014206 break;
14207 case ALC880_MIC_EVENT:
14208 alc_mic_automute(codec);
14209 break;
14210 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014211}
14212
Tony Vroon64154832008-11-06 15:08:49 +000014213static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14214 unsigned int res)
14215{
14216 if ((res >> 26) == ALC880_HP_EVENT)
14217 alc269_lifebook_speaker_automute(codec);
14218 if ((res >> 26) == ALC880_MIC_EVENT)
14219 alc269_lifebook_mic_autoswitch(codec);
14220}
14221
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014222static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14223{
14224 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014225 spec->autocfg.hp_pins[0] = 0x15;
14226 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014227 spec->ext_mic.pin = 0x18;
14228 spec->ext_mic.mux_idx = 0;
14229 spec->int_mic.pin = 0x19;
14230 spec->int_mic.mux_idx = 1;
14231 spec->auto_mic = 1;
14232}
14233
Kailang Yang60db6b52008-08-26 13:13:00 +020014234static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14235{
14236 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014237 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014238}
14239
Tony Vroon64154832008-11-06 15:08:49 +000014240static void alc269_lifebook_init_hook(struct hda_codec *codec)
14241{
14242 alc269_lifebook_speaker_automute(codec);
14243 alc269_lifebook_mic_autoswitch(codec);
14244}
14245
Kailang Yang84898e82010-02-04 14:16:14 +010014246static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014247 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14248 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14249 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14250 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14251 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14252 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14253 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14254 {}
14255};
14256
Kailang Yang84898e82010-02-04 14:16:14 +010014257static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014258 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14259 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14260 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14261 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14262 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14263 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14264 {}
14265};
14266
Kailang Yang84898e82010-02-04 14:16:14 +010014267static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14268 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14269 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14270 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14271 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14272 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14273 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14274 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14275 {}
14276};
14277
14278static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14279 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14280 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14281 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14282 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14283 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14284 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14285 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14286 {}
14287};
14288
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014289static struct hda_verb alc271_acer_dmic_verbs[] = {
14290 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14291 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14292 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14293 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14294 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14295 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14296 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14297 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14298 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14299 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14300 { }
14301};
14302
Kailang Yang60db6b52008-08-26 13:13:00 +020014303/* toggle speaker-output according to the hp-jack state */
14304static void alc269_speaker_automute(struct hda_codec *codec)
14305{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014306 struct alc_spec *spec = codec->spec;
14307 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014308 unsigned int present;
14309 unsigned char bits;
14310
Kailang Yangebb83ee2009-12-17 12:23:00 +010014311 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014312 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014313 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014314 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014315 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014316 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014317}
14318
Kailang Yang60db6b52008-08-26 13:13:00 +020014319/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014320static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014321 unsigned int res)
14322{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014323 switch (res >> 26) {
14324 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014325 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014326 break;
14327 case ALC880_MIC_EVENT:
14328 alc_mic_automute(codec);
14329 break;
14330 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014331}
14332
Kailang Yang226b1ec2010-04-09 11:01:20 +020014333static void alc269_laptop_amic_setup(struct hda_codec *codec)
14334{
14335 struct alc_spec *spec = codec->spec;
14336 spec->autocfg.hp_pins[0] = 0x15;
14337 spec->autocfg.speaker_pins[0] = 0x14;
14338 spec->ext_mic.pin = 0x18;
14339 spec->ext_mic.mux_idx = 0;
14340 spec->int_mic.pin = 0x19;
14341 spec->int_mic.mux_idx = 1;
14342 spec->auto_mic = 1;
14343}
14344
Kailang Yang84898e82010-02-04 14:16:14 +010014345static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014346{
14347 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014348 spec->autocfg.hp_pins[0] = 0x15;
14349 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014350 spec->ext_mic.pin = 0x18;
14351 spec->ext_mic.mux_idx = 0;
14352 spec->int_mic.pin = 0x12;
14353 spec->int_mic.mux_idx = 5;
14354 spec->auto_mic = 1;
14355}
14356
Kailang Yang226b1ec2010-04-09 11:01:20 +020014357static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014358{
14359 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014360 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014361 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014362 spec->ext_mic.pin = 0x18;
14363 spec->ext_mic.mux_idx = 0;
14364 spec->int_mic.pin = 0x19;
14365 spec->int_mic.mux_idx = 1;
14366 spec->auto_mic = 1;
14367}
14368
Kailang Yang226b1ec2010-04-09 11:01:20 +020014369static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14370{
14371 struct alc_spec *spec = codec->spec;
14372 spec->autocfg.hp_pins[0] = 0x21;
14373 spec->autocfg.speaker_pins[0] = 0x14;
14374 spec->ext_mic.pin = 0x18;
14375 spec->ext_mic.mux_idx = 0;
14376 spec->int_mic.pin = 0x12;
14377 spec->int_mic.mux_idx = 6;
14378 spec->auto_mic = 1;
14379}
14380
Kailang Yang84898e82010-02-04 14:16:14 +010014381static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014382{
14383 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014384 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014385}
14386
Kailang Yangf6a92242007-12-13 16:52:54 +010014387/*
14388 * generic initialization of ADC, input mixers and output mixers
14389 */
14390static struct hda_verb alc269_init_verbs[] = {
14391 /*
14392 * Unmute ADC0 and set the default input to mic-in
14393 */
Kailang Yang84898e82010-02-04 14:16:14 +010014394 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014395
14396 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014397 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014398 */
14399 /* set vol=0 to output mixers */
14400 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14401 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14402
14403 /* set up input amps for analog loopback */
14404 /* Amp Indices: DAC = 0, mixer = 1 */
14405 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14406 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14407 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14409 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14410 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14411
14412 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14413 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14414 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14415 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14416 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14417 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14418 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14419
14420 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14421 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014422
Kailang Yang84898e82010-02-04 14:16:14 +010014423 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014424 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14425 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014426 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014427
14428 /* set EAPD */
14429 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014430 { }
14431};
14432
14433static struct hda_verb alc269vb_init_verbs[] = {
14434 /*
14435 * Unmute ADC0 and set the default input to mic-in
14436 */
14437 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14438
14439 /*
14440 * Set up output mixers (0x02 - 0x03)
14441 */
14442 /* set vol=0 to output mixers */
14443 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14444 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14445
14446 /* set up input amps for analog loopback */
14447 /* Amp Indices: DAC = 0, mixer = 1 */
14448 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14449 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14450 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14451 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14452 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14453 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14454
14455 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14456 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14457 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14458 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14459 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14460 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14461 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14462
14463 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14464 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14465
14466 /* FIXME: use Mux-type input source selection */
14467 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14468 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14469 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14470
14471 /* set EAPD */
14472 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014473 { }
14474};
14475
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014476#define alc269_auto_create_multi_out_ctls \
14477 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014478#define alc269_auto_create_input_ctls \
14479 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014480
14481#ifdef CONFIG_SND_HDA_POWER_SAVE
14482#define alc269_loopbacks alc880_loopbacks
14483#endif
14484
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014485/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014486#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14487#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14488#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14489#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14490
Takashi Iwaif03d3112009-03-05 14:18:16 +010014491static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14492 .substreams = 1,
14493 .channels_min = 2,
14494 .channels_max = 8,
14495 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14496 /* NID is set in alc_build_pcms */
14497 .ops = {
14498 .open = alc880_playback_pcm_open,
14499 .prepare = alc880_playback_pcm_prepare,
14500 .cleanup = alc880_playback_pcm_cleanup
14501 },
14502};
14503
14504static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14505 .substreams = 1,
14506 .channels_min = 2,
14507 .channels_max = 2,
14508 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14509 /* NID is set in alc_build_pcms */
14510};
14511
Takashi Iwaiad358792010-03-30 18:00:59 +020014512#ifdef CONFIG_SND_HDA_POWER_SAVE
14513static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14514{
14515 switch (codec->subsystem_id) {
14516 case 0x103c1586:
14517 return 1;
14518 }
14519 return 0;
14520}
14521
14522static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14523{
14524 /* update mute-LED according to the speaker mute state */
14525 if (nid == 0x01 || nid == 0x14) {
14526 int pinval;
14527 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14528 HDA_AMP_MUTE)
14529 pinval = 0x24;
14530 else
14531 pinval = 0x20;
14532 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014533 snd_hda_codec_update_cache(codec, 0x19, 0,
14534 AC_VERB_SET_PIN_WIDGET_CONTROL,
14535 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014536 }
14537 return alc_check_power_status(codec, nid);
14538}
14539#endif /* CONFIG_SND_HDA_POWER_SAVE */
14540
Takashi Iwai840b64c2010-07-13 22:49:01 +020014541static int alc275_setup_dual_adc(struct hda_codec *codec)
14542{
14543 struct alc_spec *spec = codec->spec;
14544
14545 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14546 return 0;
14547 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14548 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14549 if (spec->ext_mic.pin <= 0x12) {
14550 spec->private_adc_nids[0] = 0x08;
14551 spec->private_adc_nids[1] = 0x11;
14552 spec->private_capsrc_nids[0] = 0x23;
14553 spec->private_capsrc_nids[1] = 0x22;
14554 } else {
14555 spec->private_adc_nids[0] = 0x11;
14556 spec->private_adc_nids[1] = 0x08;
14557 spec->private_capsrc_nids[0] = 0x22;
14558 spec->private_capsrc_nids[1] = 0x23;
14559 }
14560 spec->adc_nids = spec->private_adc_nids;
14561 spec->capsrc_nids = spec->private_capsrc_nids;
14562 spec->num_adc_nids = 2;
14563 spec->dual_adc_switch = 1;
14564 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14565 spec->adc_nids[0], spec->adc_nids[1]);
14566 return 1;
14567 }
14568 return 0;
14569}
14570
Kailang Yangf6a92242007-12-13 16:52:54 +010014571/*
14572 * BIOS auto configuration
14573 */
14574static int alc269_parse_auto_config(struct hda_codec *codec)
14575{
14576 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014577 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014578 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14579
14580 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14581 alc269_ignore);
14582 if (err < 0)
14583 return err;
14584
14585 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14586 if (err < 0)
14587 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020014588 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yangf6a92242007-12-13 16:52:54 +010014589 if (err < 0)
14590 return err;
14591
14592 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14593
Takashi Iwai757899a2010-07-30 10:48:14 +020014594 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014595
Takashi Iwai603c4012008-07-30 15:01:44 +020014596 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014597 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014598
Kailang Yang84898e82010-02-04 14:16:14 +010014599 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010) {
14600 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014601 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014602 } else {
14603 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014604 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014605 }
14606
Kailang Yangf6a92242007-12-13 16:52:54 +010014607 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014608 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014609
14610 if (!alc275_setup_dual_adc(codec))
14611 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14612 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014613
Takashi Iwaie01bf502008-08-21 16:25:07 +020014614 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014615 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014616 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14617 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014618
14619 err = alc_auto_add_mic_boost(codec);
14620 if (err < 0)
14621 return err;
14622
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014623 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014624 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014625
Kailang Yangf6a92242007-12-13 16:52:54 +010014626 return 1;
14627}
14628
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014629#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14630#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014631#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14632
14633
14634/* init callback for auto-configuration model -- overriding the default init */
14635static void alc269_auto_init(struct hda_codec *codec)
14636{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014637 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014638 alc269_auto_init_multi_out(codec);
14639 alc269_auto_init_hp_out(codec);
14640 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014641 alc_auto_init_digital(codec);
Kailang Yang9ad0e492010-09-14 23:22:00 +020014642 alc_init_jacks(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014643 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014644 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014645}
14646
Kailang Yang977ddd62010-09-15 10:02:29 +020014647#ifdef CONFIG_SND_HDA_POWER_SAVE
14648static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14649{
14650 struct alc_spec *spec = codec->spec;
14651 int val;
14652
14653 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14654 val = alc_read_coef_idx(codec, 0x04);
14655 /* Power down output pin */
14656 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14657 }
14658
14659 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14660 val = alc_read_coef_idx(codec, 0x04);
14661 /* Power down output pin */
14662 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14663 msleep(150);
14664 }
14665
14666 alc_shutup(codec);
14667 if (spec && spec->power_hook)
14668 spec->power_hook(codec);
14669 return 0;
14670}
14671#endif
14672#ifdef SND_HDA_NEEDS_RESUME
14673static int alc269_resume(struct hda_codec *codec)
14674{
14675 int val;
14676
14677 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14678 val = alc_read_coef_idx(codec, 0x04);
14679 /* Power down output pin */
14680 alc_write_coef_idx(codec, 0x04, val & ~(1<<11));
14681 msleep(150);
14682 }
14683
14684 codec->patch_ops.init(codec);
14685
14686 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14687 val = alc_read_coef_idx(codec, 0x04);
14688 /* Power up output pin */
14689 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14690 msleep(200);
14691 }
14692
14693 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14694 val = alc_read_coef_idx(codec, 0x04);
14695 /* Power up output pin */
14696 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14697 }
14698
14699 snd_hda_codec_resume_amp(codec);
14700 snd_hda_codec_resume_cache(codec);
14701#ifdef CONFIG_SND_HDA_POWER_SAVE
14702 if (codec->patch_ops.check_power_status)
14703 codec->patch_ops.check_power_status(codec, 0x01);
14704#endif
14705 return 0;
14706}
14707#endif
14708
Takashi Iwaiff818c22010-04-12 08:59:25 +020014709enum {
14710 ALC269_FIXUP_SONY_VAIO,
14711};
14712
Takashi Iwaiff818c22010-04-12 08:59:25 +020014713static const struct alc_fixup alc269_fixups[] = {
14714 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014715 .verbs = (const struct hda_verb[]) {
14716 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14717 {}
14718 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014719 },
14720};
14721
14722static struct snd_pci_quirk alc269_fixup_tbl[] = {
14723 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningssondbbcbc02010-08-23 08:14:35 +020014724 SND_PCI_QUIRK(0x104d, 0x9077, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014725 {}
14726};
14727
14728
Kailang Yangf6a92242007-12-13 16:52:54 +010014729/*
14730 * configuration and preset
14731 */
14732static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014733 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014734 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014735 [ALC269_AMIC] = "laptop-amic",
14736 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014737 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014738 [ALC269_LIFEBOOK] = "lifebook",
14739 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014740};
14741
14742static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014743 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014744 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014745 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014746 ALC269_AMIC),
14747 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14748 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14749 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14750 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14751 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14752 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14753 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14754 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14755 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14756 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14757 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14758 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14759 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14760 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14761 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14762 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14763 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14764 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14765 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14766 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14767 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14768 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14769 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14770 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14771 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14772 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14773 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14774 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14775 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14776 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14777 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14778 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14779 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14780 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14781 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14782 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014783 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014784 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014785 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014786 ALC269_DMIC),
14787 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14788 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014789 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014790 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014791 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14792 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14793 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14794 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14795 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14796 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014797 {}
14798};
14799
14800static struct alc_config_preset alc269_presets[] = {
14801 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014802 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014803 .init_verbs = { alc269_init_verbs },
14804 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14805 .dac_nids = alc269_dac_nids,
14806 .hp_nid = 0x03,
14807 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14808 .channel_mode = alc269_modes,
14809 .input_mux = &alc269_capture_source,
14810 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014811 [ALC269_QUANTA_FL1] = {
14812 .mixers = { alc269_quanta_fl1_mixer },
14813 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14814 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14815 .dac_nids = alc269_dac_nids,
14816 .hp_nid = 0x03,
14817 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14818 .channel_mode = alc269_modes,
14819 .input_mux = &alc269_capture_source,
14820 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014821 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014822 .init_hook = alc269_quanta_fl1_init_hook,
14823 },
Kailang Yang84898e82010-02-04 14:16:14 +010014824 [ALC269_AMIC] = {
14825 .mixers = { alc269_laptop_mixer },
14826 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014827 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014828 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014829 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14830 .dac_nids = alc269_dac_nids,
14831 .hp_nid = 0x03,
14832 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14833 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014834 .unsol_event = alc269_laptop_unsol_event,
14835 .setup = alc269_laptop_amic_setup,
14836 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014837 },
Kailang Yang84898e82010-02-04 14:16:14 +010014838 [ALC269_DMIC] = {
14839 .mixers = { alc269_laptop_mixer },
14840 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014841 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014842 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014843 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14844 .dac_nids = alc269_dac_nids,
14845 .hp_nid = 0x03,
14846 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14847 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014848 .unsol_event = alc269_laptop_unsol_event,
14849 .setup = alc269_laptop_dmic_setup,
14850 .init_hook = alc269_laptop_inithook,
14851 },
14852 [ALC269VB_AMIC] = {
14853 .mixers = { alc269vb_laptop_mixer },
14854 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14855 .init_verbs = { alc269vb_init_verbs,
14856 alc269vb_laptop_amic_init_verbs },
14857 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14858 .dac_nids = alc269_dac_nids,
14859 .hp_nid = 0x03,
14860 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14861 .channel_mode = alc269_modes,
14862 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014863 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014864 .init_hook = alc269_laptop_inithook,
14865 },
14866 [ALC269VB_DMIC] = {
14867 .mixers = { alc269vb_laptop_mixer },
14868 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14869 .init_verbs = { alc269vb_init_verbs,
14870 alc269vb_laptop_dmic_init_verbs },
14871 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14872 .dac_nids = alc269_dac_nids,
14873 .hp_nid = 0x03,
14874 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14875 .channel_mode = alc269_modes,
14876 .unsol_event = alc269_laptop_unsol_event,
14877 .setup = alc269vb_laptop_dmic_setup,
14878 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014879 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014880 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014881 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014882 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014883 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014884 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014885 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14886 .dac_nids = alc269_dac_nids,
14887 .hp_nid = 0x03,
14888 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14889 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014890 .unsol_event = alc269_laptop_unsol_event,
14891 .setup = alc269_laptop_dmic_setup,
14892 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014893 },
Tony Vroon64154832008-11-06 15:08:49 +000014894 [ALC269_LIFEBOOK] = {
14895 .mixers = { alc269_lifebook_mixer },
14896 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14897 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14898 .dac_nids = alc269_dac_nids,
14899 .hp_nid = 0x03,
14900 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14901 .channel_mode = alc269_modes,
14902 .input_mux = &alc269_capture_source,
14903 .unsol_event = alc269_lifebook_unsol_event,
14904 .init_hook = alc269_lifebook_init_hook,
14905 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014906 [ALC271_ACER] = {
14907 .mixers = { alc269_asus_mixer },
14908 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14909 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
14910 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14911 .dac_nids = alc269_dac_nids,
14912 .adc_nids = alc262_dmic_adc_nids,
14913 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
14914 .capsrc_nids = alc262_dmic_capsrc_nids,
14915 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14916 .channel_mode = alc269_modes,
14917 .input_mux = &alc269_capture_source,
14918 .dig_out_nid = ALC880_DIGOUT_NID,
14919 .unsol_event = alc_sku_unsol_event,
14920 .setup = alc269vb_laptop_dmic_setup,
14921 .init_hook = alc_inithook,
14922 },
Kailang Yangf6a92242007-12-13 16:52:54 +010014923};
14924
Kailang Yang977ddd62010-09-15 10:02:29 +020014925static int alc269_fill_coef(struct hda_codec *codec)
14926{
14927 int val;
14928
14929 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
14930 alc_write_coef_idx(codec, 0xf, 0x960b);
14931 alc_write_coef_idx(codec, 0xe, 0x8817);
14932 }
14933
14934 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
14935 alc_write_coef_idx(codec, 0xf, 0x960b);
14936 alc_write_coef_idx(codec, 0xe, 0x8814);
14937 }
14938
14939 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
14940 val = alc_read_coef_idx(codec, 0x04);
14941 /* Power up output pin */
14942 alc_write_coef_idx(codec, 0x04, val | (1<<11));
14943 }
14944
14945 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
14946 val = alc_read_coef_idx(codec, 0xd);
14947 if ((val & 0x0c00) >> 10 != 0x1) {
14948 /* Capless ramp up clock control */
14949 alc_write_coef_idx(codec, 0xd, val | 1<<10);
14950 }
14951 val = alc_read_coef_idx(codec, 0x17);
14952 if ((val & 0x01c0) >> 6 != 0x4) {
14953 /* Class D power on reset */
14954 alc_write_coef_idx(codec, 0x17, val | 1<<7);
14955 }
14956 }
14957 return 0;
14958}
14959
Kailang Yangf6a92242007-12-13 16:52:54 +010014960static int patch_alc269(struct hda_codec *codec)
14961{
14962 struct alc_spec *spec;
14963 int board_config;
14964 int err;
Kailang Yang84898e82010-02-04 14:16:14 +010014965 int is_alc269vb = 0;
Kailang Yangf6a92242007-12-13 16:52:54 +010014966
14967 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
14968 if (spec == NULL)
14969 return -ENOMEM;
14970
14971 codec->spec = spec;
14972
Kailang Yangda00c242010-03-19 11:23:45 +010014973 alc_auto_parse_customize_define(codec);
14974
Kailang Yang274693f2009-12-03 10:07:50 +010014975 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
Kailang Yangc027ddc2010-03-19 11:33:06 +010014976 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14977 spec->cdefine.platform_type == 1)
14978 alc_codec_rename(codec, "ALC271X");
14979 else
14980 alc_codec_rename(codec, "ALC259");
Kailang Yang84898e82010-02-04 14:16:14 +010014981 is_alc269vb = 1;
Kailang Yangc027ddc2010-03-19 11:33:06 +010014982 } else
14983 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010014984
Kailang Yang977ddd62010-09-15 10:02:29 +020014985 alc269_fill_coef(codec);
14986
Kailang Yangf6a92242007-12-13 16:52:54 +010014987 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14988 alc269_models,
14989 alc269_cfg_tbl);
14990
14991 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020014992 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
14993 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010014994 board_config = ALC269_AUTO;
14995 }
14996
Takashi Iwaiff818c22010-04-12 08:59:25 +020014997 if (board_config == ALC269_AUTO)
14998 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
14999
Kailang Yangf6a92242007-12-13 16:52:54 +010015000 if (board_config == ALC269_AUTO) {
15001 /* automatic parse from the BIOS config */
15002 err = alc269_parse_auto_config(codec);
15003 if (err < 0) {
15004 alc_free(codec);
15005 return err;
15006 } else if (!err) {
15007 printk(KERN_INFO
15008 "hda_codec: Cannot set up configuration "
15009 "from BIOS. Using base mode...\n");
15010 board_config = ALC269_BASIC;
15011 }
15012 }
15013
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015014 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015015 err = snd_hda_attach_beep_device(codec, 0x1);
15016 if (err < 0) {
15017 alc_free(codec);
15018 return err;
15019 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015020 }
15021
Kailang Yangf6a92242007-12-13 16:52:54 +010015022 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015023 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015024
Kailang Yang84898e82010-02-04 14:16:14 +010015025 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015026 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15027 * fix the sample rate of analog I/O to 44.1kHz
15028 */
15029 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15030 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015031 } else if (spec->dual_adc_switch) {
15032 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15033 /* switch ADC dynamically */
15034 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015035 } else {
15036 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15037 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15038 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015039 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15040 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15041
Takashi Iwai66946352010-03-29 17:21:45 +020015042 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
15043 if (!is_alc269vb) {
15044 spec->adc_nids = alc269_adc_nids;
15045 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15046 spec->capsrc_nids = alc269_capsrc_nids;
15047 } else {
15048 spec->adc_nids = alc269vb_adc_nids;
15049 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15050 spec->capsrc_nids = alc269vb_capsrc_nids;
15051 }
Kailang Yang84898e82010-02-04 14:16:14 +010015052 }
15053
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015054 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015055 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015056 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015057 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015058
Takashi Iwaiff818c22010-04-12 08:59:25 +020015059 if (board_config == ALC269_AUTO)
15060 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
15061
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015062 spec->vmaster_nid = 0x02;
15063
Kailang Yangf6a92242007-12-13 16:52:54 +010015064 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015065#ifdef CONFIG_SND_HDA_POWER_SAVE
15066 codec->patch_ops.suspend = alc269_suspend;
15067#endif
15068#ifdef SND_HDA_NEEDS_RESUME
15069 codec->patch_ops.resume = alc269_resume;
15070#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015071 if (board_config == ALC269_AUTO)
15072 spec->init_hook = alc269_auto_init;
15073#ifdef CONFIG_SND_HDA_POWER_SAVE
15074 if (!spec->loopback.amplist)
15075 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015076 if (alc269_mic2_for_mute_led(codec))
15077 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015078#endif
15079
15080 return 0;
15081}
15082
15083/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015084 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15085 */
15086
15087/*
15088 * set the path ways for 2 channel output
15089 * need to set the codec line out and mic 1 pin widgets to inputs
15090 */
15091static struct hda_verb alc861_threestack_ch2_init[] = {
15092 /* set pin widget 1Ah (line in) for input */
15093 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015094 /* set pin widget 18h (mic1/2) for input, for mic also enable
15095 * the vref
15096 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015097 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15098
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015099 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15100#if 0
15101 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15102 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15103#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015104 { } /* end */
15105};
15106/*
15107 * 6ch mode
15108 * need to set the codec line out and mic 1 pin widgets to outputs
15109 */
15110static struct hda_verb alc861_threestack_ch6_init[] = {
15111 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15112 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15113 /* set pin widget 18h (mic1) for output (CLFE)*/
15114 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15115
15116 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015117 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015118
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015119 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15120#if 0
15121 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15122 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15123#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015124 { } /* end */
15125};
15126
15127static struct hda_channel_mode alc861_threestack_modes[2] = {
15128 { 2, alc861_threestack_ch2_init },
15129 { 6, alc861_threestack_ch6_init },
15130};
Takashi Iwai22309c32006-08-09 16:57:28 +020015131/* Set mic1 as input and unmute the mixer */
15132static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15133 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15134 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15135 { } /* end */
15136};
15137/* Set mic1 as output and mute mixer */
15138static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15139 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15140 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15141 { } /* end */
15142};
15143
15144static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15145 { 2, alc861_uniwill_m31_ch2_init },
15146 { 4, alc861_uniwill_m31_ch4_init },
15147};
Kailang Yangdf694da2005-12-05 19:42:22 +010015148
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015149/* Set mic1 and line-in as input and unmute the mixer */
15150static struct hda_verb alc861_asus_ch2_init[] = {
15151 /* set pin widget 1Ah (line in) for input */
15152 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015153 /* set pin widget 18h (mic1/2) for input, for mic also enable
15154 * the vref
15155 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015156 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15157
15158 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15159#if 0
15160 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15161 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15162#endif
15163 { } /* end */
15164};
15165/* Set mic1 nad line-in as output and mute mixer */
15166static struct hda_verb alc861_asus_ch6_init[] = {
15167 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15168 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15169 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15170 /* set pin widget 18h (mic1) for output (CLFE)*/
15171 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15172 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15173 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15174 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15175
15176 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15177#if 0
15178 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15179 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15180#endif
15181 { } /* end */
15182};
15183
15184static struct hda_channel_mode alc861_asus_modes[2] = {
15185 { 2, alc861_asus_ch2_init },
15186 { 6, alc861_asus_ch6_init },
15187};
15188
Kailang Yangdf694da2005-12-05 19:42:22 +010015189/* patch-ALC861 */
15190
15191static struct snd_kcontrol_new alc861_base_mixer[] = {
15192 /* output mixer control */
15193 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15194 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15195 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15196 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15197 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15198
15199 /*Input mixer control */
15200 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15201 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15202 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15203 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15204 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15205 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15206 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15207 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15208 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15209 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015210
Kailang Yangdf694da2005-12-05 19:42:22 +010015211 { } /* end */
15212};
15213
15214static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15215 /* output mixer control */
15216 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15217 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15218 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15219 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15220 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15221
15222 /* Input mixer control */
15223 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15224 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15225 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15226 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15227 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15228 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15229 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15230 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15231 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15232 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015233
Kailang Yangdf694da2005-12-05 19:42:22 +010015234 {
15235 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15236 .name = "Channel Mode",
15237 .info = alc_ch_mode_info,
15238 .get = alc_ch_mode_get,
15239 .put = alc_ch_mode_put,
15240 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15241 },
15242 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015243};
15244
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015245static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015246 /* output mixer control */
15247 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15248 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15249 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015250
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015251 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015252};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015253
Takashi Iwai22309c32006-08-09 16:57:28 +020015254static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15255 /* output mixer control */
15256 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15257 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15258 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15259 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15260 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15261
15262 /* Input mixer control */
15263 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15264 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15265 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15266 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15267 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15268 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15269 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15270 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15271 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15272 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015273
Takashi Iwai22309c32006-08-09 16:57:28 +020015274 {
15275 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15276 .name = "Channel Mode",
15277 .info = alc_ch_mode_info,
15278 .get = alc_ch_mode_get,
15279 .put = alc_ch_mode_put,
15280 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15281 },
15282 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015283};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015284
15285static struct snd_kcontrol_new alc861_asus_mixer[] = {
15286 /* output mixer control */
15287 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15288 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15289 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15290 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15291 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15292
15293 /* Input mixer control */
15294 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15295 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15296 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15297 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15298 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15299 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15300 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15301 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15302 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015303 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15304
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015305 {
15306 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15307 .name = "Channel Mode",
15308 .info = alc_ch_mode_info,
15309 .get = alc_ch_mode_get,
15310 .put = alc_ch_mode_put,
15311 .private_value = ARRAY_SIZE(alc861_asus_modes),
15312 },
15313 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015314};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015315
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015316/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015317static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015318 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15319 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015320 { }
15321};
15322
Kailang Yangdf694da2005-12-05 19:42:22 +010015323/*
15324 * generic initialization of ADC, input mixers and output mixers
15325 */
15326static struct hda_verb alc861_base_init_verbs[] = {
15327 /*
15328 * Unmute ADC0 and set the default input to mic-in
15329 */
15330 /* port-A for surround (rear panel) */
15331 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15332 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15333 /* port-B for mic-in (rear panel) with vref */
15334 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15335 /* port-C for line-in (rear panel) */
15336 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15337 /* port-D for Front */
15338 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15339 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15340 /* port-E for HP out (front panel) */
15341 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15342 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015343 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015344 /* port-F for mic-in (front panel) with vref */
15345 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15346 /* port-G for CLFE (rear panel) */
15347 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15348 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15349 /* port-H for side (rear panel) */
15350 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15351 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15352 /* CD-in */
15353 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15354 /* route front mic to ADC1*/
15355 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15356 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015357
Kailang Yangdf694da2005-12-05 19:42:22 +010015358 /* Unmute DAC0~3 & spdif out*/
15359 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15360 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15361 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15362 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15363 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015364
Kailang Yangdf694da2005-12-05 19:42:22 +010015365 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15366 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15367 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15368 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15369 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015370
Kailang Yangdf694da2005-12-05 19:42:22 +010015371 /* Unmute Stereo Mixer 15 */
15372 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15373 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15374 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015375 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015376
15377 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15378 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15379 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15380 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15381 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15382 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15383 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15384 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015385 /* hp used DAC 3 (Front) */
15386 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015387 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15388
15389 { }
15390};
15391
15392static struct hda_verb alc861_threestack_init_verbs[] = {
15393 /*
15394 * Unmute ADC0 and set the default input to mic-in
15395 */
15396 /* port-A for surround (rear panel) */
15397 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15398 /* port-B for mic-in (rear panel) with vref */
15399 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15400 /* port-C for line-in (rear panel) */
15401 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15402 /* port-D for Front */
15403 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15404 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15405 /* port-E for HP out (front panel) */
15406 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15407 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015408 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015409 /* port-F for mic-in (front panel) with vref */
15410 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15411 /* port-G for CLFE (rear panel) */
15412 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15413 /* port-H for side (rear panel) */
15414 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15415 /* CD-in */
15416 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15417 /* route front mic to ADC1*/
15418 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15419 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15420 /* Unmute DAC0~3 & spdif out*/
15421 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15422 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15423 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15424 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15425 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015426
Kailang Yangdf694da2005-12-05 19:42:22 +010015427 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15428 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15429 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15430 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15431 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015432
Kailang Yangdf694da2005-12-05 19:42:22 +010015433 /* Unmute Stereo Mixer 15 */
15434 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15435 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15436 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015437 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015438
15439 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15440 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15441 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15442 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15443 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15444 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15445 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15446 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015447 /* hp used DAC 3 (Front) */
15448 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015449 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15450 { }
15451};
Takashi Iwai22309c32006-08-09 16:57:28 +020015452
15453static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15454 /*
15455 * Unmute ADC0 and set the default input to mic-in
15456 */
15457 /* port-A for surround (rear panel) */
15458 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15459 /* port-B for mic-in (rear panel) with vref */
15460 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15461 /* port-C for line-in (rear panel) */
15462 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15463 /* port-D for Front */
15464 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15465 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15466 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015467 /* this has to be set to VREF80 */
15468 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015469 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015470 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015471 /* port-F for mic-in (front panel) with vref */
15472 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15473 /* port-G for CLFE (rear panel) */
15474 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15475 /* port-H for side (rear panel) */
15476 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15477 /* CD-in */
15478 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15479 /* route front mic to ADC1*/
15480 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15481 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15482 /* Unmute DAC0~3 & spdif out*/
15483 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15484 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15485 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15486 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15487 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015488
Takashi Iwai22309c32006-08-09 16:57:28 +020015489 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15490 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15491 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15492 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15493 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015494
Takashi Iwai22309c32006-08-09 16:57:28 +020015495 /* Unmute Stereo Mixer 15 */
15496 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15497 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15498 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015499 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015500
15501 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15502 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15503 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15504 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15505 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15506 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15507 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15508 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015509 /* hp used DAC 3 (Front) */
15510 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015511 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15512 { }
15513};
15514
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015515static struct hda_verb alc861_asus_init_verbs[] = {
15516 /*
15517 * Unmute ADC0 and set the default input to mic-in
15518 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015519 /* port-A for surround (rear panel)
15520 * according to codec#0 this is the HP jack
15521 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015522 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15523 /* route front PCM to HP */
15524 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15525 /* port-B for mic-in (rear panel) with vref */
15526 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15527 /* port-C for line-in (rear panel) */
15528 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15529 /* port-D for Front */
15530 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15531 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15532 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015533 /* this has to be set to VREF80 */
15534 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015535 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015536 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015537 /* port-F for mic-in (front panel) with vref */
15538 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15539 /* port-G for CLFE (rear panel) */
15540 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15541 /* port-H for side (rear panel) */
15542 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15543 /* CD-in */
15544 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15545 /* route front mic to ADC1*/
15546 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15547 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15548 /* Unmute DAC0~3 & spdif out*/
15549 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15550 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15551 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15552 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15553 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15554 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15555 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15556 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15557 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15558 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015559
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015560 /* Unmute Stereo Mixer 15 */
15561 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15562 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15563 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015564 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015565
15566 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15567 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15568 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15569 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15570 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15571 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15572 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15573 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015574 /* hp used DAC 3 (Front) */
15575 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15577 { }
15578};
15579
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015580/* additional init verbs for ASUS laptops */
15581static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15582 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15583 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15584 { }
15585};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015586
Kailang Yangdf694da2005-12-05 19:42:22 +010015587/*
15588 * generic initialization of ADC, input mixers and output mixers
15589 */
15590static struct hda_verb alc861_auto_init_verbs[] = {
15591 /*
15592 * Unmute ADC0 and set the default input to mic-in
15593 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015594 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015595 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015596
Kailang Yangdf694da2005-12-05 19:42:22 +010015597 /* Unmute DAC0~3 & spdif out*/
15598 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15599 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15600 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15601 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15602 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015603
Kailang Yangdf694da2005-12-05 19:42:22 +010015604 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15605 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15606 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15607 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15608 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015609
Kailang Yangdf694da2005-12-05 19:42:22 +010015610 /* Unmute Stereo Mixer 15 */
15611 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15612 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15613 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15614 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15615
Takashi Iwai1c209302009-07-22 15:17:45 +020015616 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15617 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15618 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15619 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15620 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15621 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15622 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15623 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015624
15625 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15626 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015627 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15628 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015629 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15630 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015631 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15632 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015633
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015634 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015635
15636 { }
15637};
15638
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015639static struct hda_verb alc861_toshiba_init_verbs[] = {
15640 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015641
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015642 { }
15643};
15644
15645/* toggle speaker-output according to the hp-jack state */
15646static void alc861_toshiba_automute(struct hda_codec *codec)
15647{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015648 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015649
Takashi Iwai47fd8302007-08-10 17:11:07 +020015650 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15651 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15652 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15653 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015654}
15655
15656static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15657 unsigned int res)
15658{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015659 if ((res >> 26) == ALC880_HP_EVENT)
15660 alc861_toshiba_automute(codec);
15661}
15662
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015663/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015664#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15665#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15666#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15667#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15668
15669
15670#define ALC861_DIGOUT_NID 0x07
15671
15672static struct hda_channel_mode alc861_8ch_modes[1] = {
15673 { 8, NULL }
15674};
15675
15676static hda_nid_t alc861_dac_nids[4] = {
15677 /* front, surround, clfe, side */
15678 0x03, 0x06, 0x05, 0x04
15679};
15680
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015681static hda_nid_t alc660_dac_nids[3] = {
15682 /* front, clfe, surround */
15683 0x03, 0x05, 0x06
15684};
15685
Kailang Yangdf694da2005-12-05 19:42:22 +010015686static hda_nid_t alc861_adc_nids[1] = {
15687 /* ADC0-2 */
15688 0x08,
15689};
15690
15691static struct hda_input_mux alc861_capture_source = {
15692 .num_items = 5,
15693 .items = {
15694 { "Mic", 0x0 },
15695 { "Front Mic", 0x3 },
15696 { "Line", 0x1 },
15697 { "CD", 0x4 },
15698 { "Mixer", 0x5 },
15699 },
15700};
15701
Takashi Iwai1c209302009-07-22 15:17:45 +020015702static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15703{
15704 struct alc_spec *spec = codec->spec;
15705 hda_nid_t mix, srcs[5];
15706 int i, j, num;
15707
15708 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15709 return 0;
15710 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15711 if (num < 0)
15712 return 0;
15713 for (i = 0; i < num; i++) {
15714 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015715 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015716 if (type != AC_WID_AUD_OUT)
15717 continue;
15718 for (j = 0; j < spec->multiout.num_dacs; j++)
15719 if (spec->multiout.dac_nids[j] == srcs[i])
15720 break;
15721 if (j >= spec->multiout.num_dacs)
15722 return srcs[i];
15723 }
15724 return 0;
15725}
15726
Kailang Yangdf694da2005-12-05 19:42:22 +010015727/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015728static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015729 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015730{
Takashi Iwai1c209302009-07-22 15:17:45 +020015731 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015732 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015733 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015734
15735 spec->multiout.dac_nids = spec->private_dac_nids;
15736 for (i = 0; i < cfg->line_outs; i++) {
15737 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015738 dac = alc861_look_for_dac(codec, nid);
15739 if (!dac)
15740 continue;
15741 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015742 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015743 return 0;
15744}
15745
Takashi Iwai1c209302009-07-22 15:17:45 +020015746static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15747 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015748{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015749 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015750 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15751}
15752
15753/* add playback controls from the parsed DAC table */
15754static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15755 const struct auto_pin_cfg *cfg)
15756{
15757 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015758 static const char *chname[4] = {
15759 "Front", "Surround", NULL /*CLFE*/, "Side"
15760 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015761 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015762 int i, err;
15763
15764 if (cfg->line_outs == 1) {
15765 const char *pfx = NULL;
15766 if (!cfg->hp_outs)
15767 pfx = "Master";
15768 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15769 pfx = "Speaker";
15770 if (pfx) {
15771 nid = spec->multiout.dac_nids[0];
15772 return alc861_create_out_sw(codec, pfx, nid, 3);
15773 }
15774 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015775
15776 for (i = 0; i < cfg->line_outs; i++) {
15777 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015778 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015779 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015780 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015781 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015782 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015783 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015784 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015785 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015786 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015787 return err;
15788 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015789 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015790 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015791 return err;
15792 }
15793 }
15794 return 0;
15795}
15796
Takashi Iwai1c209302009-07-22 15:17:45 +020015797static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015798{
Takashi Iwai1c209302009-07-22 15:17:45 +020015799 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015800 int err;
15801 hda_nid_t nid;
15802
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015803 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015804 return 0;
15805
15806 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015807 nid = alc861_look_for_dac(codec, pin);
15808 if (nid) {
15809 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15810 if (err < 0)
15811 return err;
15812 spec->multiout.hp_nid = nid;
15813 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015814 }
15815 return 0;
15816}
15817
15818/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015819static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015820 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015821{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015822 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015823}
15824
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015825static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15826 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015827 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015828{
Takashi Iwai1c209302009-07-22 15:17:45 +020015829 hda_nid_t mix, srcs[5];
15830 int i, num;
15831
Jacek Luczak564c5be2008-05-03 18:41:23 +020015832 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15833 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015834 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015835 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015836 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15837 return;
15838 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15839 if (num < 0)
15840 return;
15841 for (i = 0; i < num; i++) {
15842 unsigned int mute;
15843 if (srcs[i] == dac || srcs[i] == 0x15)
15844 mute = AMP_IN_UNMUTE(i);
15845 else
15846 mute = AMP_IN_MUTE(i);
15847 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15848 mute);
15849 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015850}
15851
15852static void alc861_auto_init_multi_out(struct hda_codec *codec)
15853{
15854 struct alc_spec *spec = codec->spec;
15855 int i;
15856
15857 for (i = 0; i < spec->autocfg.line_outs; i++) {
15858 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015859 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015860 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015861 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015862 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015863 }
15864}
15865
15866static void alc861_auto_init_hp_out(struct hda_codec *codec)
15867{
15868 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015869
Takashi Iwai15870f02009-10-05 08:25:13 +020015870 if (spec->autocfg.hp_outs)
15871 alc861_auto_set_output_and_unmute(codec,
15872 spec->autocfg.hp_pins[0],
15873 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015874 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015875 if (spec->autocfg.speaker_outs)
15876 alc861_auto_set_output_and_unmute(codec,
15877 spec->autocfg.speaker_pins[0],
15878 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015879 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015880}
15881
15882static void alc861_auto_init_analog_input(struct hda_codec *codec)
15883{
15884 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015885 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010015886 int i;
15887
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015888 for (i = 0; i < cfg->num_inputs; i++) {
15889 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010015890 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020015891 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015892 }
15893}
15894
15895/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015896/* return 1 if successful, 0 if the proper config is not found,
15897 * or a negative error code
15898 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015899static int alc861_parse_auto_config(struct hda_codec *codec)
15900{
15901 struct alc_spec *spec = codec->spec;
15902 int err;
15903 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
15904
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015905 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
15906 alc861_ignore);
15907 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015908 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015909 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015910 return 0; /* can't find valid BIOS pin config */
15911
Takashi Iwai1c209302009-07-22 15:17:45 +020015912 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015913 if (err < 0)
15914 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015915 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015916 if (err < 0)
15917 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015918 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015919 if (err < 0)
15920 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020015921 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015922 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015923 return err;
15924
15925 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
15926
Takashi Iwai757899a2010-07-30 10:48:14 +020015927 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015928
Takashi Iwai603c4012008-07-30 15:01:44 +020015929 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010015930 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010015931
Takashi Iwaid88897e2008-10-31 15:01:37 +010015932 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010015933
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020015934 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020015935 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010015936
15937 spec->adc_nids = alc861_adc_nids;
15938 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015939 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015940
Kailang Yang6227cdc2010-02-25 08:36:52 +010015941 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020015942
Kailang Yangdf694da2005-12-05 19:42:22 +010015943 return 1;
15944}
15945
Takashi Iwaiae6b8132006-03-03 16:47:17 +010015946/* additional initialization for auto-configuration model */
15947static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010015948{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015949 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015950 alc861_auto_init_multi_out(codec);
15951 alc861_auto_init_hp_out(codec);
15952 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020015953 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010015954 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020015955 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010015956}
15957
Takashi Iwaicb53c622007-08-10 17:21:45 +020015958#ifdef CONFIG_SND_HDA_POWER_SAVE
15959static struct hda_amp_list alc861_loopbacks[] = {
15960 { 0x15, HDA_INPUT, 0 },
15961 { 0x15, HDA_INPUT, 1 },
15962 { 0x15, HDA_INPUT, 2 },
15963 { 0x15, HDA_INPUT, 3 },
15964 { } /* end */
15965};
15966#endif
15967
Kailang Yangdf694da2005-12-05 19:42:22 +010015968
15969/*
15970 * configuration and preset
15971 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015972static const char *alc861_models[ALC861_MODEL_LAST] = {
15973 [ALC861_3ST] = "3stack",
15974 [ALC660_3ST] = "3stack-660",
15975 [ALC861_3ST_DIG] = "3stack-dig",
15976 [ALC861_6ST_DIG] = "6stack-dig",
15977 [ALC861_UNIWILL_M31] = "uniwill-m31",
15978 [ALC861_TOSHIBA] = "toshiba",
15979 [ALC861_ASUS] = "asus",
15980 [ALC861_ASUS_LAPTOP] = "asus-laptop",
15981 [ALC861_AUTO] = "auto",
15982};
15983
15984static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010015985 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010015986 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15987 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
15988 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015989 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020015990 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010015991 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020015992 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
15993 * Any other models that need this preset?
15994 */
15995 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020015996 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
15997 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010015998 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
15999 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16000 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16001 /* FIXME: the below seems conflict */
16002 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16003 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16004 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016005 {}
16006};
16007
16008static struct alc_config_preset alc861_presets[] = {
16009 [ALC861_3ST] = {
16010 .mixers = { alc861_3ST_mixer },
16011 .init_verbs = { alc861_threestack_init_verbs },
16012 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16013 .dac_nids = alc861_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,
Kailang Yangdf694da2005-12-05 19:42:22 +010016017 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16018 .adc_nids = alc861_adc_nids,
16019 .input_mux = &alc861_capture_source,
16020 },
16021 [ALC861_3ST_DIG] = {
16022 .mixers = { alc861_base_mixer },
16023 .init_verbs = { alc861_threestack_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_threestack_modes),
16028 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016029 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016030 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16031 .adc_nids = alc861_adc_nids,
16032 .input_mux = &alc861_capture_source,
16033 },
16034 [ALC861_6ST_DIG] = {
16035 .mixers = { alc861_base_mixer },
16036 .init_verbs = { alc861_base_init_verbs },
16037 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16038 .dac_nids = alc861_dac_nids,
16039 .dig_out_nid = ALC861_DIGOUT_NID,
16040 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16041 .channel_mode = alc861_8ch_modes,
16042 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16043 .adc_nids = alc861_adc_nids,
16044 .input_mux = &alc861_capture_source,
16045 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016046 [ALC660_3ST] = {
16047 .mixers = { alc861_3ST_mixer },
16048 .init_verbs = { alc861_threestack_init_verbs },
16049 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16050 .dac_nids = alc660_dac_nids,
16051 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16052 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016053 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016054 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16055 .adc_nids = alc861_adc_nids,
16056 .input_mux = &alc861_capture_source,
16057 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016058 [ALC861_UNIWILL_M31] = {
16059 .mixers = { alc861_uniwill_m31_mixer },
16060 .init_verbs = { alc861_uniwill_m31_init_verbs },
16061 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16062 .dac_nids = alc861_dac_nids,
16063 .dig_out_nid = ALC861_DIGOUT_NID,
16064 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16065 .channel_mode = alc861_uniwill_m31_modes,
16066 .need_dac_fix = 1,
16067 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16068 .adc_nids = alc861_adc_nids,
16069 .input_mux = &alc861_capture_source,
16070 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016071 [ALC861_TOSHIBA] = {
16072 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016073 .init_verbs = { alc861_base_init_verbs,
16074 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016075 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16076 .dac_nids = alc861_dac_nids,
16077 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16078 .channel_mode = alc883_3ST_2ch_modes,
16079 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16080 .adc_nids = alc861_adc_nids,
16081 .input_mux = &alc861_capture_source,
16082 .unsol_event = alc861_toshiba_unsol_event,
16083 .init_hook = alc861_toshiba_automute,
16084 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016085 [ALC861_ASUS] = {
16086 .mixers = { alc861_asus_mixer },
16087 .init_verbs = { alc861_asus_init_verbs },
16088 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16089 .dac_nids = alc861_dac_nids,
16090 .dig_out_nid = ALC861_DIGOUT_NID,
16091 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16092 .channel_mode = alc861_asus_modes,
16093 .need_dac_fix = 1,
16094 .hp_nid = 0x06,
16095 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16096 .adc_nids = alc861_adc_nids,
16097 .input_mux = &alc861_capture_source,
16098 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016099 [ALC861_ASUS_LAPTOP] = {
16100 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16101 .init_verbs = { alc861_asus_init_verbs,
16102 alc861_asus_laptop_init_verbs },
16103 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16104 .dac_nids = alc861_dac_nids,
16105 .dig_out_nid = ALC861_DIGOUT_NID,
16106 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16107 .channel_mode = alc883_3ST_2ch_modes,
16108 .need_dac_fix = 1,
16109 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16110 .adc_nids = alc861_adc_nids,
16111 .input_mux = &alc861_capture_source,
16112 },
16113};
Kailang Yangdf694da2005-12-05 19:42:22 +010016114
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016115/* Pin config fixes */
16116enum {
16117 PINFIX_FSC_AMILO_PI1505,
16118};
16119
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016120static const struct alc_fixup alc861_fixups[] = {
16121 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016122 .pins = (const struct alc_pincfg[]) {
16123 { 0x0b, 0x0221101f }, /* HP */
16124 { 0x0f, 0x90170310 }, /* speaker */
16125 { }
16126 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016127 },
16128};
16129
16130static struct snd_pci_quirk alc861_fixup_tbl[] = {
16131 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16132 {}
16133};
Kailang Yangdf694da2005-12-05 19:42:22 +010016134
16135static int patch_alc861(struct hda_codec *codec)
16136{
16137 struct alc_spec *spec;
16138 int board_config;
16139 int err;
16140
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016141 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016142 if (spec == NULL)
16143 return -ENOMEM;
16144
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016145 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016146
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016147 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16148 alc861_models,
16149 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016150
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016151 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016152 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16153 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016154 board_config = ALC861_AUTO;
16155 }
16156
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016157 if (board_config == ALC861_AUTO)
16158 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016159
Kailang Yangdf694da2005-12-05 19:42:22 +010016160 if (board_config == ALC861_AUTO) {
16161 /* automatic parse from the BIOS config */
16162 err = alc861_parse_auto_config(codec);
16163 if (err < 0) {
16164 alc_free(codec);
16165 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016166 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016167 printk(KERN_INFO
16168 "hda_codec: Cannot set up configuration "
16169 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016170 board_config = ALC861_3ST_DIG;
16171 }
16172 }
16173
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016174 err = snd_hda_attach_beep_device(codec, 0x23);
16175 if (err < 0) {
16176 alc_free(codec);
16177 return err;
16178 }
16179
Kailang Yangdf694da2005-12-05 19:42:22 +010016180 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016181 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016182
Kailang Yangdf694da2005-12-05 19:42:22 +010016183 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16184 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16185
Kailang Yangdf694da2005-12-05 19:42:22 +010016186 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16187 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16188
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016189 if (!spec->cap_mixer)
16190 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016191 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16192
Takashi Iwai2134ea42008-01-10 16:53:55 +010016193 spec->vmaster_nid = 0x03;
16194
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016195 if (board_config == ALC861_AUTO)
16196 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
16197
Kailang Yangdf694da2005-12-05 19:42:22 +010016198 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016199 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016200 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016201#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016202 spec->power_hook = alc_power_eapd;
16203#endif
16204 }
16205#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016206 if (!spec->loopback.amplist)
16207 spec->loopback.amplist = alc861_loopbacks;
16208#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016209
Kailang Yangdf694da2005-12-05 19:42:22 +010016210 return 0;
16211}
16212
16213/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016214 * ALC861-VD support
16215 *
16216 * Based on ALC882
16217 *
16218 * In addition, an independent DAC
16219 */
16220#define ALC861VD_DIGOUT_NID 0x06
16221
16222static hda_nid_t alc861vd_dac_nids[4] = {
16223 /* front, surr, clfe, side surr */
16224 0x02, 0x03, 0x04, 0x05
16225};
16226
16227/* dac_nids for ALC660vd are in a different order - according to
16228 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016229 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016230 * of ALC660vd codecs, but for now there is only 3stack mixer
16231 * - and it is the same as in 861vd.
16232 * adc_nids in ALC660vd are (is) the same as in 861vd
16233 */
16234static hda_nid_t alc660vd_dac_nids[3] = {
16235 /* front, rear, clfe, rear_surr */
16236 0x02, 0x04, 0x03
16237};
16238
16239static hda_nid_t alc861vd_adc_nids[1] = {
16240 /* ADC0 */
16241 0x09,
16242};
16243
Takashi Iwaie1406342008-02-11 18:32:32 +010016244static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16245
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016246/* input MUX */
16247/* FIXME: should be a matrix-type input source selection */
16248static struct hda_input_mux alc861vd_capture_source = {
16249 .num_items = 4,
16250 .items = {
16251 { "Mic", 0x0 },
16252 { "Front Mic", 0x1 },
16253 { "Line", 0x2 },
16254 { "CD", 0x4 },
16255 },
16256};
16257
Kailang Yang272a5272007-05-14 11:00:38 +020016258static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016259 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016260 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010016261 { "Ext Mic", 0x0 },
16262 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016263 },
16264};
16265
Kailang Yangd1a991a2007-08-15 16:21:59 +020016266static struct hda_input_mux alc861vd_hp_capture_source = {
16267 .num_items = 2,
16268 .items = {
16269 { "Front Mic", 0x0 },
16270 { "ATAPI Mic", 0x1 },
16271 },
16272};
16273
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016274/*
16275 * 2ch mode
16276 */
16277static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16278 { 2, NULL }
16279};
16280
16281/*
16282 * 6ch mode
16283 */
16284static struct hda_verb alc861vd_6stack_ch6_init[] = {
16285 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16286 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16287 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16288 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16289 { } /* end */
16290};
16291
16292/*
16293 * 8ch mode
16294 */
16295static struct hda_verb alc861vd_6stack_ch8_init[] = {
16296 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16297 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16298 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16299 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16300 { } /* end */
16301};
16302
16303static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16304 { 6, alc861vd_6stack_ch6_init },
16305 { 8, alc861vd_6stack_ch8_init },
16306};
16307
16308static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16309 {
16310 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16311 .name = "Channel Mode",
16312 .info = alc_ch_mode_info,
16313 .get = alc_ch_mode_get,
16314 .put = alc_ch_mode_put,
16315 },
16316 { } /* end */
16317};
16318
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016319/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16320 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16321 */
16322static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16323 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16324 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16325
16326 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16327 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16328
16329 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16330 HDA_OUTPUT),
16331 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16332 HDA_OUTPUT),
16333 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16334 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16335
16336 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16337 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16338
16339 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16340
16341 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16342 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16343 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16344
16345 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16346 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16347 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16348
16349 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16350 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16351
16352 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16353 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16354
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016355 { } /* end */
16356};
16357
16358static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16359 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16360 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16361
16362 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16363
16364 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16365 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16366 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16367
16368 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16369 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16370 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16371
16372 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16373 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16374
16375 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16376 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16377
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016378 { } /* end */
16379};
16380
Kailang Yangbdd148a2007-05-08 15:19:08 +020016381static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16382 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16383 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16384 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16385
16386 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16387
16388 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16389 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16390 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16391
16392 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16393 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16394 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16395
16396 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16397 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16398
16399 { } /* end */
16400};
16401
Tobin Davisb419f342008-03-07 11:57:51 +010016402/* Pin assignment: Speaker=0x14, HP = 0x15,
16403 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016404 */
16405static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016406 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16407 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016408 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16409 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016410 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16411 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16412 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16413 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16414 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16415 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016416 { } /* end */
16417};
16418
Kailang Yangd1a991a2007-08-15 16:21:59 +020016419/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16420 * Front Mic=0x18, ATAPI Mic = 0x19,
16421 */
16422static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16423 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16424 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16425 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16426 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16427 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16428 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16429 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16430 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016431
Kailang Yangd1a991a2007-08-15 16:21:59 +020016432 { } /* end */
16433};
16434
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016435/*
16436 * generic initialization of ADC, input mixers and output mixers
16437 */
16438static struct hda_verb alc861vd_volume_init_verbs[] = {
16439 /*
16440 * Unmute ADC0 and set the default input to mic-in
16441 */
16442 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16443 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16444
16445 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16446 * the analog-loopback mixer widget
16447 */
16448 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016449 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16450 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16451 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16452 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16453 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016454
16455 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016456 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16457 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16458 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016459 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016460
16461 /*
16462 * Set up output mixers (0x02 - 0x05)
16463 */
16464 /* set vol=0 to output mixers */
16465 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16466 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16467 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16468 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16469
16470 /* set up input amps for analog loopback */
16471 /* Amp Indices: DAC = 0, mixer = 1 */
16472 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16473 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16474 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16475 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16476 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16477 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16478 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16479 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16480
16481 { }
16482};
16483
16484/*
16485 * 3-stack pin configuration:
16486 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16487 */
16488static struct hda_verb alc861vd_3stack_init_verbs[] = {
16489 /*
16490 * Set pin mode and muting
16491 */
16492 /* set front pin widgets 0x14 for output */
16493 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16494 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16495 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16496
16497 /* Mic (rear) pin: input vref at 80% */
16498 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16499 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16500 /* Front Mic pin: input vref at 80% */
16501 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16502 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16503 /* Line In pin: input */
16504 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16505 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16506 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16507 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16508 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16509 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16510 /* CD pin widget for input */
16511 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16512
16513 { }
16514};
16515
16516/*
16517 * 6-stack pin configuration:
16518 */
16519static struct hda_verb alc861vd_6stack_init_verbs[] = {
16520 /*
16521 * Set pin mode and muting
16522 */
16523 /* set front pin widgets 0x14 for output */
16524 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16525 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16526 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16527
16528 /* Rear Pin: output 1 (0x0d) */
16529 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16530 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16531 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16532 /* CLFE Pin: output 2 (0x0e) */
16533 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16534 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16535 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16536 /* Side Pin: output 3 (0x0f) */
16537 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16538 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16539 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16540
16541 /* Mic (rear) pin: input vref at 80% */
16542 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16543 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16544 /* Front Mic pin: input vref at 80% */
16545 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16546 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16547 /* Line In pin: input */
16548 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16549 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16550 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16551 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16552 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16553 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16554 /* CD pin widget for input */
16555 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16556
16557 { }
16558};
16559
Kailang Yangbdd148a2007-05-08 15:19:08 +020016560static struct hda_verb alc861vd_eapd_verbs[] = {
16561 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16562 { }
16563};
16564
Kailang Yangf9423e72008-05-27 12:32:25 +020016565static struct hda_verb alc660vd_eapd_verbs[] = {
16566 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16567 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16568 { }
16569};
16570
Kailang Yangbdd148a2007-05-08 15:19:08 +020016571static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16572 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16573 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16574 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16575 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016576 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016577 {}
16578};
16579
Kailang Yangbdd148a2007-05-08 15:19:08 +020016580static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
16581{
16582 unsigned int present;
16583 unsigned char bits;
16584
Wu Fengguang864f92b2009-11-18 12:38:02 +080016585 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +020016586 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080016587
Takashi Iwai47fd8302007-08-10 17:11:07 +020016588 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
16589 HDA_AMP_MUTE, bits);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016590}
16591
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016592static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016593{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016594 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016595 spec->autocfg.hp_pins[0] = 0x1b;
16596 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016597}
16598
16599static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16600{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016601 alc_automute_amp(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016602 alc861vd_lenovo_mic_automute(codec);
16603}
16604
16605static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16606 unsigned int res)
16607{
16608 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016609 case ALC880_MIC_EVENT:
16610 alc861vd_lenovo_mic_automute(codec);
16611 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016612 default:
16613 alc_automute_amp_unsol_event(codec, res);
16614 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016615 }
16616}
16617
Kailang Yang272a5272007-05-14 11:00:38 +020016618static struct hda_verb alc861vd_dallas_verbs[] = {
16619 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16620 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16621 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16622 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16623
16624 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16625 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16626 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16627 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16628 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16629 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16630 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16631 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016632
Kailang Yang272a5272007-05-14 11:00:38 +020016633 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16634 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16635 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16636 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16637 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16638 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16639 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16640 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16641
16642 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16643 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16644 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16645 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16646 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16647 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16648 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16649 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16650
16651 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16652 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16653 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16654 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16655
16656 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016657 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016658 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16659
16660 { } /* end */
16661};
16662
16663/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016664static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016665{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016666 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016667
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016668 spec->autocfg.hp_pins[0] = 0x15;
16669 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016670}
16671
Takashi Iwaicb53c622007-08-10 17:21:45 +020016672#ifdef CONFIG_SND_HDA_POWER_SAVE
16673#define alc861vd_loopbacks alc880_loopbacks
16674#endif
16675
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016676/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016677#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16678#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16679#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16680#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16681
16682/*
16683 * configuration and preset
16684 */
16685static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16686 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016687 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016688 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016689 [ALC861VD_3ST] = "3stack",
16690 [ALC861VD_3ST_DIG] = "3stack-digout",
16691 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016692 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016693 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016694 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016695 [ALC861VD_AUTO] = "auto",
16696};
16697
16698static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016699 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16700 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016701 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016702 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016703 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016704 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016705 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016706 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016707 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016708 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016709 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016710 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016711 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016712 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016713 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016714 {}
16715};
16716
16717static struct alc_config_preset alc861vd_presets[] = {
16718 [ALC660VD_3ST] = {
16719 .mixers = { alc861vd_3st_mixer },
16720 .init_verbs = { alc861vd_volume_init_verbs,
16721 alc861vd_3stack_init_verbs },
16722 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16723 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016724 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16725 .channel_mode = alc861vd_3stack_2ch_modes,
16726 .input_mux = &alc861vd_capture_source,
16727 },
Mike Crash6963f842007-06-25 12:12:51 +020016728 [ALC660VD_3ST_DIG] = {
16729 .mixers = { alc861vd_3st_mixer },
16730 .init_verbs = { alc861vd_volume_init_verbs,
16731 alc861vd_3stack_init_verbs },
16732 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16733 .dac_nids = alc660vd_dac_nids,
16734 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016735 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16736 .channel_mode = alc861vd_3stack_2ch_modes,
16737 .input_mux = &alc861vd_capture_source,
16738 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016739 [ALC861VD_3ST] = {
16740 .mixers = { alc861vd_3st_mixer },
16741 .init_verbs = { alc861vd_volume_init_verbs,
16742 alc861vd_3stack_init_verbs },
16743 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16744 .dac_nids = alc861vd_dac_nids,
16745 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16746 .channel_mode = alc861vd_3stack_2ch_modes,
16747 .input_mux = &alc861vd_capture_source,
16748 },
16749 [ALC861VD_3ST_DIG] = {
16750 .mixers = { alc861vd_3st_mixer },
16751 .init_verbs = { alc861vd_volume_init_verbs,
16752 alc861vd_3stack_init_verbs },
16753 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16754 .dac_nids = alc861vd_dac_nids,
16755 .dig_out_nid = ALC861VD_DIGOUT_NID,
16756 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16757 .channel_mode = alc861vd_3stack_2ch_modes,
16758 .input_mux = &alc861vd_capture_source,
16759 },
16760 [ALC861VD_6ST_DIG] = {
16761 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16762 .init_verbs = { alc861vd_volume_init_verbs,
16763 alc861vd_6stack_init_verbs },
16764 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16765 .dac_nids = alc861vd_dac_nids,
16766 .dig_out_nid = ALC861VD_DIGOUT_NID,
16767 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16768 .channel_mode = alc861vd_6stack_modes,
16769 .input_mux = &alc861vd_capture_source,
16770 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016771 [ALC861VD_LENOVO] = {
16772 .mixers = { alc861vd_lenovo_mixer },
16773 .init_verbs = { alc861vd_volume_init_verbs,
16774 alc861vd_3stack_init_verbs,
16775 alc861vd_eapd_verbs,
16776 alc861vd_lenovo_unsol_verbs },
16777 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16778 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016779 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16780 .channel_mode = alc861vd_3stack_2ch_modes,
16781 .input_mux = &alc861vd_capture_source,
16782 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016783 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016784 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016785 },
Kailang Yang272a5272007-05-14 11:00:38 +020016786 [ALC861VD_DALLAS] = {
16787 .mixers = { alc861vd_dallas_mixer },
16788 .init_verbs = { alc861vd_dallas_verbs },
16789 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16790 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016791 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16792 .channel_mode = alc861vd_3stack_2ch_modes,
16793 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016794 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016795 .setup = alc861vd_dallas_setup,
16796 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016797 },
16798 [ALC861VD_HP] = {
16799 .mixers = { alc861vd_hp_mixer },
16800 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16801 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16802 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016803 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016804 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16805 .channel_mode = alc861vd_3stack_2ch_modes,
16806 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016807 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016808 .setup = alc861vd_dallas_setup,
16809 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016810 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016811 [ALC660VD_ASUS_V1S] = {
16812 .mixers = { alc861vd_lenovo_mixer },
16813 .init_verbs = { alc861vd_volume_init_verbs,
16814 alc861vd_3stack_init_verbs,
16815 alc861vd_eapd_verbs,
16816 alc861vd_lenovo_unsol_verbs },
16817 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16818 .dac_nids = alc660vd_dac_nids,
16819 .dig_out_nid = ALC861VD_DIGOUT_NID,
16820 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16821 .channel_mode = alc861vd_3stack_2ch_modes,
16822 .input_mux = &alc861vd_capture_source,
16823 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016824 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016825 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016826 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016827};
16828
16829/*
16830 * BIOS auto configuration
16831 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016832static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16833 const struct auto_pin_cfg *cfg)
16834{
Kailang Yang6227cdc2010-02-25 08:36:52 +010016835 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x09, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016836}
16837
16838
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016839static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16840 hda_nid_t nid, int pin_type, int dac_idx)
16841{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016842 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016843}
16844
16845static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16846{
16847 struct alc_spec *spec = codec->spec;
16848 int i;
16849
16850 for (i = 0; i <= HDA_SIDE; i++) {
16851 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016852 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016853 if (nid)
16854 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016855 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016856 }
16857}
16858
16859
16860static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16861{
16862 struct alc_spec *spec = codec->spec;
16863 hda_nid_t pin;
16864
16865 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016866 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016867 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016868 pin = spec->autocfg.speaker_pins[0];
16869 if (pin)
16870 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016871}
16872
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016873#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16874
16875static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16876{
16877 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016878 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016879 int i;
16880
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016881 for (i = 0; i < cfg->num_inputs; i++) {
16882 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016883 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020016884 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016885 if (nid != ALC861VD_PIN_CD_NID &&
16886 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016887 snd_hda_codec_write(codec, nid, 0,
16888 AC_VERB_SET_AMP_GAIN_MUTE,
16889 AMP_OUT_MUTE);
16890 }
16891 }
16892}
16893
Takashi Iwaif511b012008-08-15 16:46:42 +020016894#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16895
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016896#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16897#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16898
16899/* add playback controls from the parsed DAC table */
16900/* Based on ALC880 version. But ALC861VD has separate,
16901 * different NIDs for mute/unmute switch and volume control */
16902static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
16903 const struct auto_pin_cfg *cfg)
16904{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016905 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
16906 hda_nid_t nid_v, nid_s;
16907 int i, err;
16908
16909 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016910 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016911 continue;
16912 nid_v = alc861vd_idx_to_mixer_vol(
16913 alc880_dac_to_idx(
16914 spec->multiout.dac_nids[i]));
16915 nid_s = alc861vd_idx_to_mixer_switch(
16916 alc880_dac_to_idx(
16917 spec->multiout.dac_nids[i]));
16918
16919 if (i == 2) {
16920 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016921 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16922 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016923 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
16924 HDA_OUTPUT));
16925 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016926 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016927 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
16928 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016929 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
16930 HDA_OUTPUT));
16931 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016932 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016933 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16934 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016935 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
16936 HDA_INPUT));
16937 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016938 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016939 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
16940 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016941 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
16942 HDA_INPUT));
16943 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016944 return err;
16945 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016946 const char *pfx;
16947 if (cfg->line_outs == 1 &&
16948 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
16949 if (!cfg->hp_pins)
16950 pfx = "Speaker";
16951 else
16952 pfx = "PCM";
16953 } else
16954 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016955 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016956 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
16957 HDA_OUTPUT));
16958 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016959 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020016960 if (cfg->line_outs == 1 &&
16961 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
16962 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016963 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016964 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016965 HDA_INPUT));
16966 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016967 return err;
16968 }
16969 }
16970 return 0;
16971}
16972
16973/* add playback controls for speaker and HP outputs */
16974/* Based on ALC880 version. But ALC861VD has separate,
16975 * different NIDs for mute/unmute switch and volume control */
16976static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
16977 hda_nid_t pin, const char *pfx)
16978{
16979 hda_nid_t nid_v, nid_s;
16980 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016981
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016982 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016983 return 0;
16984
16985 if (alc880_is_fixed_pin(pin)) {
16986 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
16987 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016988 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016989 spec->multiout.hp_nid = nid_v;
16990 else
16991 spec->multiout.extra_out_nid[0] = nid_v;
16992 /* control HP volume/switch on the output mixer amp */
16993 nid_v = alc861vd_idx_to_mixer_vol(
16994 alc880_fixed_pin_idx(pin));
16995 nid_s = alc861vd_idx_to_mixer_switch(
16996 alc880_fixed_pin_idx(pin));
16997
Takashi Iwai0afe5f82009-10-02 09:20:00 +020016998 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016999 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17000 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017001 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017002 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017003 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17004 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017005 return err;
17006 } else if (alc880_is_multi_pin(pin)) {
17007 /* set manual connection */
17008 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017009 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017010 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17011 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017012 return err;
17013 }
17014 return 0;
17015}
17016
17017/* parse the BIOS configuration and set up the alc_spec
17018 * return 1 if successful, 0 if the proper config is not found,
17019 * or a negative error code
17020 * Based on ALC880 version - had to change it to override
17021 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17022static int alc861vd_parse_auto_config(struct hda_codec *codec)
17023{
17024 struct alc_spec *spec = codec->spec;
17025 int err;
17026 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17027
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017028 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17029 alc861vd_ignore);
17030 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017031 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017032 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017033 return 0; /* can't find valid BIOS pin config */
17034
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017035 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17036 if (err < 0)
17037 return err;
17038 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17039 if (err < 0)
17040 return err;
17041 err = alc861vd_auto_create_extra_out(spec,
17042 spec->autocfg.speaker_pins[0],
17043 "Speaker");
17044 if (err < 0)
17045 return err;
17046 err = alc861vd_auto_create_extra_out(spec,
17047 spec->autocfg.hp_pins[0],
17048 "Headphone");
17049 if (err < 0)
17050 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017051 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017052 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017053 return err;
17054
17055 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17056
Takashi Iwai757899a2010-07-30 10:48:14 +020017057 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017058
Takashi Iwai603c4012008-07-30 15:01:44 +020017059 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017060 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017061
Takashi Iwaid88897e2008-10-31 15:01:37 +010017062 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017063
17064 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017065 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017066
Takashi Iwai776e1842007-08-29 15:07:11 +020017067 err = alc_auto_add_mic_boost(codec);
17068 if (err < 0)
17069 return err;
17070
Kailang Yang6227cdc2010-02-25 08:36:52 +010017071 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017072
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017073 return 1;
17074}
17075
17076/* additional initialization for auto-configuration model */
17077static void alc861vd_auto_init(struct hda_codec *codec)
17078{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017079 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017080 alc861vd_auto_init_multi_out(codec);
17081 alc861vd_auto_init_hp_out(codec);
17082 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017083 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017084 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017085 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017086 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017087}
17088
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017089enum {
17090 ALC660VD_FIX_ASUS_GPIO1
17091};
17092
17093/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017094static const struct alc_fixup alc861vd_fixups[] = {
17095 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020017096 .verbs = (const struct hda_verb[]) {
17097 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17098 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17099 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17100 { }
17101 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017102 },
17103};
17104
17105static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17106 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17107 {}
17108};
17109
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017110static int patch_alc861vd(struct hda_codec *codec)
17111{
17112 struct alc_spec *spec;
17113 int err, board_config;
17114
17115 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17116 if (spec == NULL)
17117 return -ENOMEM;
17118
17119 codec->spec = spec;
17120
17121 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17122 alc861vd_models,
17123 alc861vd_cfg_tbl);
17124
17125 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017126 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17127 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017128 board_config = ALC861VD_AUTO;
17129 }
17130
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017131 if (board_config == ALC861VD_AUTO)
17132 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017133
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017134 if (board_config == ALC861VD_AUTO) {
17135 /* automatic parse from the BIOS config */
17136 err = alc861vd_parse_auto_config(codec);
17137 if (err < 0) {
17138 alc_free(codec);
17139 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017140 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017141 printk(KERN_INFO
17142 "hda_codec: Cannot set up configuration "
17143 "from BIOS. Using base mode...\n");
17144 board_config = ALC861VD_3ST;
17145 }
17146 }
17147
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017148 err = snd_hda_attach_beep_device(codec, 0x23);
17149 if (err < 0) {
17150 alc_free(codec);
17151 return err;
17152 }
17153
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017154 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017155 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017156
Kailang Yang2f893282008-05-27 12:14:47 +020017157 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017158 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017159 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017160 }
17161
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017162 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17163 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17164
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017165 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17166 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17167
Takashi Iwaidd704692009-08-11 08:45:11 +020017168 if (!spec->adc_nids) {
17169 spec->adc_nids = alc861vd_adc_nids;
17170 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17171 }
17172 if (!spec->capsrc_nids)
17173 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017174
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017175 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017176 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017177
Takashi Iwai2134ea42008-01-10 16:53:55 +010017178 spec->vmaster_nid = 0x02;
17179
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017180 if (board_config == ALC861VD_AUTO)
17181 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
17182
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017183 codec->patch_ops = alc_patch_ops;
17184
17185 if (board_config == ALC861VD_AUTO)
17186 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017187#ifdef CONFIG_SND_HDA_POWER_SAVE
17188 if (!spec->loopback.amplist)
17189 spec->loopback.amplist = alc861vd_loopbacks;
17190#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017191
17192 return 0;
17193}
17194
17195/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017196 * ALC662 support
17197 *
17198 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17199 * configuration. Each pin widget can choose any input DACs and a mixer.
17200 * Each ADC is connected from a mixer of all inputs. This makes possible
17201 * 6-channel independent captures.
17202 *
17203 * In addition, an independent DAC for the multi-playback (not used in this
17204 * driver yet).
17205 */
17206#define ALC662_DIGOUT_NID 0x06
17207#define ALC662_DIGIN_NID 0x0a
17208
17209static hda_nid_t alc662_dac_nids[4] = {
17210 /* front, rear, clfe, rear_surr */
17211 0x02, 0x03, 0x04
17212};
17213
Kailang Yang622e84c2009-04-21 07:39:04 +020017214static hda_nid_t alc272_dac_nids[2] = {
17215 0x02, 0x03
17216};
17217
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017218static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017219 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017220 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017221};
Takashi Iwaie1406342008-02-11 18:32:32 +010017222
Kailang Yang622e84c2009-04-21 07:39:04 +020017223static hda_nid_t alc272_adc_nids[1] = {
17224 /* ADC1-2 */
17225 0x08,
17226};
17227
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017228static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017229static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17230
Takashi Iwaie1406342008-02-11 18:32:32 +010017231
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017232/* input MUX */
17233/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017234static struct hda_input_mux alc662_capture_source = {
17235 .num_items = 4,
17236 .items = {
17237 { "Mic", 0x0 },
17238 { "Front Mic", 0x1 },
17239 { "Line", 0x2 },
17240 { "CD", 0x4 },
17241 },
17242};
17243
17244static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17245 .num_items = 2,
17246 .items = {
17247 { "Mic", 0x1 },
17248 { "Line", 0x2 },
17249 },
17250};
Kailang Yang291702f2007-10-16 14:28:03 +020017251
Kailang Yang6dda9f42008-05-27 12:05:31 +020017252static struct hda_input_mux alc663_capture_source = {
17253 .num_items = 3,
17254 .items = {
17255 { "Mic", 0x0 },
17256 { "Front Mic", 0x1 },
17257 { "Line", 0x2 },
17258 },
17259};
17260
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017261#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017262static struct hda_input_mux alc272_nc10_capture_source = {
17263 .num_items = 16,
17264 .items = {
17265 { "Autoselect Mic", 0x0 },
17266 { "Internal Mic", 0x1 },
17267 { "In-0x02", 0x2 },
17268 { "In-0x03", 0x3 },
17269 { "In-0x04", 0x4 },
17270 { "In-0x05", 0x5 },
17271 { "In-0x06", 0x6 },
17272 { "In-0x07", 0x7 },
17273 { "In-0x08", 0x8 },
17274 { "In-0x09", 0x9 },
17275 { "In-0x0a", 0x0a },
17276 { "In-0x0b", 0x0b },
17277 { "In-0x0c", 0x0c },
17278 { "In-0x0d", 0x0d },
17279 { "In-0x0e", 0x0e },
17280 { "In-0x0f", 0x0f },
17281 },
17282};
17283#endif
17284
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017285/*
17286 * 2ch mode
17287 */
17288static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17289 { 2, NULL }
17290};
17291
17292/*
17293 * 2ch mode
17294 */
17295static struct hda_verb alc662_3ST_ch2_init[] = {
17296 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17297 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17298 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17299 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17300 { } /* end */
17301};
17302
17303/*
17304 * 6ch mode
17305 */
17306static struct hda_verb alc662_3ST_ch6_init[] = {
17307 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17308 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17309 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17310 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17311 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17312 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17313 { } /* end */
17314};
17315
17316static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17317 { 2, alc662_3ST_ch2_init },
17318 { 6, alc662_3ST_ch6_init },
17319};
17320
17321/*
17322 * 2ch mode
17323 */
17324static struct hda_verb alc662_sixstack_ch6_init[] = {
17325 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17326 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17327 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17328 { } /* end */
17329};
17330
17331/*
17332 * 6ch mode
17333 */
17334static struct hda_verb alc662_sixstack_ch8_init[] = {
17335 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17336 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17337 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17338 { } /* end */
17339};
17340
17341static struct hda_channel_mode alc662_5stack_modes[2] = {
17342 { 2, alc662_sixstack_ch6_init },
17343 { 6, alc662_sixstack_ch8_init },
17344};
17345
17346/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17347 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17348 */
17349
17350static struct snd_kcontrol_new alc662_base_mixer[] = {
17351 /* output mixer control */
17352 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017353 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017354 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017355 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017356 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17357 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017358 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17359 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017360 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17361
17362 /*Input mixer control */
17363 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17364 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17365 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17366 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17367 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17368 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17369 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17370 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017371 { } /* end */
17372};
17373
17374static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17375 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017376 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017377 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17378 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17379 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17380 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17381 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17382 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17383 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17384 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17385 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017386 { } /* end */
17387};
17388
17389static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17390 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017391 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017392 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017393 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017394 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17395 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017396 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17397 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017398 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17399 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17400 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17401 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17402 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17403 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17404 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17405 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17406 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017407 { } /* end */
17408};
17409
17410static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17411 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17412 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017413 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17414 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017415 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17416 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17417 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17418 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17419 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017420 { } /* end */
17421};
17422
Kailang Yang291702f2007-10-16 14:28:03 +020017423static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017424 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17425 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017426
17427 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17428 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17429 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17430
17431 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17432 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17433 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17434 { } /* end */
17435};
17436
Kailang Yang8c427222008-01-10 13:03:59 +010017437static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017438 ALC262_HIPPO_MASTER_SWITCH,
17439 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017440 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017441 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17442 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017443 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17444 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17445 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17446 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17447 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17448 { } /* end */
17449};
17450
Kailang Yangf1d4e282008-08-26 14:03:29 +020017451static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17452 .ops = &snd_hda_bind_vol,
17453 .values = {
17454 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17455 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17456 0
17457 },
17458};
17459
17460static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17461 .ops = &snd_hda_bind_sw,
17462 .values = {
17463 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17464 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17465 0
17466 },
17467};
17468
Kailang Yang6dda9f42008-05-27 12:05:31 +020017469static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017470 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17471 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17474 { } /* end */
17475};
17476
17477static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17478 .ops = &snd_hda_bind_sw,
17479 .values = {
17480 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17481 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17482 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17483 0
17484 },
17485};
17486
17487static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17488 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17489 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17490 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17491 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17492 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17493 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17494
17495 { } /* end */
17496};
17497
17498static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17499 .ops = &snd_hda_bind_sw,
17500 .values = {
17501 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17502 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17503 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17504 0
17505 },
17506};
17507
17508static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17509 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17510 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17511 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17512 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17513 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17514 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17515 { } /* end */
17516};
17517
17518static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017519 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17520 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017521 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17522 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17523 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17524 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17525 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17526 { } /* end */
17527};
17528
17529static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17530 .ops = &snd_hda_bind_vol,
17531 .values = {
17532 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17533 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17534 0
17535 },
17536};
17537
17538static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17539 .ops = &snd_hda_bind_sw,
17540 .values = {
17541 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17542 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17543 0
17544 },
17545};
17546
17547static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17548 HDA_BIND_VOL("Master Playback Volume",
17549 &alc663_asus_two_bind_master_vol),
17550 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17551 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017552 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17553 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17554 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017555 { } /* end */
17556};
17557
17558static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17559 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17560 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17561 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17562 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17563 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17564 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017565 { } /* end */
17566};
17567
17568static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17569 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17570 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17571 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17572 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17573 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17574
17575 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17576 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17577 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17578 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17579 { } /* end */
17580};
17581
17582static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17583 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17584 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17585 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17586
17587 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17588 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17589 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17590 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17591 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17592 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17593 { } /* end */
17594};
17595
Kailang Yangebb83ee2009-12-17 12:23:00 +010017596static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17597 .ops = &snd_hda_bind_sw,
17598 .values = {
17599 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17600 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17601 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17602 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17603 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17604 0
17605 },
17606};
17607
17608static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17609 .ops = &snd_hda_bind_sw,
17610 .values = {
17611 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17612 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17613 0
17614 },
17615};
17616
17617static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17618 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17619 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17620 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17621 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17622 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17623 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17624 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17626 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17627 { } /* end */
17628};
17629
17630static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17631 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17632 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17633 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17634 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17635 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17636 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17637 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17638 { } /* end */
17639};
17640
17641
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017642static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17643 {
17644 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17645 .name = "Channel Mode",
17646 .info = alc_ch_mode_info,
17647 .get = alc_ch_mode_get,
17648 .put = alc_ch_mode_put,
17649 },
17650 { } /* end */
17651};
17652
17653static struct hda_verb alc662_init_verbs[] = {
17654 /* ADC: mute amp left and right */
17655 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17656 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017657
Kailang Yangb60dd392007-09-20 12:50:29 +020017658 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17660 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17661 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17662 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17663 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017664
17665 /* Front Pin: output 0 (0x0c) */
17666 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17667 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17668
17669 /* Rear Pin: output 1 (0x0d) */
17670 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17671 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17672
17673 /* CLFE Pin: output 2 (0x0e) */
17674 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17675 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17676
17677 /* Mic (rear) pin: input vref at 80% */
17678 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17679 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17680 /* Front Mic pin: input vref at 80% */
17681 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17682 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17683 /* Line In pin: input */
17684 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17685 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17686 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17687 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17688 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17689 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17690 /* CD pin widget for input */
17691 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17692
17693 /* FIXME: use matrix-type input source selection */
17694 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17695 /* Input mixer */
17696 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017697 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017698
17699 /* always trun on EAPD */
17700 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17701 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17702
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017703 { }
17704};
17705
Kailang Yangcec27c82010-02-04 14:18:18 +010017706static struct hda_verb alc663_init_verbs[] = {
17707 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17708 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17709 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17710 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17711 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17712 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17713 { }
17714};
17715
17716static struct hda_verb alc272_init_verbs[] = {
17717 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17718 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17719 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17720 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17721 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17722 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17723 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17724 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17725 { }
17726};
17727
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017728static struct hda_verb alc662_sue_init_verbs[] = {
17729 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17730 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017731 {}
17732};
17733
17734static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17735 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17736 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17737 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017738};
17739
Kailang Yang8c427222008-01-10 13:03:59 +010017740/* Set Unsolicited Event*/
17741static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17742 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17743 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17744 {}
17745};
17746
Kailang Yang6dda9f42008-05-27 12:05:31 +020017747static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017748 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17749 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017750 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17751 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017752 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17753 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17754 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017755 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17756 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17757 {}
17758};
17759
Kailang Yangf1d4e282008-08-26 14:03:29 +020017760static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17761 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17762 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17763 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17764 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17765 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17766 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17767 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17768 {}
17769};
17770
17771static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17772 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17773 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17774 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17775 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17776 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17777 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17778 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17779 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17780 {}
17781};
17782
17783static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17784 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17785 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17786 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17787 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17788 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17789 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17790 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17791 {}
17792};
17793
17794static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17795 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17796 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17797 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17798 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17799 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17800 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17801 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17802 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17803 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17804 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17805 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17806 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17807 {}
17808};
17809
17810static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17811 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17812 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17813 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17814 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17815 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17816 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17817 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17818 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17819 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17820 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17821 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17822 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17823 {}
17824};
17825
Kailang Yang6dda9f42008-05-27 12:05:31 +020017826static struct hda_verb alc663_g71v_init_verbs[] = {
17827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17828 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17829 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17830
17831 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17832 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17833 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17834
17835 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17836 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17837 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17838 {}
17839};
17840
17841static struct hda_verb alc663_g50v_init_verbs[] = {
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, 0x00}, /* Headphone */
17845
17846 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17847 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17848 {}
17849};
17850
Kailang Yangf1d4e282008-08-26 14:03:29 +020017851static struct hda_verb alc662_ecs_init_verbs[] = {
17852 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17853 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17854 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17855 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17856 {}
17857};
17858
Kailang Yang622e84c2009-04-21 07:39:04 +020017859static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17860 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17861 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17862 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17863 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17864 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17865 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17866 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17867 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17868 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17869 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17870 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17871 {}
17872};
17873
17874static struct hda_verb alc272_dell_init_verbs[] = {
17875 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17876 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17877 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17878 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17879 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17880 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17881 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17882 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17883 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17884 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17885 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17886 {}
17887};
17888
Kailang Yangebb83ee2009-12-17 12:23:00 +010017889static struct hda_verb alc663_mode7_init_verbs[] = {
17890 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17891 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17892 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17893 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17894 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17895 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17896 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17897 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17898 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17899 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17900 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17902 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17903 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17904 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17905 {}
17906};
17907
17908static struct hda_verb alc663_mode8_init_verbs[] = {
17909 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17910 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17911 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17912 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
17913 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17914 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17915 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17916 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17917 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17918 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17919 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17920 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17921 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17922 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17923 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17924 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17925 {}
17926};
17927
Kailang Yangf1d4e282008-08-26 14:03:29 +020017928static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
17929 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
17930 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
17931 { } /* end */
17932};
17933
Kailang Yang622e84c2009-04-21 07:39:04 +020017934static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
17935 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
17936 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
17937 { } /* end */
17938};
17939
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017940static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
17941{
17942 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017943 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017944
Wu Fengguang864f92b2009-11-18 12:38:02 +080017945 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017946 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017947
Takashi Iwai47fd8302007-08-10 17:11:07 +020017948 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17949 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017950}
17951
17952static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
17953{
17954 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017955 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017956
Wu Fengguang864f92b2009-11-18 12:38:02 +080017957 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020017958 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080017959
Takashi Iwai47fd8302007-08-10 17:11:07 +020017960 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
17961 HDA_AMP_MUTE, bits);
17962 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
17963 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017964}
17965
17966static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
17967 unsigned int res)
17968{
17969 if ((res >> 26) == ALC880_HP_EVENT)
17970 alc662_lenovo_101e_all_automute(codec);
17971 if ((res >> 26) == ALC880_FRONT_EVENT)
17972 alc662_lenovo_101e_ispeaker_automute(codec);
17973}
17974
Kailang Yang291702f2007-10-16 14:28:03 +020017975/* unsolicited event for HP jack sensing */
17976static void alc662_eeepc_unsol_event(struct hda_codec *codec,
17977 unsigned int res)
17978{
Kailang Yang291702f2007-10-16 14:28:03 +020017979 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017980 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020017981 else
17982 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020017983}
17984
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017985static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020017986{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017987 struct alc_spec *spec = codec->spec;
17988
17989 alc262_hippo1_setup(codec);
17990 spec->ext_mic.pin = 0x18;
17991 spec->ext_mic.mux_idx = 0;
17992 spec->int_mic.pin = 0x19;
17993 spec->int_mic.mux_idx = 1;
17994 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020017995}
17996
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017997static void alc662_eeepc_inithook(struct hda_codec *codec)
17998{
17999 alc262_hippo_automute(codec);
18000 alc_mic_automute(codec);
18001}
18002
18003static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018004{
Takashi Iwai42171c12009-05-08 14:11:43 +020018005 struct alc_spec *spec = codec->spec;
18006
18007 spec->autocfg.hp_pins[0] = 0x14;
18008 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018009}
18010
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018011#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18012
Kailang Yang6dda9f42008-05-27 12:05:31 +020018013static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18014{
18015 unsigned int present;
18016 unsigned char bits;
18017
Wu Fengguang864f92b2009-11-18 12:38:02 +080018018 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018019 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018020 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018021 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018022 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018023 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018024}
18025
18026static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18027{
18028 unsigned int present;
18029 unsigned char bits;
18030
Wu Fengguang864f92b2009-11-18 12:38:02 +080018031 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018032 bits = present ? HDA_AMP_MUTE : 0;
18033 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018034 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018035 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018036 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018037 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018038 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018039 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018040 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018041}
18042
18043static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18044{
18045 unsigned int present;
18046 unsigned char bits;
18047
Wu Fengguang864f92b2009-11-18 12:38:02 +080018048 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018049 bits = present ? HDA_AMP_MUTE : 0;
18050 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018051 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018052 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018053 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018054 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018055 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018056 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018057 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018058}
18059
18060static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18061{
18062 unsigned int present;
18063 unsigned char bits;
18064
Wu Fengguang864f92b2009-11-18 12:38:02 +080018065 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018066 bits = present ? 0 : PIN_OUT;
18067 snd_hda_codec_write(codec, 0x14, 0,
18068 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18069}
18070
18071static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18072{
18073 unsigned int present1, present2;
18074
Wu Fengguang864f92b2009-11-18 12:38:02 +080018075 present1 = snd_hda_jack_detect(codec, 0x21);
18076 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018077
18078 if (present1 || present2) {
18079 snd_hda_codec_write_cache(codec, 0x14, 0,
18080 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18081 } else {
18082 snd_hda_codec_write_cache(codec, 0x14, 0,
18083 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18084 }
18085}
18086
18087static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18088{
18089 unsigned int present1, present2;
18090
Wu Fengguang864f92b2009-11-18 12:38:02 +080018091 present1 = snd_hda_jack_detect(codec, 0x1b);
18092 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018093
18094 if (present1 || present2) {
18095 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018096 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018097 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018098 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018099 } else {
18100 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018101 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018102 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018103 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018104 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018105}
18106
Kailang Yangebb83ee2009-12-17 12:23:00 +010018107static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18108{
18109 unsigned int present1, present2;
18110
18111 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18112 AC_VERB_GET_PIN_SENSE, 0)
18113 & AC_PINSENSE_PRESENCE;
18114 present2 = snd_hda_codec_read(codec, 0x21, 0,
18115 AC_VERB_GET_PIN_SENSE, 0)
18116 & AC_PINSENSE_PRESENCE;
18117
18118 if (present1 || present2) {
18119 snd_hda_codec_write_cache(codec, 0x14, 0,
18120 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18121 snd_hda_codec_write_cache(codec, 0x17, 0,
18122 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18123 } else {
18124 snd_hda_codec_write_cache(codec, 0x14, 0,
18125 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18126 snd_hda_codec_write_cache(codec, 0x17, 0,
18127 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18128 }
18129}
18130
18131static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18132{
18133 unsigned int present1, present2;
18134
18135 present1 = snd_hda_codec_read(codec, 0x21, 0,
18136 AC_VERB_GET_PIN_SENSE, 0)
18137 & AC_PINSENSE_PRESENCE;
18138 present2 = snd_hda_codec_read(codec, 0x15, 0,
18139 AC_VERB_GET_PIN_SENSE, 0)
18140 & AC_PINSENSE_PRESENCE;
18141
18142 if (present1 || present2) {
18143 snd_hda_codec_write_cache(codec, 0x14, 0,
18144 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18145 snd_hda_codec_write_cache(codec, 0x17, 0,
18146 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18147 } else {
18148 snd_hda_codec_write_cache(codec, 0x14, 0,
18149 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18150 snd_hda_codec_write_cache(codec, 0x17, 0,
18151 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18152 }
18153}
18154
Kailang Yang6dda9f42008-05-27 12:05:31 +020018155static void alc663_m51va_unsol_event(struct hda_codec *codec,
18156 unsigned int res)
18157{
18158 switch (res >> 26) {
18159 case ALC880_HP_EVENT:
18160 alc663_m51va_speaker_automute(codec);
18161 break;
18162 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018163 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018164 break;
18165 }
18166}
18167
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018168static void alc663_m51va_setup(struct hda_codec *codec)
18169{
18170 struct alc_spec *spec = codec->spec;
18171 spec->ext_mic.pin = 0x18;
18172 spec->ext_mic.mux_idx = 0;
18173 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018174 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018175 spec->auto_mic = 1;
18176}
18177
Kailang Yang6dda9f42008-05-27 12:05:31 +020018178static void alc663_m51va_inithook(struct hda_codec *codec)
18179{
18180 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018181 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018182}
18183
Kailang Yangf1d4e282008-08-26 14:03:29 +020018184/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018185#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018186
18187static void alc663_mode1_setup(struct hda_codec *codec)
18188{
18189 struct alc_spec *spec = codec->spec;
18190 spec->ext_mic.pin = 0x18;
18191 spec->ext_mic.mux_idx = 0;
18192 spec->int_mic.pin = 0x19;
18193 spec->int_mic.mux_idx = 1;
18194 spec->auto_mic = 1;
18195}
18196
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018197#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018198
Kailang Yangf1d4e282008-08-26 14:03:29 +020018199/* ***************** Mode2 ******************************/
18200static void alc662_mode2_unsol_event(struct hda_codec *codec,
18201 unsigned int res)
18202{
18203 switch (res >> 26) {
18204 case ALC880_HP_EVENT:
18205 alc662_f5z_speaker_automute(codec);
18206 break;
18207 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018208 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018209 break;
18210 }
18211}
18212
Kailang Yangebb83ee2009-12-17 12:23:00 +010018213#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018214
Kailang Yangf1d4e282008-08-26 14:03:29 +020018215static void alc662_mode2_inithook(struct hda_codec *codec)
18216{
18217 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018218 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018219}
18220/* ***************** Mode3 ******************************/
18221static void alc663_mode3_unsol_event(struct hda_codec *codec,
18222 unsigned int res)
18223{
18224 switch (res >> 26) {
18225 case ALC880_HP_EVENT:
18226 alc663_two_hp_m1_speaker_automute(codec);
18227 break;
18228 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018229 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018230 break;
18231 }
18232}
18233
Kailang Yangebb83ee2009-12-17 12:23:00 +010018234#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018235
Kailang Yangf1d4e282008-08-26 14:03:29 +020018236static void alc663_mode3_inithook(struct hda_codec *codec)
18237{
18238 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018239 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018240}
18241/* ***************** Mode4 ******************************/
18242static void alc663_mode4_unsol_event(struct hda_codec *codec,
18243 unsigned int res)
18244{
18245 switch (res >> 26) {
18246 case ALC880_HP_EVENT:
18247 alc663_21jd_two_speaker_automute(codec);
18248 break;
18249 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018250 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018251 break;
18252 }
18253}
18254
Kailang Yangebb83ee2009-12-17 12:23:00 +010018255#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018256
Kailang Yangf1d4e282008-08-26 14:03:29 +020018257static void alc663_mode4_inithook(struct hda_codec *codec)
18258{
18259 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018260 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018261}
18262/* ***************** Mode5 ******************************/
18263static void alc663_mode5_unsol_event(struct hda_codec *codec,
18264 unsigned int res)
18265{
18266 switch (res >> 26) {
18267 case ALC880_HP_EVENT:
18268 alc663_15jd_two_speaker_automute(codec);
18269 break;
18270 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018271 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018272 break;
18273 }
18274}
18275
Kailang Yangebb83ee2009-12-17 12:23:00 +010018276#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018277
Kailang Yangf1d4e282008-08-26 14:03:29 +020018278static void alc663_mode5_inithook(struct hda_codec *codec)
18279{
18280 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018281 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018282}
18283/* ***************** Mode6 ******************************/
18284static void alc663_mode6_unsol_event(struct hda_codec *codec,
18285 unsigned int res)
18286{
18287 switch (res >> 26) {
18288 case ALC880_HP_EVENT:
18289 alc663_two_hp_m2_speaker_automute(codec);
18290 break;
18291 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018292 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018293 break;
18294 }
18295}
18296
Kailang Yangebb83ee2009-12-17 12:23:00 +010018297#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018298
Kailang Yangf1d4e282008-08-26 14:03:29 +020018299static void alc663_mode6_inithook(struct hda_codec *codec)
18300{
18301 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018302 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018303}
18304
Kailang Yangebb83ee2009-12-17 12:23:00 +010018305/* ***************** Mode7 ******************************/
18306static void alc663_mode7_unsol_event(struct hda_codec *codec,
18307 unsigned int res)
18308{
18309 switch (res >> 26) {
18310 case ALC880_HP_EVENT:
18311 alc663_two_hp_m7_speaker_automute(codec);
18312 break;
18313 case ALC880_MIC_EVENT:
18314 alc_mic_automute(codec);
18315 break;
18316 }
18317}
18318
18319#define alc663_mode7_setup alc663_mode1_setup
18320
18321static void alc663_mode7_inithook(struct hda_codec *codec)
18322{
18323 alc663_two_hp_m7_speaker_automute(codec);
18324 alc_mic_automute(codec);
18325}
18326
18327/* ***************** Mode8 ******************************/
18328static void alc663_mode8_unsol_event(struct hda_codec *codec,
18329 unsigned int res)
18330{
18331 switch (res >> 26) {
18332 case ALC880_HP_EVENT:
18333 alc663_two_hp_m8_speaker_automute(codec);
18334 break;
18335 case ALC880_MIC_EVENT:
18336 alc_mic_automute(codec);
18337 break;
18338 }
18339}
18340
18341#define alc663_mode8_setup alc663_m51va_setup
18342
18343static void alc663_mode8_inithook(struct hda_codec *codec)
18344{
18345 alc663_two_hp_m8_speaker_automute(codec);
18346 alc_mic_automute(codec);
18347}
18348
Kailang Yang6dda9f42008-05-27 12:05:31 +020018349static void alc663_g71v_hp_automute(struct hda_codec *codec)
18350{
18351 unsigned int present;
18352 unsigned char bits;
18353
Wu Fengguang864f92b2009-11-18 12:38:02 +080018354 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018355 bits = present ? HDA_AMP_MUTE : 0;
18356 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18357 HDA_AMP_MUTE, bits);
18358 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18359 HDA_AMP_MUTE, bits);
18360}
18361
18362static void alc663_g71v_front_automute(struct hda_codec *codec)
18363{
18364 unsigned int present;
18365 unsigned char bits;
18366
Wu Fengguang864f92b2009-11-18 12:38:02 +080018367 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018368 bits = present ? HDA_AMP_MUTE : 0;
18369 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18370 HDA_AMP_MUTE, bits);
18371}
18372
18373static void alc663_g71v_unsol_event(struct hda_codec *codec,
18374 unsigned int res)
18375{
18376 switch (res >> 26) {
18377 case ALC880_HP_EVENT:
18378 alc663_g71v_hp_automute(codec);
18379 break;
18380 case ALC880_FRONT_EVENT:
18381 alc663_g71v_front_automute(codec);
18382 break;
18383 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018384 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018385 break;
18386 }
18387}
18388
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018389#define alc663_g71v_setup alc663_m51va_setup
18390
Kailang Yang6dda9f42008-05-27 12:05:31 +020018391static void alc663_g71v_inithook(struct hda_codec *codec)
18392{
18393 alc663_g71v_front_automute(codec);
18394 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018395 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018396}
18397
18398static void alc663_g50v_unsol_event(struct hda_codec *codec,
18399 unsigned int res)
18400{
18401 switch (res >> 26) {
18402 case ALC880_HP_EVENT:
18403 alc663_m51va_speaker_automute(codec);
18404 break;
18405 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018406 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018407 break;
18408 }
18409}
18410
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018411#define alc663_g50v_setup alc663_m51va_setup
18412
Kailang Yang6dda9f42008-05-27 12:05:31 +020018413static void alc663_g50v_inithook(struct hda_codec *codec)
18414{
18415 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018416 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018417}
18418
Kailang Yangf1d4e282008-08-26 14:03:29 +020018419static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18420 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018421 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018422
18423 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18424 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18425 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18426
18427 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18428 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18429 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18430 { } /* end */
18431};
18432
Chris Pockelé9541ba12009-05-12 08:08:53 +020018433static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18434 /* Master Playback automatically created from Speaker and Headphone */
18435 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18436 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18437 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18438 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18439
18440 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18441 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18442 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18443
18444 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18445 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18446 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18447 { } /* end */
18448};
18449
Takashi Iwaicb53c622007-08-10 17:21:45 +020018450#ifdef CONFIG_SND_HDA_POWER_SAVE
18451#define alc662_loopbacks alc880_loopbacks
18452#endif
18453
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018454
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018455/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018456#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18457#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18458#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18459#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18460
18461/*
18462 * configuration and preset
18463 */
18464static const char *alc662_models[ALC662_MODEL_LAST] = {
18465 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18466 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18467 [ALC662_3ST_6ch] = "3stack-6ch",
18468 [ALC662_5ST_DIG] = "6stack-dig",
18469 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018470 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018471 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018472 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018473 [ALC663_ASUS_M51VA] = "m51va",
18474 [ALC663_ASUS_G71V] = "g71v",
18475 [ALC663_ASUS_H13] = "h13",
18476 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018477 [ALC663_ASUS_MODE1] = "asus-mode1",
18478 [ALC662_ASUS_MODE2] = "asus-mode2",
18479 [ALC663_ASUS_MODE3] = "asus-mode3",
18480 [ALC663_ASUS_MODE4] = "asus-mode4",
18481 [ALC663_ASUS_MODE5] = "asus-mode5",
18482 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018483 [ALC663_ASUS_MODE7] = "asus-mode7",
18484 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018485 [ALC272_DELL] = "dell",
18486 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018487 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018488 [ALC662_AUTO] = "auto",
18489};
18490
18491static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018492 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018493 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18494 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018495 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18496 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018497 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018498 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18499 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18500 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18501 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018502 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18503 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018504 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018505 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18506 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18507 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18508 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18509 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018510 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018511 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18512 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018513 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18514 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18515 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18516 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018517 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018518 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18519 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18520 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018521 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18522 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18523 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18524 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018525 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018526 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18527 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018528 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018529 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18530 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18531 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018532 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018533 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018534 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18535 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018536 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18537 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18538 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018539 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018540 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18541 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018542 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018543 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018544 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018545 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18546 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18547 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018548 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018549 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18550 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018551 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018552 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018553 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018554 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018555 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18556 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018557 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018558 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018559 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18560 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018561 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018562 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018563 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018564 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018565 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018566 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018567 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18568 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018569 {}
18570};
18571
18572static struct alc_config_preset alc662_presets[] = {
18573 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018574 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018575 .init_verbs = { alc662_init_verbs },
18576 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18577 .dac_nids = alc662_dac_nids,
18578 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018579 .dig_in_nid = ALC662_DIGIN_NID,
18580 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18581 .channel_mode = alc662_3ST_2ch_modes,
18582 .input_mux = &alc662_capture_source,
18583 },
18584 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018585 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018586 .init_verbs = { alc662_init_verbs },
18587 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18588 .dac_nids = alc662_dac_nids,
18589 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018590 .dig_in_nid = ALC662_DIGIN_NID,
18591 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18592 .channel_mode = alc662_3ST_6ch_modes,
18593 .need_dac_fix = 1,
18594 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018595 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018596 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018597 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018598 .init_verbs = { alc662_init_verbs },
18599 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18600 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018601 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18602 .channel_mode = alc662_3ST_6ch_modes,
18603 .need_dac_fix = 1,
18604 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018605 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018606 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018607 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018608 .init_verbs = { alc662_init_verbs },
18609 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18610 .dac_nids = alc662_dac_nids,
18611 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018612 .dig_in_nid = ALC662_DIGIN_NID,
18613 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18614 .channel_mode = alc662_5stack_modes,
18615 .input_mux = &alc662_capture_source,
18616 },
18617 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018618 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018619 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18620 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18621 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018622 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18623 .channel_mode = alc662_3ST_2ch_modes,
18624 .input_mux = &alc662_lenovo_101e_capture_source,
18625 .unsol_event = alc662_lenovo_101e_unsol_event,
18626 .init_hook = alc662_lenovo_101e_all_automute,
18627 },
Kailang Yang291702f2007-10-16 14:28:03 +020018628 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018629 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018630 .init_verbs = { alc662_init_verbs,
18631 alc662_eeepc_sue_init_verbs },
18632 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18633 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018634 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18635 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018636 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018637 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018638 .init_hook = alc662_eeepc_inithook,
18639 },
Kailang Yang8c427222008-01-10 13:03:59 +010018640 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018641 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018642 alc662_chmode_mixer },
18643 .init_verbs = { alc662_init_verbs,
18644 alc662_eeepc_ep20_sue_init_verbs },
18645 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18646 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018647 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18648 .channel_mode = alc662_3ST_6ch_modes,
18649 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018650 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018651 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018652 .init_hook = alc662_eeepc_ep20_inithook,
18653 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018654 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018655 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018656 .init_verbs = { alc662_init_verbs,
18657 alc662_ecs_init_verbs },
18658 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18659 .dac_nids = alc662_dac_nids,
18660 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18661 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018662 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018663 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018664 .init_hook = alc662_eeepc_inithook,
18665 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018666 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018667 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018668 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18669 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18670 .dac_nids = alc662_dac_nids,
18671 .dig_out_nid = ALC662_DIGOUT_NID,
18672 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18673 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018674 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018675 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018676 .init_hook = alc663_m51va_inithook,
18677 },
18678 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018679 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018680 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18681 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18682 .dac_nids = alc662_dac_nids,
18683 .dig_out_nid = ALC662_DIGOUT_NID,
18684 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18685 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018686 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018687 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018688 .init_hook = alc663_g71v_inithook,
18689 },
18690 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018691 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018692 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18693 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18694 .dac_nids = alc662_dac_nids,
18695 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18696 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018697 .unsol_event = alc663_m51va_unsol_event,
18698 .init_hook = alc663_m51va_inithook,
18699 },
18700 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018701 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018702 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18703 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18704 .dac_nids = alc662_dac_nids,
18705 .dig_out_nid = ALC662_DIGOUT_NID,
18706 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18707 .channel_mode = alc662_3ST_6ch_modes,
18708 .input_mux = &alc663_capture_source,
18709 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018710 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018711 .init_hook = alc663_g50v_inithook,
18712 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018713 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018714 .mixers = { alc663_m51va_mixer },
18715 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018716 .init_verbs = { alc662_init_verbs,
18717 alc663_21jd_amic_init_verbs },
18718 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18719 .hp_nid = 0x03,
18720 .dac_nids = alc662_dac_nids,
18721 .dig_out_nid = ALC662_DIGOUT_NID,
18722 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18723 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018724 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018725 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018726 .init_hook = alc663_mode1_inithook,
18727 },
18728 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018729 .mixers = { alc662_1bjd_mixer },
18730 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018731 .init_verbs = { alc662_init_verbs,
18732 alc662_1bjd_amic_init_verbs },
18733 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18734 .dac_nids = alc662_dac_nids,
18735 .dig_out_nid = ALC662_DIGOUT_NID,
18736 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18737 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018738 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018739 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018740 .init_hook = alc662_mode2_inithook,
18741 },
18742 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018743 .mixers = { alc663_two_hp_m1_mixer },
18744 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018745 .init_verbs = { alc662_init_verbs,
18746 alc663_two_hp_amic_m1_init_verbs },
18747 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18748 .hp_nid = 0x03,
18749 .dac_nids = alc662_dac_nids,
18750 .dig_out_nid = ALC662_DIGOUT_NID,
18751 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18752 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018753 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018754 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018755 .init_hook = alc663_mode3_inithook,
18756 },
18757 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018758 .mixers = { alc663_asus_21jd_clfe_mixer },
18759 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018760 .init_verbs = { alc662_init_verbs,
18761 alc663_21jd_amic_init_verbs},
18762 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18763 .hp_nid = 0x03,
18764 .dac_nids = alc662_dac_nids,
18765 .dig_out_nid = ALC662_DIGOUT_NID,
18766 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18767 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018768 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018769 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018770 .init_hook = alc663_mode4_inithook,
18771 },
18772 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018773 .mixers = { alc663_asus_15jd_clfe_mixer },
18774 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018775 .init_verbs = { alc662_init_verbs,
18776 alc663_15jd_amic_init_verbs },
18777 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18778 .hp_nid = 0x03,
18779 .dac_nids = alc662_dac_nids,
18780 .dig_out_nid = ALC662_DIGOUT_NID,
18781 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18782 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018783 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018784 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018785 .init_hook = alc663_mode5_inithook,
18786 },
18787 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018788 .mixers = { alc663_two_hp_m2_mixer },
18789 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018790 .init_verbs = { alc662_init_verbs,
18791 alc663_two_hp_amic_m2_init_verbs },
18792 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18793 .hp_nid = 0x03,
18794 .dac_nids = alc662_dac_nids,
18795 .dig_out_nid = ALC662_DIGOUT_NID,
18796 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18797 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018798 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018799 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018800 .init_hook = alc663_mode6_inithook,
18801 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018802 [ALC663_ASUS_MODE7] = {
18803 .mixers = { alc663_mode7_mixer },
18804 .cap_mixer = alc662_auto_capture_mixer,
18805 .init_verbs = { alc662_init_verbs,
18806 alc663_mode7_init_verbs },
18807 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18808 .hp_nid = 0x03,
18809 .dac_nids = alc662_dac_nids,
18810 .dig_out_nid = ALC662_DIGOUT_NID,
18811 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18812 .channel_mode = alc662_3ST_2ch_modes,
18813 .unsol_event = alc663_mode7_unsol_event,
18814 .setup = alc663_mode7_setup,
18815 .init_hook = alc663_mode7_inithook,
18816 },
18817 [ALC663_ASUS_MODE8] = {
18818 .mixers = { alc663_mode8_mixer },
18819 .cap_mixer = alc662_auto_capture_mixer,
18820 .init_verbs = { alc662_init_verbs,
18821 alc663_mode8_init_verbs },
18822 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18823 .hp_nid = 0x03,
18824 .dac_nids = alc662_dac_nids,
18825 .dig_out_nid = ALC662_DIGOUT_NID,
18826 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18827 .channel_mode = alc662_3ST_2ch_modes,
18828 .unsol_event = alc663_mode8_unsol_event,
18829 .setup = alc663_mode8_setup,
18830 .init_hook = alc663_mode8_inithook,
18831 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018832 [ALC272_DELL] = {
18833 .mixers = { alc663_m51va_mixer },
18834 .cap_mixer = alc272_auto_capture_mixer,
18835 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18836 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18837 .dac_nids = alc662_dac_nids,
18838 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18839 .adc_nids = alc272_adc_nids,
18840 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18841 .capsrc_nids = alc272_capsrc_nids,
18842 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018843 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018844 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018845 .init_hook = alc663_m51va_inithook,
18846 },
18847 [ALC272_DELL_ZM1] = {
18848 .mixers = { alc663_m51va_mixer },
18849 .cap_mixer = alc662_auto_capture_mixer,
18850 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18851 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18852 .dac_nids = alc662_dac_nids,
18853 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18854 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018855 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018856 .capsrc_nids = alc662_capsrc_nids,
18857 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018858 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018859 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018860 .init_hook = alc663_m51va_inithook,
18861 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018862 [ALC272_SAMSUNG_NC10] = {
18863 .mixers = { alc272_nc10_mixer },
18864 .init_verbs = { alc662_init_verbs,
18865 alc663_21jd_amic_init_verbs },
18866 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18867 .dac_nids = alc272_dac_nids,
18868 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18869 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018870 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018871 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018872 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018873 .init_hook = alc663_mode4_inithook,
18874 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018875};
18876
18877
18878/*
18879 * BIOS auto configuration
18880 */
18881
Takashi Iwai7085ec12009-10-02 09:03:58 +020018882/* convert from MIX nid to DAC */
18883static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18884{
18885 if (nid == 0x0f)
18886 return 0x02;
18887 else if (nid >= 0x0c && nid <= 0x0e)
18888 return nid - 0x0c + 0x02;
18889 else
18890 return 0;
18891}
18892
18893/* get MIX nid connected to the given pin targeted to DAC */
18894static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18895 hda_nid_t dac)
18896{
18897 hda_nid_t mix[4];
18898 int i, num;
18899
18900 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
18901 for (i = 0; i < num; i++) {
18902 if (alc662_mix_to_dac(mix[i]) == dac)
18903 return mix[i];
18904 }
18905 return 0;
18906}
18907
18908/* look for an empty DAC slot */
18909static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
18910{
18911 struct alc_spec *spec = codec->spec;
18912 hda_nid_t srcs[5];
18913 int i, j, num;
18914
18915 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
18916 if (num < 0)
18917 return 0;
18918 for (i = 0; i < num; i++) {
18919 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
18920 if (!nid)
18921 continue;
18922 for (j = 0; j < spec->multiout.num_dacs; j++)
18923 if (spec->multiout.dac_nids[j] == nid)
18924 break;
18925 if (j >= spec->multiout.num_dacs)
18926 return nid;
18927 }
18928 return 0;
18929}
18930
18931/* fill in the dac_nids table from the parsed pin configuration */
18932static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
18933 const struct auto_pin_cfg *cfg)
18934{
18935 struct alc_spec *spec = codec->spec;
18936 int i;
18937 hda_nid_t dac;
18938
18939 spec->multiout.dac_nids = spec->private_dac_nids;
18940 for (i = 0; i < cfg->line_outs; i++) {
18941 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
18942 if (!dac)
18943 continue;
18944 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
18945 }
18946 return 0;
18947}
18948
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018949static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018950 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018951{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018952 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018953 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
18954}
18955
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018956static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018957 hda_nid_t nid, unsigned int chs)
18958{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020018959 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020018960 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
18961}
18962
18963#define alc662_add_stereo_vol(spec, pfx, nid) \
18964 alc662_add_vol_ctl(spec, pfx, nid, 3)
18965#define alc662_add_stereo_sw(spec, pfx, nid) \
18966 alc662_add_sw_ctl(spec, pfx, nid, 3)
18967
18968/* add playback controls from the parsed DAC table */
18969static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
18970 const struct auto_pin_cfg *cfg)
18971{
18972 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018973 static const char *chname[4] = {
18974 "Front", "Surround", NULL /*CLFE*/, "Side"
18975 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020018976 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018977 int i, err;
18978
18979 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020018980 nid = spec->multiout.dac_nids[i];
18981 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018982 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018983 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
18984 if (!mix)
18985 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018986 if (i == 2) {
18987 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020018988 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018989 if (err < 0)
18990 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018991 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018992 if (err < 0)
18993 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018994 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018995 if (err < 0)
18996 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018997 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018998 if (err < 0)
18999 return err;
19000 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019001 const char *pfx;
19002 if (cfg->line_outs == 1 &&
19003 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019004 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019005 pfx = "Speaker";
19006 else
19007 pfx = "PCM";
19008 } else
19009 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019010 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019011 if (err < 0)
19012 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019013 if (cfg->line_outs == 1 &&
19014 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19015 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020019016 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019017 if (err < 0)
19018 return err;
19019 }
19020 }
19021 return 0;
19022}
19023
19024/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019025/* return DAC nid if any new DAC is assigned */
19026static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019027 const char *pfx)
19028{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019029 struct alc_spec *spec = codec->spec;
19030 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019031 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019032
19033 if (!pin)
19034 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019035 nid = alc662_look_for_dac(codec, pin);
19036 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019037 /* the corresponding DAC is already occupied */
19038 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19039 return 0; /* no way */
19040 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019041 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019042 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19043 }
19044
19045 mix = alc662_dac_to_mix(codec, pin, nid);
19046 if (!mix)
19047 return 0;
19048 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19049 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019050 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019051 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19052 if (err < 0)
19053 return err;
19054 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019055}
19056
19057/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019058#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019059 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019060
19061static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19062 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019063 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019064{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019065 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019066 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019067
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019068 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019069 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019070 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19071 if (num <= 1)
19072 return;
19073 for (i = 0; i < num; i++) {
19074 if (alc662_mix_to_dac(srcs[i]) != dac)
19075 continue;
19076 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19077 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019078 }
19079}
19080
19081static void alc662_auto_init_multi_out(struct hda_codec *codec)
19082{
19083 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019084 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019085 int i;
19086
19087 for (i = 0; i <= HDA_SIDE; i++) {
19088 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19089 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019090 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019091 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019092 }
19093}
19094
19095static void alc662_auto_init_hp_out(struct hda_codec *codec)
19096{
19097 struct alc_spec *spec = codec->spec;
19098 hda_nid_t pin;
19099
19100 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019101 if (pin)
19102 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19103 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019104 pin = spec->autocfg.speaker_pins[0];
19105 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019106 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19107 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019108}
19109
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019110#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19111
19112static void alc662_auto_init_analog_input(struct hda_codec *codec)
19113{
19114 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019115 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019116 int i;
19117
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019118 for (i = 0; i < cfg->num_inputs; i++) {
19119 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019120 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019121 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019122 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019123 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019124 snd_hda_codec_write(codec, nid, 0,
19125 AC_VERB_SET_AMP_GAIN_MUTE,
19126 AMP_OUT_MUTE);
19127 }
19128 }
19129}
19130
Takashi Iwaif511b012008-08-15 16:46:42 +020019131#define alc662_auto_init_input_src alc882_auto_init_input_src
19132
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019133static int alc662_parse_auto_config(struct hda_codec *codec)
19134{
19135 struct alc_spec *spec = codec->spec;
19136 int err;
19137 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19138
19139 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19140 alc662_ignore);
19141 if (err < 0)
19142 return err;
19143 if (!spec->autocfg.line_outs)
19144 return 0; /* can't find valid BIOS pin config */
19145
Takashi Iwai7085ec12009-10-02 09:03:58 +020019146 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019147 if (err < 0)
19148 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019149 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019150 if (err < 0)
19151 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019152 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019153 spec->autocfg.speaker_pins[0],
19154 "Speaker");
19155 if (err < 0)
19156 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019157 if (err)
19158 spec->multiout.extra_out_nid[0] = err;
19159 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019160 "Headphone");
19161 if (err < 0)
19162 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019163 if (err)
19164 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019165 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019166 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019167 return err;
19168
19169 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19170
Takashi Iwai757899a2010-07-30 10:48:14 +020019171 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019172
Takashi Iwai603c4012008-07-30 15:01:44 +020019173 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019174 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019175
19176 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019177 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019178
Kailang Yangcec27c82010-02-04 14:18:18 +010019179 add_verb(spec, alc662_init_verbs);
19180 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019181 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019182 add_verb(spec, alc663_init_verbs);
19183
19184 if (codec->vendor_id == 0x10ec0272)
19185 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019186
19187 err = alc_auto_add_mic_boost(codec);
19188 if (err < 0)
19189 return err;
19190
Kailang Yang6227cdc2010-02-25 08:36:52 +010019191 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19192 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19193 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19194 else
19195 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019196
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019197 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019198}
19199
19200/* additional initialization for auto-configuration model */
19201static void alc662_auto_init(struct hda_codec *codec)
19202{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019203 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019204 alc662_auto_init_multi_out(codec);
19205 alc662_auto_init_hp_out(codec);
19206 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019207 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019208 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019209 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019210 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019211}
19212
David Henningsson6cb3b702010-09-09 08:51:44 +020019213enum {
19214 ALC662_FIXUP_IDEAPAD,
19215};
19216
19217static const struct alc_fixup alc662_fixups[] = {
19218 [ALC662_FIXUP_IDEAPAD] = {
19219 .pins = (const struct alc_pincfg[]) {
19220 { 0x17, 0x99130112 }, /* subwoofer */
19221 { }
19222 }
19223 },
19224};
19225
19226static struct snd_pci_quirk alc662_fixup_tbl[] = {
19227 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19228 {}
19229};
19230
19231
19232
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019233static int patch_alc662(struct hda_codec *codec)
19234{
19235 struct alc_spec *spec;
19236 int err, board_config;
19237
19238 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19239 if (!spec)
19240 return -ENOMEM;
19241
19242 codec->spec = spec;
19243
Kailang Yangda00c242010-03-19 11:23:45 +010019244 alc_auto_parse_customize_define(codec);
19245
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019246 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19247
Kailang Yangc027ddc2010-03-19 11:33:06 +010019248 if (alc_read_coef_idx(codec, 0) == 0x8020)
19249 alc_codec_rename(codec, "ALC661");
19250 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
19251 codec->bus->pci->subsystem_vendor == 0x1025 &&
19252 spec->cdefine.platform_type == 1)
19253 alc_codec_rename(codec, "ALC272X");
Kailang Yang274693f2009-12-03 10:07:50 +010019254
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019255 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19256 alc662_models,
19257 alc662_cfg_tbl);
19258 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019259 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19260 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019261 board_config = ALC662_AUTO;
19262 }
19263
19264 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019265 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019266 /* automatic parse from the BIOS config */
19267 err = alc662_parse_auto_config(codec);
19268 if (err < 0) {
19269 alc_free(codec);
19270 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019271 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019272 printk(KERN_INFO
19273 "hda_codec: Cannot set up configuration "
19274 "from BIOS. Using base mode...\n");
19275 board_config = ALC662_3ST_2ch_DIG;
19276 }
19277 }
19278
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019279 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019280 err = snd_hda_attach_beep_device(codec, 0x1);
19281 if (err < 0) {
19282 alc_free(codec);
19283 return err;
19284 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019285 }
19286
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019287 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019288 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019289
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019290 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19291 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19292
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019293 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19294 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19295
Takashi Iwaidd704692009-08-11 08:45:11 +020019296 if (!spec->adc_nids) {
19297 spec->adc_nids = alc662_adc_nids;
19298 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19299 }
19300 if (!spec->capsrc_nids)
19301 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019302
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019303 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019304 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019305
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019306 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019307 switch (codec->vendor_id) {
19308 case 0x10ec0662:
19309 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19310 break;
19311 case 0x10ec0272:
19312 case 0x10ec0663:
19313 case 0x10ec0665:
19314 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19315 break;
19316 case 0x10ec0273:
19317 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19318 break;
19319 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019320 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019321 spec->vmaster_nid = 0x02;
19322
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019323 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019324 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019325 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019326 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 0);
19327 }
19328
Takashi Iwaicb53c622007-08-10 17:21:45 +020019329#ifdef CONFIG_SND_HDA_POWER_SAVE
19330 if (!spec->loopback.amplist)
19331 spec->loopback.amplist = alc662_loopbacks;
19332#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019333
19334 return 0;
19335}
19336
Kailang Yang274693f2009-12-03 10:07:50 +010019337static int patch_alc888(struct hda_codec *codec)
19338{
19339 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19340 kfree(codec->chip_name);
19341 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019342 if (!codec->chip_name) {
19343 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019344 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019345 }
19346 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019347 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019348 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019349}
19350
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019351/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019352 * ALC680 support
19353 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019354#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019355#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19356#define alc680_modes alc260_modes
19357
19358static hda_nid_t alc680_dac_nids[3] = {
19359 /* Lout1, Lout2, hp */
19360 0x02, 0x03, 0x04
19361};
19362
19363static hda_nid_t alc680_adc_nids[3] = {
19364 /* ADC0-2 */
19365 /* DMIC, MIC, Line-in*/
19366 0x07, 0x08, 0x09
19367};
19368
Kailang Yangc69aefa2010-08-17 10:39:22 +020019369/*
19370 * Analog capture ADC cgange
19371 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019372static void alc680_rec_autoswitch(struct hda_codec *codec)
19373{
19374 struct alc_spec *spec = codec->spec;
19375 struct auto_pin_cfg *cfg = &spec->autocfg;
19376 int pin_found = 0;
19377 int type_found = AUTO_PIN_LAST;
19378 hda_nid_t nid;
19379 int i;
19380
19381 for (i = 0; i < cfg->num_inputs; i++) {
19382 nid = cfg->inputs[i].pin;
19383 if (!(snd_hda_query_pin_caps(codec, nid) &
19384 AC_PINCAP_PRES_DETECT))
19385 continue;
19386 if (snd_hda_jack_detect(codec, nid)) {
19387 if (cfg->inputs[i].type < type_found) {
19388 type_found = cfg->inputs[i].type;
19389 pin_found = nid;
19390 }
19391 }
19392 }
19393
19394 nid = 0x07;
19395 if (pin_found)
19396 snd_hda_get_connections(codec, pin_found, &nid, 1);
19397
19398 if (nid != spec->cur_adc)
19399 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19400 spec->cur_adc = nid;
19401 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19402 spec->cur_adc_format);
19403}
19404
Kailang Yangc69aefa2010-08-17 10:39:22 +020019405static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19406 struct hda_codec *codec,
19407 unsigned int stream_tag,
19408 unsigned int format,
19409 struct snd_pcm_substream *substream)
19410{
19411 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019412
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019413 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019414 spec->cur_adc_stream_tag = stream_tag;
19415 spec->cur_adc_format = format;
19416
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019417 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019418 return 0;
19419}
19420
19421static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19422 struct hda_codec *codec,
19423 struct snd_pcm_substream *substream)
19424{
19425 snd_hda_codec_cleanup_stream(codec, 0x07);
19426 snd_hda_codec_cleanup_stream(codec, 0x08);
19427 snd_hda_codec_cleanup_stream(codec, 0x09);
19428 return 0;
19429}
19430
19431static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19432 .substreams = 1, /* can be overridden */
19433 .channels_min = 2,
19434 .channels_max = 2,
19435 /* NID is set in alc_build_pcms */
19436 .ops = {
19437 .prepare = alc680_capture_pcm_prepare,
19438 .cleanup = alc680_capture_pcm_cleanup
19439 },
19440};
19441
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019442static struct snd_kcontrol_new alc680_base_mixer[] = {
19443 /* output mixer control */
19444 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19445 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19446 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19447 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019448 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019449 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019450 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019451 { }
19452};
19453
Kailang Yangc69aefa2010-08-17 10:39:22 +020019454static struct hda_bind_ctls alc680_bind_cap_vol = {
19455 .ops = &snd_hda_bind_vol,
19456 .values = {
19457 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19458 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19459 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19460 0
19461 },
19462};
19463
19464static struct hda_bind_ctls alc680_bind_cap_switch = {
19465 .ops = &snd_hda_bind_sw,
19466 .values = {
19467 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19468 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19469 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19470 0
19471 },
19472};
19473
19474static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19475 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19476 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019477 { } /* end */
19478};
19479
19480/*
19481 * generic initialization of ADC, input mixers and output mixers
19482 */
19483static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019484 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19485 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19486 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019487
Kailang Yangc69aefa2010-08-17 10:39:22 +020019488 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19489 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19490 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19491 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19492 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19493 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019494
19495 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19496 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19497 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19498 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19499 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019500
19501 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19502 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019503 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019504
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019505 { }
19506};
19507
Kailang Yangc69aefa2010-08-17 10:39:22 +020019508/* toggle speaker-output according to the hp-jack state */
19509static void alc680_base_setup(struct hda_codec *codec)
19510{
19511 struct alc_spec *spec = codec->spec;
19512
19513 spec->autocfg.hp_pins[0] = 0x16;
19514 spec->autocfg.speaker_pins[0] = 0x14;
19515 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019516 spec->autocfg.num_inputs = 2;
19517 spec->autocfg.inputs[0].pin = 0x18;
19518 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19519 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019520 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019521}
19522
19523static void alc680_unsol_event(struct hda_codec *codec,
19524 unsigned int res)
19525{
19526 if ((res >> 26) == ALC880_HP_EVENT)
19527 alc_automute_amp(codec);
19528 if ((res >> 26) == ALC880_MIC_EVENT)
19529 alc680_rec_autoswitch(codec);
19530}
19531
19532static void alc680_inithook(struct hda_codec *codec)
19533{
19534 alc_automute_amp(codec);
19535 alc680_rec_autoswitch(codec);
19536}
19537
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019538/* create input playback/capture controls for the given pin */
19539static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19540 const char *ctlname, int idx)
19541{
19542 hda_nid_t dac;
19543 int err;
19544
19545 switch (nid) {
19546 case 0x14:
19547 dac = 0x02;
19548 break;
19549 case 0x15:
19550 dac = 0x03;
19551 break;
19552 case 0x16:
19553 dac = 0x04;
19554 break;
19555 default:
19556 return 0;
19557 }
19558 if (spec->multiout.dac_nids[0] != dac &&
19559 spec->multiout.dac_nids[1] != dac) {
19560 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19561 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19562 HDA_OUTPUT));
19563 if (err < 0)
19564 return err;
19565
19566 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19567 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19568
19569 if (err < 0)
19570 return err;
19571 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19572 }
19573
19574 return 0;
19575}
19576
19577/* add playback controls from the parsed DAC table */
19578static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19579 const struct auto_pin_cfg *cfg)
19580{
19581 hda_nid_t nid;
19582 int err;
19583
19584 spec->multiout.dac_nids = spec->private_dac_nids;
19585
19586 nid = cfg->line_out_pins[0];
19587 if (nid) {
19588 const char *name;
19589 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19590 name = "Speaker";
19591 else
19592 name = "Front";
19593 err = alc680_new_analog_output(spec, nid, name, 0);
19594 if (err < 0)
19595 return err;
19596 }
19597
19598 nid = cfg->speaker_pins[0];
19599 if (nid) {
19600 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19601 if (err < 0)
19602 return err;
19603 }
19604 nid = cfg->hp_pins[0];
19605 if (nid) {
19606 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19607 if (err < 0)
19608 return err;
19609 }
19610
19611 return 0;
19612}
19613
19614static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19615 hda_nid_t nid, int pin_type)
19616{
19617 alc_set_pin_output(codec, nid, pin_type);
19618}
19619
19620static void alc680_auto_init_multi_out(struct hda_codec *codec)
19621{
19622 struct alc_spec *spec = codec->spec;
19623 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19624 if (nid) {
19625 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19626 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19627 }
19628}
19629
19630static void alc680_auto_init_hp_out(struct hda_codec *codec)
19631{
19632 struct alc_spec *spec = codec->spec;
19633 hda_nid_t pin;
19634
19635 pin = spec->autocfg.hp_pins[0];
19636 if (pin)
19637 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19638 pin = spec->autocfg.speaker_pins[0];
19639 if (pin)
19640 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19641}
19642
19643/* pcm configuration: identical with ALC880 */
19644#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19645#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19646#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19647#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019648#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019649
19650/*
19651 * BIOS auto configuration
19652 */
19653static int alc680_parse_auto_config(struct hda_codec *codec)
19654{
19655 struct alc_spec *spec = codec->spec;
19656 int err;
19657 static hda_nid_t alc680_ignore[] = { 0 };
19658
19659 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19660 alc680_ignore);
19661 if (err < 0)
19662 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019663
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019664 if (!spec->autocfg.line_outs) {
19665 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19666 spec->multiout.max_channels = 2;
19667 spec->no_analog = 1;
19668 goto dig_only;
19669 }
19670 return 0; /* can't find valid BIOS pin config */
19671 }
19672 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19673 if (err < 0)
19674 return err;
19675
19676 spec->multiout.max_channels = 2;
19677
19678 dig_only:
19679 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019680 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019681 if (spec->kctls.list)
19682 add_mixer(spec, spec->kctls.list);
19683
19684 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019685
19686 err = alc_auto_add_mic_boost(codec);
19687 if (err < 0)
19688 return err;
19689
19690 return 1;
19691}
19692
19693#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19694
19695/* init callback for auto-configuration model -- overriding the default init */
19696static void alc680_auto_init(struct hda_codec *codec)
19697{
19698 struct alc_spec *spec = codec->spec;
19699 alc680_auto_init_multi_out(codec);
19700 alc680_auto_init_hp_out(codec);
19701 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019702 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019703 if (spec->unsol_event)
19704 alc_inithook(codec);
19705}
19706
19707/*
19708 * configuration and preset
19709 */
19710static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019711 [ALC680_BASE] = "base",
19712 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019713};
19714
19715static struct snd_pci_quirk alc680_cfg_tbl[] = {
19716 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19717 {}
19718};
19719
19720static struct alc_config_preset alc680_presets[] = {
19721 [ALC680_BASE] = {
19722 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019723 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019724 .init_verbs = { alc680_init_verbs },
19725 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19726 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019727 .dig_out_nid = ALC680_DIGOUT_NID,
19728 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19729 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019730 .unsol_event = alc680_unsol_event,
19731 .setup = alc680_base_setup,
19732 .init_hook = alc680_inithook,
19733
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019734 },
19735};
19736
19737static int patch_alc680(struct hda_codec *codec)
19738{
19739 struct alc_spec *spec;
19740 int board_config;
19741 int err;
19742
19743 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19744 if (spec == NULL)
19745 return -ENOMEM;
19746
19747 codec->spec = spec;
19748
19749 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19750 alc680_models,
19751 alc680_cfg_tbl);
19752
19753 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19754 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19755 codec->chip_name);
19756 board_config = ALC680_AUTO;
19757 }
19758
19759 if (board_config == ALC680_AUTO) {
19760 /* automatic parse from the BIOS config */
19761 err = alc680_parse_auto_config(codec);
19762 if (err < 0) {
19763 alc_free(codec);
19764 return err;
19765 } else if (!err) {
19766 printk(KERN_INFO
19767 "hda_codec: Cannot set up configuration "
19768 "from BIOS. Using base mode...\n");
19769 board_config = ALC680_BASE;
19770 }
19771 }
19772
19773 if (board_config != ALC680_AUTO)
19774 setup_preset(codec, &alc680_presets[board_config]);
19775
19776 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019777 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019778 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019779 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019780
19781 if (!spec->adc_nids) {
19782 spec->adc_nids = alc680_adc_nids;
19783 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19784 }
19785
19786 if (!spec->cap_mixer)
19787 set_capture_mixer(codec);
19788
19789 spec->vmaster_nid = 0x02;
19790
19791 codec->patch_ops = alc_patch_ops;
19792 if (board_config == ALC680_AUTO)
19793 spec->init_hook = alc680_auto_init;
19794
19795 return 0;
19796}
19797
19798/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019799 * patch entries
19800 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019801static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019802 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019803 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019804 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019805 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019806 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019807 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019808 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019809 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019810 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019811 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019812 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19813 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19814 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019815 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019816 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019817 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19818 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019819 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019820 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019821 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019822 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019823 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019824 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019825 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019826 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019827 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019828 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019829 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019830 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019831 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
Kailang Yang44426082008-10-15 11:18:05 +020019832 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019833 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019834 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019835 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019836 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019837 {} /* terminator */
19838};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019839
19840MODULE_ALIAS("snd-hda-codec-id:10ec*");
19841
19842MODULE_LICENSE("GPL");
19843MODULE_DESCRIPTION("Realtek HD-audio codec");
19844
19845static struct hda_codec_preset_list realtek_list = {
19846 .preset = snd_hda_preset_realtek,
19847 .owner = THIS_MODULE,
19848};
19849
19850static int __init patch_realtek_init(void)
19851{
19852 return snd_hda_add_codec_preset(&realtek_list);
19853}
19854
19855static void __exit patch_realtek_exit(void)
19856{
19857 snd_hda_delete_codec_preset(&realtek_list);
19858}
19859
19860module_init(patch_realtek_init)
19861module_exit(patch_realtek_exit)