blob: fc435b59a52f136276b64402a0a49c2d2cbacba9 [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,
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +0200234 ALC883_MEDION_WIM2160,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +0100235 ALC883_LAPTOP_EAPD,
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200236 ALC883_LENOVO_101E_2ch,
Kailang Yang272a5272007-05-14 11:00:38 +0200237 ALC883_LENOVO_NB0763,
Kailang Yang189609a2007-08-20 11:31:23 +0200238 ALC888_LENOVO_MS7195_DIG,
Kailang Yange2757d52008-08-26 13:17:46 +0200239 ALC888_LENOVO_SKY,
Kailang Yangea1fb292008-08-26 12:58:38 +0200240 ALC883_HAIER_W66,
Claudio Matsuoka4723c022007-07-13 14:36:19 +0200241 ALC888_3ST_HP,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +0100242 ALC888_6ST_DELL,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +0100243 ALC883_MITAC,
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -0430244 ALC883_CLEVO_M540R,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +0100245 ALC883_CLEVO_M720,
Jiang zhefb97dc62008-03-06 11:07:11 +0100246 ALC883_FUJITSU_PI2515,
Vincent Petryef8ef5f2008-11-23 11:31:41 +0800247 ALC888_FUJITSU_XA3530,
Jiang zhe17bba1b2008-06-04 12:11:07 +0200248 ALC883_3ST_6ch_INTEL,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +0200249 ALC889A_INTEL,
250 ALC889_INTEL,
Kailang Yange2757d52008-08-26 13:17:46 +0200251 ALC888_ASUS_M90V,
252 ALC888_ASUS_EEE1601,
Torben Schulzeb4c41d2009-05-18 15:02:35 +0200253 ALC889A_MB31,
Wu Fengguang3ab90932008-11-17 09:51:09 +0100254 ALC1200_ASUS_P5Q,
Guido Günther3e1647c2009-06-05 00:47:26 +0200255 ALC883_SONY_VAIO_TT,
Takashi Iwai4953550a2009-06-30 15:28:30 +0200256 ALC882_AUTO,
257 ALC882_MODEL_LAST,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200258};
259
Takashi Iwaid4a86d82010-06-23 17:51:26 +0200260/* ALC680 models */
261enum {
262 ALC680_BASE,
263 ALC680_AUTO,
264 ALC680_MODEL_LAST,
265};
266
Kailang Yangdf694da2005-12-05 19:42:22 +0100267/* for GPIO Poll */
268#define GPIO_MASK 0x03
269
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200270/* extra amp-initialization sequence types */
271enum {
272 ALC_INIT_NONE,
273 ALC_INIT_DEFAULT,
274 ALC_INIT_GPIO1,
275 ALC_INIT_GPIO2,
276 ALC_INIT_GPIO3,
277};
278
Takashi Iwai6c819492009-08-10 18:47:44 +0200279struct alc_mic_route {
280 hda_nid_t pin;
281 unsigned char mux_idx;
282 unsigned char amix_idx;
283};
284
Kailang Yang9ad0e492010-09-14 23:22:00 +0200285struct alc_jack {
286 hda_nid_t nid;
287 int type;
288 struct snd_jack *jack;
289};
290
Takashi Iwai6c819492009-08-10 18:47:44 +0200291#define MUX_IDX_UNDEF ((unsigned char)-1)
292
Kailang Yangda00c242010-03-19 11:23:45 +0100293struct alc_customize_define {
294 unsigned int sku_cfg;
295 unsigned char port_connectivity;
296 unsigned char check_sum;
297 unsigned char customization;
298 unsigned char external_amp;
299 unsigned int enable_pcbeep:1;
300 unsigned int platform_type:1;
301 unsigned int swap:1;
302 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200303 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100304};
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 Iwaid433a672010-09-20 15:11:54 +0200396 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100397
Takashi Iwai2134ea42008-01-10 16:53:55 +0100398 /* for virtual master */
399 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200400#ifdef CONFIG_SND_HDA_POWER_SAVE
401 struct hda_loopback_check loopback;
402#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200403
404 /* for PLL fix */
405 hda_nid_t pll_nid;
406 unsigned int pll_coef_idx, pll_coef_bit;
Kailang Yangdf694da2005-12-05 19:42:22 +0100407};
408
409/*
410 * configuration template - to be copied to the spec instance
411 */
412struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200413 struct snd_kcontrol_new *mixers[5]; /* should be identical size
414 * with spec
415 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100416 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100417 const struct hda_verb *init_verbs[5];
418 unsigned int num_dacs;
419 hda_nid_t *dac_nids;
420 hda_nid_t dig_out_nid; /* optional */
421 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800422 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100423 unsigned int num_adc_nids;
424 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100425 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100426 hda_nid_t dig_in_nid;
427 unsigned int num_channel_mode;
428 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200429 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200430 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200431 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100432 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100433 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200434 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100435 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200436#ifdef CONFIG_SND_HDA_POWER_SAVE
437 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500438 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200439#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440};
441
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
443/*
444 * input MUX handling
445 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200446static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
447 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448{
449 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
450 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200451 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
452 if (mux_idx >= spec->num_mux_defs)
453 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100454 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
455 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200456 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457}
458
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200459static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461{
462 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
463 struct alc_spec *spec = codec->spec;
464 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
465
466 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
467 return 0;
468}
469
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200470static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
471 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472{
473 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
474 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100475 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100477 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100478 hda_nid_t nid = spec->capsrc_nids ?
479 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200480 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481
Takashi Iwaicd896c32008-11-18 12:36:33 +0100482 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
483 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100484 if (!imux->num_items && mux_idx > 0)
485 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100486
Takashi Iwaia22d5432009-07-27 12:54:26 +0200487 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200488 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100489 /* Matrix-mixer style (e.g. ALC882) */
490 unsigned int *cur_val = &spec->cur_mux[adc_idx];
491 unsigned int i, idx;
492
493 idx = ucontrol->value.enumerated.item[0];
494 if (idx >= imux->num_items)
495 idx = imux->num_items - 1;
496 if (*cur_val == idx)
497 return 0;
498 for (i = 0; i < imux->num_items; i++) {
499 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
500 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
501 imux->items[i].index,
502 HDA_AMP_MUTE, v);
503 }
504 *cur_val = idx;
505 return 1;
506 } else {
507 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100508 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100509 &spec->cur_mux[adc_idx]);
510 }
511}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200512
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513/*
514 * channel mode setting
515 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200516static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
517 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518{
519 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
520 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100521 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
522 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523}
524
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200525static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
526 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527{
528 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
529 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100530 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200531 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200532 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533}
534
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200535static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
536 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537{
538 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
539 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200540 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
541 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200542 &spec->ext_channel_count);
543 if (err >= 0 && !spec->const_channel_count) {
544 spec->multiout.max_channels = spec->ext_channel_count;
545 if (spec->need_dac_fix)
546 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
547 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200548 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549}
550
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200553 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100554 * being part of a format specifier. Maximum allowed length of a value is
555 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100556 *
557 * Note: some retasking pin complexes seem to ignore requests for input
558 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
559 * are requested. Therefore order this list so that this behaviour will not
560 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200561 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
562 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200563 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100564static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100565 "Mic 50pc bias", "Mic 80pc bias",
566 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100567};
568static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100569 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100570};
571/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200572 * in the pin being assumed to be exclusively an input or an output pin. In
573 * addition, "input" pins may or may not process the mic bias option
574 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
575 * accept requests for bias as of chip versions up to March 2006) and/or
576 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100577 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200578#define ALC_PIN_DIR_IN 0x00
579#define ALC_PIN_DIR_OUT 0x01
580#define ALC_PIN_DIR_INOUT 0x02
581#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
582#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100583
Kailang Yangea1fb292008-08-26 12:58:38 +0200584/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100585 * For each direction the minimum and maximum values are given.
586 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200587static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100588 { 0, 2 }, /* ALC_PIN_DIR_IN */
589 { 3, 4 }, /* ALC_PIN_DIR_OUT */
590 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200591 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
592 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100593};
594#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
595#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
596#define alc_pin_mode_n_items(_dir) \
597 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
598
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200599static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
600 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200601{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100602 unsigned int item_num = uinfo->value.enumerated.item;
603 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
604
605 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200606 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100607 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
608
609 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
610 item_num = alc_pin_mode_min(dir);
611 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200612 return 0;
613}
614
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200615static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
616 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200617{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100618 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200619 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
620 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100621 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200622 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200623 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
624 AC_VERB_GET_PIN_WIDGET_CONTROL,
625 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200626
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100627 /* Find enumerated value for current pinctl setting */
628 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200629 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100630 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200631 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100632 return 0;
633}
634
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200635static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
636 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100637{
638 signed int change;
639 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
640 hda_nid_t nid = kcontrol->private_value & 0xffff;
641 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
642 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200643 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
644 AC_VERB_GET_PIN_WIDGET_CONTROL,
645 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100646
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200647 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100648 val = alc_pin_mode_min(dir);
649
650 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100651 if (change) {
652 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200653 snd_hda_codec_write_cache(codec, nid, 0,
654 AC_VERB_SET_PIN_WIDGET_CONTROL,
655 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100656
Kailang Yangea1fb292008-08-26 12:58:38 +0200657 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100658 * for the requested pin mode. Enum values of 2 or less are
659 * input modes.
660 *
661 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200662 * reduces noise slightly (particularly on input) so we'll
663 * do it. However, having both input and output buffers
664 * enabled simultaneously doesn't seem to be problematic if
665 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100666 */
667 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200668 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
669 HDA_AMP_MUTE, HDA_AMP_MUTE);
670 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
671 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100672 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200673 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
674 HDA_AMP_MUTE, HDA_AMP_MUTE);
675 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
676 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100677 }
678 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200679 return change;
680}
681
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100682#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200683 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100684 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100685 .info = alc_pin_mode_info, \
686 .get = alc_pin_mode_get, \
687 .put = alc_pin_mode_put, \
688 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100689
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100690/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
691 * together using a mask with more than one bit set. This control is
692 * currently used only by the ALC260 test model. At this stage they are not
693 * needed for any "production" models.
694 */
695#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200696#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200697
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200698static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
699 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100700{
701 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
702 hda_nid_t nid = kcontrol->private_value & 0xffff;
703 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
704 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200705 unsigned int val = snd_hda_codec_read(codec, nid, 0,
706 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100707
708 *valp = (val & mask) != 0;
709 return 0;
710}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200711static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
712 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100713{
714 signed int change;
715 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
716 hda_nid_t nid = kcontrol->private_value & 0xffff;
717 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
718 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200719 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
720 AC_VERB_GET_GPIO_DATA,
721 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100722
723 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200724 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
725 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100726 gpio_data &= ~mask;
727 else
728 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200729 snd_hda_codec_write_cache(codec, nid, 0,
730 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100731
732 return change;
733}
734#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
735 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100736 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100737 .info = alc_gpio_data_info, \
738 .get = alc_gpio_data_get, \
739 .put = alc_gpio_data_put, \
740 .private_value = nid | (mask<<16) }
741#endif /* CONFIG_SND_DEBUG */
742
Jonathan Woithe92621f12006-02-28 11:47:47 +0100743/* A switch control to allow the enabling of the digital IO pins on the
744 * ALC260. This is incredibly simplistic; the intention of this control is
745 * to provide something in the test model allowing digital outputs to be
746 * identified if present. If models are found which can utilise these
747 * outputs a more complete mixer control can be devised for those models if
748 * necessary.
749 */
750#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200751#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200752
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200753static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
754 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100755{
756 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
757 hda_nid_t nid = kcontrol->private_value & 0xffff;
758 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
759 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200760 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100761 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100762
763 *valp = (val & mask) != 0;
764 return 0;
765}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200766static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
767 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100768{
769 signed int change;
770 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
771 hda_nid_t nid = kcontrol->private_value & 0xffff;
772 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
773 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200774 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100775 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200776 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100777
778 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200779 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100780 if (val==0)
781 ctrl_data &= ~mask;
782 else
783 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200784 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
785 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100786
787 return change;
788}
789#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
790 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100791 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100792 .info = alc_spdif_ctrl_info, \
793 .get = alc_spdif_ctrl_get, \
794 .put = alc_spdif_ctrl_put, \
795 .private_value = nid | (mask<<16) }
796#endif /* CONFIG_SND_DEBUG */
797
Jonathan Woithef8225f62008-01-08 12:16:54 +0100798/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
799 * Again, this is only used in the ALC26x test models to help identify when
800 * the EAPD line must be asserted for features to work.
801 */
802#ifdef CONFIG_SND_DEBUG
803#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
804
805static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
806 struct snd_ctl_elem_value *ucontrol)
807{
808 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
809 hda_nid_t nid = kcontrol->private_value & 0xffff;
810 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
811 long *valp = ucontrol->value.integer.value;
812 unsigned int val = snd_hda_codec_read(codec, nid, 0,
813 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
814
815 *valp = (val & mask) != 0;
816 return 0;
817}
818
819static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
820 struct snd_ctl_elem_value *ucontrol)
821{
822 int change;
823 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
824 hda_nid_t nid = kcontrol->private_value & 0xffff;
825 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
826 long val = *ucontrol->value.integer.value;
827 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
828 AC_VERB_GET_EAPD_BTLENABLE,
829 0x00);
830
831 /* Set/unset the masked control bit(s) as needed */
832 change = (!val ? 0 : mask) != (ctrl_data & mask);
833 if (!val)
834 ctrl_data &= ~mask;
835 else
836 ctrl_data |= mask;
837 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
838 ctrl_data);
839
840 return change;
841}
842
843#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
844 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100845 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100846 .info = alc_eapd_ctrl_info, \
847 .get = alc_eapd_ctrl_get, \
848 .put = alc_eapd_ctrl_put, \
849 .private_value = nid | (mask<<16) }
850#endif /* CONFIG_SND_DEBUG */
851
Kailang Yangdf694da2005-12-05 19:42:22 +0100852/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100853 * set up the input pin config (depending on the given auto-pin type)
854 */
855static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
856 int auto_pin_type)
857{
858 unsigned int val = PIN_IN;
859
Takashi Iwai86e29592010-09-09 14:50:17 +0200860 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100861 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200862 unsigned int oldval;
863 oldval = snd_hda_codec_read(codec, nid, 0,
864 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100865 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100866 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200867 /* if the default pin setup is vref50, we give it priority */
868 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100869 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200870 else if (pincap & AC_PINCAP_VREF_50)
871 val = PIN_VREF50;
872 else if (pincap & AC_PINCAP_VREF_100)
873 val = PIN_VREF100;
874 else if (pincap & AC_PINCAP_VREF_GRD)
875 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100876 }
877 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
878}
879
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200880static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
881{
882 struct alc_spec *spec = codec->spec;
883 struct auto_pin_cfg *cfg = &spec->autocfg;
884
885 if (!cfg->line_outs) {
886 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
887 cfg->line_out_pins[cfg->line_outs])
888 cfg->line_outs++;
889 }
890 if (!cfg->speaker_outs) {
891 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
892 cfg->speaker_pins[cfg->speaker_outs])
893 cfg->speaker_outs++;
894 }
895 if (!cfg->hp_outs) {
896 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
897 cfg->hp_pins[cfg->hp_outs])
898 cfg->hp_outs++;
899 }
900}
901
Takashi Iwai23f0c042009-02-26 13:03:58 +0100902/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100903 */
904static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
905{
906 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
907 return;
908 spec->mixers[spec->num_mixers++] = mix;
909}
910
911static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
912{
913 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
914 return;
915 spec->init_verbs[spec->num_init_verbs++] = verb;
916}
917
918/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100919 * set up from the preset table
920 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200921static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200922 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100923{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200924 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100925 int i;
926
927 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100928 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100929 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200930 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
931 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100932 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200933
Kailang Yangdf694da2005-12-05 19:42:22 +0100934 spec->channel_mode = preset->channel_mode;
935 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200936 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200937 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100938
Hector Martin3b315d72009-06-02 10:54:19 +0200939 if (preset->const_channel_count)
940 spec->multiout.max_channels = preset->const_channel_count;
941 else
942 spec->multiout.max_channels = spec->channel_mode[0].channels;
943 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100944
945 spec->multiout.num_dacs = preset->num_dacs;
946 spec->multiout.dac_nids = preset->dac_nids;
947 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800948 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100949 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200950
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200951 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200952 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200953 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100954 spec->input_mux = preset->input_mux;
955
956 spec->num_adc_nids = preset->num_adc_nids;
957 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100958 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100959 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100960
961 spec->unsol_event = preset->unsol_event;
962 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200963#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100964 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200965 spec->loopback.amplist = preset->loopbacks;
966#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200967
968 if (preset->setup)
969 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200970
971 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100972}
973
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200974/* Enable GPIO mask and set output */
975static struct hda_verb alc_gpio1_init_verbs[] = {
976 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
977 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
978 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
979 { }
980};
981
982static struct hda_verb alc_gpio2_init_verbs[] = {
983 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
984 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
985 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
986 { }
987};
988
Kailang Yangbdd148a2007-05-08 15:19:08 +0200989static struct hda_verb alc_gpio3_init_verbs[] = {
990 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
991 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
992 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
993 { }
994};
995
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200996/*
997 * Fix hardware PLL issue
998 * On some codecs, the analog PLL gating control must be off while
999 * the default value is 1.
1000 */
1001static void alc_fix_pll(struct hda_codec *codec)
1002{
1003 struct alc_spec *spec = codec->spec;
1004 unsigned int val;
1005
1006 if (!spec->pll_nid)
1007 return;
1008 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1009 spec->pll_coef_idx);
1010 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1011 AC_VERB_GET_PROC_COEF, 0);
1012 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1013 spec->pll_coef_idx);
1014 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1015 val & ~(1 << spec->pll_coef_bit));
1016}
1017
1018static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1019 unsigned int coef_idx, unsigned int coef_bit)
1020{
1021 struct alc_spec *spec = codec->spec;
1022 spec->pll_nid = nid;
1023 spec->pll_coef_idx = coef_idx;
1024 spec->pll_coef_bit = coef_bit;
1025 alc_fix_pll(codec);
1026}
1027
Kailang Yang9ad0e492010-09-14 23:22:00 +02001028#ifdef CONFIG_SND_HDA_INPUT_JACK
1029static void alc_free_jack_priv(struct snd_jack *jack)
1030{
1031 struct alc_jack *jacks = jack->private_data;
1032 jacks->nid = 0;
1033 jacks->jack = NULL;
1034}
1035
1036static int alc_add_jack(struct hda_codec *codec,
1037 hda_nid_t nid, int type)
1038{
1039 struct alc_spec *spec;
1040 struct alc_jack *jack;
1041 const char *name;
1042 int err;
1043
1044 spec = codec->spec;
1045 snd_array_init(&spec->jacks, sizeof(*jack), 32);
1046 jack = snd_array_new(&spec->jacks);
1047 if (!jack)
1048 return -ENOMEM;
1049
1050 jack->nid = nid;
1051 jack->type = type;
1052 name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ;
1053
1054 err = snd_jack_new(codec->bus->card, name, type, &jack->jack);
1055 if (err < 0)
1056 return err;
1057 jack->jack->private_data = jack;
1058 jack->jack->private_free = alc_free_jack_priv;
1059 return 0;
1060}
1061
1062static void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1063{
1064 struct alc_spec *spec = codec->spec;
1065 struct alc_jack *jacks = spec->jacks.list;
1066
1067 if (jacks) {
1068 int i;
1069 for (i = 0; i < spec->jacks.used; i++) {
1070 if (jacks->nid == nid) {
1071 unsigned int present;
1072 present = snd_hda_jack_detect(codec, nid);
1073
1074 present = (present) ? jacks->type : 0;
1075
1076 snd_jack_report(jacks->jack, present);
1077 }
1078 jacks++;
1079 }
1080 }
1081}
1082
1083static int alc_init_jacks(struct hda_codec *codec)
1084{
1085 struct alc_spec *spec = codec->spec;
1086 int err;
1087 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1088 unsigned int mic_nid = spec->ext_mic.pin;
1089
Takashi Iwai265a0242010-09-21 11:26:21 +02001090 if (hp_nid) {
1091 err = alc_add_jack(codec, hp_nid, SND_JACK_HEADPHONE);
1092 if (err < 0)
1093 return err;
1094 alc_report_jack(codec, hp_nid);
1095 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001096
Takashi Iwai265a0242010-09-21 11:26:21 +02001097 if (mic_nid) {
1098 err = alc_add_jack(codec, mic_nid, SND_JACK_MICROPHONE);
1099 if (err < 0)
1100 return err;
1101 alc_report_jack(codec, mic_nid);
1102 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001103
1104 return 0;
1105}
1106#else
1107static inline void alc_report_jack(struct hda_codec *codec, hda_nid_t nid)
1108{
1109}
1110
1111static inline int alc_init_jacks(struct hda_codec *codec)
1112{
1113 return 0;
1114}
1115#endif
1116
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001117static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001118{
1119 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001120 unsigned int mute;
1121 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001122 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001123
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001124 spec->jack_present = 0;
1125 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1126 nid = spec->autocfg.hp_pins[i];
1127 if (!nid)
1128 break;
1129 if (snd_hda_jack_detect(codec, nid)) {
1130 spec->jack_present = 1;
1131 break;
1132 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001133 alc_report_jack(codec, spec->autocfg.hp_pins[i]);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001134 }
1135
1136 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1137 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001138 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1139 nid = spec->autocfg.speaker_pins[i];
1140 if (!nid)
1141 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001142 if (pinctl) {
1143 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001144 AC_VERB_SET_PIN_WIDGET_CONTROL,
1145 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001146 } else {
1147 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1148 HDA_AMP_MUTE, mute);
1149 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001150 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001151}
1152
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001153static void alc_automute_pin(struct hda_codec *codec)
1154{
1155 alc_automute_speaker(codec, 1);
1156}
1157
Takashi Iwai6c819492009-08-10 18:47:44 +02001158static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1159 hda_nid_t nid)
1160{
1161 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1162 int i, nums;
1163
1164 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1165 for (i = 0; i < nums; i++)
1166 if (conn[i] == nid)
1167 return i;
1168 return -1;
1169}
1170
Takashi Iwai840b64c2010-07-13 22:49:01 +02001171/* switch the current ADC according to the jack state */
1172static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1173{
1174 struct alc_spec *spec = codec->spec;
1175 unsigned int present;
1176 hda_nid_t new_adc;
1177
1178 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1179 if (present)
1180 spec->cur_adc_idx = 1;
1181 else
1182 spec->cur_adc_idx = 0;
1183 new_adc = spec->adc_nids[spec->cur_adc_idx];
1184 if (spec->cur_adc && spec->cur_adc != new_adc) {
1185 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001186 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001187 spec->cur_adc = new_adc;
1188 snd_hda_codec_setup_stream(codec, new_adc,
1189 spec->cur_adc_stream_tag, 0,
1190 spec->cur_adc_format);
1191 }
1192}
1193
Kailang Yang7fb0d782008-10-15 11:12:35 +02001194static void alc_mic_automute(struct hda_codec *codec)
1195{
1196 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001197 struct alc_mic_route *dead, *alive;
1198 unsigned int present, type;
1199 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001200
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001201 if (!spec->auto_mic)
1202 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001203 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1204 return;
1205 if (snd_BUG_ON(!spec->adc_nids))
1206 return;
1207
Takashi Iwai840b64c2010-07-13 22:49:01 +02001208 if (spec->dual_adc_switch) {
1209 alc_dual_mic_adc_auto_switch(codec);
1210 return;
1211 }
1212
Takashi Iwai6c819492009-08-10 18:47:44 +02001213 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1214
Wu Fengguang864f92b2009-11-18 12:38:02 +08001215 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001216 if (present) {
1217 alive = &spec->ext_mic;
1218 dead = &spec->int_mic;
1219 } else {
1220 alive = &spec->int_mic;
1221 dead = &spec->ext_mic;
1222 }
1223
Takashi Iwai6c819492009-08-10 18:47:44 +02001224 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1225 if (type == AC_WID_AUD_MIX) {
1226 /* Matrix-mixer style (e.g. ALC882) */
1227 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1228 alive->mux_idx,
1229 HDA_AMP_MUTE, 0);
1230 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1231 dead->mux_idx,
1232 HDA_AMP_MUTE, HDA_AMP_MUTE);
1233 } else {
1234 /* MUX style (e.g. ALC880) */
1235 snd_hda_codec_write_cache(codec, cap_nid, 0,
1236 AC_VERB_SET_CONNECT_SEL,
1237 alive->mux_idx);
1238 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001239 alc_report_jack(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001240
1241 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001242}
1243
Kailang Yangc9b58002007-10-16 14:30:01 +02001244/* unsolicited event for HP jack sensing */
1245static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1246{
1247 if (codec->vendor_id == 0x10ec0880)
1248 res >>= 28;
1249 else
1250 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001251 switch (res) {
1252 case ALC880_HP_EVENT:
1253 alc_automute_pin(codec);
1254 break;
1255 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001256 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001257 break;
1258 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001259}
1260
1261static void alc_inithook(struct hda_codec *codec)
1262{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001263 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001264 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001265}
1266
Kailang Yangf9423e72008-05-27 12:32:25 +02001267/* additional initialization for ALC888 variants */
1268static void alc888_coef_init(struct hda_codec *codec)
1269{
1270 unsigned int tmp;
1271
1272 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1273 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1274 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001275 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001276 /* alc888S-VC */
1277 snd_hda_codec_read(codec, 0x20, 0,
1278 AC_VERB_SET_PROC_COEF, 0x830);
1279 else
1280 /* alc888-VB */
1281 snd_hda_codec_read(codec, 0x20, 0,
1282 AC_VERB_SET_PROC_COEF, 0x3030);
1283}
1284
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001285static void alc889_coef_init(struct hda_codec *codec)
1286{
1287 unsigned int tmp;
1288
1289 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1290 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1291 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1292 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1293}
1294
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001295/* turn on/off EAPD control (only if available) */
1296static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1297{
1298 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1299 return;
1300 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1301 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1302 on ? 2 : 0);
1303}
1304
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001305static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001306{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001307 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001308
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001309 switch (type) {
1310 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001311 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1312 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001313 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001314 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1315 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001316 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001317 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1318 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001319 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001320 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001321 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001322 set_eapd(codec, 0x0f, 1);
1323 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001324 break;
1325 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001326 case 0x10ec0267:
1327 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001328 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001329 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001330 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001331 case 0x10ec0660:
1332 case 0x10ec0662:
1333 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001334 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001335 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001336 set_eapd(codec, 0x14, 1);
1337 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001338 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001339 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001340 switch (codec->vendor_id) {
1341 case 0x10ec0260:
1342 snd_hda_codec_write(codec, 0x1a, 0,
1343 AC_VERB_SET_COEF_INDEX, 7);
1344 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1345 AC_VERB_GET_PROC_COEF, 0);
1346 snd_hda_codec_write(codec, 0x1a, 0,
1347 AC_VERB_SET_COEF_INDEX, 7);
1348 snd_hda_codec_write(codec, 0x1a, 0,
1349 AC_VERB_SET_PROC_COEF,
1350 tmp | 0x2010);
1351 break;
1352 case 0x10ec0262:
1353 case 0x10ec0880:
1354 case 0x10ec0882:
1355 case 0x10ec0883:
1356 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001357 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001358 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001359 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001360 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001361 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001362 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001363 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001364#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001365 case 0x10ec0267:
1366 case 0x10ec0268:
1367 snd_hda_codec_write(codec, 0x20, 0,
1368 AC_VERB_SET_COEF_INDEX, 7);
1369 tmp = snd_hda_codec_read(codec, 0x20, 0,
1370 AC_VERB_GET_PROC_COEF, 0);
1371 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001372 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001373 snd_hda_codec_write(codec, 0x20, 0,
1374 AC_VERB_SET_PROC_COEF,
1375 tmp | 0x3000);
1376 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001377#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001378 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001379 break;
1380 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001381}
Kailang Yangea1fb292008-08-26 12:58:38 +02001382
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001383static void alc_init_auto_hp(struct hda_codec *codec)
1384{
1385 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001386 struct auto_pin_cfg *cfg = &spec->autocfg;
1387 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001388
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001389 if (!cfg->hp_pins[0]) {
1390 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001391 return;
1392 }
1393
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001394 if (!cfg->speaker_pins[0]) {
1395 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1396 return;
1397 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1398 sizeof(cfg->speaker_pins));
1399 cfg->speaker_outs = cfg->line_outs;
1400 }
1401
1402 if (!cfg->hp_pins[0]) {
1403 memcpy(cfg->hp_pins, cfg->line_out_pins,
1404 sizeof(cfg->hp_pins));
1405 cfg->hp_outs = cfg->line_outs;
1406 }
1407
1408 for (i = 0; i < cfg->hp_outs; i++) {
1409 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1410 cfg->hp_pins[i]);
1411 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001412 AC_VERB_SET_UNSOLICITED_ENABLE,
1413 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001414 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001415 spec->unsol_event = alc_sku_unsol_event;
1416}
1417
Takashi Iwai6c819492009-08-10 18:47:44 +02001418static void alc_init_auto_mic(struct hda_codec *codec)
1419{
1420 struct alc_spec *spec = codec->spec;
1421 struct auto_pin_cfg *cfg = &spec->autocfg;
1422 hda_nid_t fixed, ext;
1423 int i;
1424
1425 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001426 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001427 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001428 return;
1429
1430 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001431 for (i = 0; i < cfg->num_inputs; i++) {
1432 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001433 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001434 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001435 switch (snd_hda_get_input_pin_attr(defcfg)) {
1436 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001437 if (fixed)
1438 return; /* already occupied */
1439 fixed = nid;
1440 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001441 case INPUT_PIN_ATTR_UNUSED:
1442 return; /* invalid entry */
1443 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001444 if (ext)
1445 return; /* already occupied */
1446 ext = nid;
1447 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001448 }
1449 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001450 if (!ext || !fixed)
1451 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001452 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1453 return; /* no unsol support */
1454 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1455 ext, fixed);
1456 spec->ext_mic.pin = ext;
1457 spec->int_mic.pin = fixed;
1458 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1459 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1460 spec->auto_mic = 1;
1461 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1462 AC_VERB_SET_UNSOLICITED_ENABLE,
1463 AC_USRSP_EN | ALC880_MIC_EVENT);
1464 spec->unsol_event = alc_sku_unsol_event;
1465}
1466
David Henningsson90622912010-10-14 14:50:18 +02001467/* Could be any non-zero and even value. When used as fixup, tells
1468 * the driver to ignore any present sku defines.
1469 */
1470#define ALC_FIXUP_SKU_IGNORE (2)
1471
Kailang Yangda00c242010-03-19 11:23:45 +01001472static int alc_auto_parse_customize_define(struct hda_codec *codec)
1473{
1474 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001475 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001476 struct alc_spec *spec = codec->spec;
1477
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001478 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1479
David Henningsson90622912010-10-14 14:50:18 +02001480 if (spec->cdefine.fixup) {
1481 ass = spec->cdefine.sku_cfg;
1482 if (ass == ALC_FIXUP_SKU_IGNORE)
1483 return -1;
1484 goto do_sku;
1485 }
1486
Kailang Yangda00c242010-03-19 11:23:45 +01001487 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001488 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001489 goto do_sku;
1490
1491 nid = 0x1d;
1492 if (codec->vendor_id == 0x10ec0260)
1493 nid = 0x17;
1494 ass = snd_hda_codec_get_pincfg(codec, nid);
1495
1496 if (!(ass & 1)) {
1497 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1498 codec->chip_name, ass);
1499 return -1;
1500 }
1501
1502 /* check sum */
1503 tmp = 0;
1504 for (i = 1; i < 16; i++) {
1505 if ((ass >> i) & 1)
1506 tmp++;
1507 }
1508 if (((ass >> 16) & 0xf) != tmp)
1509 return -1;
1510
1511 spec->cdefine.port_connectivity = ass >> 30;
1512 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1513 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1514 spec->cdefine.customization = ass >> 8;
1515do_sku:
1516 spec->cdefine.sku_cfg = ass;
1517 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1518 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1519 spec->cdefine.swap = (ass & 0x2) >> 1;
1520 spec->cdefine.override = ass & 0x1;
1521
1522 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1523 nid, spec->cdefine.sku_cfg);
1524 snd_printd("SKU: port_connectivity=0x%x\n",
1525 spec->cdefine.port_connectivity);
1526 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1527 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1528 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1529 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1530 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1531 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1532 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1533
1534 return 0;
1535}
1536
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001537/* check subsystem ID and set up device-specific initialization;
1538 * return 1 if initialized, 0 if invalid SSID
1539 */
1540/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1541 * 31 ~ 16 : Manufacture ID
1542 * 15 ~ 8 : SKU ID
1543 * 7 ~ 0 : Assembly ID
1544 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1545 */
1546static int alc_subsystem_id(struct hda_codec *codec,
1547 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001548 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001549{
1550 unsigned int ass, tmp, i;
1551 unsigned nid;
1552 struct alc_spec *spec = codec->spec;
1553
David Henningsson90622912010-10-14 14:50:18 +02001554 if (spec->cdefine.fixup) {
1555 ass = spec->cdefine.sku_cfg;
1556 if (ass == ALC_FIXUP_SKU_IGNORE)
1557 return 0;
1558 goto do_sku;
1559 }
1560
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001561 ass = codec->subsystem_id & 0xffff;
1562 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1563 goto do_sku;
1564
1565 /* invalid SSID, check the special NID pin defcfg instead */
1566 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001567 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001568 * 29~21 : reserve
1569 * 20 : PCBEEP input
1570 * 19~16 : Check sum (15:1)
1571 * 15~1 : Custom
1572 * 0 : override
1573 */
1574 nid = 0x1d;
1575 if (codec->vendor_id == 0x10ec0260)
1576 nid = 0x17;
1577 ass = snd_hda_codec_get_pincfg(codec, nid);
1578 snd_printd("realtek: No valid SSID, "
1579 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001580 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001581 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001582 return 0;
1583 if ((ass >> 30) != 1) /* no physical connection */
1584 return 0;
1585
1586 /* check sum */
1587 tmp = 0;
1588 for (i = 1; i < 16; i++) {
1589 if ((ass >> i) & 1)
1590 tmp++;
1591 }
1592 if (((ass >> 16) & 0xf) != tmp)
1593 return 0;
1594do_sku:
1595 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1596 ass & 0xffff, codec->vendor_id);
1597 /*
1598 * 0 : override
1599 * 1 : Swap Jack
1600 * 2 : 0 --> Desktop, 1 --> Laptop
1601 * 3~5 : External Amplifier control
1602 * 7~6 : Reserved
1603 */
1604 tmp = (ass & 0x38) >> 3; /* external Amp control */
1605 switch (tmp) {
1606 case 1:
1607 spec->init_amp = ALC_INIT_GPIO1;
1608 break;
1609 case 3:
1610 spec->init_amp = ALC_INIT_GPIO2;
1611 break;
1612 case 7:
1613 spec->init_amp = ALC_INIT_GPIO3;
1614 break;
1615 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001616 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001617 spec->init_amp = ALC_INIT_DEFAULT;
1618 break;
1619 }
1620
1621 /* is laptop or Desktop and enable the function "Mute internal speaker
1622 * when the external headphone out jack is plugged"
1623 */
1624 if (!(ass & 0x8000))
1625 return 1;
1626 /*
1627 * 10~8 : Jack location
1628 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1629 * 14~13: Resvered
1630 * 15 : 1 --> enable the function "Mute internal speaker
1631 * when the external headphone out jack is plugged"
1632 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001633 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001634 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001635 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1636 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001637 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001638 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001639 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001640 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001641 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001642 else if (tmp == 3)
1643 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001644 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001645 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001646 for (i = 0; i < spec->autocfg.line_outs; i++)
1647 if (spec->autocfg.line_out_pins[i] == nid)
1648 return 1;
1649 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001650 }
1651
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001652 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001653 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001654 return 1;
1655}
Kailang Yangea1fb292008-08-26 12:58:38 +02001656
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001657static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001658 hda_nid_t porta, hda_nid_t porte,
1659 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001660{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001661 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001662 struct alc_spec *spec = codec->spec;
1663 snd_printd("realtek: "
1664 "Enable default setup for auto mode as fallback\n");
1665 spec->init_amp = ALC_INIT_DEFAULT;
1666 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001667 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001668 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001669}
1670
Takashi Iwai41e41f12005-06-08 14:48:49 +02001671/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001672 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001673 */
1674
1675struct alc_pincfg {
1676 hda_nid_t nid;
1677 u32 val;
1678};
1679
Todd Broche1eb5f12010-12-06 11:19:51 -08001680struct alc_model_fixup {
1681 const int id;
1682 const char *name;
1683};
1684
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001685struct alc_fixup {
David Henningsson90622912010-10-14 14:50:18 +02001686 unsigned int sku;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001687 const struct alc_pincfg *pins;
1688 const struct hda_verb *verbs;
Takashi Iwai9d578832010-11-22 13:29:19 +01001689 void (*func)(struct hda_codec *codec, const struct alc_fixup *fix,
1690 int pre_init);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001691};
1692
Todd Broche1eb5f12010-12-06 11:19:51 -08001693static void __alc_pick_fixup(struct hda_codec *codec,
1694 const struct alc_fixup *fix,
1695 const char *modelname,
1696 int pre_init)
Takashi Iwaif95474e2007-07-10 00:47:43 +02001697{
1698 const struct alc_pincfg *cfg;
David Henningsson90622912010-10-14 14:50:18 +02001699 struct alc_spec *spec;
Takashi Iwaif95474e2007-07-10 00:47:43 +02001700
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001701 cfg = fix->pins;
David Henningsson90622912010-10-14 14:50:18 +02001702 if (pre_init && fix->sku) {
1703#ifdef CONFIG_SND_DEBUG_VERBOSE
1704 snd_printdd(KERN_INFO "hda_codec: %s: Apply sku override for %s\n",
Todd Broche1eb5f12010-12-06 11:19:51 -08001705 codec->chip_name, modelname);
David Henningsson90622912010-10-14 14:50:18 +02001706#endif
1707 spec = codec->spec;
1708 spec->cdefine.sku_cfg = fix->sku;
1709 spec->cdefine.fixup = 1;
1710 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001711 if (pre_init && cfg) {
1712#ifdef CONFIG_SND_DEBUG_VERBOSE
1713 snd_printdd(KERN_INFO "hda_codec: %s: Apply pincfg for %s\n",
Todd Broche1eb5f12010-12-06 11:19:51 -08001714 codec->chip_name, modelname);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001715#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001716 for (; cfg->nid; cfg++)
1717 snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
1718 }
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001719 if (!pre_init && fix->verbs) {
1720#ifdef CONFIG_SND_DEBUG_VERBOSE
1721 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-verbs for %s\n",
Todd Broche1eb5f12010-12-06 11:19:51 -08001722 codec->chip_name, modelname);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001723#endif
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001724 add_verb(codec->spec, fix->verbs);
Takashi Iwai7fa90e82010-04-12 08:49:00 +02001725 }
Takashi Iwai9d578832010-11-22 13:29:19 +01001726 if (fix->func) {
1727#ifdef CONFIG_SND_DEBUG_VERBOSE
1728 snd_printdd(KERN_INFO "hda_codec: %s: Apply fix-func for %s\n",
Todd Broche1eb5f12010-12-06 11:19:51 -08001729 codec->chip_name, modelname);
Takashi Iwai9d578832010-11-22 13:29:19 +01001730#endif
1731 fix->func(codec, fix, pre_init);
1732 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001733}
1734
Todd Broche1eb5f12010-12-06 11:19:51 -08001735static void alc_pick_fixup(struct hda_codec *codec,
1736 const struct snd_pci_quirk *quirk,
1737 const struct alc_fixup *fix,
1738 int pre_init)
1739{
1740 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1741 if (quirk) {
1742 fix += quirk->value;
1743#ifdef CONFIG_SND_DEBUG_VERBOSE
1744 __alc_pick_fixup(codec, fix, quirk->name, pre_init);
1745#else
1746 __alc_pick_fixup(codec, fix, NULL, pre_init);
1747#endif
1748 }
1749}
1750
1751static void alc_pick_fixup_model(struct hda_codec *codec,
1752 const struct alc_model_fixup *models,
1753 const struct snd_pci_quirk *quirk,
1754 const struct alc_fixup *fix,
1755 int pre_init)
1756{
1757 if (codec->modelname && models) {
1758 while (models->name) {
1759 if (!strcmp(codec->modelname, models->name)) {
1760 fix += models->id;
1761 break;
1762 }
1763 models++;
1764 }
1765 __alc_pick_fixup(codec, fix, codec->modelname, pre_init);
1766 } else {
1767 alc_pick_fixup(codec, quirk, fix, pre_init);
1768 }
1769}
1770
Kailang Yang274693f2009-12-03 10:07:50 +01001771static int alc_read_coef_idx(struct hda_codec *codec,
1772 unsigned int coef_idx)
1773{
1774 unsigned int val;
1775 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1776 coef_idx);
1777 val = snd_hda_codec_read(codec, 0x20, 0,
1778 AC_VERB_GET_PROC_COEF, 0);
1779 return val;
1780}
1781
Kailang Yang977ddd62010-09-15 10:02:29 +02001782static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1783 unsigned int coef_val)
1784{
1785 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1786 coef_idx);
1787 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1788 coef_val);
1789}
1790
Takashi Iwai757899a2010-07-30 10:48:14 +02001791/* set right pin controls for digital I/O */
1792static void alc_auto_init_digital(struct hda_codec *codec)
1793{
1794 struct alc_spec *spec = codec->spec;
1795 int i;
1796 hda_nid_t pin;
1797
1798 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1799 pin = spec->autocfg.dig_out_pins[i];
1800 if (pin) {
1801 snd_hda_codec_write(codec, pin, 0,
1802 AC_VERB_SET_PIN_WIDGET_CONTROL,
1803 PIN_OUT);
1804 }
1805 }
1806 pin = spec->autocfg.dig_in_pin;
1807 if (pin)
1808 snd_hda_codec_write(codec, pin, 0,
1809 AC_VERB_SET_PIN_WIDGET_CONTROL,
1810 PIN_IN);
1811}
1812
1813/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1814static void alc_auto_parse_digital(struct hda_codec *codec)
1815{
1816 struct alc_spec *spec = codec->spec;
1817 int i, err;
1818 hda_nid_t dig_nid;
1819
1820 /* support multiple SPDIFs; the secondary is set up as a slave */
1821 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1822 err = snd_hda_get_connections(codec,
1823 spec->autocfg.dig_out_pins[i],
1824 &dig_nid, 1);
1825 if (err < 0)
1826 continue;
1827 if (!i) {
1828 spec->multiout.dig_out_nid = dig_nid;
1829 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1830 } else {
1831 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1832 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1833 break;
1834 spec->slave_dig_outs[i - 1] = dig_nid;
1835 }
1836 }
1837
1838 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001839 dig_nid = codec->start_nid;
1840 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1841 unsigned int wcaps = get_wcaps(codec, dig_nid);
1842 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1843 continue;
1844 if (!(wcaps & AC_WCAP_DIGITAL))
1845 continue;
1846 if (!(wcaps & AC_WCAP_CONN_LIST))
1847 continue;
1848 err = get_connection_index(codec, dig_nid,
1849 spec->autocfg.dig_in_pin);
1850 if (err >= 0) {
1851 spec->dig_in_nid = dig_nid;
1852 break;
1853 }
1854 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001855 }
1856}
1857
Takashi Iwaif95474e2007-07-10 00:47:43 +02001858/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001859 * ALC888
1860 */
1861
1862/*
1863 * 2ch mode
1864 */
1865static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1866/* Mic-in jack as mic in */
1867 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1868 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1869/* Line-in jack as Line in */
1870 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1871 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1872/* Line-Out as Front */
1873 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1874 { } /* end */
1875};
1876
1877/*
1878 * 4ch mode
1879 */
1880static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1881/* Mic-in jack as mic in */
1882 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1883 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1884/* Line-in jack as Surround */
1885 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1886 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1887/* Line-Out as Front */
1888 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1889 { } /* end */
1890};
1891
1892/*
1893 * 6ch mode
1894 */
1895static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1896/* Mic-in jack as CLFE */
1897 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1898 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1899/* Line-in jack as Surround */
1900 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1901 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1902/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1903 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1904 { } /* end */
1905};
1906
1907/*
1908 * 8ch mode
1909 */
1910static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1911/* Mic-in jack as CLFE */
1912 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1913 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1914/* Line-in jack as Surround */
1915 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1916 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1917/* Line-Out as Side */
1918 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1919 { } /* end */
1920};
1921
1922static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1923 { 2, alc888_4ST_ch2_intel_init },
1924 { 4, alc888_4ST_ch4_intel_init },
1925 { 6, alc888_4ST_ch6_intel_init },
1926 { 8, alc888_4ST_ch8_intel_init },
1927};
1928
1929/*
1930 * ALC888 Fujitsu Siemens Amillo xa3530
1931 */
1932
1933static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1934/* Front Mic: set to PIN_IN (empty by default) */
1935 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1936/* Connect Internal HP to Front */
1937 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1938 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1939 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1940/* Connect Bass HP to Front */
1941 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1942 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1943 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1944/* Connect Line-Out side jack (SPDIF) to Side */
1945 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1946 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1947 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1948/* Connect Mic jack to CLFE */
1949 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1950 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1951 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1952/* Connect Line-in jack to Surround */
1953 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1954 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1955 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1956/* Connect HP out jack to Front */
1957 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1958 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1959 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1960/* Enable unsolicited event for HP jack and Line-out jack */
1961 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1962 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1963 {}
1964};
1965
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001966static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001967{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001968 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001969}
1970
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001971static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1972 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001973{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001974 if (codec->vendor_id == 0x10ec0880)
1975 res >>= 28;
1976 else
1977 res >>= 26;
1978 if (res == ALC880_HP_EVENT)
1979 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001980}
1981
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001982static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001983{
1984 struct alc_spec *spec = codec->spec;
1985
1986 spec->autocfg.hp_pins[0] = 0x15;
1987 spec->autocfg.speaker_pins[0] = 0x14;
1988 spec->autocfg.speaker_pins[1] = 0x16;
1989 spec->autocfg.speaker_pins[2] = 0x17;
1990 spec->autocfg.speaker_pins[3] = 0x19;
1991 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001992}
1993
1994static void alc889_intel_init_hook(struct hda_codec *codec)
1995{
1996 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001997 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001998}
1999
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002000static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002001{
2002 struct alc_spec *spec = codec->spec;
2003
2004 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
2005 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
2006 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
2007 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002008}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002009
2010/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002011 * ALC888 Acer Aspire 4930G model
2012 */
2013
2014static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
2015/* Front Mic: set to PIN_IN (empty by default) */
2016 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2017/* Unselect Front Mic by default in input mixer 3 */
2018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002019/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002020 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2021/* Connect Internal HP to front */
2022 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2023 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2024 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2025/* Connect HP out to front */
2026 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2027 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2028 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2029 { }
2030};
2031
Hector Martin3b315d72009-06-02 10:54:19 +02002032/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002033 * ALC888 Acer Aspire 6530G model
2034 */
2035
2036static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002037/* Route to built-in subwoofer as well as speakers */
2038 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2039 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2040 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2041 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002042/* Bias voltage on for external mic port */
2043 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002044/* Front Mic: set to PIN_IN (empty by default) */
2045 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2046/* Unselect Front Mic by default in input mixer 3 */
2047 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002048/* Enable unsolicited event for HP jack */
2049 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2050/* Enable speaker output */
2051 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2052 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002053 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002054/* Enable headphone output */
2055 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2056 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2057 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002058 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002059 { }
2060};
2061
2062/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002063 *ALC888 Acer Aspire 7730G model
2064 */
2065
2066static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2067/* Bias voltage on for external mic port */
2068 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2069/* Front Mic: set to PIN_IN (empty by default) */
2070 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2071/* Unselect Front Mic by default in input mixer 3 */
2072 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2073/* Enable unsolicited event for HP jack */
2074 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2075/* Enable speaker output */
2076 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2077 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2078 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2079/* Enable headphone output */
2080 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2081 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2082 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2083 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2084/*Enable internal subwoofer */
2085 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2086 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2087 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2088 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2089 { }
2090};
2091
2092/*
Hector Martin018df412009-06-04 00:13:40 +02002093 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002094 */
2095
Hector Martin018df412009-06-04 00:13:40 +02002096static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002097/* Front Mic: set to PIN_IN (empty by default) */
2098 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2099/* Unselect Front Mic by default in input mixer 3 */
2100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2101/* Enable unsolicited event for HP jack */
2102 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2103/* Connect Internal Front to Front */
2104 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2105 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2106 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2107/* Connect Internal Rear to Rear */
2108 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2109 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2110 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2111/* Connect Internal CLFE to CLFE */
2112 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2113 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2114 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2115/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002116 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002117 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2118 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2119/* Enable all DACs */
2120/* DAC DISABLE/MUTE 1? */
2121/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2122 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2123 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2124/* DAC DISABLE/MUTE 2? */
2125/* some bit here disables the other DACs. Init=0x4900 */
2126 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2127 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002128/* DMIC fix
2129 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2130 * which makes the stereo useless. However, either the mic or the ALC889
2131 * makes the signal become a difference/sum signal instead of standard
2132 * stereo, which is annoying. So instead we flip this bit which makes the
2133 * codec replicate the sum signal to both channels, turning it into a
2134 * normal mono mic.
2135 */
2136/* DMIC_CONTROL? Init value = 0x0001 */
2137 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2138 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002139 { }
2140};
2141
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002142static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002143 /* Front mic only available on one ADC */
2144 {
2145 .num_items = 4,
2146 .items = {
2147 { "Mic", 0x0 },
2148 { "Line", 0x2 },
2149 { "CD", 0x4 },
2150 { "Front Mic", 0xb },
2151 },
2152 },
2153 {
2154 .num_items = 3,
2155 .items = {
2156 { "Mic", 0x0 },
2157 { "Line", 0x2 },
2158 { "CD", 0x4 },
2159 },
2160 }
2161};
2162
Tony Vroond2fd4b02009-06-21 00:40:10 +01002163static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2164 /* Interal mic only available on one ADC */
2165 {
Tony Vroon684a8842009-06-26 09:27:50 +01002166 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002167 .items = {
2168 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002169 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002170 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002171 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002172 { "Int Mic", 0xb },
2173 },
2174 },
2175 {
Tony Vroon684a8842009-06-26 09:27:50 +01002176 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002177 .items = {
2178 { "Ext Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002179 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002180 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002181 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002182 },
2183 }
2184};
2185
Hector Martin018df412009-06-04 00:13:40 +02002186static struct hda_input_mux alc889_capture_sources[3] = {
2187 /* Digital mic only available on first "ADC" */
2188 {
2189 .num_items = 5,
2190 .items = {
2191 { "Mic", 0x0 },
2192 { "Line", 0x2 },
2193 { "CD", 0x4 },
2194 { "Front Mic", 0xb },
2195 { "Input Mix", 0xa },
2196 },
2197 },
2198 {
2199 .num_items = 4,
2200 .items = {
2201 { "Mic", 0x0 },
2202 { "Line", 0x2 },
2203 { "CD", 0x4 },
2204 { "Input Mix", 0xa },
2205 },
2206 },
2207 {
2208 .num_items = 4,
2209 .items = {
2210 { "Mic", 0x0 },
2211 { "Line", 0x2 },
2212 { "CD", 0x4 },
2213 { "Input Mix", 0xa },
2214 },
2215 }
2216};
2217
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002218static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002219 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2220 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2221 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2222 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2223 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2224 HDA_OUTPUT),
2225 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2226 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2227 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2228 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2229 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2230 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2231 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2232 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2233 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2234 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2235 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2236 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002237 { } /* end */
2238};
2239
Hector Martin556eea92009-12-20 22:51:23 +01002240static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2241 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2242 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2243 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2244 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2245 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2246 HDA_OUTPUT),
2247 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2248 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2249 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2250 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2251 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2252 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2253 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
2254 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2255 { } /* end */
2256};
2257
2258
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002259static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002260{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002261 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002262
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002263 spec->autocfg.hp_pins[0] = 0x15;
2264 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002265 spec->autocfg.speaker_pins[1] = 0x16;
2266 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002267}
2268
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002269static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002270{
2271 struct alc_spec *spec = codec->spec;
2272
2273 spec->autocfg.hp_pins[0] = 0x15;
2274 spec->autocfg.speaker_pins[0] = 0x14;
2275 spec->autocfg.speaker_pins[1] = 0x16;
2276 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002277}
2278
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002279static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2280{
2281 struct alc_spec *spec = codec->spec;
2282
2283 spec->autocfg.hp_pins[0] = 0x15;
2284 spec->autocfg.speaker_pins[0] = 0x14;
2285 spec->autocfg.speaker_pins[1] = 0x16;
2286 spec->autocfg.speaker_pins[2] = 0x17;
2287}
2288
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002289static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002290{
2291 struct alc_spec *spec = codec->spec;
2292
2293 spec->autocfg.hp_pins[0] = 0x15;
2294 spec->autocfg.speaker_pins[0] = 0x14;
2295 spec->autocfg.speaker_pins[1] = 0x16;
2296 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002297}
2298
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002299/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002300 * ALC880 3-stack model
2301 *
2302 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002303 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2304 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305 */
2306
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002307static hda_nid_t alc880_dac_nids[4] = {
2308 /* front, rear, clfe, rear_surr */
2309 0x02, 0x05, 0x04, 0x03
2310};
2311
2312static hda_nid_t alc880_adc_nids[3] = {
2313 /* ADC0-2 */
2314 0x07, 0x08, 0x09,
2315};
2316
2317/* The datasheet says the node 0x07 is connected from inputs,
2318 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002319 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002320 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002321static hda_nid_t alc880_adc_nids_alt[2] = {
2322 /* ADC1-2 */
2323 0x08, 0x09,
2324};
2325
2326#define ALC880_DIGOUT_NID 0x06
2327#define ALC880_DIGIN_NID 0x0a
2328
2329static struct hda_input_mux alc880_capture_source = {
2330 .num_items = 4,
2331 .items = {
2332 { "Mic", 0x0 },
2333 { "Front Mic", 0x3 },
2334 { "Line", 0x2 },
2335 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002336 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002337};
2338
2339/* channel source setting (2/6 channel selection for 3-stack) */
2340/* 2ch mode */
2341static struct hda_verb alc880_threestack_ch2_init[] = {
2342 /* set line-in to input, mute it */
2343 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2344 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2345 /* set mic-in to input vref 80%, mute it */
2346 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2347 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002348 { } /* end */
2349};
2350
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002351/* 6ch mode */
2352static struct hda_verb alc880_threestack_ch6_init[] = {
2353 /* set line-in to output, unmute it */
2354 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2355 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2356 /* set mic-in to output, unmute it */
2357 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2358 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2359 { } /* end */
2360};
2361
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002362static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002363 { 2, alc880_threestack_ch2_init },
2364 { 6, alc880_threestack_ch6_init },
2365};
2366
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002367static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002368 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002369 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002370 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002371 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002372 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2373 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002374 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2375 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2377 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2378 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2379 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2381 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2382 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2383 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002385 {
2386 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2387 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002388 .info = alc_ch_mode_info,
2389 .get = alc_ch_mode_get,
2390 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002391 },
2392 { } /* end */
2393};
2394
2395/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002396static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2397 struct snd_ctl_elem_info *uinfo)
2398{
2399 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2400 struct alc_spec *spec = codec->spec;
2401 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002402
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002403 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002404 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2405 HDA_INPUT);
2406 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002407 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002408 return err;
2409}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002410
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002411static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2412 unsigned int size, unsigned int __user *tlv)
2413{
2414 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2415 struct alc_spec *spec = codec->spec;
2416 int err;
2417
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002418 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002419 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2420 HDA_INPUT);
2421 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002422 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002423 return err;
2424}
2425
2426typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2427 struct snd_ctl_elem_value *ucontrol);
2428
2429static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2430 struct snd_ctl_elem_value *ucontrol,
2431 getput_call_t func)
2432{
2433 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2434 struct alc_spec *spec = codec->spec;
2435 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2436 int err;
2437
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002438 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002439 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2440 3, 0, HDA_INPUT);
2441 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002442 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002443 return err;
2444}
2445
2446static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2447 struct snd_ctl_elem_value *ucontrol)
2448{
2449 return alc_cap_getput_caller(kcontrol, ucontrol,
2450 snd_hda_mixer_amp_volume_get);
2451}
2452
2453static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2454 struct snd_ctl_elem_value *ucontrol)
2455{
2456 return alc_cap_getput_caller(kcontrol, ucontrol,
2457 snd_hda_mixer_amp_volume_put);
2458}
2459
2460/* capture mixer elements */
2461#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2462
2463static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2464 struct snd_ctl_elem_value *ucontrol)
2465{
2466 return alc_cap_getput_caller(kcontrol, ucontrol,
2467 snd_hda_mixer_amp_switch_get);
2468}
2469
2470static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2471 struct snd_ctl_elem_value *ucontrol)
2472{
2473 return alc_cap_getput_caller(kcontrol, ucontrol,
2474 snd_hda_mixer_amp_switch_put);
2475}
2476
Takashi Iwaia23b6882009-03-23 15:21:36 +01002477#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002478 { \
2479 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2480 .name = "Capture Switch", \
2481 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2482 .count = num, \
2483 .info = alc_cap_sw_info, \
2484 .get = alc_cap_sw_get, \
2485 .put = alc_cap_sw_put, \
2486 }, \
2487 { \
2488 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2489 .name = "Capture Volume", \
2490 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2491 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2492 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2493 .count = num, \
2494 .info = alc_cap_vol_info, \
2495 .get = alc_cap_vol_get, \
2496 .put = alc_cap_vol_put, \
2497 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002498 }
2499
2500#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002501 { \
2502 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2503 /* .name = "Capture Source", */ \
2504 .name = "Input Source", \
2505 .count = num, \
2506 .info = alc_mux_enum_info, \
2507 .get = alc_mux_enum_get, \
2508 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002509 }
2510
2511#define DEFINE_CAPMIX(num) \
2512static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2513 _DEFINE_CAPMIX(num), \
2514 _DEFINE_CAPSRC(num), \
2515 { } /* end */ \
2516}
2517
2518#define DEFINE_CAPMIX_NOSRC(num) \
2519static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2520 _DEFINE_CAPMIX(num), \
2521 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002522}
2523
2524/* up to three ADCs */
2525DEFINE_CAPMIX(1);
2526DEFINE_CAPMIX(2);
2527DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002528DEFINE_CAPMIX_NOSRC(1);
2529DEFINE_CAPMIX_NOSRC(2);
2530DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002531
2532/*
2533 * ALC880 5-stack model
2534 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002535 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2536 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002537 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2538 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2539 */
2540
2541/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002542static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002543 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002544 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002545 { } /* end */
2546};
2547
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002548/* channel source setting (6/8 channel selection for 5-stack) */
2549/* 6ch mode */
2550static struct hda_verb alc880_fivestack_ch6_init[] = {
2551 /* set line-in to input, mute it */
2552 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2553 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002554 { } /* end */
2555};
2556
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002557/* 8ch mode */
2558static struct hda_verb alc880_fivestack_ch8_init[] = {
2559 /* set line-in to output, unmute it */
2560 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2561 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2562 { } /* end */
2563};
2564
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002565static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002566 { 6, alc880_fivestack_ch6_init },
2567 { 8, alc880_fivestack_ch8_init },
2568};
2569
2570
2571/*
2572 * ALC880 6-stack model
2573 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002574 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2575 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002576 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2577 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2578 */
2579
2580static hda_nid_t alc880_6st_dac_nids[4] = {
2581 /* front, rear, clfe, rear_surr */
2582 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002583};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002584
2585static struct hda_input_mux alc880_6stack_capture_source = {
2586 .num_items = 4,
2587 .items = {
2588 { "Mic", 0x0 },
2589 { "Front Mic", 0x1 },
2590 { "Line", 0x2 },
2591 { "CD", 0x4 },
2592 },
2593};
2594
2595/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002596static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002597 { 8, NULL },
2598};
2599
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002600static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002601 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002602 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002603 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002604 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002605 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2606 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002607 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2608 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002609 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002610 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002611 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2612 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2613 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2614 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2615 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2616 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2617 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2618 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002619 {
2620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2621 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002622 .info = alc_ch_mode_info,
2623 .get = alc_ch_mode_get,
2624 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002625 },
2626 { } /* end */
2627};
2628
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002629
2630/*
2631 * ALC880 W810 model
2632 *
2633 * W810 has rear IO for:
2634 * Front (DAC 02)
2635 * Surround (DAC 03)
2636 * Center/LFE (DAC 04)
2637 * Digital out (06)
2638 *
2639 * The system also has a pair of internal speakers, and a headphone jack.
2640 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002641 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002642 * There is a variable resistor to control the speaker or headphone
2643 * volume. This is a hardware-only device without a software API.
2644 *
2645 * Plugging headphones in will disable the internal speakers. This is
2646 * implemented in hardware, not via the driver using jack sense. In
2647 * a similar fashion, plugging into the rear socket marked "front" will
2648 * disable both the speakers and headphones.
2649 *
2650 * For input, there's a microphone jack, and an "audio in" jack.
2651 * These may not do anything useful with this driver yet, because I
2652 * haven't setup any initialization verbs for these yet...
2653 */
2654
2655static hda_nid_t alc880_w810_dac_nids[3] = {
2656 /* front, rear/surround, clfe */
2657 0x02, 0x03, 0x04
2658};
2659
2660/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002661static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002662 { 6, NULL }
2663};
2664
2665/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002666static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002667 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002668 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002669 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002670 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002671 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2672 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002673 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2674 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002675 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2676 { } /* end */
2677};
2678
2679
2680/*
2681 * Z710V model
2682 *
2683 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002684 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2685 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002686 */
2687
2688static hda_nid_t alc880_z71v_dac_nids[1] = {
2689 0x02
2690};
2691#define ALC880_Z71V_HP_DAC 0x03
2692
2693/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002694static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002695 { 2, NULL }
2696};
2697
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002698static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002699 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002700 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002701 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002702 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002703 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2704 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2705 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2706 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2707 { } /* end */
2708};
2709
2710
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002711/*
2712 * ALC880 F1734 model
2713 *
2714 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2715 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2716 */
2717
2718static hda_nid_t alc880_f1734_dac_nids[1] = {
2719 0x03
2720};
2721#define ALC880_F1734_HP_DAC 0x02
2722
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002723static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002724 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002725 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002726 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2727 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002728 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2729 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002730 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2731 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002732 { } /* end */
2733};
2734
Takashi Iwai937b4162008-02-11 14:52:36 +01002735static struct hda_input_mux alc880_f1734_capture_source = {
2736 .num_items = 2,
2737 .items = {
2738 { "Mic", 0x1 },
2739 { "CD", 0x4 },
2740 },
2741};
2742
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002743
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002744/*
2745 * ALC880 ASUS model
2746 *
2747 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2748 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2749 * Mic = 0x18, Line = 0x1a
2750 */
2751
2752#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2753#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2754
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002755static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002756 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002757 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002758 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002759 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002760 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2761 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002762 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2763 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002764 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2765 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2766 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2767 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2768 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2769 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002770 {
2771 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2772 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002773 .info = alc_ch_mode_info,
2774 .get = alc_ch_mode_get,
2775 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002776 },
2777 { } /* end */
2778};
2779
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002780/*
2781 * ALC880 ASUS W1V model
2782 *
2783 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2784 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2785 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2786 */
2787
2788/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002789static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002790 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2791 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002792 { } /* end */
2793};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002794
Kailang Yangdf694da2005-12-05 19:42:22 +01002795/* TCL S700 */
2796static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2797 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2798 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2799 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2800 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2801 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2802 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2803 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2804 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2805 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002806 { } /* end */
2807};
2808
Kailang Yangccc656c2006-10-17 12:32:26 +02002809/* Uniwill */
2810static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002811 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2812 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2813 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2814 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002815 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2816 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2817 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2818 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2819 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2820 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2821 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2822 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2823 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2824 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2825 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2826 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002827 {
2828 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2829 .name = "Channel Mode",
2830 .info = alc_ch_mode_info,
2831 .get = alc_ch_mode_get,
2832 .put = alc_ch_mode_put,
2833 },
2834 { } /* end */
2835};
2836
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002837static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2838 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2839 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2840 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2841 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2842 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2843 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2844 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2845 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2846 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2847 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
2848 { } /* end */
2849};
2850
Kailang Yangccc656c2006-10-17 12:32:26 +02002851static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002852 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2853 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2854 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2855 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2858 { } /* end */
2859};
2860
Linus Torvalds1da177e2005-04-16 15:20:36 -07002861/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002862 * virtual master controls
2863 */
2864
2865/*
2866 * slave controls for virtual master
2867 */
2868static const char *alc_slave_vols[] = {
2869 "Front Playback Volume",
2870 "Surround Playback Volume",
2871 "Center Playback Volume",
2872 "LFE Playback Volume",
2873 "Side Playback Volume",
2874 "Headphone Playback Volume",
2875 "Speaker Playback Volume",
2876 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002877 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002878 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002879 NULL,
2880};
2881
2882static const char *alc_slave_sws[] = {
2883 "Front Playback Switch",
2884 "Surround Playback Switch",
2885 "Center Playback Switch",
2886 "LFE Playback Switch",
2887 "Side Playback Switch",
2888 "Headphone Playback Switch",
2889 "Speaker Playback Switch",
2890 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002891 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002892 "Line-Out Playback Switch",
2893 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002894 NULL,
2895};
2896
2897/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002898 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002899 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002900
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002901#define NID_MAPPING (-1)
2902
2903#define SUBDEV_SPEAKER_ (0 << 6)
2904#define SUBDEV_HP_ (1 << 6)
2905#define SUBDEV_LINE_ (2 << 6)
2906#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2907#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2908#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2909
Takashi Iwai603c4012008-07-30 15:01:44 +02002910static void alc_free_kctls(struct hda_codec *codec);
2911
Takashi Iwai67d634c2009-11-16 15:35:59 +01002912#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002913/* additional beep mixers; the actual parameters are overwritten at build */
2914static struct snd_kcontrol_new alc_beep_mixer[] = {
2915 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002916 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002917 { } /* end */
2918};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002919#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002920
Linus Torvalds1da177e2005-04-16 15:20:36 -07002921static int alc_build_controls(struct hda_codec *codec)
2922{
2923 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002924 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002925 struct snd_kcontrol_new *knew;
2926 int i, j, err;
2927 unsigned int u;
2928 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002929
2930 for (i = 0; i < spec->num_mixers; i++) {
2931 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2932 if (err < 0)
2933 return err;
2934 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002935 if (spec->cap_mixer) {
2936 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2937 if (err < 0)
2938 return err;
2939 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002940 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002941 err = snd_hda_create_spdif_out_ctls(codec,
2942 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002943 if (err < 0)
2944 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002945 if (!spec->no_analog) {
2946 err = snd_hda_create_spdif_share_sw(codec,
2947 &spec->multiout);
2948 if (err < 0)
2949 return err;
2950 spec->multiout.share_spdif = 1;
2951 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002952 }
2953 if (spec->dig_in_nid) {
2954 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2955 if (err < 0)
2956 return err;
2957 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002958
Takashi Iwai67d634c2009-11-16 15:35:59 +01002959#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002960 /* create beep controls if needed */
2961 if (spec->beep_amp) {
2962 struct snd_kcontrol_new *knew;
2963 for (knew = alc_beep_mixer; knew->name; knew++) {
2964 struct snd_kcontrol *kctl;
2965 kctl = snd_ctl_new1(knew, codec);
2966 if (!kctl)
2967 return -ENOMEM;
2968 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002969 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002970 if (err < 0)
2971 return err;
2972 }
2973 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002974#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002975
Takashi Iwai2134ea42008-01-10 16:53:55 +01002976 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002977 if (!spec->no_analog &&
2978 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002979 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002980 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002981 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002982 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002983 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002984 if (err < 0)
2985 return err;
2986 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002987 if (!spec->no_analog &&
2988 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002989 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2990 NULL, alc_slave_sws);
2991 if (err < 0)
2992 return err;
2993 }
2994
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002995 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002996 if (spec->capsrc_nids || spec->adc_nids) {
2997 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2998 if (!kctl)
2999 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3000 for (i = 0; kctl && i < kctl->count; i++) {
3001 hda_nid_t *nids = spec->capsrc_nids;
3002 if (!nids)
3003 nids = spec->adc_nids;
3004 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3005 if (err < 0)
3006 return err;
3007 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003008 }
3009 if (spec->cap_mixer) {
3010 const char *kname = kctl ? kctl->id.name : NULL;
3011 for (knew = spec->cap_mixer; knew->name; knew++) {
3012 if (kname && strcmp(knew->name, kname) == 0)
3013 continue;
3014 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3015 for (i = 0; kctl && i < kctl->count; i++) {
3016 err = snd_hda_add_nid(codec, kctl, i,
3017 spec->adc_nids[i]);
3018 if (err < 0)
3019 return err;
3020 }
3021 }
3022 }
3023
3024 /* other nid->control mapping */
3025 for (i = 0; i < spec->num_mixers; i++) {
3026 for (knew = spec->mixers[i]; knew->name; knew++) {
3027 if (knew->iface != NID_MAPPING)
3028 continue;
3029 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3030 if (kctl == NULL)
3031 continue;
3032 u = knew->subdevice;
3033 for (j = 0; j < 4; j++, u >>= 8) {
3034 nid = u & 0x3f;
3035 if (nid == 0)
3036 continue;
3037 switch (u & 0xc0) {
3038 case SUBDEV_SPEAKER_:
3039 nid = spec->autocfg.speaker_pins[nid];
3040 break;
3041 case SUBDEV_LINE_:
3042 nid = spec->autocfg.line_out_pins[nid];
3043 break;
3044 case SUBDEV_HP_:
3045 nid = spec->autocfg.hp_pins[nid];
3046 break;
3047 default:
3048 continue;
3049 }
3050 err = snd_hda_add_nid(codec, kctl, 0, nid);
3051 if (err < 0)
3052 return err;
3053 }
3054 u = knew->private_value;
3055 for (j = 0; j < 4; j++, u >>= 8) {
3056 nid = u & 0xff;
3057 if (nid == 0)
3058 continue;
3059 err = snd_hda_add_nid(codec, kctl, 0, nid);
3060 if (err < 0)
3061 return err;
3062 }
3063 }
3064 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003065
3066 alc_free_kctls(codec); /* no longer needed */
3067
Linus Torvalds1da177e2005-04-16 15:20:36 -07003068 return 0;
3069}
3070
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003071
Linus Torvalds1da177e2005-04-16 15:20:36 -07003072/*
3073 * initialize the codec volumes, etc
3074 */
3075
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003076/*
3077 * generic initialization of ADC, input mixers and output mixers
3078 */
3079static struct hda_verb alc880_volume_init_verbs[] = {
3080 /*
3081 * Unmute ADC0-2 and set the default input to mic-in
3082 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003083 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003084 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003085 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003086 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003087 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003088 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003089
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003090 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3091 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003092 * Note: PASD motherboards uses the Line In 2 as the input for front
3093 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003094 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003095 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003096 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003103
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003104 /*
3105 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003106 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003107 /* set vol=0 to output mixers */
3108 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3109 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3110 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3111 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3112 /* set up input amps for analog loopback */
3113 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003114 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003116 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003118 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003120 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3121 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003122
3123 { }
3124};
3125
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003126/*
3127 * 3-stack pin configuration:
3128 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3129 */
3130static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3131 /*
3132 * preset connection lists of input pins
3133 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3134 */
3135 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3136 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3137 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3138
3139 /*
3140 * Set pin mode and muting
3141 */
3142 /* set front pin widgets 0x14 for output */
3143 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3144 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3145 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3146 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3147 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3148 /* Mic2 (as headphone out) for HP output */
3149 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3150 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3151 /* Line In pin widget for input */
3152 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3153 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3154 /* Line2 (as front mic) pin widget for input and vref at 80% */
3155 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3156 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3157 /* CD pin widget for input */
3158 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3159
3160 { }
3161};
3162
3163/*
3164 * 5-stack pin configuration:
3165 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3166 * line-in/side = 0x1a, f-mic = 0x1b
3167 */
3168static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3169 /*
3170 * preset connection lists of input pins
3171 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3172 */
3173 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3174 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3175
3176 /*
3177 * Set pin mode and muting
3178 */
3179 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003180 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3181 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3182 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3183 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003184 /* unmute pins for output (no gain on this amp) */
3185 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3186 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3188 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3189
Linus Torvalds1da177e2005-04-16 15:20:36 -07003190 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003191 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003192 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3193 /* Mic2 (as headphone out) for HP output */
3194 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003195 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003196 /* Line In pin widget for input */
3197 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3198 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3199 /* Line2 (as front mic) pin widget for input and vref at 80% */
3200 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3201 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3202 /* CD pin widget for input */
3203 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003204
3205 { }
3206};
3207
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003208/*
3209 * W810 pin configuration:
3210 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3211 */
3212static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003213 /* hphone/speaker input selector: front DAC */
3214 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3215
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003216 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3217 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3218 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3219 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3220 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3221 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3222
3223 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003224 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003225
Linus Torvalds1da177e2005-04-16 15:20:36 -07003226 { }
3227};
3228
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003229/*
3230 * Z71V pin configuration:
3231 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3232 */
3233static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003234 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003235 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003238
Takashi Iwai16ded522005-06-10 19:58:24 +02003239 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003240 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003241 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003242 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003243
3244 { }
3245};
3246
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003247/*
3248 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003249 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3250 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003251 */
3252static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3253 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3254
Takashi Iwai16ded522005-06-10 19:58:24 +02003255 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003256 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003257 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003258 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003259 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003260 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003261 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003262 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3263
Takashi Iwai16ded522005-06-10 19:58:24 +02003264 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003265 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003266 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003267 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003268 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003269 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003270 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003271 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003272 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003273
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003274 { }
3275};
Takashi Iwai16ded522005-06-10 19:58:24 +02003276
Kailang Yangccc656c2006-10-17 12:32:26 +02003277/*
3278 * Uniwill pin configuration:
3279 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3280 * line = 0x1a
3281 */
3282static struct hda_verb alc880_uniwill_init_verbs[] = {
3283 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3284
3285 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3286 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3287 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3288 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3289 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3290 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3291 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3292 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3293 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3295 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3296 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3297 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3299
3300 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3301 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3302 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3303 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3304 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3305 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3306 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3307 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3308 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3309
3310 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3311 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3312
3313 { }
3314};
3315
3316/*
3317* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003318* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003319 */
3320static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3321 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3322
3323 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3324 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3326 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3327 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3328 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3329 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3331 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3333 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3335
3336 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3337 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3338 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3339 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3340 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3341 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3342
3343 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3344 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3345
3346 { }
3347};
3348
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003349static struct hda_verb alc880_beep_init_verbs[] = {
3350 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3351 { }
3352};
3353
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003354/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003355static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003356{
3357 unsigned int present;
3358 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003359
Wu Fengguang864f92b2009-11-18 12:38:02 +08003360 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003361 bits = present ? HDA_AMP_MUTE : 0;
3362 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003363}
3364
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003365static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003366{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003367 struct alc_spec *spec = codec->spec;
3368
3369 spec->autocfg.hp_pins[0] = 0x14;
3370 spec->autocfg.speaker_pins[0] = 0x15;
3371 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003372}
3373
3374static void alc880_uniwill_init_hook(struct hda_codec *codec)
3375{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003376 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003377 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003378}
3379
3380static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3381 unsigned int res)
3382{
3383 /* Looks like the unsol event is incompatible with the standard
3384 * definition. 4bit tag is placed at 28 bit!
3385 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003386 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003387 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003388 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003389 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003390 default:
3391 alc_automute_amp_unsol_event(codec, res);
3392 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003393 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003394}
3395
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003396static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003397{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003398 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003399
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003400 spec->autocfg.hp_pins[0] = 0x14;
3401 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003402}
3403
3404static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3405{
3406 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003407
Kailang Yangccc656c2006-10-17 12:32:26 +02003408 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003409 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3410 present &= HDA_AMP_VOLMASK;
3411 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3412 HDA_AMP_VOLMASK, present);
3413 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3414 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003415}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003416
Kailang Yangccc656c2006-10-17 12:32:26 +02003417static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3418 unsigned int res)
3419{
3420 /* Looks like the unsol event is incompatible with the standard
3421 * definition. 4bit tag is placed at 28 bit!
3422 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003423 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003424 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003425 else
3426 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003427}
3428
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003429/*
3430 * F1734 pin configuration:
3431 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3432 */
3433static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003434 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003435 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3436 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3437 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3438 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3439
3440 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3441 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3442 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3443 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3444
3445 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3446 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003447 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003448 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3449 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3450 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3451 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3452 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3453 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003454
Takashi Iwai937b4162008-02-11 14:52:36 +01003455 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3456 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3457
Takashi Iwai16ded522005-06-10 19:58:24 +02003458 { }
3459};
3460
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003461/*
3462 * ASUS pin configuration:
3463 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3464 */
3465static struct hda_verb alc880_pin_asus_init_verbs[] = {
3466 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3467 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3468 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3469 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3470
3471 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3472 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3473 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3474 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3475 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3476 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3477 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3478 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3479
3480 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3481 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3483 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3484 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3485 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3486 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3487 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3488 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003489
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003490 { }
3491};
3492
3493/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003494#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3495#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003496#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003497
Kailang Yangdf694da2005-12-05 19:42:22 +01003498/* Clevo m520g init */
3499static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3500 /* headphone output */
3501 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3502 /* line-out */
3503 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3504 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3505 /* Line-in */
3506 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3507 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3508 /* CD */
3509 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3510 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3511 /* Mic1 (rear panel) */
3512 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3513 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3514 /* Mic2 (front panel) */
3515 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3516 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3517 /* headphone */
3518 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3519 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3520 /* change to EAPD mode */
3521 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3522 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3523
3524 { }
3525};
3526
3527static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003528 /* change to EAPD mode */
3529 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3530 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3531
Kailang Yangdf694da2005-12-05 19:42:22 +01003532 /* Headphone output */
3533 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3534 /* Front output*/
3535 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3536 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3537
3538 /* Line In pin widget for input */
3539 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3540 /* CD pin widget for input */
3541 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3542 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3544
3545 /* change to EAPD mode */
3546 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3547 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3548
3549 { }
3550};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003551
3552/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003553 * LG m1 express dual
3554 *
3555 * Pin assignment:
3556 * Rear Line-In/Out (blue): 0x14
3557 * Build-in Mic-In: 0x15
3558 * Speaker-out: 0x17
3559 * HP-Out (green): 0x1b
3560 * Mic-In/Out (red): 0x19
3561 * SPDIF-Out: 0x1e
3562 */
3563
3564/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3565static hda_nid_t alc880_lg_dac_nids[3] = {
3566 0x05, 0x02, 0x03
3567};
3568
3569/* seems analog CD is not working */
3570static struct hda_input_mux alc880_lg_capture_source = {
3571 .num_items = 3,
3572 .items = {
3573 { "Mic", 0x1 },
3574 { "Line", 0x5 },
3575 { "Internal Mic", 0x6 },
3576 },
3577};
3578
3579/* 2,4,6 channel modes */
3580static struct hda_verb alc880_lg_ch2_init[] = {
3581 /* set line-in and mic-in to input */
3582 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3583 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3584 { }
3585};
3586
3587static struct hda_verb alc880_lg_ch4_init[] = {
3588 /* set line-in to out and mic-in to input */
3589 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3590 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3591 { }
3592};
3593
3594static struct hda_verb alc880_lg_ch6_init[] = {
3595 /* set line-in and mic-in to output */
3596 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3597 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3598 { }
3599};
3600
3601static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3602 { 2, alc880_lg_ch2_init },
3603 { 4, alc880_lg_ch4_init },
3604 { 6, alc880_lg_ch6_init },
3605};
3606
3607static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003608 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3609 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003610 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3611 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3612 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3613 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3614 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3615 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3618 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3619 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3620 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3621 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3622 {
3623 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3624 .name = "Channel Mode",
3625 .info = alc_ch_mode_info,
3626 .get = alc_ch_mode_get,
3627 .put = alc_ch_mode_put,
3628 },
3629 { } /* end */
3630};
3631
3632static struct hda_verb alc880_lg_init_verbs[] = {
3633 /* set capture source to mic-in */
3634 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3635 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3636 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3637 /* mute all amp mixer inputs */
3638 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003641 /* line-in to input */
3642 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3643 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3644 /* built-in mic */
3645 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3646 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3647 /* speaker-out */
3648 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3649 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3650 /* mic-in to input */
3651 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3652 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3653 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3654 /* HP-out */
3655 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3656 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3657 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3658 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003659 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003660 { }
3661};
3662
3663/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003664static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003665{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003666 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003667
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003668 spec->autocfg.hp_pins[0] = 0x1b;
3669 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003670}
3671
3672/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003673 * LG LW20
3674 *
3675 * Pin assignment:
3676 * Speaker-out: 0x14
3677 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003678 * Built-in Mic-In: 0x19
3679 * Line-In: 0x1b
3680 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003681 * SPDIF-Out: 0x1e
3682 */
3683
Takashi Iwaid6815182006-03-23 16:06:23 +01003684static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003685 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003686 .items = {
3687 { "Mic", 0x0 },
3688 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003689 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003690 },
3691};
3692
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003693#define alc880_lg_lw_modes alc880_threestack_modes
3694
Takashi Iwaid6815182006-03-23 16:06:23 +01003695static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003696 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3697 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3698 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3699 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3700 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3701 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3702 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3703 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3704 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3705 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3708 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3709 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003710 {
3711 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3712 .name = "Channel Mode",
3713 .info = alc_ch_mode_info,
3714 .get = alc_ch_mode_get,
3715 .put = alc_ch_mode_put,
3716 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003717 { } /* end */
3718};
3719
3720static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003721 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3722 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3723 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3724
Takashi Iwaid6815182006-03-23 16:06:23 +01003725 /* set capture source to mic-in */
3726 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3727 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3728 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003729 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003730 /* speaker-out */
3731 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3732 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3733 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003734 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3735 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3736 /* mic-in to input */
3737 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3738 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3739 /* built-in mic */
3740 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3741 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3742 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003743 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003744 { }
3745};
3746
3747/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003748static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003749{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003750 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003751
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003752 spec->autocfg.hp_pins[0] = 0x1b;
3753 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003754}
3755
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003756static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3757 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3758 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3759 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3760 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3761 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3762 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3763 { } /* end */
3764};
3765
3766static struct hda_input_mux alc880_medion_rim_capture_source = {
3767 .num_items = 2,
3768 .items = {
3769 { "Mic", 0x0 },
3770 { "Internal Mic", 0x1 },
3771 },
3772};
3773
3774static struct hda_verb alc880_medion_rim_init_verbs[] = {
3775 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3776
3777 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3778 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3779
3780 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3781 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3782 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3783 /* Mic2 (as headphone out) for HP output */
3784 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3785 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3786 /* Internal Speaker */
3787 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3788 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3789
3790 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3791 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3792
3793 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3794 { }
3795};
3796
3797/* toggle speaker-output according to the hp-jack state */
3798static void alc880_medion_rim_automute(struct hda_codec *codec)
3799{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003800 struct alc_spec *spec = codec->spec;
3801 alc_automute_amp(codec);
3802 /* toggle EAPD */
3803 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003804 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3805 else
3806 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3807}
3808
3809static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3810 unsigned int res)
3811{
3812 /* Looks like the unsol event is incompatible with the standard
3813 * definition. 4bit tag is placed at 28 bit!
3814 */
3815 if ((res >> 28) == ALC880_HP_EVENT)
3816 alc880_medion_rim_automute(codec);
3817}
3818
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003819static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003820{
3821 struct alc_spec *spec = codec->spec;
3822
3823 spec->autocfg.hp_pins[0] = 0x14;
3824 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003825}
3826
Takashi Iwaicb53c622007-08-10 17:21:45 +02003827#ifdef CONFIG_SND_HDA_POWER_SAVE
3828static struct hda_amp_list alc880_loopbacks[] = {
3829 { 0x0b, HDA_INPUT, 0 },
3830 { 0x0b, HDA_INPUT, 1 },
3831 { 0x0b, HDA_INPUT, 2 },
3832 { 0x0b, HDA_INPUT, 3 },
3833 { 0x0b, HDA_INPUT, 4 },
3834 { } /* end */
3835};
3836
3837static struct hda_amp_list alc880_lg_loopbacks[] = {
3838 { 0x0b, HDA_INPUT, 1 },
3839 { 0x0b, HDA_INPUT, 6 },
3840 { 0x0b, HDA_INPUT, 7 },
3841 { } /* end */
3842};
3843#endif
3844
Takashi Iwaid6815182006-03-23 16:06:23 +01003845/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003846 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003847 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003848
Linus Torvalds1da177e2005-04-16 15:20:36 -07003849static int alc_init(struct hda_codec *codec)
3850{
3851 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003852 unsigned int i;
3853
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003854 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003855 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003856
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003857 for (i = 0; i < spec->num_init_verbs; i++)
3858 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003859
3860 if (spec->init_hook)
3861 spec->init_hook(codec);
3862
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003863 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003864 return 0;
3865}
3866
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003867static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3868{
3869 struct alc_spec *spec = codec->spec;
3870
3871 if (spec->unsol_event)
3872 spec->unsol_event(codec, res);
3873}
3874
Takashi Iwaicb53c622007-08-10 17:21:45 +02003875#ifdef CONFIG_SND_HDA_POWER_SAVE
3876static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3877{
3878 struct alc_spec *spec = codec->spec;
3879 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3880}
3881#endif
3882
Linus Torvalds1da177e2005-04-16 15:20:36 -07003883/*
3884 * Analog playback callbacks
3885 */
3886static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3887 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003888 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003889{
3890 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003891 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3892 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003893}
3894
3895static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3896 struct hda_codec *codec,
3897 unsigned int stream_tag,
3898 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003899 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003900{
3901 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003902 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3903 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003904}
3905
3906static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3907 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003908 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003909{
3910 struct alc_spec *spec = codec->spec;
3911 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3912}
3913
3914/*
3915 * Digital out
3916 */
3917static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3918 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003919 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003920{
3921 struct alc_spec *spec = codec->spec;
3922 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3923}
3924
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003925static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3926 struct hda_codec *codec,
3927 unsigned int stream_tag,
3928 unsigned int format,
3929 struct snd_pcm_substream *substream)
3930{
3931 struct alc_spec *spec = codec->spec;
3932 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3933 stream_tag, format, substream);
3934}
3935
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003936static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3937 struct hda_codec *codec,
3938 struct snd_pcm_substream *substream)
3939{
3940 struct alc_spec *spec = codec->spec;
3941 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3942}
3943
Linus Torvalds1da177e2005-04-16 15:20:36 -07003944static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3945 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003946 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003947{
3948 struct alc_spec *spec = codec->spec;
3949 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3950}
3951
3952/*
3953 * Analog capture
3954 */
Takashi Iwai63300792008-01-24 15:31:36 +01003955static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003956 struct hda_codec *codec,
3957 unsigned int stream_tag,
3958 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003959 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003960{
3961 struct alc_spec *spec = codec->spec;
3962
Takashi Iwai63300792008-01-24 15:31:36 +01003963 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003964 stream_tag, 0, format);
3965 return 0;
3966}
3967
Takashi Iwai63300792008-01-24 15:31:36 +01003968static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003969 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003970 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003971{
3972 struct alc_spec *spec = codec->spec;
3973
Takashi Iwai888afa12008-03-18 09:57:50 +01003974 snd_hda_codec_cleanup_stream(codec,
3975 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003976 return 0;
3977}
3978
Takashi Iwai840b64c2010-07-13 22:49:01 +02003979/* analog capture with dynamic dual-adc changes */
3980static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3981 struct hda_codec *codec,
3982 unsigned int stream_tag,
3983 unsigned int format,
3984 struct snd_pcm_substream *substream)
3985{
3986 struct alc_spec *spec = codec->spec;
3987 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3988 spec->cur_adc_stream_tag = stream_tag;
3989 spec->cur_adc_format = format;
3990 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3991 return 0;
3992}
3993
3994static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3995 struct hda_codec *codec,
3996 struct snd_pcm_substream *substream)
3997{
3998 struct alc_spec *spec = codec->spec;
3999 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4000 spec->cur_adc = 0;
4001 return 0;
4002}
4003
4004static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4005 .substreams = 1,
4006 .channels_min = 2,
4007 .channels_max = 2,
4008 .nid = 0, /* fill later */
4009 .ops = {
4010 .prepare = dualmic_capture_pcm_prepare,
4011 .cleanup = dualmic_capture_pcm_cleanup
4012 },
4013};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004014
4015/*
4016 */
4017static struct hda_pcm_stream alc880_pcm_analog_playback = {
4018 .substreams = 1,
4019 .channels_min = 2,
4020 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004021 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004022 .ops = {
4023 .open = alc880_playback_pcm_open,
4024 .prepare = alc880_playback_pcm_prepare,
4025 .cleanup = alc880_playback_pcm_cleanup
4026 },
4027};
4028
4029static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004030 .substreams = 1,
4031 .channels_min = 2,
4032 .channels_max = 2,
4033 /* NID is set in alc_build_pcms */
4034};
4035
4036static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4037 .substreams = 1,
4038 .channels_min = 2,
4039 .channels_max = 2,
4040 /* NID is set in alc_build_pcms */
4041};
4042
4043static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4044 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004045 .channels_min = 2,
4046 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004047 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004048 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004049 .prepare = alc880_alt_capture_pcm_prepare,
4050 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004051 },
4052};
4053
4054static struct hda_pcm_stream alc880_pcm_digital_playback = {
4055 .substreams = 1,
4056 .channels_min = 2,
4057 .channels_max = 2,
4058 /* NID is set in alc_build_pcms */
4059 .ops = {
4060 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004061 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004062 .prepare = alc880_dig_playback_pcm_prepare,
4063 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004064 },
4065};
4066
4067static struct hda_pcm_stream alc880_pcm_digital_capture = {
4068 .substreams = 1,
4069 .channels_min = 2,
4070 .channels_max = 2,
4071 /* NID is set in alc_build_pcms */
4072};
4073
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004074/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004075static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004076 .substreams = 0,
4077 .channels_min = 0,
4078 .channels_max = 0,
4079};
4080
Linus Torvalds1da177e2005-04-16 15:20:36 -07004081static int alc_build_pcms(struct hda_codec *codec)
4082{
4083 struct alc_spec *spec = codec->spec;
4084 struct hda_pcm *info = spec->pcm_rec;
4085 int i;
4086
4087 codec->num_pcms = 1;
4088 codec->pcm_info = info;
4089
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004090 if (spec->no_analog)
4091 goto skip_analog;
4092
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004093 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4094 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004095 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004096
Takashi Iwai4a471b72005-12-07 13:56:29 +01004097 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004098 if (snd_BUG_ON(!spec->multiout.dac_nids))
4099 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004100 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4101 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4102 }
4103 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004104 if (snd_BUG_ON(!spec->adc_nids))
4105 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004106 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4107 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4108 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004109
Takashi Iwai4a471b72005-12-07 13:56:29 +01004110 if (spec->channel_mode) {
4111 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4112 for (i = 0; i < spec->num_channel_mode; i++) {
4113 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4114 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4115 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004116 }
4117 }
4118
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004119 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004120 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004121 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004122 snprintf(spec->stream_name_digital,
4123 sizeof(spec->stream_name_digital),
4124 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004125 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004126 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004127 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004128 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004129 if (spec->dig_out_type)
4130 info->pcm_type = spec->dig_out_type;
4131 else
4132 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004133 if (spec->multiout.dig_out_nid &&
4134 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004135 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4136 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4137 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004138 if (spec->dig_in_nid &&
4139 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004140 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4141 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4142 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004143 /* FIXME: do we need this for all Realtek codec models? */
4144 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004145 }
4146
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004147 if (spec->no_analog)
4148 return 0;
4149
Takashi Iwaie08a0072006-09-07 17:52:14 +02004150 /* If the use of more than one ADC is requested for the current
4151 * model, configure a second analog capture-only PCM.
4152 */
4153 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004154 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4155 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004156 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004157 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004158 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004159 if (spec->alt_dac_nid) {
4160 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4161 *spec->stream_analog_alt_playback;
4162 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4163 spec->alt_dac_nid;
4164 } else {
4165 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4166 alc_pcm_null_stream;
4167 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4168 }
4169 if (spec->num_adc_nids > 1) {
4170 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4171 *spec->stream_analog_alt_capture;
4172 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4173 spec->adc_nids[1];
4174 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4175 spec->num_adc_nids - 1;
4176 } else {
4177 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4178 alc_pcm_null_stream;
4179 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004180 }
4181 }
4182
Linus Torvalds1da177e2005-04-16 15:20:36 -07004183 return 0;
4184}
4185
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004186static inline void alc_shutup(struct hda_codec *codec)
4187{
4188 snd_hda_shutup_pins(codec);
4189}
4190
Takashi Iwai603c4012008-07-30 15:01:44 +02004191static void alc_free_kctls(struct hda_codec *codec)
4192{
4193 struct alc_spec *spec = codec->spec;
4194
4195 if (spec->kctls.list) {
4196 struct snd_kcontrol_new *kctl = spec->kctls.list;
4197 int i;
4198 for (i = 0; i < spec->kctls.used; i++)
4199 kfree(kctl[i].name);
4200 }
4201 snd_array_free(&spec->kctls);
4202}
4203
Linus Torvalds1da177e2005-04-16 15:20:36 -07004204static void alc_free(struct hda_codec *codec)
4205{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004206 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004207
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004208 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004209 return;
4210
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004211 alc_shutup(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004212 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004213 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004214 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004215}
4216
Hector Martinf5de24b2009-12-20 22:51:31 +01004217#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004218static void alc_power_eapd(struct hda_codec *codec)
4219{
4220 /* We currently only handle front, HP */
4221 switch (codec->vendor_id) {
4222 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004223 set_eapd(codec, 0x0f, 0);
4224 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004225 break;
4226 case 0x10ec0262:
4227 case 0x10ec0267:
4228 case 0x10ec0268:
4229 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004230 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004231 case 0x10ec0272:
4232 case 0x10ec0660:
4233 case 0x10ec0662:
4234 case 0x10ec0663:
4235 case 0x10ec0862:
4236 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004237 set_eapd(codec, 0x14, 0);
4238 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004239 break;
4240 }
4241}
4242
Hector Martinf5de24b2009-12-20 22:51:31 +01004243static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4244{
4245 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004246 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004247 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004248 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004249 return 0;
4250}
4251#endif
4252
Takashi Iwaie044c392008-10-27 16:56:24 +01004253#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004254static int alc_resume(struct hda_codec *codec)
4255{
Takashi Iwaie044c392008-10-27 16:56:24 +01004256 codec->patch_ops.init(codec);
4257 snd_hda_codec_resume_amp(codec);
4258 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004259 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004260 return 0;
4261}
Takashi Iwaie044c392008-10-27 16:56:24 +01004262#endif
4263
Linus Torvalds1da177e2005-04-16 15:20:36 -07004264/*
4265 */
4266static struct hda_codec_ops alc_patch_ops = {
4267 .build_controls = alc_build_controls,
4268 .build_pcms = alc_build_pcms,
4269 .init = alc_init,
4270 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004271 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004272#ifdef SND_HDA_NEEDS_RESUME
4273 .resume = alc_resume,
4274#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004275#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004276 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004277 .check_power_status = alc_check_power_status,
4278#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004279 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004280};
4281
Kailang Yangc027ddc2010-03-19 11:33:06 +01004282/* replace the codec chip_name with the given string */
4283static int alc_codec_rename(struct hda_codec *codec, const char *name)
4284{
4285 kfree(codec->chip_name);
4286 codec->chip_name = kstrdup(name, GFP_KERNEL);
4287 if (!codec->chip_name) {
4288 alc_free(codec);
4289 return -ENOMEM;
4290 }
4291 return 0;
4292}
4293
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004294/*
4295 * Test configuration for debugging
4296 *
4297 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4298 * enum controls.
4299 */
4300#ifdef CONFIG_SND_DEBUG
4301static hda_nid_t alc880_test_dac_nids[4] = {
4302 0x02, 0x03, 0x04, 0x05
4303};
4304
4305static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004306 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004307 .items = {
4308 { "In-1", 0x0 },
4309 { "In-2", 0x1 },
4310 { "In-3", 0x2 },
4311 { "In-4", 0x3 },
4312 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004313 { "Front", 0x5 },
4314 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004315 },
4316};
4317
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004318static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004319 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004320 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004321 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004322 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004323};
4324
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004325static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4326 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004327{
4328 static char *texts[] = {
4329 "N/A", "Line Out", "HP Out",
4330 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4331 };
4332 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4333 uinfo->count = 1;
4334 uinfo->value.enumerated.items = 8;
4335 if (uinfo->value.enumerated.item >= 8)
4336 uinfo->value.enumerated.item = 7;
4337 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4338 return 0;
4339}
4340
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004341static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4342 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004343{
4344 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4345 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4346 unsigned int pin_ctl, item = 0;
4347
4348 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4349 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4350 if (pin_ctl & AC_PINCTL_OUT_EN) {
4351 if (pin_ctl & AC_PINCTL_HP_EN)
4352 item = 2;
4353 else
4354 item = 1;
4355 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4356 switch (pin_ctl & AC_PINCTL_VREFEN) {
4357 case AC_PINCTL_VREF_HIZ: item = 3; break;
4358 case AC_PINCTL_VREF_50: item = 4; break;
4359 case AC_PINCTL_VREF_GRD: item = 5; break;
4360 case AC_PINCTL_VREF_80: item = 6; break;
4361 case AC_PINCTL_VREF_100: item = 7; break;
4362 }
4363 }
4364 ucontrol->value.enumerated.item[0] = item;
4365 return 0;
4366}
4367
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004368static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4369 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004370{
4371 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4372 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4373 static unsigned int ctls[] = {
4374 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4375 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4376 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4377 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4378 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4379 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4380 };
4381 unsigned int old_ctl, new_ctl;
4382
4383 old_ctl = snd_hda_codec_read(codec, nid, 0,
4384 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4385 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4386 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004387 int val;
4388 snd_hda_codec_write_cache(codec, nid, 0,
4389 AC_VERB_SET_PIN_WIDGET_CONTROL,
4390 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004391 val = ucontrol->value.enumerated.item[0] >= 3 ?
4392 HDA_AMP_MUTE : 0;
4393 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4394 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004395 return 1;
4396 }
4397 return 0;
4398}
4399
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004400static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4401 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004402{
4403 static char *texts[] = {
4404 "Front", "Surround", "CLFE", "Side"
4405 };
4406 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4407 uinfo->count = 1;
4408 uinfo->value.enumerated.items = 4;
4409 if (uinfo->value.enumerated.item >= 4)
4410 uinfo->value.enumerated.item = 3;
4411 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4412 return 0;
4413}
4414
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004415static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4416 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004417{
4418 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4419 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4420 unsigned int sel;
4421
4422 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4423 ucontrol->value.enumerated.item[0] = sel & 3;
4424 return 0;
4425}
4426
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004427static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4428 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004429{
4430 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4431 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4432 unsigned int sel;
4433
4434 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4435 if (ucontrol->value.enumerated.item[0] != sel) {
4436 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004437 snd_hda_codec_write_cache(codec, nid, 0,
4438 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004439 return 1;
4440 }
4441 return 0;
4442}
4443
4444#define PIN_CTL_TEST(xname,nid) { \
4445 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4446 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004447 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004448 .info = alc_test_pin_ctl_info, \
4449 .get = alc_test_pin_ctl_get, \
4450 .put = alc_test_pin_ctl_put, \
4451 .private_value = nid \
4452 }
4453
4454#define PIN_SRC_TEST(xname,nid) { \
4455 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4456 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004457 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004458 .info = alc_test_pin_src_info, \
4459 .get = alc_test_pin_src_get, \
4460 .put = alc_test_pin_src_put, \
4461 .private_value = nid \
4462 }
4463
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004464static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004465 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4466 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4467 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4468 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004469 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4470 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4471 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4472 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004473 PIN_CTL_TEST("Front Pin Mode", 0x14),
4474 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4475 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4476 PIN_CTL_TEST("Side Pin Mode", 0x17),
4477 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4478 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4479 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4480 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4481 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4482 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4483 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4484 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4485 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4486 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4487 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4488 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4489 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4490 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4491 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4492 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4493 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4494 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004495 {
4496 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4497 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004498 .info = alc_ch_mode_info,
4499 .get = alc_ch_mode_get,
4500 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004501 },
4502 { } /* end */
4503};
4504
4505static struct hda_verb alc880_test_init_verbs[] = {
4506 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004507 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4508 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4509 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4510 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4511 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4512 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4513 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4514 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004515 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004516 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4517 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4518 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4519 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004520 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004521 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4522 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4523 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4524 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004525 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004526 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4527 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4528 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4529 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004530 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004531 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4532 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004533 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4534 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4535 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004536 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004537 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4538 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4539 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4540 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004541 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004542 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004543 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004544 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004545 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004546 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004547 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004548 /* Analog input/passthru */
4549 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4550 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4551 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4552 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004554 { }
4555};
4556#endif
4557
Linus Torvalds1da177e2005-04-16 15:20:36 -07004558/*
4559 */
4560
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004561static const char *alc880_models[ALC880_MODEL_LAST] = {
4562 [ALC880_3ST] = "3stack",
4563 [ALC880_TCL_S700] = "tcl",
4564 [ALC880_3ST_DIG] = "3stack-digout",
4565 [ALC880_CLEVO] = "clevo",
4566 [ALC880_5ST] = "5stack",
4567 [ALC880_5ST_DIG] = "5stack-digout",
4568 [ALC880_W810] = "w810",
4569 [ALC880_Z71V] = "z71v",
4570 [ALC880_6ST] = "6stack",
4571 [ALC880_6ST_DIG] = "6stack-digout",
4572 [ALC880_ASUS] = "asus",
4573 [ALC880_ASUS_W1V] = "asus-w1v",
4574 [ALC880_ASUS_DIG] = "asus-dig",
4575 [ALC880_ASUS_DIG2] = "asus-dig2",
4576 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004577 [ALC880_UNIWILL_P53] = "uniwill-p53",
4578 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004579 [ALC880_F1734] = "F1734",
4580 [ALC880_LG] = "lg",
4581 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004582 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004583#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004584 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004585#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004586 [ALC880_AUTO] = "auto",
4587};
4588
4589static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004590 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004591 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4592 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4593 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4594 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4595 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4596 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4597 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4598 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004599 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4600 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004601 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4602 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4603 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4604 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4605 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4606 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4607 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4608 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4609 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4610 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004611 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004612 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4613 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4614 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004615 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004616 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004617 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4618 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004619 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4620 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004621 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4622 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4623 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4624 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004625 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4626 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004627 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004628 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004629 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004630 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004631 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4632 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004633 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004634 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004635 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004636 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004637 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004638 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004639 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004640 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004641 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004642 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004643 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004644 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004645 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004646 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4647 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4648 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4649 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004650 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4651 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004652 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004653 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004654 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4655 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004656 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4657 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4658 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004659 /* default Intel */
4660 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004661 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4662 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004663 {}
4664};
4665
Takashi Iwai16ded522005-06-10 19:58:24 +02004666/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004667 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004668 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004669static struct alc_config_preset alc880_presets[] = {
4670 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004671 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004672 .init_verbs = { alc880_volume_init_verbs,
4673 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004674 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004675 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004676 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4677 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004678 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004679 .input_mux = &alc880_capture_source,
4680 },
4681 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004682 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004683 .init_verbs = { alc880_volume_init_verbs,
4684 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004685 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004686 .dac_nids = alc880_dac_nids,
4687 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004688 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4689 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004690 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004691 .input_mux = &alc880_capture_source,
4692 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004693 [ALC880_TCL_S700] = {
4694 .mixers = { alc880_tcl_s700_mixer },
4695 .init_verbs = { alc880_volume_init_verbs,
4696 alc880_pin_tcl_S700_init_verbs,
4697 alc880_gpio2_init_verbs },
4698 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4699 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004700 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4701 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004702 .hp_nid = 0x03,
4703 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4704 .channel_mode = alc880_2_jack_modes,
4705 .input_mux = &alc880_capture_source,
4706 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004707 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004708 .mixers = { alc880_three_stack_mixer,
4709 alc880_five_stack_mixer},
4710 .init_verbs = { alc880_volume_init_verbs,
4711 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004712 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4713 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004714 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4715 .channel_mode = alc880_fivestack_modes,
4716 .input_mux = &alc880_capture_source,
4717 },
4718 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004719 .mixers = { alc880_three_stack_mixer,
4720 alc880_five_stack_mixer },
4721 .init_verbs = { alc880_volume_init_verbs,
4722 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004723 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4724 .dac_nids = alc880_dac_nids,
4725 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004726 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4727 .channel_mode = alc880_fivestack_modes,
4728 .input_mux = &alc880_capture_source,
4729 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004730 [ALC880_6ST] = {
4731 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004732 .init_verbs = { alc880_volume_init_verbs,
4733 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004734 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4735 .dac_nids = alc880_6st_dac_nids,
4736 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4737 .channel_mode = alc880_sixstack_modes,
4738 .input_mux = &alc880_6stack_capture_source,
4739 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004740 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004741 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004742 .init_verbs = { alc880_volume_init_verbs,
4743 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004744 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4745 .dac_nids = alc880_6st_dac_nids,
4746 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004747 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4748 .channel_mode = alc880_sixstack_modes,
4749 .input_mux = &alc880_6stack_capture_source,
4750 },
4751 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004752 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004753 .init_verbs = { alc880_volume_init_verbs,
4754 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004755 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004756 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4757 .dac_nids = alc880_w810_dac_nids,
4758 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004759 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4760 .channel_mode = alc880_w810_modes,
4761 .input_mux = &alc880_capture_source,
4762 },
4763 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004764 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004765 .init_verbs = { alc880_volume_init_verbs,
4766 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004767 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4768 .dac_nids = alc880_z71v_dac_nids,
4769 .dig_out_nid = ALC880_DIGOUT_NID,
4770 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004771 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4772 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004773 .input_mux = &alc880_capture_source,
4774 },
4775 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004776 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004777 .init_verbs = { alc880_volume_init_verbs,
4778 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004779 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4780 .dac_nids = alc880_f1734_dac_nids,
4781 .hp_nid = 0x02,
4782 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4783 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004784 .input_mux = &alc880_f1734_capture_source,
4785 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004786 .setup = alc880_uniwill_p53_setup,
4787 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004788 },
4789 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004790 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004791 .init_verbs = { alc880_volume_init_verbs,
4792 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004793 alc880_gpio1_init_verbs },
4794 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4795 .dac_nids = alc880_asus_dac_nids,
4796 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4797 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004798 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004799 .input_mux = &alc880_capture_source,
4800 },
4801 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004802 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004803 .init_verbs = { alc880_volume_init_verbs,
4804 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004805 alc880_gpio1_init_verbs },
4806 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4807 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004808 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004809 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4810 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004811 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004812 .input_mux = &alc880_capture_source,
4813 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004814 [ALC880_ASUS_DIG2] = {
4815 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004816 .init_verbs = { alc880_volume_init_verbs,
4817 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004818 alc880_gpio2_init_verbs }, /* use GPIO2 */
4819 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4820 .dac_nids = alc880_asus_dac_nids,
4821 .dig_out_nid = ALC880_DIGOUT_NID,
4822 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4823 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004824 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004825 .input_mux = &alc880_capture_source,
4826 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004827 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004828 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004829 .init_verbs = { alc880_volume_init_verbs,
4830 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004831 alc880_gpio1_init_verbs },
4832 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4833 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004834 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004835 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4836 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004837 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004838 .input_mux = &alc880_capture_source,
4839 },
4840 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004841 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004842 .init_verbs = { alc880_volume_init_verbs,
4843 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004844 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4845 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004846 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004847 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4848 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004849 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004850 .input_mux = &alc880_capture_source,
4851 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004852 [ALC880_UNIWILL] = {
4853 .mixers = { alc880_uniwill_mixer },
4854 .init_verbs = { alc880_volume_init_verbs,
4855 alc880_uniwill_init_verbs },
4856 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4857 .dac_nids = alc880_asus_dac_nids,
4858 .dig_out_nid = ALC880_DIGOUT_NID,
4859 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4860 .channel_mode = alc880_threestack_modes,
4861 .need_dac_fix = 1,
4862 .input_mux = &alc880_capture_source,
4863 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004864 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004865 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004866 },
4867 [ALC880_UNIWILL_P53] = {
4868 .mixers = { alc880_uniwill_p53_mixer },
4869 .init_verbs = { alc880_volume_init_verbs,
4870 alc880_uniwill_p53_init_verbs },
4871 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4872 .dac_nids = alc880_asus_dac_nids,
4873 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004874 .channel_mode = alc880_threestack_modes,
4875 .input_mux = &alc880_capture_source,
4876 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004877 .setup = alc880_uniwill_p53_setup,
4878 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004879 },
4880 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004881 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004882 .init_verbs = { alc880_volume_init_verbs,
4883 alc880_uniwill_p53_init_verbs,
4884 alc880_beep_init_verbs },
4885 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4886 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004887 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004888 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4889 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004890 .input_mux = &alc880_capture_source,
4891 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004892 .setup = alc880_uniwill_p53_setup,
4893 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004894 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004895 [ALC880_CLEVO] = {
4896 .mixers = { alc880_three_stack_mixer },
4897 .init_verbs = { alc880_volume_init_verbs,
4898 alc880_pin_clevo_init_verbs },
4899 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4900 .dac_nids = alc880_dac_nids,
4901 .hp_nid = 0x03,
4902 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4903 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004904 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004905 .input_mux = &alc880_capture_source,
4906 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004907 [ALC880_LG] = {
4908 .mixers = { alc880_lg_mixer },
4909 .init_verbs = { alc880_volume_init_verbs,
4910 alc880_lg_init_verbs },
4911 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4912 .dac_nids = alc880_lg_dac_nids,
4913 .dig_out_nid = ALC880_DIGOUT_NID,
4914 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4915 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004916 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004917 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004918 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004919 .setup = alc880_lg_setup,
4920 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004921#ifdef CONFIG_SND_HDA_POWER_SAVE
4922 .loopbacks = alc880_lg_loopbacks,
4923#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004924 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004925 [ALC880_LG_LW] = {
4926 .mixers = { alc880_lg_lw_mixer },
4927 .init_verbs = { alc880_volume_init_verbs,
4928 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004929 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004930 .dac_nids = alc880_dac_nids,
4931 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004932 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4933 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004934 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004935 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004936 .setup = alc880_lg_lw_setup,
4937 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004938 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004939 [ALC880_MEDION_RIM] = {
4940 .mixers = { alc880_medion_rim_mixer },
4941 .init_verbs = { alc880_volume_init_verbs,
4942 alc880_medion_rim_init_verbs,
4943 alc_gpio2_init_verbs },
4944 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4945 .dac_nids = alc880_dac_nids,
4946 .dig_out_nid = ALC880_DIGOUT_NID,
4947 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4948 .channel_mode = alc880_2_jack_modes,
4949 .input_mux = &alc880_medion_rim_capture_source,
4950 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004951 .setup = alc880_medion_rim_setup,
4952 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004953 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004954#ifdef CONFIG_SND_DEBUG
4955 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004956 .mixers = { alc880_test_mixer },
4957 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004958 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4959 .dac_nids = alc880_test_dac_nids,
4960 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004961 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4962 .channel_mode = alc880_test_modes,
4963 .input_mux = &alc880_test_capture_source,
4964 },
4965#endif
4966};
4967
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004968/*
4969 * Automatic parse of I/O pins from the BIOS configuration
4970 */
4971
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004972enum {
4973 ALC_CTL_WIDGET_VOL,
4974 ALC_CTL_WIDGET_MUTE,
4975 ALC_CTL_BIND_MUTE,
4976};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004977static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004978 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4979 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004980 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004981};
4982
4983/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004984static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004985 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004986{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004987 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004988
Takashi Iwai603c4012008-07-30 15:01:44 +02004989 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4990 knew = snd_array_new(&spec->kctls);
4991 if (!knew)
4992 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004993 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004994 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004995 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004996 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004997 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01004998 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01004999 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005000 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005001 return 0;
5002}
5003
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005004static int add_control_with_pfx(struct alc_spec *spec, int type,
5005 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005006 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005007{
5008 char name[32];
5009 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005010 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005011}
5012
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005013#define add_pb_vol_ctrl(spec, type, pfx, val) \
5014 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5015#define add_pb_sw_ctrl(spec, type, pfx, val) \
5016 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5017#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5018 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5019#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5020 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005021
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005022#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5023#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5024#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5025#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005026#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5027#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5028#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5029#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5030#define ALC880_PIN_CD_NID 0x1c
5031
5032/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005033static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5034 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005035{
5036 hda_nid_t nid;
5037 int assigned[4];
5038 int i, j;
5039
5040 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005041 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005042
5043 /* check the pins hardwired to audio widget */
5044 for (i = 0; i < cfg->line_outs; i++) {
5045 nid = cfg->line_out_pins[i];
5046 if (alc880_is_fixed_pin(nid)) {
5047 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005048 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005049 assigned[idx] = 1;
5050 }
5051 }
5052 /* left pins can be connect to any audio widget */
5053 for (i = 0; i < cfg->line_outs; i++) {
5054 nid = cfg->line_out_pins[i];
5055 if (alc880_is_fixed_pin(nid))
5056 continue;
5057 /* search for an empty channel */
5058 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005059 if (!assigned[j]) {
5060 spec->multiout.dac_nids[i] =
5061 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005062 assigned[j] = 1;
5063 break;
5064 }
5065 }
5066 }
5067 spec->multiout.num_dacs = cfg->line_outs;
5068 return 0;
5069}
5070
5071/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005072static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5073 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005074{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005075 static const char *chname[4] = {
5076 "Front", "Surround", NULL /*CLFE*/, "Side"
5077 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005078 hda_nid_t nid;
5079 int i, err;
5080
5081 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005082 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005083 continue;
5084 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
5085 if (i == 2) {
5086 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005087 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5088 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005089 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5090 HDA_OUTPUT));
5091 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005092 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005093 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5094 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005095 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5096 HDA_OUTPUT));
5097 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005098 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005099 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5100 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005101 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5102 HDA_INPUT));
5103 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005104 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005105 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5106 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005107 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5108 HDA_INPUT));
5109 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005110 return err;
5111 } else {
Takashi Iwaicb162b62009-08-25 16:05:03 +02005112 const char *pfx;
5113 if (cfg->line_outs == 1 &&
5114 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
5115 pfx = "Speaker";
5116 else
5117 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005118 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005119 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5120 HDA_OUTPUT));
5121 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005122 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005123 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005124 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5125 HDA_INPUT));
5126 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005127 return err;
5128 }
5129 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005130 return 0;
5131}
5132
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005133/* add playback controls for speaker and HP outputs */
5134static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5135 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005136{
5137 hda_nid_t nid;
5138 int err;
5139
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005140 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005141 return 0;
5142
5143 if (alc880_is_fixed_pin(pin)) {
5144 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005145 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005146 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005147 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005148 else
5149 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005150 /* control HP volume/switch on the output mixer amp */
5151 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005152 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005153 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5154 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005155 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005156 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005157 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5158 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005159 return err;
5160 } else if (alc880_is_multi_pin(pin)) {
5161 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005162 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005163 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005164 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5165 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005166 return err;
5167 }
5168 return 0;
5169}
5170
5171/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005172static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005173 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005174 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005175{
Kailang Yangdf694da2005-12-05 19:42:22 +01005176 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005177
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005178 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005179 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5180 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005181 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005182 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005183 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5184 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005185 return err;
5186 return 0;
5187}
5188
Takashi Iwai05f5f472009-08-25 13:10:18 +02005189static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005190{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005191 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5192 return (pincap & AC_PINCAP_IN) != 0;
5193}
5194
5195/* create playback/capture controls for input pins */
5196static int alc_auto_create_input_ctls(struct hda_codec *codec,
5197 const struct auto_pin_cfg *cfg,
5198 hda_nid_t mixer,
5199 hda_nid_t cap1, hda_nid_t cap2)
5200{
5201 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005202 struct hda_input_mux *imux = &spec->private_imux[0];
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005203 int i, err, idx, type, type_idx = 0;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005204
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005205 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005206 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005207 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005208
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005209 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005210 if (!alc_is_input_pin(codec, pin))
5211 continue;
5212
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005213 type = cfg->inputs[i].type;
5214 if (i > 0 && type == cfg->inputs[i - 1].type)
5215 type_idx++;
5216 else
5217 type_idx = 0;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005218 label = hda_get_autocfg_input_label(codec, cfg, i);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005219 if (mixer) {
5220 idx = get_connection_index(codec, mixer, pin);
5221 if (idx >= 0) {
5222 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005223 label, type_idx,
5224 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005225 if (err < 0)
5226 return err;
5227 }
5228 }
5229
5230 if (!cap1)
5231 continue;
5232 idx = get_connection_index(codec, cap1, pin);
5233 if (idx < 0 && cap2)
5234 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005235 if (idx >= 0)
5236 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005237 }
5238 return 0;
5239}
5240
Takashi Iwai05f5f472009-08-25 13:10:18 +02005241static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5242 const struct auto_pin_cfg *cfg)
5243{
5244 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5245}
5246
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005247static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5248 unsigned int pin_type)
5249{
5250 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5251 pin_type);
5252 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005253 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5254 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005255}
5256
Kailang Yangdf694da2005-12-05 19:42:22 +01005257static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5258 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005259 int dac_idx)
5260{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005261 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005262 /* need the manual connection? */
5263 if (alc880_is_multi_pin(nid)) {
5264 struct alc_spec *spec = codec->spec;
5265 int idx = alc880_multi_pin_idx(nid);
5266 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5267 AC_VERB_SET_CONNECT_SEL,
5268 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5269 }
5270}
5271
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005272static int get_pin_type(int line_out_type)
5273{
5274 if (line_out_type == AUTO_PIN_HP_OUT)
5275 return PIN_HP;
5276 else
5277 return PIN_OUT;
5278}
5279
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005280static void alc880_auto_init_multi_out(struct hda_codec *codec)
5281{
5282 struct alc_spec *spec = codec->spec;
5283 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005284
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005285 for (i = 0; i < spec->autocfg.line_outs; i++) {
5286 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005287 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5288 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005289 }
5290}
5291
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005292static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005293{
5294 struct alc_spec *spec = codec->spec;
5295 hda_nid_t pin;
5296
Takashi Iwai82bc9552006-03-21 11:24:42 +01005297 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005298 if (pin) /* connect to front */
5299 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005300 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005301 if (pin) /* connect to front */
5302 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5303}
5304
5305static void alc880_auto_init_analog_input(struct hda_codec *codec)
5306{
5307 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005308 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005309 int i;
5310
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005311 for (i = 0; i < cfg->num_inputs; i++) {
5312 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005313 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005314 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005315 if (nid != ALC880_PIN_CD_NID &&
5316 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005317 snd_hda_codec_write(codec, nid, 0,
5318 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005319 AMP_OUT_MUTE);
5320 }
5321 }
5322}
5323
Takashi Iwai7f311a42010-04-09 17:32:23 +02005324static void alc880_auto_init_input_src(struct hda_codec *codec)
5325{
5326 struct alc_spec *spec = codec->spec;
5327 int c;
5328
5329 for (c = 0; c < spec->num_adc_nids; c++) {
5330 unsigned int mux_idx;
5331 const struct hda_input_mux *imux;
5332 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5333 imux = &spec->input_mux[mux_idx];
5334 if (!imux->num_items && mux_idx > 0)
5335 imux = &spec->input_mux[0];
5336 if (imux)
5337 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5338 AC_VERB_SET_CONNECT_SEL,
5339 imux->items[0].index);
5340 }
5341}
5342
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005343/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005344/* return 1 if successful, 0 if the proper config is not found,
5345 * or a negative error code
5346 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005347static int alc880_parse_auto_config(struct hda_codec *codec)
5348{
5349 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005350 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005351 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005352
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005353 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5354 alc880_ignore);
5355 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005356 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005357 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005358 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005359
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005360 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5361 if (err < 0)
5362 return err;
5363 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5364 if (err < 0)
5365 return err;
5366 err = alc880_auto_create_extra_out(spec,
5367 spec->autocfg.speaker_pins[0],
5368 "Speaker");
5369 if (err < 0)
5370 return err;
5371 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5372 "Headphone");
5373 if (err < 0)
5374 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005375 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005376 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005377 return err;
5378
5379 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5380
Takashi Iwai757899a2010-07-30 10:48:14 +02005381 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005382
Takashi Iwai603c4012008-07-30 15:01:44 +02005383 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005384 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005385
Takashi Iwaid88897e2008-10-31 15:01:37 +01005386 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005387
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005388 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005389 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005390
Kailang Yang6227cdc2010-02-25 08:36:52 +01005391 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005392
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005393 return 1;
5394}
5395
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005396/* additional initialization for auto-configuration model */
5397static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005398{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005399 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005400 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005401 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005402 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005403 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005404 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005405 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005406 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005407}
5408
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005409/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5410 * one of two digital mic pins, e.g. on ALC272
5411 */
5412static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005413{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005414 struct alc_spec *spec = codec->spec;
5415 int i;
5416
5417 for (i = 0; i < spec->num_adc_nids; i++) {
5418 hda_nid_t cap = spec->capsrc_nids ?
5419 spec->capsrc_nids[i] : spec->adc_nids[i];
5420 int iidx, eidx;
5421
5422 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5423 if (iidx < 0)
5424 continue;
5425 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5426 if (eidx < 0)
5427 continue;
5428 spec->int_mic.mux_idx = iidx;
5429 spec->ext_mic.mux_idx = eidx;
5430 if (spec->capsrc_nids)
5431 spec->capsrc_nids += i;
5432 spec->adc_nids += i;
5433 spec->num_adc_nids = 1;
5434 return;
5435 }
5436 snd_printd(KERN_INFO "hda_codec: %s: "
5437 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5438 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5439 spec->auto_mic = 0; /* disable auto-mic to be sure */
5440}
5441
Takashi Iwai748cce42010-08-04 07:37:39 +02005442/* select or unmute the given capsrc route */
5443static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5444 int idx)
5445{
5446 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5447 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5448 HDA_AMP_MUTE, 0);
5449 } else {
5450 snd_hda_codec_write_cache(codec, cap, 0,
5451 AC_VERB_SET_CONNECT_SEL, idx);
5452 }
5453}
5454
Takashi Iwai840b64c2010-07-13 22:49:01 +02005455/* set the default connection to that pin */
5456static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5457{
5458 struct alc_spec *spec = codec->spec;
5459 int i;
5460
5461 for (i = 0; i < spec->num_adc_nids; i++) {
5462 hda_nid_t cap = spec->capsrc_nids ?
5463 spec->capsrc_nids[i] : spec->adc_nids[i];
5464 int idx;
5465
5466 idx = get_connection_index(codec, cap, pin);
5467 if (idx < 0)
5468 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005469 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005470 return i; /* return the found index */
5471 }
5472 return -1; /* not found */
5473}
5474
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005475/* choose the ADC/MUX containing the input pin and initialize the setup */
5476static void fixup_single_adc(struct hda_codec *codec)
5477{
5478 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005479 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005480 int i;
5481
5482 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005483 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005484 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005485 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005486 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005487 /* use only this ADC */
5488 if (spec->capsrc_nids)
5489 spec->capsrc_nids += i;
5490 spec->adc_nids += i;
5491 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005492 }
5493}
5494
Takashi Iwai840b64c2010-07-13 22:49:01 +02005495/* initialize dual adcs */
5496static void fixup_dual_adc_switch(struct hda_codec *codec)
5497{
5498 struct alc_spec *spec = codec->spec;
5499 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5500 init_capsrc_for_pin(codec, spec->int_mic.pin);
5501}
5502
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005503static void set_capture_mixer(struct hda_codec *codec)
5504{
5505 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005506 static struct snd_kcontrol_new *caps[2][3] = {
5507 { alc_capture_mixer_nosrc1,
5508 alc_capture_mixer_nosrc2,
5509 alc_capture_mixer_nosrc3 },
5510 { alc_capture_mixer1,
5511 alc_capture_mixer2,
5512 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005513 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005514 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005515 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005516 int num_adcs = spec->num_adc_nids;
5517 if (spec->dual_adc_switch)
5518 fixup_dual_adc_switch(codec);
5519 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005520 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005521 else if (spec->input_mux) {
5522 if (spec->input_mux->num_items > 1)
5523 mux = 1;
5524 else if (spec->input_mux->num_items == 1)
5525 fixup_single_adc(codec);
5526 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005527 if (spec->dual_adc_switch)
5528 num_adcs = 1;
5529 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005530 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005531}
5532
Takashi Iwai66946352010-03-29 17:21:45 +02005533/* fill adc_nids (and capsrc_nids) containing all active input pins */
5534static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5535 int num_nids)
5536{
5537 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005538 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005539 int n;
5540 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5541
5542 for (n = 0; n < num_nids; n++) {
5543 hda_nid_t adc, cap;
5544 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5545 int nconns, i, j;
5546
5547 adc = nids[n];
5548 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5549 continue;
5550 cap = adc;
5551 nconns = snd_hda_get_connections(codec, cap, conn,
5552 ARRAY_SIZE(conn));
5553 if (nconns == 1) {
5554 cap = conn[0];
5555 nconns = snd_hda_get_connections(codec, cap, conn,
5556 ARRAY_SIZE(conn));
5557 }
5558 if (nconns <= 0)
5559 continue;
5560 if (!fallback_adc) {
5561 fallback_adc = adc;
5562 fallback_cap = cap;
5563 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005564 for (i = 0; i < cfg->num_inputs; i++) {
5565 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005566 for (j = 0; j < nconns; j++) {
5567 if (conn[j] == nid)
5568 break;
5569 }
5570 if (j >= nconns)
5571 break;
5572 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005573 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005574 int num_adcs = spec->num_adc_nids;
5575 spec->private_adc_nids[num_adcs] = adc;
5576 spec->private_capsrc_nids[num_adcs] = cap;
5577 spec->num_adc_nids++;
5578 spec->adc_nids = spec->private_adc_nids;
5579 if (adc != cap)
5580 spec->capsrc_nids = spec->private_capsrc_nids;
5581 }
5582 }
5583 if (!spec->num_adc_nids) {
5584 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005585 " using fallback 0x%x\n",
5586 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005587 spec->private_adc_nids[0] = fallback_adc;
5588 spec->adc_nids = spec->private_adc_nids;
5589 if (fallback_adc != fallback_cap) {
5590 spec->private_capsrc_nids[0] = fallback_cap;
5591 spec->capsrc_nids = spec->private_adc_nids;
5592 }
5593 }
5594}
5595
Takashi Iwai67d634c2009-11-16 15:35:59 +01005596#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005597#define set_beep_amp(spec, nid, idx, dir) \
5598 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005599
5600static struct snd_pci_quirk beep_white_list[] = {
5601 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005602 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005603 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005604 {}
5605};
5606
5607static inline int has_cdefine_beep(struct hda_codec *codec)
5608{
5609 struct alc_spec *spec = codec->spec;
5610 const struct snd_pci_quirk *q;
5611 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5612 if (q)
5613 return q->value;
5614 return spec->cdefine.enable_pcbeep;
5615}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005616#else
5617#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005618#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005619#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005620
5621/*
5622 * OK, here we have finally the patch for ALC880
5623 */
5624
Linus Torvalds1da177e2005-04-16 15:20:36 -07005625static int patch_alc880(struct hda_codec *codec)
5626{
5627 struct alc_spec *spec;
5628 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005629 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005630
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005631 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005632 if (spec == NULL)
5633 return -ENOMEM;
5634
5635 codec->spec = spec;
5636
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005637 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5638 alc880_models,
5639 alc880_cfg_tbl);
5640 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005641 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5642 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005643 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005644 }
5645
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005646 if (board_config == ALC880_AUTO) {
5647 /* automatic parse from the BIOS config */
5648 err = alc880_parse_auto_config(codec);
5649 if (err < 0) {
5650 alc_free(codec);
5651 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005652 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005653 printk(KERN_INFO
5654 "hda_codec: Cannot set up configuration "
5655 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005656 board_config = ALC880_3ST;
5657 }
5658 }
5659
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005660 err = snd_hda_attach_beep_device(codec, 0x1);
5661 if (err < 0) {
5662 alc_free(codec);
5663 return err;
5664 }
5665
Kailang Yangdf694da2005-12-05 19:42:22 +01005666 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005667 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005668
Linus Torvalds1da177e2005-04-16 15:20:36 -07005669 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5670 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005671 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005672
Linus Torvalds1da177e2005-04-16 15:20:36 -07005673 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5674 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5675
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005676 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005677 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005678 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005679 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005680 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005681 if (wcap != AC_WID_AUD_IN) {
5682 spec->adc_nids = alc880_adc_nids_alt;
5683 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005684 } else {
5685 spec->adc_nids = alc880_adc_nids;
5686 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005687 }
5688 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005689 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005690 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005691
Takashi Iwai2134ea42008-01-10 16:53:55 +01005692 spec->vmaster_nid = 0x0c;
5693
Linus Torvalds1da177e2005-04-16 15:20:36 -07005694 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005695 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005696 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005697#ifdef CONFIG_SND_HDA_POWER_SAVE
5698 if (!spec->loopback.amplist)
5699 spec->loopback.amplist = alc880_loopbacks;
5700#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005701
5702 return 0;
5703}
5704
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005705
Linus Torvalds1da177e2005-04-16 15:20:36 -07005706/*
5707 * ALC260 support
5708 */
5709
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005710static hda_nid_t alc260_dac_nids[1] = {
5711 /* front */
5712 0x02,
5713};
5714
5715static hda_nid_t alc260_adc_nids[1] = {
5716 /* ADC0 */
5717 0x04,
5718};
5719
Kailang Yangdf694da2005-12-05 19:42:22 +01005720static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005721 /* ADC1 */
5722 0x05,
5723};
5724
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005725/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5726 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5727 */
5728static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005729 /* ADC0, ADC1 */
5730 0x04, 0x05
5731};
5732
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005733#define ALC260_DIGOUT_NID 0x03
5734#define ALC260_DIGIN_NID 0x06
5735
5736static struct hda_input_mux alc260_capture_source = {
5737 .num_items = 4,
5738 .items = {
5739 { "Mic", 0x0 },
5740 { "Front Mic", 0x1 },
5741 { "Line", 0x2 },
5742 { "CD", 0x4 },
5743 },
5744};
5745
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005746/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005747 * headphone jack and the internal CD lines since these are the only pins at
5748 * which audio can appear. For flexibility, also allow the option of
5749 * recording the mixer output on the second ADC (ADC0 doesn't have a
5750 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005751 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005752static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5753 {
5754 .num_items = 3,
5755 .items = {
5756 { "Mic/Line", 0x0 },
5757 { "CD", 0x4 },
5758 { "Headphone", 0x2 },
5759 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005760 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005761 {
5762 .num_items = 4,
5763 .items = {
5764 { "Mic/Line", 0x0 },
5765 { "CD", 0x4 },
5766 { "Headphone", 0x2 },
5767 { "Mixer", 0x5 },
5768 },
5769 },
5770
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005771};
5772
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005773/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5774 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005775 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005776static struct hda_input_mux alc260_acer_capture_sources[2] = {
5777 {
5778 .num_items = 4,
5779 .items = {
5780 { "Mic", 0x0 },
5781 { "Line", 0x2 },
5782 { "CD", 0x4 },
5783 { "Headphone", 0x5 },
5784 },
5785 },
5786 {
5787 .num_items = 5,
5788 .items = {
5789 { "Mic", 0x0 },
5790 { "Line", 0x2 },
5791 { "CD", 0x4 },
5792 { "Headphone", 0x6 },
5793 { "Mixer", 0x5 },
5794 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005795 },
5796};
Michael Schwingencc959482009-02-22 18:58:45 +01005797
5798/* Maxdata Favorit 100XS */
5799static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5800 {
5801 .num_items = 2,
5802 .items = {
5803 { "Line/Mic", 0x0 },
5804 { "CD", 0x4 },
5805 },
5806 },
5807 {
5808 .num_items = 3,
5809 .items = {
5810 { "Line/Mic", 0x0 },
5811 { "CD", 0x4 },
5812 { "Mixer", 0x5 },
5813 },
5814 },
5815};
5816
Linus Torvalds1da177e2005-04-16 15:20:36 -07005817/*
5818 * This is just place-holder, so there's something for alc_build_pcms to look
5819 * at when it calculates the maximum number of channels. ALC260 has no mixer
5820 * element which allows changing the channel mode, so the verb list is
5821 * never used.
5822 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005823static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005824 { 2, NULL },
5825};
5826
Kailang Yangdf694da2005-12-05 19:42:22 +01005827
5828/* Mixer combinations
5829 *
5830 * basic: base_output + input + pc_beep + capture
5831 * HP: base_output + input + capture_alt
5832 * HP_3013: hp_3013 + input + capture
5833 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005834 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005835 */
5836
5837static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005838 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005839 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005840 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5841 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5842 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5843 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5844 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005845};
Kailang Yangdf694da2005-12-05 19:42:22 +01005846
5847static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005848 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5849 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5850 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5851 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5852 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5853 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5854 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5855 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005856 { } /* end */
5857};
5858
Takashi Iwaibec15c32008-01-28 18:16:30 +01005859/* update HP, line and mono out pins according to the master switch */
5860static void alc260_hp_master_update(struct hda_codec *codec,
5861 hda_nid_t hp, hda_nid_t line,
5862 hda_nid_t mono)
5863{
5864 struct alc_spec *spec = codec->spec;
5865 unsigned int val = spec->master_sw ? PIN_HP : 0;
5866 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005867 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005868 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005869 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005870 val);
5871 /* mono (speaker) depending on the HP jack sense */
5872 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005873 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005874 val);
5875}
5876
5877static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5878 struct snd_ctl_elem_value *ucontrol)
5879{
5880 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5881 struct alc_spec *spec = codec->spec;
5882 *ucontrol->value.integer.value = spec->master_sw;
5883 return 0;
5884}
5885
5886static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5887 struct snd_ctl_elem_value *ucontrol)
5888{
5889 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5890 struct alc_spec *spec = codec->spec;
5891 int val = !!*ucontrol->value.integer.value;
5892 hda_nid_t hp, line, mono;
5893
5894 if (val == spec->master_sw)
5895 return 0;
5896 spec->master_sw = val;
5897 hp = (kcontrol->private_value >> 16) & 0xff;
5898 line = (kcontrol->private_value >> 8) & 0xff;
5899 mono = kcontrol->private_value & 0xff;
5900 alc260_hp_master_update(codec, hp, line, mono);
5901 return 1;
5902}
5903
5904static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5905 {
5906 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5907 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005908 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005909 .info = snd_ctl_boolean_mono_info,
5910 .get = alc260_hp_master_sw_get,
5911 .put = alc260_hp_master_sw_put,
5912 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5913 },
5914 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5915 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5916 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5917 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5918 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5919 HDA_OUTPUT),
5920 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5921 { } /* end */
5922};
5923
5924static struct hda_verb alc260_hp_unsol_verbs[] = {
5925 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5926 {},
5927};
5928
5929static void alc260_hp_automute(struct hda_codec *codec)
5930{
5931 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005932
Wu Fengguang864f92b2009-11-18 12:38:02 +08005933 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005934 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5935}
5936
5937static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5938{
5939 if ((res >> 26) == ALC880_HP_EVENT)
5940 alc260_hp_automute(codec);
5941}
5942
Kailang Yangdf694da2005-12-05 19:42:22 +01005943static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005944 {
5945 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5946 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005947 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005948 .info = snd_ctl_boolean_mono_info,
5949 .get = alc260_hp_master_sw_get,
5950 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005951 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005952 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005953 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5954 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5955 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5956 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5957 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5958 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005959 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5960 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005961 { } /* end */
5962};
5963
Kailang Yang3f878302008-08-26 13:02:23 +02005964static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5965 .ops = &snd_hda_bind_vol,
5966 .values = {
5967 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5968 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5969 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
5970 0
5971 },
5972};
5973
5974static struct hda_bind_ctls alc260_dc7600_bind_switch = {
5975 .ops = &snd_hda_bind_sw,
5976 .values = {
5977 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
5978 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
5979 0
5980 },
5981};
5982
5983static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
5984 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
5985 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
5986 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
5987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5988 { } /* end */
5989};
5990
Takashi Iwaibec15c32008-01-28 18:16:30 +01005991static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
5992 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5993 {},
5994};
5995
5996static void alc260_hp_3013_automute(struct hda_codec *codec)
5997{
5998 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005999
Wu Fengguang864f92b2009-11-18 12:38:02 +08006000 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006001 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006002}
6003
6004static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6005 unsigned int res)
6006{
6007 if ((res >> 26) == ALC880_HP_EVENT)
6008 alc260_hp_3013_automute(codec);
6009}
6010
Kailang Yang3f878302008-08-26 13:02:23 +02006011static void alc260_hp_3012_automute(struct hda_codec *codec)
6012{
Wu Fengguang864f92b2009-11-18 12:38:02 +08006013 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02006014
Kailang Yang3f878302008-08-26 13:02:23 +02006015 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6016 bits);
6017 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6018 bits);
6019 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6020 bits);
6021}
6022
6023static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6024 unsigned int res)
6025{
6026 if ((res >> 26) == ALC880_HP_EVENT)
6027 alc260_hp_3012_automute(codec);
6028}
6029
6030/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006031 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6032 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006033static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006034 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006035 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006036 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006037 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6038 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6039 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6040 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006041 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006042 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6043 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006044 { } /* end */
6045};
6046
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006047/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6048 * versions of the ALC260 don't act on requests to enable mic bias from NID
6049 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6050 * datasheet doesn't mention this restriction. At this stage it's not clear
6051 * whether this behaviour is intentional or is a hardware bug in chip
6052 * revisions available in early 2006. Therefore for now allow the
6053 * "Headphone Jack Mode" control to span all choices, but if it turns out
6054 * that the lack of mic bias for this NID is intentional we could change the
6055 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6056 *
6057 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6058 * don't appear to make the mic bias available from the "line" jack, even
6059 * though the NID used for this jack (0x14) can supply it. The theory is
6060 * that perhaps Acer have included blocking capacitors between the ALC260
6061 * and the output jack. If this turns out to be the case for all such
6062 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6063 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006064 *
6065 * The C20x Tablet series have a mono internal speaker which is controlled
6066 * via the chip's Mono sum widget and pin complex, so include the necessary
6067 * controls for such models. On models without a "mono speaker" the control
6068 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006069 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006070static struct snd_kcontrol_new alc260_acer_mixer[] = {
6071 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6072 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006073 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006074 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006075 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006076 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006077 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006078 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6079 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6080 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6081 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6082 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6083 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6084 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6085 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006086 { } /* end */
6087};
6088
Michael Schwingencc959482009-02-22 18:58:45 +01006089/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6090 */
6091static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6092 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6093 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6094 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6095 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6096 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6097 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6098 { } /* end */
6099};
6100
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006101/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6102 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6103 */
6104static struct snd_kcontrol_new alc260_will_mixer[] = {
6105 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6106 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6107 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6108 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6109 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6110 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6111 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6112 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6113 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6114 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006115 { } /* end */
6116};
6117
6118/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6119 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6120 */
6121static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6122 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6123 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6124 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6125 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6126 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6127 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6128 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6129 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6130 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6131 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6132 { } /* end */
6133};
6134
Kailang Yangdf694da2005-12-05 19:42:22 +01006135/*
6136 * initialization verbs
6137 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006138static struct hda_verb alc260_init_verbs[] = {
6139 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006140 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006141 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006142 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006143 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006144 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006145 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006146 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006147 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006148 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006149 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006150 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006151 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006152 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006153 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006154 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006155 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006156 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6157 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006158 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006159 /* set connection select to line in (default select for this ADC) */
6160 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006161 /* mute capture amp left and right */
6162 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6163 /* set connection select to line in (default select for this ADC) */
6164 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006165 /* set vol=0 Line-Out mixer amp left and right */
6166 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6167 /* unmute pin widget amp left and right (no gain on this amp) */
6168 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6169 /* set vol=0 HP mixer amp left and right */
6170 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6171 /* unmute pin widget amp left and right (no gain on this amp) */
6172 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6173 /* set vol=0 Mono mixer amp left and right */
6174 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6175 /* unmute pin widget amp left and right (no gain on this amp) */
6176 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6177 /* unmute LINE-2 out pin */
6178 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006179 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6180 * Line In 2 = 0x03
6181 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006182 /* mute analog inputs */
6183 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6184 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6185 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6186 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6187 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006188 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006189 /* mute Front out path */
6190 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6192 /* mute Headphone out path */
6193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6194 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6195 /* mute Mono out path */
6196 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6197 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006198 { }
6199};
6200
Takashi Iwai474167d2006-05-17 17:17:43 +02006201#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006202static struct hda_verb alc260_hp_init_verbs[] = {
6203 /* Headphone and output */
6204 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6205 /* mono output */
6206 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6207 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6208 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6209 /* Mic2 (front panel) pin widget for input and vref at 80% */
6210 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6211 /* Line In pin widget for input */
6212 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6213 /* Line-2 pin widget for output */
6214 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6215 /* CD pin widget for input */
6216 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6217 /* unmute amp left and right */
6218 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6219 /* set connection select to line in (default select for this ADC) */
6220 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6221 /* unmute Line-Out mixer amp left and right (volume = 0) */
6222 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6223 /* mute pin widget amp left and right (no gain on this amp) */
6224 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6225 /* unmute HP mixer amp left and right (volume = 0) */
6226 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6227 /* mute pin widget amp left and right (no gain on this amp) */
6228 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006229 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6230 * Line In 2 = 0x03
6231 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006232 /* mute analog inputs */
6233 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6234 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6235 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6236 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6237 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006238 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6239 /* Unmute Front out path */
6240 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6241 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6242 /* Unmute Headphone out path */
6243 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6244 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6245 /* Unmute Mono out path */
6246 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6247 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6248 { }
6249};
Takashi Iwai474167d2006-05-17 17:17:43 +02006250#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006251
6252static struct hda_verb alc260_hp_3013_init_verbs[] = {
6253 /* Line out and output */
6254 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6255 /* mono output */
6256 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6257 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6258 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6259 /* Mic2 (front panel) pin widget for input and vref at 80% */
6260 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6261 /* Line In pin widget for input */
6262 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6263 /* Headphone pin widget for output */
6264 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6265 /* CD pin widget for input */
6266 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6267 /* unmute amp left and right */
6268 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6269 /* set connection select to line in (default select for this ADC) */
6270 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6271 /* unmute Line-Out mixer amp left and right (volume = 0) */
6272 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6273 /* mute pin widget amp left and right (no gain on this amp) */
6274 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6275 /* unmute HP mixer amp left and right (volume = 0) */
6276 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6277 /* mute pin widget amp left and right (no gain on this amp) */
6278 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006279 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6280 * Line In 2 = 0x03
6281 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006282 /* mute analog inputs */
6283 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6284 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6285 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6286 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6287 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006288 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6289 /* Unmute Front out path */
6290 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6291 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6292 /* Unmute Headphone out path */
6293 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6294 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6295 /* Unmute Mono out path */
6296 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6297 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6298 { }
6299};
6300
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006301/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006302 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6303 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006304 */
6305static struct hda_verb alc260_fujitsu_init_verbs[] = {
6306 /* Disable all GPIOs */
6307 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6308 /* Internal speaker is connected to headphone pin */
6309 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6310 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6311 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006312 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6313 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6314 /* Ensure all other unused pins are disabled and muted. */
6315 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6316 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006317 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006318 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006319 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006320 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6321 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6322 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006323
Jonathan Woithef7ace402006-02-28 11:46:14 +01006324 /* Disable digital (SPDIF) pins */
6325 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6326 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006327
Kailang Yangea1fb292008-08-26 12:58:38 +02006328 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006329 * when acting as an output.
6330 */
6331 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6332
6333 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6335 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6336 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6337 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6338 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6339 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6340 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6341 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6342 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006343
Jonathan Woithef7ace402006-02-28 11:46:14 +01006344 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6345 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6346 /* Unmute Line1 pin widget output buffer since it starts as an output.
6347 * If the pin mode is changed by the user the pin mode control will
6348 * take care of enabling the pin's input/output buffers as needed.
6349 * Therefore there's no need to enable the input buffer at this
6350 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006351 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006352 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006353 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006354 * mixer ctrl)
6355 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006356 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006357
Jonathan Woithef7ace402006-02-28 11:46:14 +01006358 /* Mute capture amp left and right */
6359 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006360 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006361 * in (on mic1 pin)
6362 */
6363 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006364
Jonathan Woithef7ace402006-02-28 11:46:14 +01006365 /* Do the same for the second ADC: mute capture input amp and
6366 * set ADC connection to line in (on mic1 pin)
6367 */
6368 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6369 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006370
Jonathan Woithef7ace402006-02-28 11:46:14 +01006371 /* Mute all inputs to mixer widget (even unconnected ones) */
6372 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6373 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6374 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6375 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6376 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6377 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6378 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6379 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006380
6381 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006382};
6383
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006384/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6385 * similar laptops (adapted from Fujitsu init verbs).
6386 */
6387static struct hda_verb alc260_acer_init_verbs[] = {
6388 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6389 * the headphone jack. Turn this on and rely on the standard mute
6390 * methods whenever the user wants to turn these outputs off.
6391 */
6392 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6393 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6394 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6395 /* Internal speaker/Headphone jack is connected to Line-out pin */
6396 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6397 /* Internal microphone/Mic jack is connected to Mic1 pin */
6398 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6399 /* Line In jack is connected to Line1 pin */
6400 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006401 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6402 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006403 /* Ensure all other unused pins are disabled and muted. */
6404 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6405 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006406 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6407 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6408 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6409 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6410 /* Disable digital (SPDIF) pins */
6411 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6412 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6413
Kailang Yangea1fb292008-08-26 12:58:38 +02006414 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006415 * bus when acting as outputs.
6416 */
6417 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6418 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6419
6420 /* Start with output sum widgets muted and their output gains at min */
6421 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6422 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6423 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6424 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6425 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6426 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6427 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6428 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6429 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6430
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006431 /* Unmute Line-out pin widget amp left and right
6432 * (no equiv mixer ctrl)
6433 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006434 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006435 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6436 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006437 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6438 * inputs. If the pin mode is changed by the user the pin mode control
6439 * will take care of enabling the pin's input/output buffers as needed.
6440 * Therefore there's no need to enable the input buffer at this
6441 * stage.
6442 */
6443 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6444 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6445
6446 /* Mute capture amp left and right */
6447 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6448 /* Set ADC connection select to match default mixer setting - mic
6449 * (on mic1 pin)
6450 */
6451 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6452
6453 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006454 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006455 */
6456 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006457 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006458
6459 /* Mute all inputs to mixer widget (even unconnected ones) */
6460 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6461 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6462 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6463 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6464 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6465 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6466 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6467 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6468
6469 { }
6470};
6471
Michael Schwingencc959482009-02-22 18:58:45 +01006472/* Initialisation sequence for Maxdata Favorit 100XS
6473 * (adapted from Acer init verbs).
6474 */
6475static struct hda_verb alc260_favorit100_init_verbs[] = {
6476 /* GPIO 0 enables the output jack.
6477 * Turn this on and rely on the standard mute
6478 * methods whenever the user wants to turn these outputs off.
6479 */
6480 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6481 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6482 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6483 /* Line/Mic input jack is connected to Mic1 pin */
6484 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6485 /* Ensure all other unused pins are disabled and muted. */
6486 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6487 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6488 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6489 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6490 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6491 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6492 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6493 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6494 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6495 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6496 /* Disable digital (SPDIF) pins */
6497 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6498 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6499
6500 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6501 * bus when acting as outputs.
6502 */
6503 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6504 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6505
6506 /* Start with output sum widgets muted and their output gains at min */
6507 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6508 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6509 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6510 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6511 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6512 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6513 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6514 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6515 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6516
6517 /* Unmute Line-out pin widget amp left and right
6518 * (no equiv mixer ctrl)
6519 */
6520 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6521 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6522 * inputs. If the pin mode is changed by the user the pin mode control
6523 * will take care of enabling the pin's input/output buffers as needed.
6524 * Therefore there's no need to enable the input buffer at this
6525 * stage.
6526 */
6527 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6528
6529 /* Mute capture amp left and right */
6530 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6531 /* Set ADC connection select to match default mixer setting - mic
6532 * (on mic1 pin)
6533 */
6534 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6535
6536 /* Do similar with the second ADC: mute capture input amp and
6537 * set ADC connection to mic to match ALSA's default state.
6538 */
6539 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6540 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6541
6542 /* Mute all inputs to mixer widget (even unconnected ones) */
6543 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6544 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6545 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6547 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6548 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6549 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6550 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6551
6552 { }
6553};
6554
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006555static struct hda_verb alc260_will_verbs[] = {
6556 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6557 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6558 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6559 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6560 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6561 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6562 {}
6563};
6564
6565static struct hda_verb alc260_replacer_672v_verbs[] = {
6566 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6567 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6568 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6569
6570 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6571 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6572 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6573
6574 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6575 {}
6576};
6577
6578/* toggle speaker-output according to the hp-jack state */
6579static void alc260_replacer_672v_automute(struct hda_codec *codec)
6580{
6581 unsigned int present;
6582
6583 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006584 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006585 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006586 snd_hda_codec_write_cache(codec, 0x01, 0,
6587 AC_VERB_SET_GPIO_DATA, 1);
6588 snd_hda_codec_write_cache(codec, 0x0f, 0,
6589 AC_VERB_SET_PIN_WIDGET_CONTROL,
6590 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006591 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006592 snd_hda_codec_write_cache(codec, 0x01, 0,
6593 AC_VERB_SET_GPIO_DATA, 0);
6594 snd_hda_codec_write_cache(codec, 0x0f, 0,
6595 AC_VERB_SET_PIN_WIDGET_CONTROL,
6596 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006597 }
6598}
6599
6600static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6601 unsigned int res)
6602{
6603 if ((res >> 26) == ALC880_HP_EVENT)
6604 alc260_replacer_672v_automute(codec);
6605}
6606
Kailang Yang3f878302008-08-26 13:02:23 +02006607static struct hda_verb alc260_hp_dc7600_verbs[] = {
6608 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6609 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6610 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6611 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6612 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6613 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6614 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6615 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6616 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6617 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6618 {}
6619};
6620
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006621/* Test configuration for debugging, modelled after the ALC880 test
6622 * configuration.
6623 */
6624#ifdef CONFIG_SND_DEBUG
6625static hda_nid_t alc260_test_dac_nids[1] = {
6626 0x02,
6627};
6628static hda_nid_t alc260_test_adc_nids[2] = {
6629 0x04, 0x05,
6630};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006631/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006632 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006633 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006634 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006635static struct hda_input_mux alc260_test_capture_sources[2] = {
6636 {
6637 .num_items = 7,
6638 .items = {
6639 { "MIC1 pin", 0x0 },
6640 { "MIC2 pin", 0x1 },
6641 { "LINE1 pin", 0x2 },
6642 { "LINE2 pin", 0x3 },
6643 { "CD pin", 0x4 },
6644 { "LINE-OUT pin", 0x5 },
6645 { "HP-OUT pin", 0x6 },
6646 },
6647 },
6648 {
6649 .num_items = 8,
6650 .items = {
6651 { "MIC1 pin", 0x0 },
6652 { "MIC2 pin", 0x1 },
6653 { "LINE1 pin", 0x2 },
6654 { "LINE2 pin", 0x3 },
6655 { "CD pin", 0x4 },
6656 { "Mixer", 0x5 },
6657 { "LINE-OUT pin", 0x6 },
6658 { "HP-OUT pin", 0x7 },
6659 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006660 },
6661};
6662static struct snd_kcontrol_new alc260_test_mixer[] = {
6663 /* Output driver widgets */
6664 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6665 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6666 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6667 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6668 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6669 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6670
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006671 /* Modes for retasking pin widgets
6672 * Note: the ALC260 doesn't seem to act on requests to enable mic
6673 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6674 * mention this restriction. At this stage it's not clear whether
6675 * this behaviour is intentional or is a hardware bug in chip
6676 * revisions available at least up until early 2006. Therefore for
6677 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6678 * choices, but if it turns out that the lack of mic bias for these
6679 * NIDs is intentional we could change their modes from
6680 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6681 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006682 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6683 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6684 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6685 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6686 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6687 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6688
6689 /* Loopback mixer controls */
6690 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6691 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6692 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6693 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6694 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6695 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6696 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6697 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6698 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6699 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006700 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6701 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6702 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6703 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006704
6705 /* Controls for GPIO pins, assuming they are configured as outputs */
6706 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6707 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6708 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6709 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6710
Jonathan Woithe92621f12006-02-28 11:47:47 +01006711 /* Switches to allow the digital IO pins to be enabled. The datasheet
6712 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006713 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006714 */
6715 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6716 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6717
Jonathan Woithef8225f62008-01-08 12:16:54 +01006718 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6719 * this output to turn on an external amplifier.
6720 */
6721 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6722 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6723
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006724 { } /* end */
6725};
6726static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006727 /* Enable all GPIOs as outputs with an initial value of 0 */
6728 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6729 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6730 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6731
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006732 /* Enable retasking pins as output, initially without power amp */
6733 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6734 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6735 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6736 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6737 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6738 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6739
Jonathan Woithe92621f12006-02-28 11:47:47 +01006740 /* Disable digital (SPDIF) pins initially, but users can enable
6741 * them via a mixer switch. In the case of SPDIF-out, this initverb
6742 * payload also sets the generation to 0, output to be in "consumer"
6743 * PCM format, copyright asserted, no pre-emphasis and no validity
6744 * control.
6745 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006746 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6747 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6748
Kailang Yangea1fb292008-08-26 12:58:38 +02006749 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006750 * OUT1 sum bus when acting as an output.
6751 */
6752 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6753 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6754 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6755 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6756
6757 /* Start with output sum widgets muted and their output gains at min */
6758 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6759 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6760 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6761 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6762 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6763 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6764 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6765 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6766 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6767
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006768 /* Unmute retasking pin widget output buffers since the default
6769 * state appears to be output. As the pin mode is changed by the
6770 * user the pin mode control will take care of enabling the pin's
6771 * input/output buffers as needed.
6772 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006773 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6774 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6775 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6776 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6777 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6778 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6779 /* Also unmute the mono-out pin widget */
6780 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6781
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006782 /* Mute capture amp left and right */
6783 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006784 /* Set ADC connection select to match default mixer setting (mic1
6785 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006786 */
6787 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6788
6789 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006790 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006791 */
6792 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6793 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6794
6795 /* Mute all inputs to mixer widget (even unconnected ones) */
6796 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6797 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6798 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6799 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6800 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6801 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6802 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6803 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6804
6805 { }
6806};
6807#endif
6808
Takashi Iwai63300792008-01-24 15:31:36 +01006809#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6810#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006811
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006812#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6813#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6814
Kailang Yangdf694da2005-12-05 19:42:22 +01006815/*
6816 * for BIOS auto-configuration
6817 */
6818
6819static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006820 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006821{
6822 hda_nid_t nid_vol;
6823 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006824 int err;
6825
6826 if (nid >= 0x0f && nid < 0x11) {
6827 nid_vol = nid - 0x7;
6828 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6829 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6830 } else if (nid == 0x11) {
6831 nid_vol = nid - 0x7;
6832 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6833 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6834 } else if (nid >= 0x12 && nid <= 0x15) {
6835 nid_vol = 0x08;
6836 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6837 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6838 } else
6839 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006840
Takashi Iwai863b4512008-10-21 17:01:47 +02006841 if (!(*vol_bits & (1 << nid_vol))) {
6842 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006843 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006844 if (err < 0)
6845 return err;
6846 *vol_bits |= (1 << nid_vol);
6847 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006848 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006849 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006850 return err;
6851 return 1;
6852}
6853
6854/* add playback controls from the parsed DAC table */
6855static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6856 const struct auto_pin_cfg *cfg)
6857{
6858 hda_nid_t nid;
6859 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006860 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006861
6862 spec->multiout.num_dacs = 1;
6863 spec->multiout.dac_nids = spec->private_dac_nids;
6864 spec->multiout.dac_nids[0] = 0x02;
6865
6866 nid = cfg->line_out_pins[0];
6867 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006868 const char *pfx;
6869 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6870 pfx = "Master";
6871 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6872 pfx = "Speaker";
6873 else
6874 pfx = "Front";
6875 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006876 if (err < 0)
6877 return err;
6878 }
6879
Takashi Iwai82bc9552006-03-21 11:24:42 +01006880 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006881 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006882 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006883 if (err < 0)
6884 return err;
6885 }
6886
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006887 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006888 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006889 err = alc260_add_playback_controls(spec, nid, "Headphone",
6890 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006891 if (err < 0)
6892 return err;
6893 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006894 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006895}
6896
6897/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006898static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006899 const struct auto_pin_cfg *cfg)
6900{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006901 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006902}
6903
6904static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6905 hda_nid_t nid, int pin_type,
6906 int sel_idx)
6907{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006908 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006909 /* need the manual connection? */
6910 if (nid >= 0x12) {
6911 int idx = nid - 0x12;
6912 snd_hda_codec_write(codec, idx + 0x0b, 0,
6913 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006914 }
6915}
6916
6917static void alc260_auto_init_multi_out(struct hda_codec *codec)
6918{
6919 struct alc_spec *spec = codec->spec;
6920 hda_nid_t nid;
6921
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006922 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006923 if (nid) {
6924 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6925 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6926 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006927
Takashi Iwai82bc9552006-03-21 11:24:42 +01006928 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006929 if (nid)
6930 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6931
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006932 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006933 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006934 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006935}
Kailang Yangdf694da2005-12-05 19:42:22 +01006936
6937#define ALC260_PIN_CD_NID 0x16
6938static void alc260_auto_init_analog_input(struct hda_codec *codec)
6939{
6940 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006941 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006942 int i;
6943
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006944 for (i = 0; i < cfg->num_inputs; i++) {
6945 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006946 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006947 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006948 if (nid != ALC260_PIN_CD_NID &&
6949 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006950 snd_hda_codec_write(codec, nid, 0,
6951 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006952 AMP_OUT_MUTE);
6953 }
6954 }
6955}
6956
Takashi Iwai7f311a42010-04-09 17:32:23 +02006957#define alc260_auto_init_input_src alc880_auto_init_input_src
6958
Kailang Yangdf694da2005-12-05 19:42:22 +01006959/*
6960 * generic initialization of ADC, input mixers and output mixers
6961 */
6962static struct hda_verb alc260_volume_init_verbs[] = {
6963 /*
6964 * Unmute ADC0-1 and set the default input to mic-in
6965 */
6966 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6967 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6968 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6969 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006970
Kailang Yangdf694da2005-12-05 19:42:22 +01006971 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
6972 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006973 * Note: PASD motherboards uses the Line In 2 as the input for
6974 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01006975 */
6976 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006977 /* mute analog inputs */
6978 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6979 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6980 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6981 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6982 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006983
6984 /*
6985 * Set up output mixers (0x08 - 0x0a)
6986 */
6987 /* set vol=0 to output mixers */
6988 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6989 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6990 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6991 /* set up input amps for analog loopback */
6992 /* Amp Indices: DAC = 0, mixer = 1 */
6993 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6994 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6995 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6996 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
6997 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6998 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006999
Kailang Yangdf694da2005-12-05 19:42:22 +01007000 { }
7001};
7002
7003static int alc260_parse_auto_config(struct hda_codec *codec)
7004{
7005 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007006 int err;
7007 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7008
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007009 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7010 alc260_ignore);
7011 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007012 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007013 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7014 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007015 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007016 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007017 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007018 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007019 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007020 return err;
7021
7022 spec->multiout.max_channels = 2;
7023
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007024 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007025 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007026 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007027 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007028
Takashi Iwaid88897e2008-10-31 15:01:37 +01007029 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007030
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007031 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007032 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007033
Kailang Yang6227cdc2010-02-25 08:36:52 +01007034 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007035
Kailang Yangdf694da2005-12-05 19:42:22 +01007036 return 1;
7037}
7038
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007039/* additional initialization for auto-configuration model */
7040static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007041{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007042 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007043 alc260_auto_init_multi_out(codec);
7044 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007045 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007046 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007047 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007048 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007049}
7050
Takashi Iwaicb53c622007-08-10 17:21:45 +02007051#ifdef CONFIG_SND_HDA_POWER_SAVE
7052static struct hda_amp_list alc260_loopbacks[] = {
7053 { 0x07, HDA_INPUT, 0 },
7054 { 0x07, HDA_INPUT, 1 },
7055 { 0x07, HDA_INPUT, 2 },
7056 { 0x07, HDA_INPUT, 3 },
7057 { 0x07, HDA_INPUT, 4 },
7058 { } /* end */
7059};
7060#endif
7061
Kailang Yangdf694da2005-12-05 19:42:22 +01007062/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007063 * Pin config fixes
7064 */
7065enum {
7066 PINFIX_HP_DC5750,
7067};
7068
Takashi Iwaifc091762010-08-04 23:53:36 +02007069static const struct alc_fixup alc260_fixups[] = {
7070 [PINFIX_HP_DC5750] = {
Takashi Iwai73413b12010-08-30 09:39:57 +02007071 .pins = (const struct alc_pincfg[]) {
7072 { 0x11, 0x90130110 }, /* speaker */
7073 { }
7074 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007075 },
7076};
7077
7078static struct snd_pci_quirk alc260_fixup_tbl[] = {
7079 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7080 {}
7081};
7082
7083/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007084 * ALC260 configurations
7085 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007086static const char *alc260_models[ALC260_MODEL_LAST] = {
7087 [ALC260_BASIC] = "basic",
7088 [ALC260_HP] = "hp",
7089 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007090 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007091 [ALC260_FUJITSU_S702X] = "fujitsu",
7092 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007093 [ALC260_WILL] = "will",
7094 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007095 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007096#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007097 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007098#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007099 [ALC260_AUTO] = "auto",
7100};
7101
7102static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007103 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007104 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007105 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007106 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007107 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007108 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007109 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007110 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007111 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007112 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7113 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7114 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7115 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7116 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7117 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7118 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7119 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7120 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007121 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007122 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007123 {}
7124};
7125
Kailang Yangdf694da2005-12-05 19:42:22 +01007126static struct alc_config_preset alc260_presets[] = {
7127 [ALC260_BASIC] = {
7128 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007129 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007130 .init_verbs = { alc260_init_verbs },
7131 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7132 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007133 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007134 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007135 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7136 .channel_mode = alc260_modes,
7137 .input_mux = &alc260_capture_source,
7138 },
7139 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007140 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007141 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007142 .init_verbs = { alc260_init_verbs,
7143 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007144 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7145 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007146 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7147 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007148 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7149 .channel_mode = alc260_modes,
7150 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007151 .unsol_event = alc260_hp_unsol_event,
7152 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007153 },
Kailang Yang3f878302008-08-26 13:02:23 +02007154 [ALC260_HP_DC7600] = {
7155 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007156 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007157 .init_verbs = { alc260_init_verbs,
7158 alc260_hp_dc7600_verbs },
7159 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7160 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007161 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7162 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007163 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7164 .channel_mode = alc260_modes,
7165 .input_mux = &alc260_capture_source,
7166 .unsol_event = alc260_hp_3012_unsol_event,
7167 .init_hook = alc260_hp_3012_automute,
7168 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007169 [ALC260_HP_3013] = {
7170 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007171 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007172 .init_verbs = { alc260_hp_3013_init_verbs,
7173 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007174 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7175 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007176 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7177 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007178 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7179 .channel_mode = alc260_modes,
7180 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007181 .unsol_event = alc260_hp_3013_unsol_event,
7182 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007183 },
7184 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007185 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007186 .init_verbs = { alc260_fujitsu_init_verbs },
7187 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7188 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007189 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7190 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007191 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7192 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007193 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7194 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007195 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007196 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007197 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007198 .init_verbs = { alc260_acer_init_verbs },
7199 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7200 .dac_nids = alc260_dac_nids,
7201 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7202 .adc_nids = alc260_dual_adc_nids,
7203 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7204 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007205 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7206 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007207 },
Michael Schwingencc959482009-02-22 18:58:45 +01007208 [ALC260_FAVORIT100] = {
7209 .mixers = { alc260_favorit100_mixer },
7210 .init_verbs = { alc260_favorit100_init_verbs },
7211 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7212 .dac_nids = alc260_dac_nids,
7213 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7214 .adc_nids = alc260_dual_adc_nids,
7215 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7216 .channel_mode = alc260_modes,
7217 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7218 .input_mux = alc260_favorit100_capture_sources,
7219 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007220 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007221 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007222 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7223 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7224 .dac_nids = alc260_dac_nids,
7225 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7226 .adc_nids = alc260_adc_nids,
7227 .dig_out_nid = ALC260_DIGOUT_NID,
7228 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7229 .channel_mode = alc260_modes,
7230 .input_mux = &alc260_capture_source,
7231 },
7232 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007233 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007234 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7235 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7236 .dac_nids = alc260_dac_nids,
7237 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7238 .adc_nids = alc260_adc_nids,
7239 .dig_out_nid = ALC260_DIGOUT_NID,
7240 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7241 .channel_mode = alc260_modes,
7242 .input_mux = &alc260_capture_source,
7243 .unsol_event = alc260_replacer_672v_unsol_event,
7244 .init_hook = alc260_replacer_672v_automute,
7245 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007246#ifdef CONFIG_SND_DEBUG
7247 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007248 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007249 .init_verbs = { alc260_test_init_verbs },
7250 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7251 .dac_nids = alc260_test_dac_nids,
7252 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7253 .adc_nids = alc260_test_adc_nids,
7254 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7255 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007256 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7257 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007258 },
7259#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007260};
7261
Linus Torvalds1da177e2005-04-16 15:20:36 -07007262static int patch_alc260(struct hda_codec *codec)
7263{
7264 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007265 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007266
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007267 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007268 if (spec == NULL)
7269 return -ENOMEM;
7270
7271 codec->spec = spec;
7272
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007273 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7274 alc260_models,
7275 alc260_cfg_tbl);
7276 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007277 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007278 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007279 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007280 }
7281
Takashi Iwaifc091762010-08-04 23:53:36 +02007282 if (board_config == ALC260_AUTO)
7283 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 1);
7284
Kailang Yangdf694da2005-12-05 19:42:22 +01007285 if (board_config == ALC260_AUTO) {
7286 /* automatic parse from the BIOS config */
7287 err = alc260_parse_auto_config(codec);
7288 if (err < 0) {
7289 alc_free(codec);
7290 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007291 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007292 printk(KERN_INFO
7293 "hda_codec: Cannot set up configuration "
7294 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007295 board_config = ALC260_BASIC;
7296 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007297 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007298
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007299 err = snd_hda_attach_beep_device(codec, 0x1);
7300 if (err < 0) {
7301 alc_free(codec);
7302 return err;
7303 }
7304
Kailang Yangdf694da2005-12-05 19:42:22 +01007305 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007306 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007307
Linus Torvalds1da177e2005-04-16 15:20:36 -07007308 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7309 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307310 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007311
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007312 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7313 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7314
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007315 if (!spec->adc_nids && spec->input_mux) {
7316 /* check whether NID 0x04 is valid */
7317 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007318 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007319 /* get type */
7320 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7321 spec->adc_nids = alc260_adc_nids_alt;
7322 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7323 } else {
7324 spec->adc_nids = alc260_adc_nids;
7325 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7326 }
7327 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007328 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007329 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007330
Takashi Iwaifc091762010-08-04 23:53:36 +02007331 if (board_config == ALC260_AUTO)
7332 alc_pick_fixup(codec, alc260_fixup_tbl, alc260_fixups, 0);
7333
Takashi Iwai2134ea42008-01-10 16:53:55 +01007334 spec->vmaster_nid = 0x08;
7335
Linus Torvalds1da177e2005-04-16 15:20:36 -07007336 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007337 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007338 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007339#ifdef CONFIG_SND_HDA_POWER_SAVE
7340 if (!spec->loopback.amplist)
7341 spec->loopback.amplist = alc260_loopbacks;
7342#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007343
7344 return 0;
7345}
7346
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007347
Linus Torvalds1da177e2005-04-16 15:20:36 -07007348/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007349 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007350 *
7351 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7352 * configuration. Each pin widget can choose any input DACs and a mixer.
7353 * Each ADC is connected from a mixer of all inputs. This makes possible
7354 * 6-channel independent captures.
7355 *
7356 * In addition, an independent DAC for the multi-playback (not used in this
7357 * driver yet).
7358 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007359#define ALC882_DIGOUT_NID 0x06
7360#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007361#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7362#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7363#define ALC1200_DIGOUT_NID 0x10
7364
Linus Torvalds1da177e2005-04-16 15:20:36 -07007365
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007366static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007367 { 8, NULL }
7368};
7369
Takashi Iwai4953550a2009-06-30 15:28:30 +02007370/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007371static hda_nid_t alc882_dac_nids[4] = {
7372 /* front, rear, clfe, rear_surr */
7373 0x02, 0x03, 0x04, 0x05
7374};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007375#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007376
Takashi Iwai4953550a2009-06-30 15:28:30 +02007377/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007378#define alc882_adc_nids alc880_adc_nids
7379#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007380#define alc883_adc_nids alc882_adc_nids_alt
7381static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7382static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7383#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007384
Takashi Iwaie1406342008-02-11 18:32:32 +01007385static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7386static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007387#define alc883_capsrc_nids alc882_capsrc_nids_alt
7388static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7389#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007390
Linus Torvalds1da177e2005-04-16 15:20:36 -07007391/* input MUX */
7392/* FIXME: should be a matrix-type input source selection */
7393
7394static struct hda_input_mux alc882_capture_source = {
7395 .num_items = 4,
7396 .items = {
7397 { "Mic", 0x0 },
7398 { "Front Mic", 0x1 },
7399 { "Line", 0x2 },
7400 { "CD", 0x4 },
7401 },
7402};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007403
Takashi Iwai4953550a2009-06-30 15:28:30 +02007404#define alc883_capture_source alc882_capture_source
7405
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007406static struct hda_input_mux alc889_capture_source = {
7407 .num_items = 3,
7408 .items = {
7409 { "Front Mic", 0x0 },
7410 { "Mic", 0x3 },
7411 { "Line", 0x2 },
7412 },
7413};
7414
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007415static struct hda_input_mux mb5_capture_source = {
7416 .num_items = 3,
7417 .items = {
7418 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307419 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007420 { "CD", 0x4 },
7421 },
7422};
7423
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007424static struct hda_input_mux macmini3_capture_source = {
7425 .num_items = 2,
7426 .items = {
7427 { "Line", 0x2 },
7428 { "CD", 0x4 },
7429 },
7430};
7431
Takashi Iwai4953550a2009-06-30 15:28:30 +02007432static struct hda_input_mux alc883_3stack_6ch_intel = {
7433 .num_items = 4,
7434 .items = {
7435 { "Mic", 0x1 },
7436 { "Front Mic", 0x0 },
7437 { "Line", 0x2 },
7438 { "CD", 0x4 },
7439 },
7440};
7441
7442static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7443 .num_items = 2,
7444 .items = {
7445 { "Mic", 0x1 },
7446 { "Line", 0x2 },
7447 },
7448};
7449
7450static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7451 .num_items = 4,
7452 .items = {
7453 { "Mic", 0x0 },
David Henningsson150b4322010-07-29 14:46:42 +02007454 { "Int Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007455 { "Line", 0x2 },
7456 { "CD", 0x4 },
7457 },
7458};
7459
7460static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7461 .num_items = 2,
7462 .items = {
7463 { "Mic", 0x0 },
7464 { "Int Mic", 0x1 },
7465 },
7466};
7467
7468static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7469 .num_items = 3,
7470 .items = {
7471 { "Mic", 0x0 },
7472 { "Front Mic", 0x1 },
7473 { "Line", 0x4 },
7474 },
7475};
7476
7477static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7478 .num_items = 2,
7479 .items = {
7480 { "Mic", 0x0 },
7481 { "Line", 0x2 },
7482 },
7483};
7484
7485static struct hda_input_mux alc889A_mb31_capture_source = {
7486 .num_items = 2,
7487 .items = {
7488 { "Mic", 0x0 },
7489 /* Front Mic (0x01) unused */
7490 { "Line", 0x2 },
7491 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007492 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007493 },
7494};
7495
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007496static struct hda_input_mux alc889A_imac91_capture_source = {
7497 .num_items = 2,
7498 .items = {
7499 { "Mic", 0x01 },
7500 { "Line", 0x2 }, /* Not sure! */
7501 },
7502};
7503
Takashi Iwai4953550a2009-06-30 15:28:30 +02007504/*
7505 * 2ch mode
7506 */
7507static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7508 { 2, NULL }
7509};
7510
Kailang Yangdf694da2005-12-05 19:42:22 +01007511/*
Kailang Yang272a5272007-05-14 11:00:38 +02007512 * 2ch mode
7513 */
7514static struct hda_verb alc882_3ST_ch2_init[] = {
7515 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7516 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7517 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7518 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7519 { } /* end */
7520};
7521
7522/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007523 * 4ch mode
7524 */
7525static struct hda_verb alc882_3ST_ch4_init[] = {
7526 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7527 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7528 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7529 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7530 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7531 { } /* end */
7532};
7533
7534/*
Kailang Yang272a5272007-05-14 11:00:38 +02007535 * 6ch mode
7536 */
7537static struct hda_verb alc882_3ST_ch6_init[] = {
7538 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7539 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7540 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7541 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7542 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7543 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7544 { } /* end */
7545};
7546
Takashi Iwai4953550a2009-06-30 15:28:30 +02007547static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007548 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007549 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007550 { 6, alc882_3ST_ch6_init },
7551};
7552
Takashi Iwai4953550a2009-06-30 15:28:30 +02007553#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7554
Kailang Yang272a5272007-05-14 11:00:38 +02007555/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307556 * 2ch mode
7557 */
7558static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7559 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7560 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7561 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7562 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7563 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7564 { } /* end */
7565};
7566
7567/*
7568 * 4ch mode
7569 */
7570static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7571 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7572 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7573 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7574 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7575 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7576 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7577 { } /* end */
7578};
7579
7580/*
7581 * 6ch mode
7582 */
7583static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7584 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7585 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7586 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7587 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7588 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7589 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7590 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7591 { } /* end */
7592};
7593
7594static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7595 { 2, alc883_3ST_ch2_clevo_init },
7596 { 4, alc883_3ST_ch4_clevo_init },
7597 { 6, alc883_3ST_ch6_clevo_init },
7598};
7599
7600
7601/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007602 * 6ch mode
7603 */
7604static struct hda_verb alc882_sixstack_ch6_init[] = {
7605 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7606 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7607 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7608 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7609 { } /* end */
7610};
7611
7612/*
7613 * 8ch mode
7614 */
7615static struct hda_verb alc882_sixstack_ch8_init[] = {
7616 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7617 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7618 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7619 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7620 { } /* end */
7621};
7622
7623static struct hda_channel_mode alc882_sixstack_modes[2] = {
7624 { 6, alc882_sixstack_ch6_init },
7625 { 8, alc882_sixstack_ch8_init },
7626};
7627
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007628
7629/* Macbook Air 2,1 */
7630
7631static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7632 { 2, NULL },
7633};
7634
Takashi Iwai87350ad2007-08-16 18:19:38 +02007635/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007636 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007637 */
7638
7639/*
7640 * 2ch mode
7641 */
7642static struct hda_verb alc885_mbp_ch2_init[] = {
7643 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7644 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7645 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7646 { } /* end */
7647};
7648
7649/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007650 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007651 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007652static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007653 { 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 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7657 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7658 { } /* end */
7659};
7660
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007661static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007662 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007663 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007664};
7665
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007666/*
7667 * 2ch
7668 * Speakers/Woofer/HP = Front
7669 * LineIn = Input
7670 */
7671static struct hda_verb alc885_mb5_ch2_init[] = {
7672 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7674 { } /* end */
7675};
7676
7677/*
7678 * 6ch mode
7679 * Speakers/HP = Front
7680 * Woofer = LFE
7681 * LineIn = Surround
7682 */
7683static struct hda_verb alc885_mb5_ch6_init[] = {
7684 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7685 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7686 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7687 { } /* end */
7688};
7689
7690static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7691 { 2, alc885_mb5_ch2_init },
7692 { 6, alc885_mb5_ch6_init },
7693};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007694
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007695#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007696
7697/*
7698 * 2ch mode
7699 */
7700static struct hda_verb alc883_4ST_ch2_init[] = {
7701 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7702 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7703 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7704 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7705 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7706 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7707 { } /* end */
7708};
7709
7710/*
7711 * 4ch mode
7712 */
7713static struct hda_verb alc883_4ST_ch4_init[] = {
7714 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7715 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7716 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7717 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7718 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7719 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7720 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7721 { } /* end */
7722};
7723
7724/*
7725 * 6ch mode
7726 */
7727static struct hda_verb alc883_4ST_ch6_init[] = {
7728 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7729 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7730 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7731 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7732 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7733 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7734 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7735 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7736 { } /* end */
7737};
7738
7739/*
7740 * 8ch mode
7741 */
7742static struct hda_verb alc883_4ST_ch8_init[] = {
7743 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7744 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7745 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7746 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7747 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7748 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7749 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7750 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7751 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7752 { } /* end */
7753};
7754
7755static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7756 { 2, alc883_4ST_ch2_init },
7757 { 4, alc883_4ST_ch4_init },
7758 { 6, alc883_4ST_ch6_init },
7759 { 8, alc883_4ST_ch8_init },
7760};
7761
7762
7763/*
7764 * 2ch mode
7765 */
7766static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7767 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7768 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7769 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7770 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7771 { } /* end */
7772};
7773
7774/*
7775 * 4ch mode
7776 */
7777static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7778 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7779 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7780 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7781 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7782 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7783 { } /* end */
7784};
7785
7786/*
7787 * 6ch mode
7788 */
7789static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7790 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7791 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7792 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7793 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7794 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7795 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7796 { } /* end */
7797};
7798
7799static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7800 { 2, alc883_3ST_ch2_intel_init },
7801 { 4, alc883_3ST_ch4_intel_init },
7802 { 6, alc883_3ST_ch6_intel_init },
7803};
7804
7805/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007806 * 2ch mode
7807 */
7808static struct hda_verb alc889_ch2_intel_init[] = {
7809 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7810 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7811 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7812 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7813 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7814 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7815 { } /* end */
7816};
7817
7818/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007819 * 6ch mode
7820 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007821static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007822 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7823 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7824 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7825 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7826 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007827 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7828 { } /* end */
7829};
7830
7831/*
7832 * 8ch mode
7833 */
7834static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007835 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7836 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7837 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7838 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7839 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007840 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7841 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007842 { } /* end */
7843};
7844
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007845static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7846 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007847 { 6, alc889_ch6_intel_init },
7848 { 8, alc889_ch8_intel_init },
7849};
7850
7851/*
7852 * 6ch mode
7853 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007854static struct hda_verb alc883_sixstack_ch6_init[] = {
7855 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7856 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7857 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7858 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7859 { } /* end */
7860};
7861
7862/*
7863 * 8ch mode
7864 */
7865static struct hda_verb alc883_sixstack_ch8_init[] = {
7866 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7867 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7868 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7869 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7870 { } /* end */
7871};
7872
7873static struct hda_channel_mode alc883_sixstack_modes[2] = {
7874 { 6, alc883_sixstack_ch6_init },
7875 { 8, alc883_sixstack_ch8_init },
7876};
7877
7878
Linus Torvalds1da177e2005-04-16 15:20:36 -07007879/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7880 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7881 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007882static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007883 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007884 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007885 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007886 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007887 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7888 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007889 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7890 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007891 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007892 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007893 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7894 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7895 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7896 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7897 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7898 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007899 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007900 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7901 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01007902 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007903 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007904 { } /* end */
7905};
7906
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007907/* Macbook Air 2,1 same control for HP and internal Speaker */
7908
7909static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7910 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7911 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7912 { }
7913};
7914
7915
Takashi Iwai87350ad2007-08-16 18:19:38 +02007916static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007917 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7918 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7919 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7920 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7921 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007922 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7923 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007924 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7925 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007926 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007927 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
7928 { } /* end */
7929};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007930
7931static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007932 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7933 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7934 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7935 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7936 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7937 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307938 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7939 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307940 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7941 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007942 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7943 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
7944 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7945 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0x00, HDA_INPUT),
7946 { } /* end */
7947};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007948
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007949static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7950 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7951 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7952 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7953 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7954 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7955 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7956 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7957 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7958 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7959 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
7960 HDA_CODEC_VOLUME("Line Boost", 0x15, 0x00, HDA_INPUT),
7961 { } /* end */
7962};
7963
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007964static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007965 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7966 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007967 { } /* end */
7968};
7969
7970
Kailang Yangbdd148a2007-05-08 15:19:08 +02007971static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
7972 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7973 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7974 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7975 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7976 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7977 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7978 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7979 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
7980 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02007981 { } /* end */
7982};
7983
Kailang Yang272a5272007-05-14 11:00:38 +02007984static struct snd_kcontrol_new alc882_targa_mixer[] = {
7985 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
7986 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
7987 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7988 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7989 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7991 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7992 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
7993 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007994 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007995 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
7996 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02007997 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02007998 { } /* end */
7999};
8000
8001/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8002 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8003 */
8004static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8006 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8007 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8008 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8009 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8010 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8011 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8012 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8013 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8014 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8015 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8016 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai96fe7cc82007-09-07 10:57:44 +02008017 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008018 { } /* end */
8019};
8020
Takashi Iwai914759b2007-09-06 14:52:04 +02008021static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8022 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8023 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8024 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8025 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8026 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8027 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8028 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8029 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8030 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8031 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008032 { } /* end */
8033};
8034
Kailang Yangdf694da2005-12-05 19:42:22 +01008035static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8036 {
8037 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8038 .name = "Channel Mode",
8039 .info = alc_ch_mode_info,
8040 .get = alc_ch_mode_get,
8041 .put = alc_ch_mode_put,
8042 },
8043 { } /* end */
8044};
8045
Takashi Iwai4953550a2009-06-30 15:28:30 +02008046static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008047 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008048 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8049 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008050 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008051 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8052 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008053 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008054 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8055 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008056 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008057 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8058 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008059
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008060 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008061 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008062 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008063 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008064 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008065 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008066 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008067 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008068 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008069 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008070 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008071 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008072 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008073 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008074 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008075 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008076 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008077 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008078 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8079 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008080 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008081 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8082 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008083 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008084 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8085 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8086 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8087 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8088 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008089 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008090 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008091
8092 /* FIXME: use matrix-type input source selection */
8093 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008094 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008095 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008096 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008097 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008098 /* ADC2: mute amp left and right */
8099 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008100 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008101 /* ADC3: mute amp left and right */
8102 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008103 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008104
8105 { }
8106};
8107
Takashi Iwai4953550a2009-06-30 15:28:30 +02008108static struct hda_verb alc882_adc1_init_verbs[] = {
8109 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8110 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8111 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8112 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8113 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8114 /* ADC1: mute amp left and right */
8115 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8116 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8117 { }
8118};
8119
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008120static struct hda_verb alc882_eapd_verbs[] = {
8121 /* change to EAPD mode */
8122 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008123 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008124 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008125};
8126
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008127static struct hda_verb alc889_eapd_verbs[] = {
8128 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8129 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8130 { }
8131};
8132
Wu Fengguang6732bd02009-07-30 09:19:14 +02008133static struct hda_verb alc_hp15_unsol_verbs[] = {
8134 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8135 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8136 {}
8137};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008138
8139static struct hda_verb alc885_init_verbs[] = {
8140 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008141 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8142 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008143 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008144 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8145 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008146 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008147 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8148 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008149 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008150 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8151 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008152
8153 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008154 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008155 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8156 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8157 /* Front Pin: output 0 (0x0c) */
8158 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8159 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8160 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8161 /* Rear Pin: output 1 (0x0d) */
8162 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8163 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8164 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8165 /* CLFE Pin: output 2 (0x0e) */
8166 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8167 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8168 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8169 /* Side Pin: output 3 (0x0f) */
8170 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8171 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8172 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8173 /* Mic (rear) pin: input vref at 80% */
8174 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8175 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8176 /* Front Mic pin: input vref at 80% */
8177 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8178 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8179 /* Line In pin: input */
8180 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8181 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8182
8183 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8184 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008185 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008186 /* Input mixer2 */
8187 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008188 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008189 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008190 /* ADC2: mute amp left and right */
8191 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8192 /* ADC3: mute amp left and right */
8193 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8194
8195 { }
8196};
8197
8198static struct hda_verb alc885_init_input_verbs[] = {
8199 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8200 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8201 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8202 { }
8203};
8204
8205
8206/* Unmute Selector 24h and set the default input to front mic */
8207static struct hda_verb alc889_init_input_verbs[] = {
8208 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8209 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8210 { }
8211};
8212
8213
Takashi Iwai4953550a2009-06-30 15:28:30 +02008214#define alc883_init_verbs alc882_base_init_verbs
8215
Tobin Davis9102cd12006-12-15 10:02:12 +01008216/* Mac Pro test */
8217static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8218 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8219 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8220 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8221 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8222 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008223 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008224 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8225 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008226 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008227 { } /* end */
8228};
8229
8230static struct hda_verb alc882_macpro_init_verbs[] = {
8231 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8232 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8233 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8234 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8235 /* Front Pin: output 0 (0x0c) */
8236 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8237 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8238 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8239 /* Front Mic pin: input vref at 80% */
8240 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8241 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8242 /* Speaker: output */
8243 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8244 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8245 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8246 /* Headphone output (output 0 - 0x0c) */
8247 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8248 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8249 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8250
8251 /* FIXME: use matrix-type input source selection */
8252 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8253 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8254 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8255 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8256 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8257 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8258 /* Input mixer2 */
8259 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8260 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8261 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8262 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8263 /* Input mixer3 */
8264 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8265 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8266 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8267 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8268 /* ADC1: mute amp left and right */
8269 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8270 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8271 /* ADC2: mute amp left and right */
8272 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8273 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8274 /* ADC3: mute amp left and right */
8275 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8276 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8277
8278 { }
8279};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008280
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008281/* Macbook 5,1 */
8282static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008283 /* DACs */
8284 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8285 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8286 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8287 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008288 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8290 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8291 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008292 /* Surround mixer */
8293 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8294 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8295 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8296 /* LFE mixer */
8297 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8300 /* HP mixer */
8301 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8302 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8303 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8304 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008305 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008307 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8308 /* LFE Pin (0x0e) */
8309 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8310 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8311 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8312 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8314 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008315 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308316 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008317 /* Front Mic pin: input vref at 80% */
8318 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8319 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8320 /* Line In pin */
8321 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8322 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8323
Alex Murrayb8f171e2010-06-14 12:08:43 +09308324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8326 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008327 { }
8328};
8329
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008330/* Macmini 3,1 */
8331static struct hda_verb alc885_macmini3_init_verbs[] = {
8332 /* DACs */
8333 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8334 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8335 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8336 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8337 /* Front mixer */
8338 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8339 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8340 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8341 /* Surround mixer */
8342 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8343 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8344 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8345 /* LFE mixer */
8346 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8349 /* HP mixer */
8350 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8351 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8353 /* Front Pin (0x0c) */
8354 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8355 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8356 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8357 /* LFE Pin (0x0e) */
8358 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8359 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8360 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8361 /* HP Pin (0x0f) */
8362 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8363 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8364 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8365 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8366 /* Line In pin */
8367 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8368 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8369
8370 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8371 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8372 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8373 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8374 { }
8375};
8376
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008377
8378static struct hda_verb alc885_mba21_init_verbs[] = {
8379 /*Internal and HP Speaker Mixer*/
8380 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8381 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8382 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8383 /*Internal Speaker Pin (0x0c)*/
8384 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8385 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8386 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8387 /* HP Pin: output 0 (0x0e) */
8388 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8389 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8390 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8391 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8392 /* Line in (is hp when jack connected)*/
8393 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8394 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8395
8396 { }
8397 };
8398
8399
Takashi Iwai87350ad2007-08-16 18:19:38 +02008400/* Macbook Pro rev3 */
8401static struct hda_verb alc885_mbp3_init_verbs[] = {
8402 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8403 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8404 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8405 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8406 /* Rear mixer */
8407 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8408 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8409 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008410 /* HP mixer */
8411 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8412 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8413 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008414 /* Front Pin: output 0 (0x0c) */
8415 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8416 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8417 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008418 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008419 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008420 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8421 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008422 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8423 /* Mic (rear) pin: input vref at 80% */
8424 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8425 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8426 /* Front Mic pin: input vref at 80% */
8427 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8428 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8429 /* Line In pin: use output 1 when in LineOut mode */
8430 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8431 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8432 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8433
8434 /* FIXME: use matrix-type input source selection */
8435 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8436 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8437 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8438 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8439 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8440 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8441 /* Input mixer2 */
8442 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8443 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8444 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8445 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8446 /* Input mixer3 */
8447 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8448 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8449 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8450 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8451 /* ADC1: mute amp left and right */
8452 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8453 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8454 /* ADC2: mute amp left and right */
8455 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8456 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8457 /* ADC3: mute amp left and right */
8458 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8459 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8460
8461 { }
8462};
8463
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008464/* iMac 9,1 */
8465static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008466 /* Internal Speaker Pin (0x0c) */
8467 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8468 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8469 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8470 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8471 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8472 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8473 /* HP Pin: Rear */
8474 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8476 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8477 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8478 /* Line in Rear */
8479 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8480 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8481 /* Front Mic pin: input vref at 80% */
8482 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8483 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008484 /* Rear mixer */
8485 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8486 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8487 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008488 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8489 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8492 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008493 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8494 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8495 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8496 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008497 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008498 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8499 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8500 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8501 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008502 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008503 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8504 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8505 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8506 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008507 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008508 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8509 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008510 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008511 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8512 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008513 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008514 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8515 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008516 { }
8517};
8518
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008519/* iMac 24 mixer. */
8520static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8521 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8522 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8523 { } /* end */
8524};
8525
8526/* iMac 24 init verbs. */
8527static struct hda_verb alc885_imac24_init_verbs[] = {
8528 /* Internal speakers: output 0 (0x0c) */
8529 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8530 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8531 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8532 /* Internal speakers: output 0 (0x0c) */
8533 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8534 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8535 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8536 /* Headphone: output 0 (0x0c) */
8537 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8538 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8539 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8540 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8541 /* Front Mic: input vref at 80% */
8542 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8543 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8544 { }
8545};
8546
8547/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008548static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008549{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008550 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008551
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008552 spec->autocfg.hp_pins[0] = 0x14;
8553 spec->autocfg.speaker_pins[0] = 0x18;
8554 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008555}
8556
Takashi Iwai9d54f082010-02-22 08:34:40 +01008557#define alc885_mb5_setup alc885_imac24_setup
8558#define alc885_macmini3_setup alc885_imac24_setup
8559
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008560/* Macbook Air 2,1 */
8561static void alc885_mba21_setup(struct hda_codec *codec)
8562{
8563 struct alc_spec *spec = codec->spec;
8564
8565 spec->autocfg.hp_pins[0] = 0x14;
8566 spec->autocfg.speaker_pins[0] = 0x18;
8567}
8568
8569
8570
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008571static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008572{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008573 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008574
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008575 spec->autocfg.hp_pins[0] = 0x15;
8576 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008577}
8578
Takashi Iwai9d54f082010-02-22 08:34:40 +01008579static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308580{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008581 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308582
Takashi Iwai9d54f082010-02-22 08:34:40 +01008583 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008584 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008585 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008586}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008587
Kailang Yang272a5272007-05-14 11:00:38 +02008588static struct hda_verb alc882_targa_verbs[] = {
8589 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8590 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8591
8592 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8593 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008594
Kailang Yang272a5272007-05-14 11:00:38 +02008595 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8596 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8597 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8598
8599 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008600 { } /* end */
8601};
8602
8603/* toggle speaker-output according to the hp-jack state */
8604static void alc882_targa_automute(struct hda_codec *codec)
8605{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008606 struct alc_spec *spec = codec->spec;
8607 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008608 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008609 spec->jack_present ? 1 : 3);
8610}
8611
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008612static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008613{
8614 struct alc_spec *spec = codec->spec;
8615
8616 spec->autocfg.hp_pins[0] = 0x14;
8617 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008618}
8619
8620static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8621{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008622 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008623 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008624}
8625
8626static struct hda_verb alc882_asus_a7j_verbs[] = {
8627 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8628 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8629
8630 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8631 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8632 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008633
Kailang Yang272a5272007-05-14 11:00:38 +02008634 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8635 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8636 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8637
8638 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8639 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8640 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8641 { } /* end */
8642};
8643
Takashi Iwai914759b2007-09-06 14:52:04 +02008644static struct hda_verb alc882_asus_a7m_verbs[] = {
8645 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8646 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8647
8648 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8649 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8650 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008651
Takashi Iwai914759b2007-09-06 14:52:04 +02008652 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8653 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8654 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8655
8656 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8657 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8658 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8659 { } /* end */
8660};
8661
Tobin Davis9102cd12006-12-15 10:02:12 +01008662static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8663{
8664 unsigned int gpiostate, gpiomask, gpiodir;
8665
8666 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8667 AC_VERB_GET_GPIO_DATA, 0);
8668
8669 if (!muted)
8670 gpiostate |= (1 << pin);
8671 else
8672 gpiostate &= ~(1 << pin);
8673
8674 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8675 AC_VERB_GET_GPIO_MASK, 0);
8676 gpiomask |= (1 << pin);
8677
8678 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8679 AC_VERB_GET_GPIO_DIRECTION, 0);
8680 gpiodir |= (1 << pin);
8681
8682
8683 snd_hda_codec_write(codec, codec->afg, 0,
8684 AC_VERB_SET_GPIO_MASK, gpiomask);
8685 snd_hda_codec_write(codec, codec->afg, 0,
8686 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8687
8688 msleep(1);
8689
8690 snd_hda_codec_write(codec, codec->afg, 0,
8691 AC_VERB_SET_GPIO_DATA, gpiostate);
8692}
8693
Takashi Iwai7debbe52007-08-16 15:01:03 +02008694/* set up GPIO at initialization */
8695static void alc885_macpro_init_hook(struct hda_codec *codec)
8696{
8697 alc882_gpio_mute(codec, 0, 0);
8698 alc882_gpio_mute(codec, 1, 0);
8699}
8700
8701/* set up GPIO and update auto-muting at initialization */
8702static void alc885_imac24_init_hook(struct hda_codec *codec)
8703{
8704 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008705 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008706}
8707
Kailang Yangdf694da2005-12-05 19:42:22 +01008708/*
8709 * generic initialization of ADC, input mixers and output mixers
8710 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008711static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008712 /*
8713 * Unmute ADC0-2 and set the default input to mic-in
8714 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008715 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8716 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8717 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8718 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8719
Kailang Yangdf694da2005-12-05 19:42:22 +01008720 /*
8721 * Set up output mixers (0x0c - 0x0f)
8722 */
8723 /* set vol=0 to output mixers */
8724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8726 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8727 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8728 /* set up input amps for analog loopback */
8729 /* Amp Indices: DAC = 0, mixer = 1 */
8730 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8731 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8732 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8733 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8734 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8735 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8736 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8737 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8738 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8739 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8740
8741 /* FIXME: use matrix-type input source selection */
8742 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008743 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008744 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008745 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008746 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008747 { }
8748};
8749
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008750/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8751static struct hda_verb alc889A_mb31_ch2_init[] = {
8752 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8753 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8754 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8755 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8756 { } /* end */
8757};
8758
8759/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8760static struct hda_verb alc889A_mb31_ch4_init[] = {
8761 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8762 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8763 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8764 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8765 { } /* end */
8766};
8767
8768/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8769static struct hda_verb alc889A_mb31_ch5_init[] = {
8770 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8771 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8772 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8773 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8774 { } /* end */
8775};
8776
8777/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8778static struct hda_verb alc889A_mb31_ch6_init[] = {
8779 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8780 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8781 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8782 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8783 { } /* end */
8784};
8785
8786static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8787 { 2, alc889A_mb31_ch2_init },
8788 { 4, alc889A_mb31_ch4_init },
8789 { 5, alc889A_mb31_ch5_init },
8790 { 6, alc889A_mb31_ch6_init },
8791};
8792
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008793static struct hda_verb alc883_medion_eapd_verbs[] = {
8794 /* eanable EAPD on medion laptop */
8795 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8796 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8797 { }
8798};
8799
Takashi Iwai4953550a2009-06-30 15:28:30 +02008800#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008801
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008802static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8803 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8804 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8805 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8806 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8807 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8808 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8809 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8810 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8811 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8812 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8813 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8814 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
8815 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008816 { } /* end */
8817};
8818
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008819static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008820 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8821 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8822 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8823 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8825 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8827 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8828 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8829 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008830 { } /* end */
8831};
8832
Jiang zhefb97dc62008-03-06 11:07:11 +01008833static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8834 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8835 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8836 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8837 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8838 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8839 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
8840 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8841 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8842 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8843 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008844 { } /* end */
8845};
8846
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008847static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8848 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8849 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8850 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8851 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8852 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8853 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8854 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8855 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008856 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008857 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8858 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008859 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008860 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008861 { } /* end */
8862};
8863
8864static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8865 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8866 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8867 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8868 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8869 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8870 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8871 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8872 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8873 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8874 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8875 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8876 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8877 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8878 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008879 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008880 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8881 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008882 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008883 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008884 { } /* end */
8885};
8886
Jiang zhe17bba1b2008-06-04 12:11:07 +02008887static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8888 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8889 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8890 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8891 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8892 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8893 HDA_OUTPUT),
8894 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8895 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8896 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8897 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8898 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8899 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8900 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8901 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8902 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8903 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
8904 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8905 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8906 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8907 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008908 { } /* end */
8909};
8910
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008911static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8912 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8913 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8914 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8915 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8916 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8917 HDA_OUTPUT),
8918 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8919 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8920 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8921 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8922 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8923 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8924 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8925 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8926 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
8927 HDA_CODEC_VOLUME("Mic Boost", 0x1b, 0, HDA_INPUT),
8928 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8929 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8930 HDA_CODEC_VOLUME("Front Mic Boost", 0x18, 0, HDA_INPUT),
8931 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8932 { } /* end */
8933};
8934
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008935static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008936 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008937 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008938 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008939 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008940 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8941 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008942 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8943 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008944 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8945 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8946 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8947 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8948 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8949 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008950 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008951 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8952 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008953 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008954 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008955 { } /* end */
8956};
8957
Sasha Alexandrc2592492009-06-16 14:52:54 -04008958static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008959 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008960 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008961 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008962 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008963 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8964 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8965 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8966 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8967 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8968 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8969 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8970 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8971 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8972 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8973 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008974 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008975 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008976 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008977};
Kailang Yangccc656c2006-10-17 12:32:26 +02008978
Sasha Alexandrc2592492009-06-16 14:52:54 -04008979static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008980 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008981 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008982 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008983 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008984 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8985 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8986 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
Thomas De Schampheleire32360412007-01-24 16:13:35 +01008987 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008988 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe4383fae2008-04-14 12:58:57 +02008989 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8990 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
8991 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008992 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008993};
Kailang Yangccc656c2006-10-17 12:32:26 +02008994
Takashi Iwaib99dba32009-09-17 18:23:00 +02008995static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
8996 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8997 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
8998 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8999 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
9000 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9001 { } /* end */
9002};
9003
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009004static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9005 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9006 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009007 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9008 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009009 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9011 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009013 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009014};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009015
Kailang Yang272a5272007-05-14 11:00:38 +02009016static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9017 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9018 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9022 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9023 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson150b4322010-07-29 14:46:42 +02009024 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9025 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009026 { } /* end */
9027};
9028
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009029static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9030 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9031 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9032 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9033 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9034 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9035 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9036 { } /* end */
9037};
9038
9039static struct hda_verb alc883_medion_wim2160_verbs[] = {
9040 /* Unmute front mixer */
9041 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9042 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9043
9044 /* Set speaker pin to front mixer */
9045 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9046
9047 /* Init headphone pin */
9048 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9049 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9050 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9051 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9052
9053 { } /* end */
9054};
9055
9056/* toggle speaker-output according to the hp-jack state */
9057static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9058{
9059 struct alc_spec *spec = codec->spec;
9060
9061 spec->autocfg.hp_pins[0] = 0x1a;
9062 spec->autocfg.speaker_pins[0] = 0x15;
9063}
9064
Tobin Davis2880a862007-08-07 11:50:26 +02009065static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009066 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9067 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009068 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009069 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9070 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009071 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9072 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9073 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009074 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009075};
Tobin Davis2880a862007-08-07 11:50:26 +02009076
Tony Vroond2fd4b02009-06-21 00:40:10 +01009077static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9078 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009079 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009080 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9081 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009082 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9083 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9084 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9085 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9086 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9087 { } /* end */
9088};
9089
Kailang Yange2757d52008-08-26 13:17:46 +02009090static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9091 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9092 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9093 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9094 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9095 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9096 0x0d, 1, 0x0, HDA_OUTPUT),
9097 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9098 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9099 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9100 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9101 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009102 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9103 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9104 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9105 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9106 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9107 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9108 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9109 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9110 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
9111 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009112 { } /* end */
9113};
9114
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009115static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9116 /* Output mixers */
9117 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9118 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9119 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9120 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9121 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9122 HDA_OUTPUT),
9123 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9124 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9125 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9126 /* Output switches */
9127 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9128 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9129 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9130 /* Boost mixers */
9131 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
9132 HDA_CODEC_VOLUME("Line Boost", 0x1a, 0x00, HDA_INPUT),
9133 /* Input mixers */
9134 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9135 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9136 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9137 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9138 { } /* end */
9139};
9140
Guido Günther3e1647c2009-06-05 00:47:26 +02009141static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9142 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9143 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9144 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9145 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9146 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
9147 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9148 { } /* end */
9149};
9150
Kailang Yange2757d52008-08-26 13:17:46 +02009151static struct hda_bind_ctls alc883_bind_cap_vol = {
9152 .ops = &snd_hda_bind_vol,
9153 .values = {
9154 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9155 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9156 0
9157 },
9158};
9159
9160static struct hda_bind_ctls alc883_bind_cap_switch = {
9161 .ops = &snd_hda_bind_sw,
9162 .values = {
9163 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9164 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9165 0
9166 },
9167};
9168
9169static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9170 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9171 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9172 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9173 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9174 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9175 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9176 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
9177 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009178 { } /* end */
9179};
9180
9181static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009182 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9183 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9184 {
9185 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9186 /* .name = "Capture Source", */
9187 .name = "Input Source",
9188 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009189 .info = alc_mux_enum_info,
9190 .get = alc_mux_enum_get,
9191 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009192 },
9193 { } /* end */
9194};
9195
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009196static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9197 {
9198 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9199 .name = "Channel Mode",
9200 .info = alc_ch_mode_info,
9201 .get = alc_ch_mode_get,
9202 .put = alc_ch_mode_put,
9203 },
9204 { } /* end */
9205};
9206
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009207/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009208static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009209{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009210 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009211
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009212 spec->autocfg.hp_pins[0] = 0x15;
9213 spec->autocfg.speaker_pins[0] = 0x14;
9214 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009215}
9216
9217/* auto-toggle front mic */
9218/*
9219static void alc883_mitac_mic_automute(struct hda_codec *codec)
9220{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009221 unsigned char bits = snd_hda_jack_detect(codec, 0x18) ? HDA_AMP_MUTE : 0;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009222
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009223 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
9224}
9225*/
9226
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009227static struct hda_verb alc883_mitac_verbs[] = {
9228 /* HP */
9229 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9230 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9231 /* Subwoofer */
9232 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9233 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9234
9235 /* enable unsolicited event */
9236 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9237 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9238
9239 { } /* end */
9240};
9241
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309242static struct hda_verb alc883_clevo_m540r_verbs[] = {
9243 /* HP */
9244 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9245 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9246 /* Int speaker */
9247 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9248
9249 /* enable unsolicited event */
9250 /*
9251 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9252 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9253 */
9254
9255 { } /* end */
9256};
9257
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009258static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009259 /* HP */
9260 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9261 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9262 /* Int speaker */
9263 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9264 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9265
9266 /* enable unsolicited event */
9267 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009268 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009269
9270 { } /* end */
9271};
9272
Jiang zhefb97dc62008-03-06 11:07:11 +01009273static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9274 /* HP */
9275 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9276 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9277 /* Subwoofer */
9278 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9279 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9280
9281 /* enable unsolicited event */
9282 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9283
9284 { } /* end */
9285};
9286
Sasha Alexandrc2592492009-06-16 14:52:54 -04009287static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009288 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9289 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9290
9291 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9292 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009293
David Heidelberger64a8be72009-06-08 16:15:18 +02009294/* Connect Line-Out side jack (SPDIF) to Side */
9295 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9296 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9297 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9298/* Connect Mic jack to CLFE */
9299 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9300 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9301 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9302/* Connect Line-in jack to Surround */
9303 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9304 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9305 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9306/* Connect HP out jack to Front */
9307 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9308 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9309 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009310
9311 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009312
9313 { } /* end */
9314};
9315
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009316static struct hda_verb alc883_lenovo_101e_verbs[] = {
9317 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9318 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9319 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9320 { } /* end */
9321};
9322
Kailang Yang272a5272007-05-14 11:00:38 +02009323static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9324 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9325 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9326 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9327 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9328 { } /* end */
9329};
9330
9331static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
9332 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9333 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9334 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9335 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9336 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9337 { } /* end */
9338};
9339
Kailang Yang189609a2007-08-20 11:31:23 +02009340static struct hda_verb alc883_haier_w66_verbs[] = {
9341 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9342 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9343
9344 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9345
9346 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9347 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9348 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9349 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9350 { } /* end */
9351};
9352
Kailang Yange2757d52008-08-26 13:17:46 +02009353static struct hda_verb alc888_lenovo_sky_verbs[] = {
9354 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9355 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9356 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9357 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9358 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9359 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9360 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9361 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9362 { } /* end */
9363};
9364
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009365static struct hda_verb alc888_6st_dell_verbs[] = {
9366 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9367 { }
9368};
9369
Guido Günther3e1647c2009-06-05 00:47:26 +02009370static struct hda_verb alc883_vaiott_verbs[] = {
9371 /* HP */
9372 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9373 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9374
9375 /* enable unsolicited event */
9376 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9377
9378 { } /* end */
9379};
9380
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009381static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009382{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009383 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009384
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009385 spec->autocfg.hp_pins[0] = 0x1b;
9386 spec->autocfg.speaker_pins[0] = 0x14;
9387 spec->autocfg.speaker_pins[1] = 0x16;
9388 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009389}
9390
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009391static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009392 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009393 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9394 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009395 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009396 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009397};
9398
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009399/*
9400 * 2ch mode
9401 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009402static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009403 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9404 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9405 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9406 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009407 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009408};
9409
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009410/*
9411 * 4ch mode
9412 */
9413static struct hda_verb alc888_3st_hp_4ch_init[] = {
9414 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9415 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9416 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9417 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9418 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9419 { } /* end */
9420};
9421
9422/*
9423 * 6ch mode
9424 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009425static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009426 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9427 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009428 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009429 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9430 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009431 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9432 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009433};
9434
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009435static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009436 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009437 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009438 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009439};
9440
Kailang Yang272a5272007-05-14 11:00:38 +02009441/* toggle front-jack and RCA according to the hp-jack state */
9442static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9443{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009444 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009445
Takashi Iwai47fd8302007-08-10 17:11:07 +02009446 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9447 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9448 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9449 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009450}
9451
9452/* toggle RCA according to the front-jack state */
9453static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9454{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009455 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009456
Takashi Iwai47fd8302007-08-10 17:11:07 +02009457 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9458 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009459}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009460
Kailang Yang272a5272007-05-14 11:00:38 +02009461static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9462 unsigned int res)
9463{
9464 if ((res >> 26) == ALC880_HP_EVENT)
9465 alc888_lenovo_ms7195_front_automute(codec);
9466 if ((res >> 26) == ALC880_FRONT_EVENT)
9467 alc888_lenovo_ms7195_rca_automute(codec);
9468}
9469
Kailang Yang272a5272007-05-14 11:00:38 +02009470/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009471static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009472{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009473 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009474
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009475 spec->autocfg.hp_pins[0] = 0x14;
9476 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009477}
9478
Kailang Yangccc656c2006-10-17 12:32:26 +02009479/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009480#define alc883_targa_init_hook alc882_targa_init_hook
9481#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009482
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009483static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009484{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009485 struct alc_spec *spec = codec->spec;
9486
9487 spec->autocfg.hp_pins[0] = 0x15;
9488 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009489}
9490
9491static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9492{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009493 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009494 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009495}
9496
9497static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009498 unsigned int res)
9499{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009500 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009501 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009502 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009503 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009504 default:
9505 alc_automute_amp_unsol_event(codec, res);
9506 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009507 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009508}
9509
Jiang zhefb97dc62008-03-06 11:07:11 +01009510/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009511static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009512{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009513 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009514
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009515 spec->autocfg.hp_pins[0] = 0x14;
9516 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009517}
9518
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009519static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009520{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009521 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009522
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009523 spec->autocfg.hp_pins[0] = 0x1b;
9524 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009525}
9526
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009527static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9528{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009529 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009530
Takashi Iwai47fd8302007-08-10 17:11:07 +02009531 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9532 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009533}
9534
9535static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9536{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009537 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009538
Takashi Iwai47fd8302007-08-10 17:11:07 +02009539 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9540 HDA_AMP_MUTE, bits);
9541 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9542 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009543}
9544
9545static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9546 unsigned int res)
9547{
9548 if ((res >> 26) == ALC880_HP_EVENT)
9549 alc883_lenovo_101e_all_automute(codec);
9550 if ((res >> 26) == ALC880_FRONT_EVENT)
9551 alc883_lenovo_101e_ispeaker_automute(codec);
9552}
9553
Takashi Iwai676a9b52007-08-16 15:23:35 +02009554/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009555static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009556{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009557 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009558
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009559 spec->autocfg.hp_pins[0] = 0x14;
9560 spec->autocfg.speaker_pins[0] = 0x15;
9561 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009562}
9563
Kailang Yangd1a991a2007-08-15 16:21:59 +02009564static struct hda_verb alc883_acer_eapd_verbs[] = {
9565 /* HP Pin: output 0 (0x0c) */
9566 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9567 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9568 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9569 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009570 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9571 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009572 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009573 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9574 /* eanable EAPD on medion laptop */
9575 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9576 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009577 /* enable unsolicited event */
9578 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009579 { }
9580};
9581
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009582static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009583{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009584 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009585
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009586 spec->autocfg.hp_pins[0] = 0x1b;
9587 spec->autocfg.speaker_pins[0] = 0x14;
9588 spec->autocfg.speaker_pins[1] = 0x15;
9589 spec->autocfg.speaker_pins[2] = 0x16;
9590 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009591}
9592
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009593static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009594{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009595 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009596
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009597 spec->autocfg.hp_pins[0] = 0x1b;
9598 spec->autocfg.speaker_pins[0] = 0x14;
9599 spec->autocfg.speaker_pins[1] = 0x15;
9600 spec->autocfg.speaker_pins[2] = 0x16;
9601 spec->autocfg.speaker_pins[3] = 0x17;
9602 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009603}
9604
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009605static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009606{
9607 struct alc_spec *spec = codec->spec;
9608
9609 spec->autocfg.hp_pins[0] = 0x15;
9610 spec->autocfg.speaker_pins[0] = 0x14;
9611 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009612}
9613
Kailang Yange2757d52008-08-26 13:17:46 +02009614static struct hda_verb alc888_asus_m90v_verbs[] = {
9615 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9616 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9617 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9618 /* enable unsolicited event */
9619 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9620 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9621 { } /* end */
9622};
9623
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009624static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009625{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009626 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009627
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009628 spec->autocfg.hp_pins[0] = 0x1b;
9629 spec->autocfg.speaker_pins[0] = 0x14;
9630 spec->autocfg.speaker_pins[1] = 0x15;
9631 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009632 spec->ext_mic.pin = 0x18;
9633 spec->int_mic.pin = 0x19;
9634 spec->ext_mic.mux_idx = 0;
9635 spec->int_mic.mux_idx = 1;
9636 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009637}
9638
9639static struct hda_verb alc888_asus_eee1601_verbs[] = {
9640 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9641 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9642 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9643 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9644 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9645 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9646 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9647 /* enable unsolicited event */
9648 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9649 { } /* end */
9650};
9651
Kailang Yange2757d52008-08-26 13:17:46 +02009652static void alc883_eee1601_inithook(struct hda_codec *codec)
9653{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009654 struct alc_spec *spec = codec->spec;
9655
9656 spec->autocfg.hp_pins[0] = 0x14;
9657 spec->autocfg.speaker_pins[0] = 0x1b;
9658 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009659}
9660
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009661static struct hda_verb alc889A_mb31_verbs[] = {
9662 /* Init rear pin (used as headphone output) */
9663 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9664 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9665 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9666 /* Init line pin (used as output in 4ch and 6ch mode) */
9667 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9668 /* Init line 2 pin (used as headphone out by default) */
9669 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9670 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9671 { } /* end */
9672};
9673
9674/* Mute speakers according to the headphone jack state */
9675static void alc889A_mb31_automute(struct hda_codec *codec)
9676{
9677 unsigned int present;
9678
9679 /* Mute only in 2ch or 4ch mode */
9680 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9681 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009682 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009683 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9684 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9685 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9686 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9687 }
9688}
9689
9690static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9691{
9692 if ((res >> 26) == ALC880_HP_EVENT)
9693 alc889A_mb31_automute(codec);
9694}
9695
Takashi Iwai4953550a2009-06-30 15:28:30 +02009696
Takashi Iwaicb53c622007-08-10 17:21:45 +02009697#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009698#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009699#endif
9700
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009701/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009702#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9703#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9704#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9705#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9706
9707static hda_nid_t alc883_slave_dig_outs[] = {
9708 ALC1200_DIGOUT_NID, 0,
9709};
9710
9711static hda_nid_t alc1200_slave_dig_outs[] = {
9712 ALC883_DIGOUT_NID, 0,
9713};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009714
9715/*
9716 * configuration and preset
9717 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009718static const char *alc882_models[ALC882_MODEL_LAST] = {
9719 [ALC882_3ST_DIG] = "3stack-dig",
9720 [ALC882_6ST_DIG] = "6stack-dig",
9721 [ALC882_ARIMA] = "arima",
9722 [ALC882_W2JC] = "w2jc",
9723 [ALC882_TARGA] = "targa",
9724 [ALC882_ASUS_A7J] = "asus-a7j",
9725 [ALC882_ASUS_A7M] = "asus-a7m",
9726 [ALC885_MACPRO] = "macpro",
9727 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009728 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009729 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009730 [ALC885_MBP3] = "mbp3",
9731 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009732 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009733 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009734 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9735 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009736 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009737 [ALC883_TARGA_DIG] = "targa-dig",
9738 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009739 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009740 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009741 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009742 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009743 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009744 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009745 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009746 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009747 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009748 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009749 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009750 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9751 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009752 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009753 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009754 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009755 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009756 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309757 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009758 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009759 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009760 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009761 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009762 [ALC889A_INTEL] = "intel-alc889a",
9763 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009764 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009765 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009766 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009767 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009768};
9769
Takashi Iwai4953550a2009-06-30 15:28:30 +02009770static struct snd_pci_quirk alc882_cfg_tbl[] = {
9771 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9772
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009773 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009774 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009775 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009776 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9777 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009778 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009779 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9780 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009781 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009782 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009783 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9784 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009785 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9786 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009787 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9788 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009789 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009790 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009791 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009792 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009793 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9794 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009795 /* default Acer -- disabled as it causes more problems.
9796 * model=auto should work fine now
9797 */
9798 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009799
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009800 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009801
Tobin Davisfebe3372007-06-12 11:27:46 +02009802 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009803 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9804 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009805 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009806 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009807 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009808
9809 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9810 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9811 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009812 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009813 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9814 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9815 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009816 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009817 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009818 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009819 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009820
9821 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009822 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009823 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009824 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009825 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9826 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009827 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009828 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009829 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9830
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009831 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9832 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9833 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009834 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009835 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009836 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009837 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009838 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009839 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9840 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9841 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9842 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9843 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9844 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009845 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009846 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9847 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9848 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009849 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009850 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009851 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9852 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009853 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009854 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009855 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009856 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009857 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009858 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009859 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009860 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009861 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009862
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009863 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009864 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009865 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9866 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309867 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009868 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009869 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009870 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009871 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009872 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009873 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009874 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009875 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009876 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009877 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009878 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9879 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009880 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009881 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009882 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009883 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009884
Jiang zhe17bba1b2008-06-04 12:11:07 +02009885 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9886 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009887 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009888 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9889 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9890 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009891 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009892
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009893 {}
9894};
9895
Takashi Iwai4953550a2009-06-30 15:28:30 +02009896/* codec SSID table for Intel Mac */
9897static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9898 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9899 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9900 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9901 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9902 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9903 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9904 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009905 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009906 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009907 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009908 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009909 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9910 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9911 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009912 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009913 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009914 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009915 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9916 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009917 */
9918 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009919 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009920 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009921 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009922};
9923
Takashi Iwai4953550a2009-06-30 15:28:30 +02009924static struct alc_config_preset alc882_presets[] = {
9925 [ALC882_3ST_DIG] = {
9926 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009927 .init_verbs = { alc882_base_init_verbs,
9928 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009929 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9930 .dac_nids = alc882_dac_nids,
9931 .dig_out_nid = ALC882_DIGOUT_NID,
9932 .dig_in_nid = ALC882_DIGIN_NID,
9933 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9934 .channel_mode = alc882_ch_modes,
9935 .need_dac_fix = 1,
9936 .input_mux = &alc882_capture_source,
9937 },
9938 [ALC882_6ST_DIG] = {
9939 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009940 .init_verbs = { alc882_base_init_verbs,
9941 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009942 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9943 .dac_nids = alc882_dac_nids,
9944 .dig_out_nid = ALC882_DIGOUT_NID,
9945 .dig_in_nid = ALC882_DIGIN_NID,
9946 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9947 .channel_mode = alc882_sixstack_modes,
9948 .input_mux = &alc882_capture_source,
9949 },
9950 [ALC882_ARIMA] = {
9951 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009952 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9953 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009954 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9955 .dac_nids = alc882_dac_nids,
9956 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9957 .channel_mode = alc882_sixstack_modes,
9958 .input_mux = &alc882_capture_source,
9959 },
9960 [ALC882_W2JC] = {
9961 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009962 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9963 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009964 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9965 .dac_nids = alc882_dac_nids,
9966 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9967 .channel_mode = alc880_threestack_modes,
9968 .need_dac_fix = 1,
9969 .input_mux = &alc882_capture_source,
9970 .dig_out_nid = ALC882_DIGOUT_NID,
9971 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009972 [ALC885_MBA21] = {
9973 .mixers = { alc885_mba21_mixer },
9974 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9975 .num_dacs = 2,
9976 .dac_nids = alc882_dac_nids,
9977 .channel_mode = alc885_mba21_ch_modes,
9978 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
9979 .input_mux = &alc882_capture_source,
9980 .unsol_event = alc_automute_amp_unsol_event,
9981 .setup = alc885_mba21_setup,
9982 .init_hook = alc_automute_amp,
9983 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009984 [ALC885_MBP3] = {
9985 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
9986 .init_verbs = { alc885_mbp3_init_verbs,
9987 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009988 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009989 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +02009990 .hp_nid = 0x04,
9991 .channel_mode = alc885_mbp_4ch_modes,
9992 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009993 .input_mux = &alc882_capture_source,
9994 .dig_out_nid = ALC882_DIGOUT_NID,
9995 .dig_in_nid = ALC882_DIGIN_NID,
9996 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009997 .setup = alc885_mbp3_setup,
9998 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +02009999 },
10000 [ALC885_MB5] = {
10001 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10002 .init_verbs = { alc885_mb5_init_verbs,
10003 alc880_gpio1_init_verbs },
10004 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10005 .dac_nids = alc882_dac_nids,
10006 .channel_mode = alc885_mb5_6ch_modes,
10007 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10008 .input_mux = &mb5_capture_source,
10009 .dig_out_nid = ALC882_DIGOUT_NID,
10010 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010011 .unsol_event = alc_automute_amp_unsol_event,
10012 .setup = alc885_mb5_setup,
10013 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010014 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010015 [ALC885_MACMINI3] = {
10016 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10017 .init_verbs = { alc885_macmini3_init_verbs,
10018 alc880_gpio1_init_verbs },
10019 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10020 .dac_nids = alc882_dac_nids,
10021 .channel_mode = alc885_macmini3_6ch_modes,
10022 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10023 .input_mux = &macmini3_capture_source,
10024 .dig_out_nid = ALC882_DIGOUT_NID,
10025 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010026 .unsol_event = alc_automute_amp_unsol_event,
10027 .setup = alc885_macmini3_setup,
10028 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010029 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010030 [ALC885_MACPRO] = {
10031 .mixers = { alc882_macpro_mixer },
10032 .init_verbs = { alc882_macpro_init_verbs },
10033 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10034 .dac_nids = alc882_dac_nids,
10035 .dig_out_nid = ALC882_DIGOUT_NID,
10036 .dig_in_nid = ALC882_DIGIN_NID,
10037 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10038 .channel_mode = alc882_ch_modes,
10039 .input_mux = &alc882_capture_source,
10040 .init_hook = alc885_macpro_init_hook,
10041 },
10042 [ALC885_IMAC24] = {
10043 .mixers = { alc885_imac24_mixer },
10044 .init_verbs = { alc885_imac24_init_verbs },
10045 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10046 .dac_nids = alc882_dac_nids,
10047 .dig_out_nid = ALC882_DIGOUT_NID,
10048 .dig_in_nid = ALC882_DIGIN_NID,
10049 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10050 .channel_mode = alc882_ch_modes,
10051 .input_mux = &alc882_capture_source,
10052 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010053 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010054 .init_hook = alc885_imac24_init_hook,
10055 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010056 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010057 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010058 .init_verbs = { alc885_imac91_init_verbs,
10059 alc880_gpio1_init_verbs },
10060 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10061 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010062 .channel_mode = alc885_mba21_ch_modes,
10063 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10064 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010065 .dig_out_nid = ALC882_DIGOUT_NID,
10066 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010067 .unsol_event = alc_automute_amp_unsol_event,
10068 .setup = alc885_imac91_setup,
10069 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010070 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010071 [ALC882_TARGA] = {
10072 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010073 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010074 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010075 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10076 .dac_nids = alc882_dac_nids,
10077 .dig_out_nid = ALC882_DIGOUT_NID,
10078 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10079 .adc_nids = alc882_adc_nids,
10080 .capsrc_nids = alc882_capsrc_nids,
10081 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10082 .channel_mode = alc882_3ST_6ch_modes,
10083 .need_dac_fix = 1,
10084 .input_mux = &alc882_capture_source,
10085 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010086 .setup = alc882_targa_setup,
10087 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010088 },
10089 [ALC882_ASUS_A7J] = {
10090 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010091 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10092 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010093 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10094 .dac_nids = alc882_dac_nids,
10095 .dig_out_nid = ALC882_DIGOUT_NID,
10096 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10097 .adc_nids = alc882_adc_nids,
10098 .capsrc_nids = alc882_capsrc_nids,
10099 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10100 .channel_mode = alc882_3ST_6ch_modes,
10101 .need_dac_fix = 1,
10102 .input_mux = &alc882_capture_source,
10103 },
10104 [ALC882_ASUS_A7M] = {
10105 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010106 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10107 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010108 alc882_asus_a7m_verbs },
10109 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10110 .dac_nids = alc882_dac_nids,
10111 .dig_out_nid = ALC882_DIGOUT_NID,
10112 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10113 .channel_mode = alc880_threestack_modes,
10114 .need_dac_fix = 1,
10115 .input_mux = &alc882_capture_source,
10116 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010117 [ALC883_3ST_2ch_DIG] = {
10118 .mixers = { alc883_3ST_2ch_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_3ST_2ch_modes),
10125 .channel_mode = alc883_3ST_2ch_modes,
10126 .input_mux = &alc883_capture_source,
10127 },
10128 [ALC883_3ST_6ch_DIG] = {
10129 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10130 .init_verbs = { alc883_init_verbs },
10131 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10132 .dac_nids = alc883_dac_nids,
10133 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010134 .dig_in_nid = ALC883_DIGIN_NID,
10135 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10136 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010137 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010138 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010139 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010140 [ALC883_3ST_6ch] = {
10141 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10142 .init_verbs = { alc883_init_verbs },
10143 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10144 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010145 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10146 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010147 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010148 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010149 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010150 [ALC883_3ST_6ch_INTEL] = {
10151 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10152 .init_verbs = { alc883_init_verbs },
10153 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10154 .dac_nids = alc883_dac_nids,
10155 .dig_out_nid = ALC883_DIGOUT_NID,
10156 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010157 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010158 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10159 .channel_mode = alc883_3ST_6ch_intel_modes,
10160 .need_dac_fix = 1,
10161 .input_mux = &alc883_3stack_6ch_intel,
10162 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010163 [ALC889A_INTEL] = {
10164 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010165 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10166 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010167 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10168 .dac_nids = alc883_dac_nids,
10169 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10170 .adc_nids = alc889_adc_nids,
10171 .dig_out_nid = ALC883_DIGOUT_NID,
10172 .dig_in_nid = ALC883_DIGIN_NID,
10173 .slave_dig_outs = alc883_slave_dig_outs,
10174 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10175 .channel_mode = alc889_8ch_intel_modes,
10176 .capsrc_nids = alc889_capsrc_nids,
10177 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010178 .setup = alc889_automute_setup,
10179 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010180 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010181 .need_dac_fix = 1,
10182 },
10183 [ALC889_INTEL] = {
10184 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10185 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010186 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010187 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10188 .dac_nids = alc883_dac_nids,
10189 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10190 .adc_nids = alc889_adc_nids,
10191 .dig_out_nid = ALC883_DIGOUT_NID,
10192 .dig_in_nid = ALC883_DIGIN_NID,
10193 .slave_dig_outs = alc883_slave_dig_outs,
10194 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10195 .channel_mode = alc889_8ch_intel_modes,
10196 .capsrc_nids = alc889_capsrc_nids,
10197 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010198 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010199 .init_hook = alc889_intel_init_hook,
10200 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010201 .need_dac_fix = 1,
10202 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010203 [ALC883_6ST_DIG] = {
10204 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10205 .init_verbs = { alc883_init_verbs },
10206 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10207 .dac_nids = alc883_dac_nids,
10208 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010209 .dig_in_nid = ALC883_DIGIN_NID,
10210 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10211 .channel_mode = alc883_sixstack_modes,
10212 .input_mux = &alc883_capture_source,
10213 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010214 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010215 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010216 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10217 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010218 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10219 .dac_nids = alc883_dac_nids,
10220 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010221 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10222 .channel_mode = alc883_3ST_6ch_modes,
10223 .need_dac_fix = 1,
10224 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010225 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010226 .setup = alc882_targa_setup,
10227 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010228 },
10229 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010230 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010231 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10232 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010233 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10234 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010235 .adc_nids = alc883_adc_nids_alt,
10236 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010237 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010238 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010239 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10240 .channel_mode = alc883_3ST_2ch_modes,
10241 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010242 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010243 .setup = alc882_targa_setup,
10244 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010245 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010246 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010247 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10248 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010249 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010250 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010251 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10252 .dac_nids = alc883_dac_nids,
10253 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10254 .adc_nids = alc883_adc_nids_rev,
10255 .capsrc_nids = alc883_capsrc_nids_rev,
10256 .dig_out_nid = ALC883_DIGOUT_NID,
10257 .dig_in_nid = ALC883_DIGIN_NID,
10258 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10259 .channel_mode = alc883_4ST_8ch_modes,
10260 .need_dac_fix = 1,
10261 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010262 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010263 .setup = alc882_targa_setup,
10264 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010265 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010266 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010267 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010268 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10269 * and the headphone jack. Turn this on and rely on the
10270 * standard mute methods whenever the user wants to turn
10271 * these outputs off.
10272 */
10273 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10274 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10275 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010276 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10277 .channel_mode = alc883_3ST_2ch_modes,
10278 .input_mux = &alc883_capture_source,
10279 },
Tobin Davis2880a862007-08-07 11:50:26 +020010280 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010281 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010282 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010283 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10284 .dac_nids = alc883_dac_nids,
10285 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010286 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10287 .channel_mode = alc883_3ST_2ch_modes,
10288 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010289 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010290 .setup = alc883_acer_aspire_setup,
10291 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010292 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010293 [ALC888_ACER_ASPIRE_4930G] = {
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010294 .mixers = { alc888_base_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010295 alc883_chmode_mixer },
10296 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10297 alc888_acer_aspire_4930g_verbs },
10298 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10299 .dac_nids = alc883_dac_nids,
10300 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10301 .adc_nids = alc883_adc_nids_rev,
10302 .capsrc_nids = alc883_capsrc_nids_rev,
10303 .dig_out_nid = ALC883_DIGOUT_NID,
10304 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10305 .channel_mode = alc883_3ST_6ch_modes,
10306 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010307 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010308 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010309 ARRAY_SIZE(alc888_2_capture_sources),
10310 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010311 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010312 .setup = alc888_acer_aspire_4930g_setup,
10313 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010314 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010315 [ALC888_ACER_ASPIRE_6530G] = {
10316 .mixers = { alc888_acer_aspire_6530_mixer },
10317 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10318 alc888_acer_aspire_6530g_verbs },
10319 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10320 .dac_nids = alc883_dac_nids,
10321 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10322 .adc_nids = alc883_adc_nids_rev,
10323 .capsrc_nids = alc883_capsrc_nids_rev,
10324 .dig_out_nid = ALC883_DIGOUT_NID,
10325 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10326 .channel_mode = alc883_3ST_2ch_modes,
10327 .num_mux_defs =
10328 ARRAY_SIZE(alc888_2_capture_sources),
10329 .input_mux = alc888_acer_aspire_6530_sources,
10330 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010331 .setup = alc888_acer_aspire_6530g_setup,
10332 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010333 },
Hector Martin3b315d72009-06-02 10:54:19 +020010334 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010335 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010336 alc883_chmode_mixer },
10337 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010338 alc889_acer_aspire_8930g_verbs,
10339 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010340 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10341 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010342 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10343 .adc_nids = alc889_adc_nids,
10344 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010345 .dig_out_nid = ALC883_DIGOUT_NID,
10346 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10347 .channel_mode = alc883_3ST_6ch_modes,
10348 .need_dac_fix = 1,
10349 .const_channel_count = 6,
10350 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010351 ARRAY_SIZE(alc889_capture_sources),
10352 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010353 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010354 .setup = alc889_acer_aspire_8930g_setup,
10355 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010356#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010357 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010358#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010359 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010360 [ALC888_ACER_ASPIRE_7730G] = {
10361 .mixers = { alc883_3ST_6ch_mixer,
10362 alc883_chmode_mixer },
10363 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10364 alc888_acer_aspire_7730G_verbs },
10365 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10366 .dac_nids = alc883_dac_nids,
10367 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10368 .adc_nids = alc883_adc_nids_rev,
10369 .capsrc_nids = alc883_capsrc_nids_rev,
10370 .dig_out_nid = ALC883_DIGOUT_NID,
10371 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10372 .channel_mode = alc883_3ST_6ch_modes,
10373 .need_dac_fix = 1,
10374 .const_channel_count = 6,
10375 .input_mux = &alc883_capture_source,
10376 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010377 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010378 .init_hook = alc_automute_amp,
10379 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010380 [ALC883_MEDION] = {
10381 .mixers = { alc883_fivestack_mixer,
10382 alc883_chmode_mixer },
10383 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010384 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010385 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10386 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010387 .adc_nids = alc883_adc_nids_alt,
10388 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010389 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010390 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10391 .channel_mode = alc883_sixstack_modes,
10392 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010393 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010394 [ALC883_MEDION_WIM2160] = {
10395 .mixers = { alc883_medion_wim2160_mixer },
10396 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10397 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10398 .dac_nids = alc883_dac_nids,
10399 .dig_out_nid = ALC883_DIGOUT_NID,
10400 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10401 .adc_nids = alc883_adc_nids,
10402 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10403 .channel_mode = alc883_3ST_2ch_modes,
10404 .input_mux = &alc883_capture_source,
10405 .unsol_event = alc_automute_amp_unsol_event,
10406 .setup = alc883_medion_wim2160_setup,
10407 .init_hook = alc_automute_amp,
10408 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010409 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010410 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010411 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10412 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10413 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010414 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10415 .channel_mode = alc883_3ST_2ch_modes,
10416 .input_mux = &alc883_capture_source,
10417 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010418 [ALC883_CLEVO_M540R] = {
10419 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10420 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10421 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10422 .dac_nids = alc883_dac_nids,
10423 .dig_out_nid = ALC883_DIGOUT_NID,
10424 .dig_in_nid = ALC883_DIGIN_NID,
10425 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10426 .channel_mode = alc883_3ST_6ch_clevo_modes,
10427 .need_dac_fix = 1,
10428 .input_mux = &alc883_capture_source,
10429 /* This machine has the hardware HP auto-muting, thus
10430 * we need no software mute via unsol event
10431 */
10432 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010433 [ALC883_CLEVO_M720] = {
10434 .mixers = { alc883_clevo_m720_mixer },
10435 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010436 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10437 .dac_nids = alc883_dac_nids,
10438 .dig_out_nid = ALC883_DIGOUT_NID,
10439 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10440 .channel_mode = alc883_3ST_2ch_modes,
10441 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010442 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010443 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010444 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010445 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010446 [ALC883_LENOVO_101E_2ch] = {
10447 .mixers = { alc883_lenovo_101e_2ch_mixer},
10448 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10449 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10450 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010451 .adc_nids = alc883_adc_nids_alt,
10452 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010453 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010454 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10455 .channel_mode = alc883_3ST_2ch_modes,
10456 .input_mux = &alc883_lenovo_101e_capture_source,
10457 .unsol_event = alc883_lenovo_101e_unsol_event,
10458 .init_hook = alc883_lenovo_101e_all_automute,
10459 },
Kailang Yang272a5272007-05-14 11:00:38 +020010460 [ALC883_LENOVO_NB0763] = {
10461 .mixers = { alc883_lenovo_nb0763_mixer },
10462 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10463 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10464 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010465 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10466 .channel_mode = alc883_3ST_2ch_modes,
10467 .need_dac_fix = 1,
10468 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010469 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010470 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010471 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010472 },
10473 [ALC888_LENOVO_MS7195_DIG] = {
10474 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10475 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10476 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10477 .dac_nids = alc883_dac_nids,
10478 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010479 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10480 .channel_mode = alc883_3ST_6ch_modes,
10481 .need_dac_fix = 1,
10482 .input_mux = &alc883_capture_source,
10483 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10484 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010485 },
10486 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010487 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010488 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10489 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10490 .dac_nids = alc883_dac_nids,
10491 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010492 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10493 .channel_mode = alc883_3ST_2ch_modes,
10494 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010495 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010496 .setup = alc883_haier_w66_setup,
10497 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010498 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010499 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010500 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010501 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010502 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10503 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010504 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10505 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010506 .need_dac_fix = 1,
10507 .input_mux = &alc883_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_3st_hp_setup,
10510 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010511 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010512 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010513 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010514 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10515 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10516 .dac_nids = alc883_dac_nids,
10517 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010518 .dig_in_nid = ALC883_DIGIN_NID,
10519 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10520 .channel_mode = alc883_sixstack_modes,
10521 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010522 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010523 .setup = alc888_6st_dell_setup,
10524 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010525 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010526 [ALC883_MITAC] = {
10527 .mixers = { alc883_mitac_mixer },
10528 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10529 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10530 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010531 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10532 .channel_mode = alc883_3ST_2ch_modes,
10533 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010534 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010535 .setup = alc883_mitac_setup,
10536 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010537 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010538 [ALC883_FUJITSU_PI2515] = {
10539 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10540 .init_verbs = { alc883_init_verbs,
10541 alc883_2ch_fujitsu_pi2515_verbs},
10542 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10543 .dac_nids = alc883_dac_nids,
10544 .dig_out_nid = ALC883_DIGOUT_NID,
10545 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10546 .channel_mode = alc883_3ST_2ch_modes,
10547 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010548 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010549 .setup = alc883_2ch_fujitsu_pi2515_setup,
10550 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010551 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010552 [ALC888_FUJITSU_XA3530] = {
10553 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10554 .init_verbs = { alc883_init_verbs,
10555 alc888_fujitsu_xa3530_verbs },
10556 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10557 .dac_nids = alc883_dac_nids,
10558 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10559 .adc_nids = alc883_adc_nids_rev,
10560 .capsrc_nids = alc883_capsrc_nids_rev,
10561 .dig_out_nid = ALC883_DIGOUT_NID,
10562 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10563 .channel_mode = alc888_4ST_8ch_intel_modes,
10564 .num_mux_defs =
10565 ARRAY_SIZE(alc888_2_capture_sources),
10566 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010567 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010568 .setup = alc888_fujitsu_xa3530_setup,
10569 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010570 },
Kailang Yange2757d52008-08-26 13:17:46 +020010571 [ALC888_LENOVO_SKY] = {
10572 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10573 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10574 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10575 .dac_nids = alc883_dac_nids,
10576 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010577 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10578 .channel_mode = alc883_sixstack_modes,
10579 .need_dac_fix = 1,
10580 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010581 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010582 .setup = alc888_lenovo_sky_setup,
10583 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010584 },
10585 [ALC888_ASUS_M90V] = {
10586 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10587 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10588 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10589 .dac_nids = alc883_dac_nids,
10590 .dig_out_nid = ALC883_DIGOUT_NID,
10591 .dig_in_nid = ALC883_DIGIN_NID,
10592 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10593 .channel_mode = alc883_3ST_6ch_modes,
10594 .need_dac_fix = 1,
10595 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010596 .unsol_event = alc_sku_unsol_event,
10597 .setup = alc883_mode2_setup,
10598 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010599 },
10600 [ALC888_ASUS_EEE1601] = {
10601 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010602 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010603 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10604 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10605 .dac_nids = alc883_dac_nids,
10606 .dig_out_nid = ALC883_DIGOUT_NID,
10607 .dig_in_nid = ALC883_DIGIN_NID,
10608 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10609 .channel_mode = alc883_3ST_2ch_modes,
10610 .need_dac_fix = 1,
10611 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010612 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010613 .init_hook = alc883_eee1601_inithook,
10614 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010615 [ALC1200_ASUS_P5Q] = {
10616 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10617 .init_verbs = { alc883_init_verbs },
10618 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10619 .dac_nids = alc883_dac_nids,
10620 .dig_out_nid = ALC1200_DIGOUT_NID,
10621 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010622 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010623 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10624 .channel_mode = alc883_sixstack_modes,
10625 .input_mux = &alc883_capture_source,
10626 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010627 [ALC889A_MB31] = {
10628 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10629 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10630 alc880_gpio1_init_verbs },
10631 .adc_nids = alc883_adc_nids,
10632 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010633 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010634 .dac_nids = alc883_dac_nids,
10635 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10636 .channel_mode = alc889A_mb31_6ch_modes,
10637 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10638 .input_mux = &alc889A_mb31_capture_source,
10639 .dig_out_nid = ALC883_DIGOUT_NID,
10640 .unsol_event = alc889A_mb31_unsol_event,
10641 .init_hook = alc889A_mb31_automute,
10642 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010643 [ALC883_SONY_VAIO_TT] = {
10644 .mixers = { alc883_vaiott_mixer },
10645 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10646 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10647 .dac_nids = alc883_dac_nids,
10648 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10649 .channel_mode = alc883_3ST_2ch_modes,
10650 .input_mux = &alc883_capture_source,
10651 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010652 .setup = alc883_vaiott_setup,
10653 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010654 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010655};
10656
10657
10658/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010659 * Pin config fixes
10660 */
10661enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010662 PINFIX_ABIT_AW9D_MAX,
10663 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010664 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010665};
10666
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010667static const struct alc_fixup alc882_fixups[] = {
10668 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010669 .pins = (const struct alc_pincfg[]) {
10670 { 0x15, 0x01080104 }, /* side */
10671 { 0x16, 0x01011012 }, /* rear */
10672 { 0x17, 0x01016011 }, /* clfe */
10673 { }
10674 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010675 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010676 [PINFIX_PB_M5210] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020010677 .verbs = (const struct hda_verb[]) {
10678 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10679 {}
10680 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010681 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010682 [PINFIX_ACER_ASPIRE_7736] = {
10683 .sku = ALC_FIXUP_SKU_IGNORE,
10684 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010685};
10686
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010687static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010688 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010689 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010690 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010691 {}
10692};
10693
10694/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010695 * BIOS auto configuration
10696 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010697static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10698 const struct auto_pin_cfg *cfg)
10699{
10700 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10701}
10702
Takashi Iwai4953550a2009-06-30 15:28:30 +020010703static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010704 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010705 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010706{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010707 int idx;
10708
Takashi Iwai489008c2010-04-07 09:06:00 +020010709 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010710 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010711
Takashi Iwai489008c2010-04-07 09:06:00 +020010712 if (dac == 0x25)
10713 idx = 4;
10714 else if (dac >= 0x02 && dac <= 0x05)
10715 idx = dac - 2;
10716 else
10717 return;
10718 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010719}
10720
Takashi Iwai4953550a2009-06-30 15:28:30 +020010721static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010722{
10723 struct alc_spec *spec = codec->spec;
10724 int i;
10725
10726 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010727 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010728 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010729 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010730 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010731 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010732 }
10733}
10734
Takashi Iwai4953550a2009-06-30 15:28:30 +020010735static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010736{
10737 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010738 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010739 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010740
Takashi Iwai5855fb82010-09-16 18:24:02 +020010741 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10742 pin = spec->autocfg.hp_pins[i];
10743 if (!pin)
10744 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010745 dac = spec->multiout.hp_nid;
10746 if (!dac)
10747 dac = spec->multiout.dac_nids[0]; /* to front */
10748 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10749 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010750 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10751 pin = spec->autocfg.speaker_pins[i];
10752 if (!pin)
10753 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010754 dac = spec->multiout.extra_out_nid[0];
10755 if (!dac)
10756 dac = spec->multiout.dac_nids[0]; /* to front */
10757 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10758 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010759}
10760
Takashi Iwai4953550a2009-06-30 15:28:30 +020010761static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010762{
10763 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010764 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010765 int i;
10766
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010767 for (i = 0; i < cfg->num_inputs; i++) {
10768 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010769 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010770 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10771 snd_hda_codec_write(codec, nid, 0,
10772 AC_VERB_SET_AMP_GAIN_MUTE,
10773 AMP_OUT_MUTE);
10774 }
10775}
10776
10777static void alc882_auto_init_input_src(struct hda_codec *codec)
10778{
10779 struct alc_spec *spec = codec->spec;
10780 int c;
10781
10782 for (c = 0; c < spec->num_adc_nids; c++) {
10783 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10784 hda_nid_t nid = spec->capsrc_nids[c];
10785 unsigned int mux_idx;
10786 const struct hda_input_mux *imux;
10787 int conns, mute, idx, item;
10788
10789 conns = snd_hda_get_connections(codec, nid, conn_list,
10790 ARRAY_SIZE(conn_list));
10791 if (conns < 0)
10792 continue;
10793 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10794 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010795 if (!imux->num_items && mux_idx > 0)
10796 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010797 for (idx = 0; idx < conns; idx++) {
10798 /* if the current connection is the selected one,
10799 * unmute it as default - otherwise mute it
10800 */
10801 mute = AMP_IN_MUTE(idx);
10802 for (item = 0; item < imux->num_items; item++) {
10803 if (imux->items[item].index == idx) {
10804 if (spec->cur_mux[c] == item)
10805 mute = AMP_IN_UNMUTE(idx);
10806 break;
10807 }
10808 }
10809 /* check if we have a selector or mixer
10810 * we could check for the widget type instead, but
10811 * just check for Amp-In presence (in case of mixer
10812 * without amp-in there is something wrong, this
10813 * function shouldn't be used or capsrc nid is wrong)
10814 */
10815 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010816 snd_hda_codec_write(codec, nid, 0,
10817 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010818 mute);
10819 else if (mute != AMP_IN_MUTE(idx))
10820 snd_hda_codec_write(codec, nid, 0,
10821 AC_VERB_SET_CONNECT_SEL,
10822 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010823 }
10824 }
10825}
10826
Takashi Iwai4953550a2009-06-30 15:28:30 +020010827/* add mic boosts if needed */
10828static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010829{
10830 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010831 struct auto_pin_cfg *cfg = &spec->autocfg;
10832 int i, err;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010833 hda_nid_t nid;
10834
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010835 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010836 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010837 break;
10838 nid = cfg->inputs[i].pin;
10839 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
Takashi Iwai10a20af2010-09-09 16:28:02 +020010840 char label[32];
10841 snprintf(label, sizeof(label), "%s Boost",
10842 hda_get_autocfg_input_label(codec, cfg, i));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010843 err = add_control(spec, ALC_CTL_WIDGET_VOL, label, 0,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010844 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010845 if (err < 0)
10846 return err;
10847 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010848 }
10849 return 0;
10850}
10851
10852/* almost identical with ALC880 parser... */
10853static int alc882_parse_auto_config(struct hda_codec *codec)
10854{
10855 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010856 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010857 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010858
Takashi Iwai05f5f472009-08-25 13:10:18 +020010859 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10860 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010861 if (err < 0)
10862 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010863 if (!spec->autocfg.line_outs)
10864 return 0; /* can't find valid BIOS pin config */
10865
10866 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10867 if (err < 0)
10868 return err;
10869 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10870 if (err < 0)
10871 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010872 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10873 "Headphone");
10874 if (err < 0)
10875 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010876 err = alc880_auto_create_extra_out(spec,
10877 spec->autocfg.speaker_pins[0],
10878 "Speaker");
10879 if (err < 0)
10880 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010881 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10882 if (err < 0)
10883 return err;
10884
10885 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10886
Takashi Iwai757899a2010-07-30 10:48:14 +020010887 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010888
10889 if (spec->kctls.list)
10890 add_mixer(spec, spec->kctls.list);
10891
10892 add_verb(spec, alc883_auto_init_verbs);
10893 /* if ADC 0x07 is available, initialize it, too */
10894 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10895 add_verb(spec, alc882_adc1_init_verbs);
10896
10897 spec->num_mux_defs = 1;
10898 spec->input_mux = &spec->private_imux[0];
10899
Kailang Yang6227cdc2010-02-25 08:36:52 +010010900 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010901
10902 err = alc_auto_add_mic_boost(codec);
10903 if (err < 0)
10904 return err;
10905
Takashi Iwai776e1842007-08-29 15:07:11 +020010906 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010907}
10908
10909/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010910static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010911{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010912 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010913 alc882_auto_init_multi_out(codec);
10914 alc882_auto_init_hp_out(codec);
10915 alc882_auto_init_analog_input(codec);
10916 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010917 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010918 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010919 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010920}
10921
Takashi Iwai4953550a2009-06-30 15:28:30 +020010922static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010923{
10924 struct alc_spec *spec;
10925 int err, board_config;
10926
10927 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10928 if (spec == NULL)
10929 return -ENOMEM;
10930
10931 codec->spec = spec;
10932
Takashi Iwai4953550a2009-06-30 15:28:30 +020010933 switch (codec->vendor_id) {
10934 case 0x10ec0882:
10935 case 0x10ec0885:
10936 break;
10937 default:
10938 /* ALC883 and variants */
10939 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10940 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010941 }
10942
Takashi Iwai4953550a2009-06-30 15:28:30 +020010943 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10944 alc882_models,
10945 alc882_cfg_tbl);
10946
10947 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10948 board_config = snd_hda_check_board_codec_sid_config(codec,
10949 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10950
10951 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010952 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020010953 codec->chip_name);
10954 board_config = ALC882_AUTO;
10955 }
10956
Takashi Iwai7fa90e82010-04-12 08:49:00 +020010957 if (board_config == ALC882_AUTO)
10958 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 1);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010959
David Henningsson90622912010-10-14 14:50:18 +020010960 alc_auto_parse_customize_define(codec);
10961
Takashi Iwai4953550a2009-06-30 15:28:30 +020010962 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010963 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010964 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010965 if (err < 0) {
10966 alc_free(codec);
10967 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010968 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010969 printk(KERN_INFO
10970 "hda_codec: Cannot set up configuration "
10971 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020010972 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010973 }
10974 }
10975
Takashi Iwaidc1eae22010-07-29 15:30:02 +020010976 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020010977 err = snd_hda_attach_beep_device(codec, 0x1);
10978 if (err < 0) {
10979 alc_free(codec);
10980 return err;
10981 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090010982 }
10983
Takashi Iwai4953550a2009-06-30 15:28:30 +020010984 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020010985 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010986
Takashi Iwai4953550a2009-06-30 15:28:30 +020010987 spec->stream_analog_playback = &alc882_pcm_analog_playback;
10988 spec->stream_analog_capture = &alc882_pcm_analog_capture;
10989 /* FIXME: setup DAC5 */
10990 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
10991 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
10992
10993 spec->stream_digital_playback = &alc882_pcm_digital_playback;
10994 spec->stream_digital_capture = &alc882_pcm_digital_capture;
10995
Takashi Iwai4953550a2009-06-30 15:28:30 +020010996 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010010997 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010998 spec->num_adc_nids = 0;
10999 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011000 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011001 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011002 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011003 hda_nid_t nid = alc882_adc_nids[i];
11004 unsigned int wcap = get_wcaps(codec, nid);
11005 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011006 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011007 if (wcap != AC_WID_AUD_IN)
11008 continue;
11009 spec->private_adc_nids[spec->num_adc_nids] = nid;
11010 err = snd_hda_get_connections(codec, nid, &cap, 1);
11011 if (err < 0)
11012 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011013 err = snd_hda_get_connections(codec, cap, items,
11014 ARRAY_SIZE(items));
11015 if (err < 0)
11016 continue;
11017 for (j = 0; j < imux->num_items; j++)
11018 if (imux->items[j].index >= err)
11019 break;
11020 if (j < imux->num_items)
11021 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011022 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11023 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011024 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011025 spec->adc_nids = spec->private_adc_nids;
11026 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011027 }
11028
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011029 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011030
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011031 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011032 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011033
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011034 if (board_config == ALC882_AUTO)
11035 alc_pick_fixup(codec, alc882_fixup_tbl, alc882_fixups, 0);
11036
Takashi Iwai2134ea42008-01-10 16:53:55 +010011037 spec->vmaster_nid = 0x0c;
11038
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011039 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011040 if (board_config == ALC882_AUTO)
11041 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011042
11043 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011044#ifdef CONFIG_SND_HDA_POWER_SAVE
11045 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011046 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011047#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011048
11049 return 0;
11050}
11051
Takashi Iwai4953550a2009-06-30 15:28:30 +020011052
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011053/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011054 * ALC262 support
11055 */
11056
11057#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11058#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11059
11060#define alc262_dac_nids alc260_dac_nids
11061#define alc262_adc_nids alc882_adc_nids
11062#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011063#define alc262_capsrc_nids alc882_capsrc_nids
11064#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011065
11066#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011067#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011068
Kailang Yang4e555fe2008-08-26 13:05:55 +020011069static hda_nid_t alc262_dmic_adc_nids[1] = {
11070 /* ADC0 */
11071 0x09
11072};
11073
11074static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11075
Kailang Yangdf694da2005-12-05 19:42:22 +010011076static struct snd_kcontrol_new alc262_base_mixer[] = {
11077 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11078 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11079 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11080 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11081 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11082 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11083 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11084 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011085 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011086 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11087 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011088 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011089 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11090 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11091 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11092 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011093 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011094};
11095
Takashi Iwaice875f02008-01-28 18:17:43 +010011096/* update HP, line and mono-out pins according to the master switch */
11097static void alc262_hp_master_update(struct hda_codec *codec)
11098{
11099 struct alc_spec *spec = codec->spec;
11100 int val = spec->master_sw;
11101
11102 /* HP & line-out */
11103 snd_hda_codec_write_cache(codec, 0x1b, 0,
11104 AC_VERB_SET_PIN_WIDGET_CONTROL,
11105 val ? PIN_HP : 0);
11106 snd_hda_codec_write_cache(codec, 0x15, 0,
11107 AC_VERB_SET_PIN_WIDGET_CONTROL,
11108 val ? PIN_HP : 0);
11109 /* mono (speaker) depending on the HP jack sense */
11110 val = val && !spec->jack_present;
11111 snd_hda_codec_write_cache(codec, 0x16, 0,
11112 AC_VERB_SET_PIN_WIDGET_CONTROL,
11113 val ? PIN_OUT : 0);
11114}
11115
11116static void alc262_hp_bpc_automute(struct hda_codec *codec)
11117{
11118 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011119
11120 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011121 alc262_hp_master_update(codec);
11122}
11123
11124static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11125{
11126 if ((res >> 26) != ALC880_HP_EVENT)
11127 return;
11128 alc262_hp_bpc_automute(codec);
11129}
11130
11131static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11132{
11133 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011134
11135 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011136 alc262_hp_master_update(codec);
11137}
11138
11139static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11140 unsigned int res)
11141{
11142 if ((res >> 26) != ALC880_HP_EVENT)
11143 return;
11144 alc262_hp_wildwest_automute(codec);
11145}
11146
Takashi Iwaib72519b2009-05-08 14:31:55 +020011147#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011148
11149static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11150 struct snd_ctl_elem_value *ucontrol)
11151{
11152 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11153 struct alc_spec *spec = codec->spec;
11154 int val = !!*ucontrol->value.integer.value;
11155
11156 if (val == spec->master_sw)
11157 return 0;
11158 spec->master_sw = val;
11159 alc262_hp_master_update(codec);
11160 return 1;
11161}
11162
Takashi Iwaib72519b2009-05-08 14:31:55 +020011163#define ALC262_HP_MASTER_SWITCH \
11164 { \
11165 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11166 .name = "Master Playback Switch", \
11167 .info = snd_ctl_boolean_mono_info, \
11168 .get = alc262_hp_master_sw_get, \
11169 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011170 }, \
11171 { \
11172 .iface = NID_MAPPING, \
11173 .name = "Master Playback Switch", \
11174 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011175 }
11176
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011177
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011178static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011179 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011180 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11181 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11182 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011183 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11184 HDA_OUTPUT),
11185 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11186 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011187 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11188 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011189 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011190 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11191 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011192 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011193 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11194 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11195 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11196 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011197 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11198 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11199 { } /* end */
11200};
11201
Kailang Yangcd7509a2007-01-26 18:33:17 +010011202static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011203 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011204 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11205 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11206 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11207 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011208 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11209 HDA_OUTPUT),
11210 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11211 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011212 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11213 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011214 HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011215 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11216 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11217 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11218 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011219 { } /* end */
11220};
11221
11222static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11223 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11224 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaicc69d122007-02-15 19:29:26 +010011225 HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011226 { } /* end */
11227};
11228
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011229/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011230static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011231{
11232 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011233
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011234 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011235 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011236}
11237
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011238static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011239 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11240 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011241 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11242 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11243 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11244 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11245 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11246 { } /* end */
11247};
11248
11249static struct hda_verb alc262_hp_t5735_verbs[] = {
11250 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11251 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11252
11253 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11254 { }
11255};
11256
Kailang Yang8c427222008-01-10 13:03:59 +010011257static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011258 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11259 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011260 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11261 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011262 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11263 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11264 { } /* end */
11265};
11266
11267static struct hda_verb alc262_hp_rp5700_verbs[] = {
11268 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11269 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11270 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11272 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11273 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11274 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11276 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11278 {}
11279};
11280
11281static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11282 .num_items = 1,
11283 .items = {
11284 { "Line", 0x1 },
11285 },
11286};
11287
Takashi Iwai42171c12009-05-08 14:11:43 +020011288/* bind hp and internal speaker mute (with plug check) as master switch */
11289static void alc262_hippo_master_update(struct hda_codec *codec)
11290{
11291 struct alc_spec *spec = codec->spec;
11292 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11293 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11294 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11295 unsigned int mute;
11296
11297 /* HP */
11298 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11299 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11300 HDA_AMP_MUTE, mute);
11301 /* mute internal speaker per jack sense */
11302 if (spec->jack_present)
11303 mute = HDA_AMP_MUTE;
11304 if (line_nid)
11305 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11306 HDA_AMP_MUTE, mute);
11307 if (speaker_nid && speaker_nid != line_nid)
11308 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11309 HDA_AMP_MUTE, mute);
11310}
11311
11312#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11313
11314static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11315 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011316{
11317 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011318 struct alc_spec *spec = codec->spec;
11319 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011320
Takashi Iwai42171c12009-05-08 14:11:43 +020011321 if (val == spec->master_sw)
11322 return 0;
11323 spec->master_sw = val;
11324 alc262_hippo_master_update(codec);
11325 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011326}
Takashi Iwai5b319542007-07-26 11:49:22 +020011327
Takashi Iwai42171c12009-05-08 14:11:43 +020011328#define ALC262_HIPPO_MASTER_SWITCH \
11329 { \
11330 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11331 .name = "Master Playback Switch", \
11332 .info = snd_ctl_boolean_mono_info, \
11333 .get = alc262_hippo_master_sw_get, \
11334 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011335 }, \
11336 { \
11337 .iface = NID_MAPPING, \
11338 .name = "Master Playback Switch", \
11339 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11340 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011341 }
11342
11343static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11344 ALC262_HIPPO_MASTER_SWITCH,
11345 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11346 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11347 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11348 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11349 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11350 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11351 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11352 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11353 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11354 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11355 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11356 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11357 { } /* end */
11358};
11359
11360static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11361 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11362 ALC262_HIPPO_MASTER_SWITCH,
11363 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11364 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11365 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11366 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11367 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11368 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11369 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11370 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11371 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11372 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11373 { } /* end */
11374};
11375
11376/* mute/unmute internal speaker according to the hp jack and mute state */
11377static void alc262_hippo_automute(struct hda_codec *codec)
11378{
11379 struct alc_spec *spec = codec->spec;
11380 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011381
Wu Fengguang864f92b2009-11-18 12:38:02 +080011382 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011383 alc262_hippo_master_update(codec);
11384}
11385
11386static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11387{
11388 if ((res >> 26) != ALC880_HP_EVENT)
11389 return;
11390 alc262_hippo_automute(codec);
11391}
11392
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011393static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011394{
11395 struct alc_spec *spec = codec->spec;
11396
11397 spec->autocfg.hp_pins[0] = 0x15;
11398 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011399}
11400
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011401static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011402{
11403 struct alc_spec *spec = codec->spec;
11404
11405 spec->autocfg.hp_pins[0] = 0x1b;
11406 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011407}
11408
11409
Kailang Yang272a5272007-05-14 11:00:38 +020011410static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011411 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011412 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011413 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11414 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11415 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11416 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11417 { } /* end */
11418};
11419
Kailang Yang83c34212007-07-05 11:43:05 +020011420static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011421 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11422 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011423 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11424 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11425 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11426 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11427 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11428 { } /* end */
11429};
Kailang Yang272a5272007-05-14 11:00:38 +020011430
Tony Vroonba340e82009-02-02 19:01:30 +000011431static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11432 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11433 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11434 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11435 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11436 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11437 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11438 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11439 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11440 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11441 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11442 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11443 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11444 { } /* end */
11445};
11446
11447static struct hda_verb alc262_tyan_verbs[] = {
11448 /* Headphone automute */
11449 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11450 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11451 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11452
11453 /* P11 AUX_IN, white 4-pin connector */
11454 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11455 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11456 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11457 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11458
11459 {}
11460};
11461
11462/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011463static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011464{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011465 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011466
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011467 spec->autocfg.hp_pins[0] = 0x1b;
11468 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011469}
11470
Tony Vroonba340e82009-02-02 19:01:30 +000011471
Kailang Yangdf694da2005-12-05 19:42:22 +010011472#define alc262_capture_mixer alc882_capture_mixer
11473#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11474
11475/*
11476 * generic initialization of ADC, input mixers and output mixers
11477 */
11478static struct hda_verb alc262_init_verbs[] = {
11479 /*
11480 * Unmute ADC0-2 and set the default input to mic-in
11481 */
11482 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11483 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11484 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11485 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11486 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11487 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11488
Takashi Iwaicb53c622007-08-10 17:21:45 +020011489 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011490 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011491 * Note: PASD motherboards uses the Line In 2 as the input for
11492 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011493 */
11494 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011495 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11496 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11497 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11498 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11499 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011500
11501 /*
11502 * Set up output mixers (0x0c - 0x0e)
11503 */
11504 /* set vol=0 to output mixers */
11505 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11506 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11507 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11508 /* set up input amps for analog loopback */
11509 /* Amp Indices: DAC = 0, mixer = 1 */
11510 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11512 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11514 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11516
11517 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11518 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11519 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11520 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11521 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11522 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11523
11524 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11525 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11526 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11527 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11528 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011529
Kailang Yangdf694da2005-12-05 19:42:22 +010011530 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11531 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011532
Kailang Yangdf694da2005-12-05 19:42:22 +010011533 /* FIXME: use matrix-type input source selection */
11534 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11535 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11536 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11537 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11538 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11539 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11540 /* Input mixer2 */
11541 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11542 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11543 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11544 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11545 /* Input mixer3 */
11546 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11547 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11548 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011549 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011550
11551 { }
11552};
11553
Kailang Yang4e555fe2008-08-26 13:05:55 +020011554static struct hda_verb alc262_eapd_verbs[] = {
11555 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11556 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11557 { }
11558};
11559
Kailang Yangccc656c2006-10-17 12:32:26 +020011560static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11561 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11562 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11563 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11564
11565 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11566 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11567 {}
11568};
11569
Kailang Yang272a5272007-05-14 11:00:38 +020011570static struct hda_verb alc262_sony_unsol_verbs[] = {
11571 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11572 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11573 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11574
11575 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11576 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011577 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011578};
11579
Kailang Yang4e555fe2008-08-26 13:05:55 +020011580static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11581 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11582 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11583 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11584 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11585 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011586 { } /* end */
11587};
11588
11589static struct hda_verb alc262_toshiba_s06_verbs[] = {
11590 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11591 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11594 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11595 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11596 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11597 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11598 {}
11599};
11600
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011601static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011602{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011603 struct alc_spec *spec = codec->spec;
11604
11605 spec->autocfg.hp_pins[0] = 0x15;
11606 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011607 spec->ext_mic.pin = 0x18;
11608 spec->ext_mic.mux_idx = 0;
11609 spec->int_mic.pin = 0x12;
11610 spec->int_mic.mux_idx = 9;
11611 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011612}
11613
Takashi Iwai834be882006-03-01 14:16:17 +010011614/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011615 * nec model
11616 * 0x15 = headphone
11617 * 0x16 = internal speaker
11618 * 0x18 = external mic
11619 */
11620
11621static struct snd_kcontrol_new alc262_nec_mixer[] = {
11622 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11623 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11624
11625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11626 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11627 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11628
11629 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11630 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11631 { } /* end */
11632};
11633
11634static struct hda_verb alc262_nec_verbs[] = {
11635 /* Unmute Speaker */
11636 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11637
11638 /* Headphone */
11639 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11641
11642 /* External mic to headphone */
11643 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11644 /* External mic to speaker */
11645 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11646 {}
11647};
11648
11649/*
Takashi Iwai834be882006-03-01 14:16:17 +010011650 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011651 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11652 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011653 */
11654
11655#define ALC_HP_EVENT 0x37
11656
11657static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11658 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11659 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011660 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11661 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011662 {}
11663};
11664
Jiang zhe0e31daf2008-03-20 12:12:39 +010011665static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11666 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11667 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11668 {}
11669};
11670
Daniel T Chene2595322009-12-19 18:19:02 -050011671static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11672 /* Front Mic pin: input vref at 50% */
11673 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11674 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11675 {}
11676};
11677
Takashi Iwai834be882006-03-01 14:16:17 +010011678static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011679 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011680 .items = {
11681 { "Mic", 0x0 },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011682 { "Int Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011683 { "CD", 0x4 },
11684 },
11685};
11686
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011687static struct hda_input_mux alc262_HP_capture_source = {
11688 .num_items = 5,
11689 .items = {
11690 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011691 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011692 { "Line", 0x2 },
11693 { "CD", 0x4 },
11694 { "AUX IN", 0x6 },
11695 },
11696};
11697
zhejiangaccbe492007-08-31 12:36:05 +020011698static struct hda_input_mux alc262_HP_D7000_capture_source = {
11699 .num_items = 4,
11700 .items = {
11701 { "Mic", 0x0 },
11702 { "Front Mic", 0x2 },
11703 { "Line", 0x1 },
11704 { "CD", 0x4 },
11705 },
11706};
11707
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011708/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011709static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11710{
11711 struct alc_spec *spec = codec->spec;
11712 unsigned int mute;
11713
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011714 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011715 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11716 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011717 spec->sense_updated = 1;
11718 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011719 /* unmute internal speaker only if both HPs are unplugged and
11720 * master switch is on
11721 */
11722 if (spec->jack_present)
11723 mute = HDA_AMP_MUTE;
11724 else
Takashi Iwai834be882006-03-01 14:16:17 +010011725 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011726 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11727 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011728}
11729
11730/* unsolicited event for HP jack sensing */
11731static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11732 unsigned int res)
11733{
11734 if ((res >> 26) != ALC_HP_EVENT)
11735 return;
11736 alc262_fujitsu_automute(codec, 1);
11737}
11738
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011739static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11740{
11741 alc262_fujitsu_automute(codec, 1);
11742}
11743
Takashi Iwai834be882006-03-01 14:16:17 +010011744/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011745static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11746 .ops = &snd_hda_bind_vol,
11747 .values = {
11748 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11749 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11750 0
11751 },
11752};
Takashi Iwai834be882006-03-01 14:16:17 +010011753
Jiang zhe0e31daf2008-03-20 12:12:39 +010011754/* mute/unmute internal speaker according to the hp jack and mute state */
11755static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11756{
11757 struct alc_spec *spec = codec->spec;
11758 unsigned int mute;
11759
11760 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011761 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011762 spec->sense_updated = 1;
11763 }
11764 if (spec->jack_present) {
11765 /* mute internal speaker */
11766 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11767 HDA_AMP_MUTE, HDA_AMP_MUTE);
11768 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11769 HDA_AMP_MUTE, HDA_AMP_MUTE);
11770 } else {
11771 /* unmute internal speaker if necessary */
11772 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11773 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11774 HDA_AMP_MUTE, mute);
11775 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11776 HDA_AMP_MUTE, mute);
11777 }
11778}
11779
11780/* unsolicited event for HP jack sensing */
11781static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11782 unsigned int res)
11783{
11784 if ((res >> 26) != ALC_HP_EVENT)
11785 return;
11786 alc262_lenovo_3000_automute(codec, 1);
11787}
11788
Takashi Iwai8de56b72009-07-24 16:51:47 +020011789static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11790 int dir, int idx, long *valp)
11791{
11792 int i, change = 0;
11793
11794 for (i = 0; i < 2; i++, valp++)
11795 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11796 HDA_AMP_MUTE,
11797 *valp ? 0 : HDA_AMP_MUTE);
11798 return change;
11799}
11800
Takashi Iwai834be882006-03-01 14:16:17 +010011801/* bind hp and internal speaker mute (with plug check) */
11802static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11803 struct snd_ctl_elem_value *ucontrol)
11804{
11805 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11806 long *valp = ucontrol->value.integer.value;
11807 int change;
11808
Takashi Iwai8de56b72009-07-24 16:51:47 +020011809 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11810 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011811 if (change)
11812 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011813 return change;
11814}
11815
11816static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011817 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011818 {
11819 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11820 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011821 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011822 .info = snd_hda_mixer_amp_switch_info,
11823 .get = snd_hda_mixer_amp_switch_get,
11824 .put = alc262_fujitsu_master_sw_put,
11825 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11826 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011827 {
11828 .iface = NID_MAPPING,
11829 .name = "Master Playback Switch",
11830 .private_value = 0x1b,
11831 },
Takashi Iwai834be882006-03-01 14:16:17 +010011832 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11833 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11834 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11835 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11836 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011837 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11838 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11839 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011840 { } /* end */
11841};
11842
Jiang zhe0e31daf2008-03-20 12:12:39 +010011843/* bind hp and internal speaker mute (with plug check) */
11844static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11845 struct snd_ctl_elem_value *ucontrol)
11846{
11847 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11848 long *valp = ucontrol->value.integer.value;
11849 int change;
11850
Takashi Iwai8de56b72009-07-24 16:51:47 +020011851 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011852 if (change)
11853 alc262_lenovo_3000_automute(codec, 0);
11854 return change;
11855}
11856
11857static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11858 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11859 {
11860 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11861 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011862 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011863 .info = snd_hda_mixer_amp_switch_info,
11864 .get = snd_hda_mixer_amp_switch_get,
11865 .put = alc262_lenovo_3000_master_sw_put,
11866 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11867 },
11868 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11869 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11870 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11871 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11873 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
11874 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11875 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
11876 { } /* end */
11877};
11878
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011879static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11880 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011881 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11883 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11884 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
11885 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11886 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11887 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
11888 { } /* end */
11889};
11890
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011891/* additional init verbs for Benq laptops */
11892static struct hda_verb alc262_EAPD_verbs[] = {
11893 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11894 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11895 {}
11896};
11897
Kailang Yang83c34212007-07-05 11:43:05 +020011898static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11899 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11900 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11901
11902 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11903 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11904 {}
11905};
11906
Tobin Davisf651b502007-10-26 12:40:47 +020011907/* Samsung Q1 Ultra Vista model setup */
11908static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011909 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11910 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011911 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11912 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11913 HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011914 HDA_CODEC_VOLUME("Headphone Mic Boost", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011915 { } /* end */
11916};
11917
11918static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011919 /* output mixer */
11920 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11921 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11922 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11923 /* speaker */
11924 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11925 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11926 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11927 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11928 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011929 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011930 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11931 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11932 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11933 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11934 /* internal mic */
11935 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11936 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11937 /* ADC, choose mic */
11938 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11939 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11940 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11941 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11942 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11943 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11944 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11945 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11946 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11947 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011948 {}
11949};
11950
Tobin Davisf651b502007-10-26 12:40:47 +020011951/* mute/unmute internal speaker according to the hp jack and mute state */
11952static void alc262_ultra_automute(struct hda_codec *codec)
11953{
11954 struct alc_spec *spec = codec->spec;
11955 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020011956
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011957 mute = 0;
11958 /* auto-mute only when HP is used as HP */
11959 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011960 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011961 if (spec->jack_present)
11962 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020011963 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011964 /* mute/unmute internal speaker */
11965 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11966 HDA_AMP_MUTE, mute);
11967 /* mute/unmute HP */
11968 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11969 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020011970}
11971
11972/* unsolicited event for HP jack sensing */
11973static void alc262_ultra_unsol_event(struct hda_codec *codec,
11974 unsigned int res)
11975{
11976 if ((res >> 26) != ALC880_HP_EVENT)
11977 return;
11978 alc262_ultra_automute(codec);
11979}
11980
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011981static struct hda_input_mux alc262_ultra_capture_source = {
11982 .num_items = 2,
11983 .items = {
11984 { "Mic", 0x1 },
11985 { "Headphone", 0x7 },
11986 },
11987};
11988
11989static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
11990 struct snd_ctl_elem_value *ucontrol)
11991{
11992 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11993 struct alc_spec *spec = codec->spec;
11994 int ret;
11995
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010011996 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011997 if (!ret)
11998 return 0;
11999 /* reprogram the HP pin as mic or HP according to the input source */
12000 snd_hda_codec_write_cache(codec, 0x15, 0,
12001 AC_VERB_SET_PIN_WIDGET_CONTROL,
12002 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12003 alc262_ultra_automute(codec); /* mute/unmute HP */
12004 return ret;
12005}
12006
12007static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12008 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12009 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12010 {
12011 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12012 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012013 .info = alc_mux_enum_info,
12014 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012015 .put = alc262_ultra_mux_enum_put,
12016 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012017 {
12018 .iface = NID_MAPPING,
12019 .name = "Capture Source",
12020 .private_value = 0x15,
12021 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012022 { } /* end */
12023};
12024
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012025/* We use two mixers depending on the output pin; 0x16 is a mono output
12026 * and thus it's bound with a different mixer.
12027 * This function returns which mixer amp should be used.
12028 */
12029static int alc262_check_volbit(hda_nid_t nid)
12030{
12031 if (!nid)
12032 return 0;
12033 else if (nid == 0x16)
12034 return 2;
12035 else
12036 return 1;
12037}
12038
12039static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012040 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012041{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012042 unsigned long val;
12043 int vbit;
12044
12045 vbit = alc262_check_volbit(nid);
12046 if (!vbit)
12047 return 0;
12048 if (*vbits & vbit) /* a volume control for this mixer already there */
12049 return 0;
12050 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012051 if (vbit == 2)
12052 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12053 else
12054 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012055 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012056}
12057
12058static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012059 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012060{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012061 unsigned long val;
12062
12063 if (!nid)
12064 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012065 if (nid == 0x16)
12066 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12067 else
12068 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012069 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012070}
12071
Kailang Yangdf694da2005-12-05 19:42:22 +010012072/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012073static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12074 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012075{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012076 const char *pfx;
12077 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012078 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012079
12080 spec->multiout.num_dacs = 1; /* only use one dac */
12081 spec->multiout.dac_nids = spec->private_dac_nids;
12082 spec->multiout.dac_nids[0] = 2;
12083
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012084 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
12085 pfx = "Master";
12086 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
12087 pfx = "Speaker";
Takashi Iwai033688a2010-09-08 15:47:09 +020012088 else if (cfg->line_out_type == AUTO_PIN_HP_OUT)
12089 pfx = "Headphone";
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012090 else
12091 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012092 for (i = 0; i < 2; i++) {
12093 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12094 if (err < 0)
12095 return err;
12096 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12097 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12098 "Speaker", i);
12099 if (err < 0)
12100 return err;
12101 }
12102 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12103 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12104 "Headphone", i);
12105 if (err < 0)
12106 return err;
12107 }
12108 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012109
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012110 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12111 alc262_check_volbit(cfg->speaker_pins[0]) |
12112 alc262_check_volbit(cfg->hp_pins[0]);
12113 if (vbits == 1 || vbits == 2)
12114 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012115 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012116 for (i = 0; i < 2; i++) {
12117 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12118 &vbits, i);
12119 if (err < 0)
12120 return err;
12121 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12122 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12123 "Speaker", &vbits, i);
12124 if (err < 0)
12125 return err;
12126 }
12127 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12128 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12129 "Headphone", &vbits, i);
12130 if (err < 0)
12131 return err;
12132 }
12133 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012134 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012135}
12136
Takashi Iwai05f5f472009-08-25 13:10:18 +020012137#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012138 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012139
12140/*
12141 * generic initialization of ADC, input mixers and output mixers
12142 */
12143static struct hda_verb alc262_volume_init_verbs[] = {
12144 /*
12145 * Unmute ADC0-2 and set the default input to mic-in
12146 */
12147 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12148 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12149 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12150 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12151 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12152 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12153
Takashi Iwaicb53c622007-08-10 17:21:45 +020012154 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012155 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012156 * Note: PASD motherboards uses the Line In 2 as the input for
12157 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012158 */
12159 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012160 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12161 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12162 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12163 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12164 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012165
12166 /*
12167 * Set up output mixers (0x0c - 0x0f)
12168 */
12169 /* set vol=0 to output mixers */
12170 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12171 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12172 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012173
Kailang Yangdf694da2005-12-05 19:42:22 +010012174 /* set up input amps for analog loopback */
12175 /* Amp Indices: DAC = 0, mixer = 1 */
12176 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12177 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12178 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12179 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12180 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12181 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12182
12183 /* FIXME: use matrix-type input source selection */
12184 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12185 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12186 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12187 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12188 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12189 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12190 /* Input mixer2 */
12191 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12192 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12193 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12194 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12195 /* Input mixer3 */
12196 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12197 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12198 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12199 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12200
12201 { }
12202};
12203
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012204static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12205 /*
12206 * Unmute ADC0-2 and set the default input to mic-in
12207 */
12208 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12209 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12210 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12211 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12212 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12213 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12214
Takashi Iwaicb53c622007-08-10 17:21:45 +020012215 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012216 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012217 * Note: PASD motherboards uses the Line In 2 as the input for
12218 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012219 */
12220 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012221 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12222 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12223 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12224 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12225 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12226 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12227 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012228
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012229 /*
12230 * Set up output mixers (0x0c - 0x0e)
12231 */
12232 /* set vol=0 to output mixers */
12233 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12234 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12235 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12236
12237 /* set up input amps for analog loopback */
12238 /* Amp Indices: DAC = 0, mixer = 1 */
12239 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12240 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12241 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12242 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12243 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12244 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12245
Takashi Iwaice875f02008-01-28 18:17:43 +010012246 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012247 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12248 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12249
12250 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12251 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12252
12253 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12254 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12255
12256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12257 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12258 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12259 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12260 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12261
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012262 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012263 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12264 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012265 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012266 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12267 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12268
12269
12270 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012271 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12272 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012273 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012274 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12275 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12276 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12277 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12278 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12279 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12280 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12281 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012282 /* Input mixer2 */
12283 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012284 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12285 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12286 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12287 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12288 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12289 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12290 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012292 /* Input mixer3 */
12293 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012294 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12295 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12300 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12301 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012302
Takashi Iwaice875f02008-01-28 18:17:43 +010012303 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12304
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012305 { }
12306};
12307
Kailang Yangcd7509a2007-01-26 18:33:17 +010012308static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12309 /*
12310 * Unmute ADC0-2 and set the default input to mic-in
12311 */
12312 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12314 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12315 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12316 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12317 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12318
Takashi Iwaicb53c622007-08-10 17:21:45 +020012319 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012320 * mixer widget
12321 * Note: PASD motherboards uses the Line In 2 as the input for front
12322 * panel mic (mic 2)
12323 */
12324 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012325 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12326 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12327 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12328 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12329 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12330 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12331 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12332 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012333 /*
12334 * Set up output mixers (0x0c - 0x0e)
12335 */
12336 /* set vol=0 to output mixers */
12337 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12338 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12339 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12340
12341 /* set up input amps for analog loopback */
12342 /* Amp Indices: DAC = 0, mixer = 1 */
12343 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12344 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12345 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12346 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12347 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12348 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12349
12350
12351 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12352 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12353 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12354 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12355 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12356 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12357 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12358
12359 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12360 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12361
12362 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12363 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12364
12365 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12366 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12367 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12368 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12369 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12370 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12371
12372 /* FIXME: use matrix-type input source selection */
12373 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12374 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12375 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12376 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12377 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12378 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12379 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12380 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12381 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12382 /* Input mixer2 */
12383 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12384 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12385 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12386 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12387 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12388 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12389 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12390 /* Input mixer3 */
12391 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12392 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12393 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12394 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12395 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12396 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12397 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12398
Takashi Iwaice875f02008-01-28 18:17:43 +010012399 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12400
Kailang Yangcd7509a2007-01-26 18:33:17 +010012401 { }
12402};
12403
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012404static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12405
12406 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12407 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12408 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12409
12410 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12411 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12412 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12413 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12414
12415 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12416 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12417 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12418 {}
12419};
12420
Takashi Iwai18675e42010-09-08 15:55:44 +020012421/*
12422 * Pin config fixes
12423 */
12424enum {
12425 PINFIX_FSC_H270,
12426};
12427
12428static const struct alc_fixup alc262_fixups[] = {
12429 [PINFIX_FSC_H270] = {
12430 .pins = (const struct alc_pincfg[]) {
12431 { 0x14, 0x99130110 }, /* speaker */
12432 { 0x15, 0x0221142f }, /* front HP */
12433 { 0x1b, 0x0121141f }, /* rear HP */
12434 { }
12435 }
12436 },
12437 [PINFIX_PB_M5210] = {
12438 .verbs = (const struct hda_verb[]) {
12439 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
12440 {}
12441 }
12442 },
12443};
12444
12445static struct snd_pci_quirk alc262_fixup_tbl[] = {
12446 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12447 {}
12448};
12449
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012450
Takashi Iwaicb53c622007-08-10 17:21:45 +020012451#ifdef CONFIG_SND_HDA_POWER_SAVE
12452#define alc262_loopbacks alc880_loopbacks
12453#endif
12454
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012455/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012456#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12457#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12458#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12459#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12460
12461/*
12462 * BIOS auto configuration
12463 */
12464static int alc262_parse_auto_config(struct hda_codec *codec)
12465{
12466 struct alc_spec *spec = codec->spec;
12467 int err;
12468 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12469
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012470 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12471 alc262_ignore);
12472 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012473 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012474 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012475 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012476 spec->multiout.max_channels = 2;
12477 spec->no_analog = 1;
12478 goto dig_only;
12479 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012480 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012481 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012482 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12483 if (err < 0)
12484 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012485 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012486 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012487 return err;
12488
12489 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12490
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012491 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012492 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012493
Takashi Iwai603c4012008-07-30 15:01:44 +020012494 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012495 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012496
Takashi Iwaid88897e2008-10-31 15:01:37 +010012497 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012498 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012499 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012500
Takashi Iwai776e1842007-08-29 15:07:11 +020012501 err = alc_auto_add_mic_boost(codec);
12502 if (err < 0)
12503 return err;
12504
Kailang Yang6227cdc2010-02-25 08:36:52 +010012505 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012506
Kailang Yangdf694da2005-12-05 19:42:22 +010012507 return 1;
12508}
12509
12510#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12511#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12512#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012513#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012514
12515
12516/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012517static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012518{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012519 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012520 alc262_auto_init_multi_out(codec);
12521 alc262_auto_init_hp_out(codec);
12522 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012523 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012524 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012525 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012526 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012527}
12528
12529/*
12530 * configuration and preset
12531 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012532static const char *alc262_models[ALC262_MODEL_LAST] = {
12533 [ALC262_BASIC] = "basic",
12534 [ALC262_HIPPO] = "hippo",
12535 [ALC262_HIPPO_1] = "hippo_1",
12536 [ALC262_FUJITSU] = "fujitsu",
12537 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012538 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012539 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012540 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012541 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012542 [ALC262_BENQ_T31] = "benq-t31",
12543 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012544 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012545 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012546 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012547 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012548 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012549 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012550 [ALC262_AUTO] = "auto",
12551};
12552
12553static struct snd_pci_quirk alc262_cfg_tbl[] = {
12554 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012555 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012556 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12557 ALC262_HP_BPC),
12558 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12559 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012560 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12561 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012562 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012563 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012564 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012565 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012566 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012567 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012568 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012569 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012570 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12571 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12572 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012573 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12574 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012575 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012576 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012577 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012578 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012579 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012580 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012581 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012582 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012583#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012584 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12585 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012586#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012587 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012588 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012589 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012590 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012591 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012592 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012593 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12594 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012595 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012596 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012597 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012598 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012599 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012600 {}
12601};
12602
12603static struct alc_config_preset alc262_presets[] = {
12604 [ALC262_BASIC] = {
12605 .mixers = { alc262_base_mixer },
12606 .init_verbs = { alc262_init_verbs },
12607 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12608 .dac_nids = alc262_dac_nids,
12609 .hp_nid = 0x03,
12610 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12611 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012612 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012613 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012614 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012615 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012616 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012617 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12618 .dac_nids = alc262_dac_nids,
12619 .hp_nid = 0x03,
12620 .dig_out_nid = ALC262_DIGOUT_NID,
12621 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12622 .channel_mode = alc262_modes,
12623 .input_mux = &alc262_capture_source,
12624 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012625 .setup = alc262_hippo_setup,
12626 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012627 },
12628 [ALC262_HIPPO_1] = {
12629 .mixers = { alc262_hippo1_mixer },
12630 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12631 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12632 .dac_nids = alc262_dac_nids,
12633 .hp_nid = 0x02,
12634 .dig_out_nid = ALC262_DIGOUT_NID,
12635 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12636 .channel_mode = alc262_modes,
12637 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012638 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012639 .setup = alc262_hippo1_setup,
12640 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012641 },
Takashi Iwai834be882006-03-01 14:16:17 +010012642 [ALC262_FUJITSU] = {
12643 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012644 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12645 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012646 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12647 .dac_nids = alc262_dac_nids,
12648 .hp_nid = 0x03,
12649 .dig_out_nid = ALC262_DIGOUT_NID,
12650 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12651 .channel_mode = alc262_modes,
12652 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012653 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012654 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012655 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012656 [ALC262_HP_BPC] = {
12657 .mixers = { alc262_HP_BPC_mixer },
12658 .init_verbs = { alc262_HP_BPC_init_verbs },
12659 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12660 .dac_nids = alc262_dac_nids,
12661 .hp_nid = 0x03,
12662 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12663 .channel_mode = alc262_modes,
12664 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012665 .unsol_event = alc262_hp_bpc_unsol_event,
12666 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012667 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012668 [ALC262_HP_BPC_D7000_WF] = {
12669 .mixers = { alc262_HP_BPC_WildWest_mixer },
12670 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12671 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12672 .dac_nids = alc262_dac_nids,
12673 .hp_nid = 0x03,
12674 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12675 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012676 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012677 .unsol_event = alc262_hp_wildwest_unsol_event,
12678 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012679 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012680 [ALC262_HP_BPC_D7000_WL] = {
12681 .mixers = { alc262_HP_BPC_WildWest_mixer,
12682 alc262_HP_BPC_WildWest_option_mixer },
12683 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12684 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12685 .dac_nids = alc262_dac_nids,
12686 .hp_nid = 0x03,
12687 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12688 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012689 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012690 .unsol_event = alc262_hp_wildwest_unsol_event,
12691 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012692 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012693 [ALC262_HP_TC_T5735] = {
12694 .mixers = { alc262_hp_t5735_mixer },
12695 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12696 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12697 .dac_nids = alc262_dac_nids,
12698 .hp_nid = 0x03,
12699 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12700 .channel_mode = alc262_modes,
12701 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012702 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012703 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012704 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012705 },
12706 [ALC262_HP_RP5700] = {
12707 .mixers = { alc262_hp_rp5700_mixer },
12708 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12709 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12710 .dac_nids = alc262_dac_nids,
12711 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12712 .channel_mode = alc262_modes,
12713 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012714 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012715 [ALC262_BENQ_ED8] = {
12716 .mixers = { alc262_base_mixer },
12717 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12718 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12719 .dac_nids = alc262_dac_nids,
12720 .hp_nid = 0x03,
12721 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12722 .channel_mode = alc262_modes,
12723 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012724 },
Kailang Yang272a5272007-05-14 11:00:38 +020012725 [ALC262_SONY_ASSAMD] = {
12726 .mixers = { alc262_sony_mixer },
12727 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12728 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12729 .dac_nids = alc262_dac_nids,
12730 .hp_nid = 0x02,
12731 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12732 .channel_mode = alc262_modes,
12733 .input_mux = &alc262_capture_source,
12734 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012735 .setup = alc262_hippo_setup,
12736 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012737 },
12738 [ALC262_BENQ_T31] = {
12739 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012740 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12741 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012742 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12743 .dac_nids = alc262_dac_nids,
12744 .hp_nid = 0x03,
12745 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12746 .channel_mode = alc262_modes,
12747 .input_mux = &alc262_capture_source,
12748 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012749 .setup = alc262_hippo_setup,
12750 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012751 },
Tobin Davisf651b502007-10-26 12:40:47 +020012752 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012753 .mixers = { alc262_ultra_mixer },
12754 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012755 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012756 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12757 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012758 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12759 .channel_mode = alc262_modes,
12760 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012761 .adc_nids = alc262_adc_nids, /* ADC0 */
12762 .capsrc_nids = alc262_capsrc_nids,
12763 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012764 .unsol_event = alc262_ultra_unsol_event,
12765 .init_hook = alc262_ultra_automute,
12766 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012767 [ALC262_LENOVO_3000] = {
12768 .mixers = { alc262_lenovo_3000_mixer },
12769 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012770 alc262_lenovo_3000_unsol_verbs,
12771 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012772 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12773 .dac_nids = alc262_dac_nids,
12774 .hp_nid = 0x03,
12775 .dig_out_nid = ALC262_DIGOUT_NID,
12776 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12777 .channel_mode = alc262_modes,
12778 .input_mux = &alc262_fujitsu_capture_source,
12779 .unsol_event = alc262_lenovo_3000_unsol_event,
12780 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012781 [ALC262_NEC] = {
12782 .mixers = { alc262_nec_mixer },
12783 .init_verbs = { alc262_nec_verbs },
12784 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12785 .dac_nids = alc262_dac_nids,
12786 .hp_nid = 0x03,
12787 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12788 .channel_mode = alc262_modes,
12789 .input_mux = &alc262_capture_source,
12790 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012791 [ALC262_TOSHIBA_S06] = {
12792 .mixers = { alc262_toshiba_s06_mixer },
12793 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12794 alc262_eapd_verbs },
12795 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12796 .capsrc_nids = alc262_dmic_capsrc_nids,
12797 .dac_nids = alc262_dac_nids,
12798 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012799 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012800 .dig_out_nid = ALC262_DIGOUT_NID,
12801 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12802 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012803 .unsol_event = alc_sku_unsol_event,
12804 .setup = alc262_toshiba_s06_setup,
12805 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012806 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012807 [ALC262_TOSHIBA_RX1] = {
12808 .mixers = { alc262_toshiba_rx1_mixer },
12809 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12810 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12811 .dac_nids = alc262_dac_nids,
12812 .hp_nid = 0x03,
12813 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12814 .channel_mode = alc262_modes,
12815 .input_mux = &alc262_capture_source,
12816 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012817 .setup = alc262_hippo_setup,
12818 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012819 },
Tony Vroonba340e82009-02-02 19:01:30 +000012820 [ALC262_TYAN] = {
12821 .mixers = { alc262_tyan_mixer },
12822 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12823 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12824 .dac_nids = alc262_dac_nids,
12825 .hp_nid = 0x02,
12826 .dig_out_nid = ALC262_DIGOUT_NID,
12827 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12828 .channel_mode = alc262_modes,
12829 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012830 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012831 .setup = alc262_tyan_setup,
12832 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012833 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012834};
12835
12836static int patch_alc262(struct hda_codec *codec)
12837{
12838 struct alc_spec *spec;
12839 int board_config;
12840 int err;
12841
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012842 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012843 if (spec == NULL)
12844 return -ENOMEM;
12845
12846 codec->spec = spec;
12847#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012848 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12849 * under-run
12850 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012851 {
12852 int tmp;
12853 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12854 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12855 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12856 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12857 }
12858#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012859 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012860
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012861 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12862
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012863 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12864 alc262_models,
12865 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012866
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012867 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012868 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12869 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012870 board_config = ALC262_AUTO;
12871 }
12872
Takashi Iwai18675e42010-09-08 15:55:44 +020012873 if (board_config == ALC262_AUTO)
12874 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 1);
12875
Kailang Yangdf694da2005-12-05 19:42:22 +010012876 if (board_config == ALC262_AUTO) {
12877 /* automatic parse from the BIOS config */
12878 err = alc262_parse_auto_config(codec);
12879 if (err < 0) {
12880 alc_free(codec);
12881 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012882 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012883 printk(KERN_INFO
12884 "hda_codec: Cannot set up configuration "
12885 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012886 board_config = ALC262_BASIC;
12887 }
12888 }
12889
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012890 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012891 err = snd_hda_attach_beep_device(codec, 0x1);
12892 if (err < 0) {
12893 alc_free(codec);
12894 return err;
12895 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012896 }
12897
Kailang Yangdf694da2005-12-05 19:42:22 +010012898 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012899 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012900
Kailang Yangdf694da2005-12-05 19:42:22 +010012901 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12902 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012903
Kailang Yangdf694da2005-12-05 19:42:22 +010012904 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12905 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12906
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012907 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012908 int i;
12909 /* check whether the digital-mic has to be supported */
12910 for (i = 0; i < spec->input_mux->num_items; i++) {
12911 if (spec->input_mux->items[i].index >= 9)
12912 break;
12913 }
12914 if (i < spec->input_mux->num_items) {
12915 /* use only ADC0 */
12916 spec->adc_nids = alc262_dmic_adc_nids;
12917 spec->num_adc_nids = 1;
12918 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012919 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012920 /* all analog inputs */
12921 /* check whether NID 0x07 is valid */
12922 unsigned int wcap = get_wcaps(codec, 0x07);
12923
12924 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012925 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012926 if (wcap != AC_WID_AUD_IN) {
12927 spec->adc_nids = alc262_adc_nids_alt;
12928 spec->num_adc_nids =
12929 ARRAY_SIZE(alc262_adc_nids_alt);
12930 spec->capsrc_nids = alc262_capsrc_nids_alt;
12931 } else {
12932 spec->adc_nids = alc262_adc_nids;
12933 spec->num_adc_nids =
12934 ARRAY_SIZE(alc262_adc_nids);
12935 spec->capsrc_nids = alc262_capsrc_nids;
12936 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012937 }
12938 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012939 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012940 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012941 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012942 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012943
Takashi Iwai18675e42010-09-08 15:55:44 +020012944 if (board_config == ALC262_AUTO)
12945 alc_pick_fixup(codec, alc262_fixup_tbl, alc262_fixups, 0);
12946
Takashi Iwai2134ea42008-01-10 16:53:55 +010012947 spec->vmaster_nid = 0x0c;
12948
Kailang Yangdf694da2005-12-05 19:42:22 +010012949 codec->patch_ops = alc_patch_ops;
12950 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012951 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020012952
12953 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020012954#ifdef CONFIG_SND_HDA_POWER_SAVE
12955 if (!spec->loopback.amplist)
12956 spec->loopback.amplist = alc262_loopbacks;
12957#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012958
Kailang Yangdf694da2005-12-05 19:42:22 +010012959 return 0;
12960}
12961
Kailang Yangdf694da2005-12-05 19:42:22 +010012962/*
Kailang Yanga361d842007-06-05 12:30:55 +020012963 * ALC268 channel source setting (2 channel)
12964 */
12965#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
12966#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020012967
Kailang Yanga361d842007-06-05 12:30:55 +020012968static hda_nid_t alc268_dac_nids[2] = {
12969 /* front, hp */
12970 0x02, 0x03
12971};
12972
12973static hda_nid_t alc268_adc_nids[2] = {
12974 /* ADC0-1 */
12975 0x08, 0x07
12976};
12977
12978static hda_nid_t alc268_adc_nids_alt[1] = {
12979 /* ADC0 */
12980 0x08
12981};
12982
Takashi Iwaie1406342008-02-11 18:32:32 +010012983static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
12984
Kailang Yanga361d842007-06-05 12:30:55 +020012985static struct snd_kcontrol_new alc268_base_mixer[] = {
12986 /* output mixer control */
12987 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
12988 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
12989 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
12990 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai33bf17a2007-08-21 11:51:42 +020012991 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
12992 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
12993 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020012994 { }
12995};
12996
Takashi Iwai42171c12009-05-08 14:11:43 +020012997static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
12998 /* output mixer control */
12999 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13000 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13001 ALC262_HIPPO_MASTER_SWITCH,
13002 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13003 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
13004 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13005 { }
13006};
13007
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013008/* bind Beep switches of both NID 0x0f and 0x10 */
13009static struct hda_bind_ctls alc268_bind_beep_sw = {
13010 .ops = &snd_hda_bind_sw,
13011 .values = {
13012 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13013 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13014 0
13015 },
13016};
13017
13018static struct snd_kcontrol_new alc268_beep_mixer[] = {
13019 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13020 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13021 { }
13022};
13023
Kailang Yangd1a991a2007-08-15 16:21:59 +020013024static struct hda_verb alc268_eapd_verbs[] = {
13025 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13026 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13027 { }
13028};
13029
Takashi Iwaid2738092007-08-16 14:59:45 +020013030/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013031static struct hda_verb alc268_toshiba_verbs[] = {
13032 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13033 { } /* end */
13034};
13035
13036/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013037/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013038static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13039 .ops = &snd_hda_bind_vol,
13040 .values = {
13041 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13042 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13043 0
13044 },
13045};
13046
Takashi Iwai889c4392007-08-23 18:56:52 +020013047/* mute/unmute internal speaker according to the hp jack and mute state */
13048static void alc268_acer_automute(struct hda_codec *codec, int force)
13049{
13050 struct alc_spec *spec = codec->spec;
13051 unsigned int mute;
13052
13053 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013054 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013055 spec->sense_updated = 1;
13056 }
13057 if (spec->jack_present)
13058 mute = HDA_AMP_MUTE; /* mute internal speaker */
13059 else /* unmute internal speaker if necessary */
13060 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13061 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13062 HDA_AMP_MUTE, mute);
13063}
13064
13065
13066/* bind hp and internal speaker mute (with plug check) */
13067static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13068 struct snd_ctl_elem_value *ucontrol)
13069{
13070 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13071 long *valp = ucontrol->value.integer.value;
13072 int change;
13073
Takashi Iwai8de56b72009-07-24 16:51:47 +020013074 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013075 if (change)
13076 alc268_acer_automute(codec, 0);
13077 return change;
13078}
Takashi Iwaid2738092007-08-16 14:59:45 +020013079
Kailang Yang8ef355d2008-08-26 13:10:22 +020013080static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13081 /* output mixer control */
13082 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13083 {
13084 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13085 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013086 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013087 .info = snd_hda_mixer_amp_switch_info,
13088 .get = snd_hda_mixer_amp_switch_get,
13089 .put = alc268_acer_master_sw_put,
13090 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13091 },
13092 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13093 { }
13094};
13095
Takashi Iwaid2738092007-08-16 14:59:45 +020013096static struct snd_kcontrol_new alc268_acer_mixer[] = {
13097 /* output mixer control */
13098 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13099 {
13100 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13101 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013102 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013103 .info = snd_hda_mixer_amp_switch_info,
13104 .get = snd_hda_mixer_amp_switch_get,
13105 .put = alc268_acer_master_sw_put,
13106 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13107 },
Takashi Iwai33bf17a2007-08-21 11:51:42 +020013108 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13109 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13110 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013111 { }
13112};
13113
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013114static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13115 /* output mixer control */
13116 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13117 {
13118 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13119 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013120 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013121 .info = snd_hda_mixer_amp_switch_info,
13122 .get = snd_hda_mixer_amp_switch_get,
13123 .put = alc268_acer_master_sw_put,
13124 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13125 },
13126 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13127 HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
13128 { }
13129};
13130
Kailang Yang8ef355d2008-08-26 13:10:22 +020013131static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13132 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13133 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13134 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13135 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13136 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13137 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13138 { }
13139};
13140
Takashi Iwaid2738092007-08-16 14:59:45 +020013141static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013142 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13143 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13145 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013146 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13147 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013148 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13149 { }
13150};
13151
13152/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013153#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013154#define alc268_toshiba_setup alc262_hippo_setup
13155#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013156
13157static void alc268_acer_unsol_event(struct hda_codec *codec,
13158 unsigned int res)
13159{
Takashi Iwai889c4392007-08-23 18:56:52 +020013160 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013161 return;
13162 alc268_acer_automute(codec, 1);
13163}
13164
Takashi Iwai889c4392007-08-23 18:56:52 +020013165static void alc268_acer_init_hook(struct hda_codec *codec)
13166{
13167 alc268_acer_automute(codec, 1);
13168}
13169
Kailang Yang8ef355d2008-08-26 13:10:22 +020013170/* toggle speaker-output according to the hp-jack state */
13171static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13172{
13173 unsigned int present;
13174 unsigned char bits;
13175
Wu Fengguang864f92b2009-11-18 12:38:02 +080013176 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013177 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013178 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013179 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013180 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013181 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013182}
13183
Kailang Yang8ef355d2008-08-26 13:10:22 +020013184static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13185 unsigned int res)
13186{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013187 switch (res >> 26) {
13188 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013189 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013190 break;
13191 case ALC880_MIC_EVENT:
13192 alc_mic_automute(codec);
13193 break;
13194 }
13195}
13196
13197static void alc268_acer_lc_setup(struct hda_codec *codec)
13198{
13199 struct alc_spec *spec = codec->spec;
13200 spec->ext_mic.pin = 0x18;
13201 spec->ext_mic.mux_idx = 0;
13202 spec->int_mic.pin = 0x12;
13203 spec->int_mic.mux_idx = 6;
13204 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013205}
13206
13207static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13208{
13209 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013210 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013211}
13212
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013213static struct snd_kcontrol_new alc268_dell_mixer[] = {
13214 /* output mixer control */
13215 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13216 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13217 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13218 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13219 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
13220 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
13221 { }
13222};
13223
13224static struct hda_verb alc268_dell_verbs[] = {
13225 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13226 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13227 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013228 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013229 { }
13230};
13231
13232/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013233static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013234{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013235 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013236
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013237 spec->autocfg.hp_pins[0] = 0x15;
13238 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013239 spec->ext_mic.pin = 0x18;
13240 spec->ext_mic.mux_idx = 0;
13241 spec->int_mic.pin = 0x19;
13242 spec->int_mic.mux_idx = 1;
13243 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013244}
13245
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013246static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13247 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13248 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13249 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13250 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13251 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13252 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
13253 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
13254 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
13255 { }
13256};
13257
13258static struct hda_verb alc267_quanta_il1_verbs[] = {
13259 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13260 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13261 { }
13262};
13263
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013264static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013265{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013266 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013267 spec->autocfg.hp_pins[0] = 0x15;
13268 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013269 spec->ext_mic.pin = 0x18;
13270 spec->ext_mic.mux_idx = 0;
13271 spec->int_mic.pin = 0x19;
13272 spec->int_mic.mux_idx = 1;
13273 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013274}
13275
Kailang Yanga361d842007-06-05 12:30:55 +020013276/*
13277 * generic initialization of ADC, input mixers and output mixers
13278 */
13279static struct hda_verb alc268_base_init_verbs[] = {
13280 /* Unmute DAC0-1 and set vol = 0 */
13281 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013282 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013283
13284 /*
13285 * Set up output mixers (0x0c - 0x0e)
13286 */
13287 /* set vol=0 to output mixers */
13288 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013289 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13290
13291 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13292 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13293
13294 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13295 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13296 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13297 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13298 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13299 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13300 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13301 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13302
13303 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13304 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13305 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013307 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013308
13309 /* set PCBEEP vol = 0, mute connections */
13310 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13311 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13312 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013313
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013314 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013315
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013316 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13317 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13318 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013320
Kailang Yanga361d842007-06-05 12:30:55 +020013321 { }
13322};
13323
13324/*
13325 * generic initialization of ADC, input mixers and output mixers
13326 */
13327static struct hda_verb alc268_volume_init_verbs[] = {
13328 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013329 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13330 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013331
13332 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13333 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13334 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13335 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13336 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13337
Kailang Yanga361d842007-06-05 12:30:55 +020013338 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013339 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13340 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13341
13342 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013343 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013344
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013345 /* set PCBEEP vol = 0, mute connections */
13346 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13347 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13348 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013349
13350 { }
13351};
13352
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013353static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13354 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13355 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13356 { } /* end */
13357};
13358
Kailang Yanga361d842007-06-05 12:30:55 +020013359static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13360 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13361 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013362 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013363 { } /* end */
13364};
13365
13366static struct snd_kcontrol_new alc268_capture_mixer[] = {
13367 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13368 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13369 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13370 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013371 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013372 { } /* end */
13373};
13374
13375static struct hda_input_mux alc268_capture_source = {
13376 .num_items = 4,
13377 .items = {
13378 { "Mic", 0x0 },
13379 { "Front Mic", 0x1 },
13380 { "Line", 0x2 },
13381 { "CD", 0x3 },
13382 },
13383};
13384
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013385static struct hda_input_mux alc268_acer_capture_source = {
13386 .num_items = 3,
13387 .items = {
13388 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013389 { "Internal Mic", 0x1 },
13390 { "Line", 0x2 },
13391 },
13392};
13393
13394static struct hda_input_mux alc268_acer_dmic_capture_source = {
13395 .num_items = 3,
13396 .items = {
13397 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013398 { "Internal Mic", 0x6 },
13399 { "Line", 0x2 },
13400 },
13401};
13402
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013403#ifdef CONFIG_SND_DEBUG
13404static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013405 /* Volume widgets */
13406 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13407 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13408 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13409 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13410 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13411 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13412 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13413 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13414 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13415 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13416 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13417 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13418 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013419 /* The below appears problematic on some hardwares */
13420 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013421 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13422 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13423 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13424 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13425
13426 /* Modes for retasking pin widgets */
13427 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13428 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13429 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13430 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13431
13432 /* Controls for GPIO pins, assuming they are configured as outputs */
13433 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13434 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13435 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13436 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13437
13438 /* Switches to allow the digital SPDIF output pin to be enabled.
13439 * The ALC268 does not have an SPDIF input.
13440 */
13441 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13442
13443 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13444 * this output to turn on an external amplifier.
13445 */
13446 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13447 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13448
13449 { } /* end */
13450};
13451#endif
13452
Kailang Yanga361d842007-06-05 12:30:55 +020013453/* create input playback/capture controls for the given pin */
13454static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13455 const char *ctlname, int idx)
13456{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013457 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013458 int err;
13459
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013460 switch (nid) {
13461 case 0x14:
13462 case 0x16:
13463 dac = 0x02;
13464 break;
13465 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013466 case 0x1a: /* ALC259/269 only */
13467 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013468 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013469 dac = 0x03;
13470 break;
13471 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013472 snd_printd(KERN_WARNING "hda_codec: "
13473 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013474 return 0;
13475 }
13476 if (spec->multiout.dac_nids[0] != dac &&
13477 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013478 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013479 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013480 HDA_OUTPUT));
13481 if (err < 0)
13482 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013483 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13484 }
13485
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013486 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013487 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013488 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013489 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013490 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013491 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013492 if (err < 0)
13493 return err;
13494 return 0;
13495}
13496
13497/* add playback controls from the parsed DAC table */
13498static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13499 const struct auto_pin_cfg *cfg)
13500{
13501 hda_nid_t nid;
13502 int err;
13503
Kailang Yanga361d842007-06-05 12:30:55 +020013504 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013505
13506 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013507 if (nid) {
13508 const char *name;
13509 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13510 name = "Speaker";
13511 else
13512 name = "Front";
13513 err = alc268_new_analog_output(spec, nid, name, 0);
13514 if (err < 0)
13515 return err;
13516 }
Kailang Yanga361d842007-06-05 12:30:55 +020013517
13518 nid = cfg->speaker_pins[0];
13519 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013520 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013521 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13522 if (err < 0)
13523 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013524 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013525 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13526 if (err < 0)
13527 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013528 }
13529 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013530 if (nid) {
13531 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13532 if (err < 0)
13533 return err;
13534 }
Kailang Yanga361d842007-06-05 12:30:55 +020013535
13536 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13537 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013538 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013539 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013540 if (err < 0)
13541 return err;
13542 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013543 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013544}
13545
13546/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013547static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013548 const struct auto_pin_cfg *cfg)
13549{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013550 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013551}
13552
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013553static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13554 hda_nid_t nid, int pin_type)
13555{
13556 int idx;
13557
13558 alc_set_pin_output(codec, nid, pin_type);
13559 if (nid == 0x14 || nid == 0x16)
13560 idx = 0;
13561 else
13562 idx = 1;
13563 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13564}
13565
13566static void alc268_auto_init_multi_out(struct hda_codec *codec)
13567{
13568 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013569 int i;
13570
13571 for (i = 0; i < spec->autocfg.line_outs; i++) {
13572 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013573 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13574 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13575 }
13576}
13577
13578static void alc268_auto_init_hp_out(struct hda_codec *codec)
13579{
13580 struct alc_spec *spec = codec->spec;
13581 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013582 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013583
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013584 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13585 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013586 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013587 }
13588 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13589 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013590 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013591 }
13592 if (spec->autocfg.mono_out_pin)
13593 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13594 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013595}
13596
Kailang Yanga361d842007-06-05 12:30:55 +020013597static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13598{
13599 struct alc_spec *spec = codec->spec;
13600 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13601 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13602 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13603 unsigned int dac_vol1, dac_vol2;
13604
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013605 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013606 snd_hda_codec_write(codec, speaker_nid, 0,
13607 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013608 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013609 snd_hda_codec_write(codec, 0x0f, 0,
13610 AC_VERB_SET_AMP_GAIN_MUTE,
13611 AMP_IN_UNMUTE(1));
13612 snd_hda_codec_write(codec, 0x10, 0,
13613 AC_VERB_SET_AMP_GAIN_MUTE,
13614 AMP_IN_UNMUTE(1));
13615 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013616 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013617 snd_hda_codec_write(codec, 0x0f, 0,
13618 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13619 snd_hda_codec_write(codec, 0x10, 0,
13620 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13621 }
13622
13623 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013624 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013625 dac_vol2 = AMP_OUT_ZERO;
13626 else if (line_nid == 0x15)
13627 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013628 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013629 dac_vol2 = AMP_OUT_ZERO;
13630 else if (hp_nid == 0x15)
13631 dac_vol1 = AMP_OUT_ZERO;
13632 if (line_nid != 0x16 || hp_nid != 0x16 ||
13633 spec->autocfg.line_out_pins[1] != 0x16 ||
13634 spec->autocfg.line_out_pins[2] != 0x16)
13635 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13636
13637 snd_hda_codec_write(codec, 0x02, 0,
13638 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13639 snd_hda_codec_write(codec, 0x03, 0,
13640 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13641}
13642
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013643/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013644#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13645#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013646#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013647#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13648
13649/*
13650 * BIOS auto configuration
13651 */
13652static int alc268_parse_auto_config(struct hda_codec *codec)
13653{
13654 struct alc_spec *spec = codec->spec;
13655 int err;
13656 static hda_nid_t alc268_ignore[] = { 0 };
13657
13658 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13659 alc268_ignore);
13660 if (err < 0)
13661 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013662 if (!spec->autocfg.line_outs) {
13663 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13664 spec->multiout.max_channels = 2;
13665 spec->no_analog = 1;
13666 goto dig_only;
13667 }
Kailang Yanga361d842007-06-05 12:30:55 +020013668 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013669 }
Kailang Yanga361d842007-06-05 12:30:55 +020013670 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13671 if (err < 0)
13672 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013673 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013674 if (err < 0)
13675 return err;
13676
13677 spec->multiout.max_channels = 2;
13678
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013679 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013680 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013681 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013682 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013683 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013684
Takashi Iwai892981f2009-03-02 08:04:35 +010013685 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013686 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013687
Takashi Iwaid88897e2008-10-31 15:01:37 +010013688 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013689 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013690 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013691
Takashi Iwai776e1842007-08-29 15:07:11 +020013692 err = alc_auto_add_mic_boost(codec);
13693 if (err < 0)
13694 return err;
13695
Kailang Yang6227cdc2010-02-25 08:36:52 +010013696 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013697
Kailang Yanga361d842007-06-05 12:30:55 +020013698 return 1;
13699}
13700
Kailang Yanga361d842007-06-05 12:30:55 +020013701#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13702
13703/* init callback for auto-configuration model -- overriding the default init */
13704static void alc268_auto_init(struct hda_codec *codec)
13705{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013706 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013707 alc268_auto_init_multi_out(codec);
13708 alc268_auto_init_hp_out(codec);
13709 alc268_auto_init_mono_speaker_out(codec);
13710 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013711 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013712 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013713 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013714}
13715
13716/*
13717 * configuration and preset
13718 */
13719static const char *alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013720 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013721 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013722 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013723 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013724 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013725 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013726 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013727 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013728#ifdef CONFIG_SND_DEBUG
13729 [ALC268_TEST] = "test",
13730#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013731 [ALC268_AUTO] = "auto",
13732};
13733
13734static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013735 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013736 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013737 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013738 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013739 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013740 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13741 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013742 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013743 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13744 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013745 /* almost compatible with toshiba but with optional digital outs;
13746 * auto-probing seems working fine
13747 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013748 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013749 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013750 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013751 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013752 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013753 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013754 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013755 {}
13756};
13757
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013758/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13759static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13760 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13761 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13762 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13763 ALC268_TOSHIBA),
13764 {}
13765};
13766
Kailang Yanga361d842007-06-05 12:30:55 +020013767static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013768 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013769 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13770 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013771 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13772 alc267_quanta_il1_verbs },
13773 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13774 .dac_nids = alc268_dac_nids,
13775 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13776 .adc_nids = alc268_adc_nids_alt,
13777 .hp_nid = 0x03,
13778 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13779 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013780 .unsol_event = alc_sku_unsol_event,
13781 .setup = alc267_quanta_il1_setup,
13782 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013783 },
Kailang Yanga361d842007-06-05 12:30:55 +020013784 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013785 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13786 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013787 .init_verbs = { alc268_base_init_verbs },
13788 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13789 .dac_nids = alc268_dac_nids,
13790 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13791 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013792 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013793 .hp_nid = 0x03,
13794 .dig_out_nid = ALC268_DIGOUT_NID,
13795 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13796 .channel_mode = alc268_modes,
13797 .input_mux = &alc268_capture_source,
13798 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013799 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013800 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013801 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013802 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13803 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013804 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13805 .dac_nids = alc268_dac_nids,
13806 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13807 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013808 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013809 .hp_nid = 0x03,
13810 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13811 .channel_mode = alc268_modes,
13812 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013813 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013814 .setup = alc268_toshiba_setup,
13815 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013816 },
13817 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013818 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013819 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013820 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13821 alc268_acer_verbs },
13822 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13823 .dac_nids = alc268_dac_nids,
13824 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13825 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013826 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013827 .hp_nid = 0x02,
13828 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13829 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013830 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013831 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013832 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013833 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013834 [ALC268_ACER_DMIC] = {
13835 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13836 alc268_beep_mixer },
13837 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13838 alc268_acer_verbs },
13839 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13840 .dac_nids = alc268_dac_nids,
13841 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13842 .adc_nids = alc268_adc_nids_alt,
13843 .capsrc_nids = alc268_capsrc_nids,
13844 .hp_nid = 0x02,
13845 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13846 .channel_mode = alc268_modes,
13847 .input_mux = &alc268_acer_dmic_capture_source,
13848 .unsol_event = alc268_acer_unsol_event,
13849 .init_hook = alc268_acer_init_hook,
13850 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013851 [ALC268_ACER_ASPIRE_ONE] = {
13852 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013853 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013854 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013855 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13856 alc268_acer_aspire_one_verbs },
13857 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13858 .dac_nids = alc268_dac_nids,
13859 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13860 .adc_nids = alc268_adc_nids_alt,
13861 .capsrc_nids = alc268_capsrc_nids,
13862 .hp_nid = 0x03,
13863 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13864 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013865 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013866 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013867 .init_hook = alc268_acer_lc_init_hook,
13868 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013869 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013870 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13871 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013872 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13873 alc268_dell_verbs },
13874 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13875 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013876 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13877 .adc_nids = alc268_adc_nids_alt,
13878 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013879 .hp_nid = 0x02,
13880 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13881 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013882 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013883 .setup = alc268_dell_setup,
13884 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013885 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013886 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013887 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13888 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013889 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13890 alc268_toshiba_verbs },
13891 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13892 .dac_nids = alc268_dac_nids,
13893 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13894 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013895 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013896 .hp_nid = 0x03,
13897 .dig_out_nid = ALC268_DIGOUT_NID,
13898 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13899 .channel_mode = alc268_modes,
13900 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013901 .setup = alc268_toshiba_setup,
13902 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013903 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013904#ifdef CONFIG_SND_DEBUG
13905 [ALC268_TEST] = {
13906 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13907 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13908 alc268_volume_init_verbs },
13909 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13910 .dac_nids = alc268_dac_nids,
13911 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13912 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013913 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013914 .hp_nid = 0x03,
13915 .dig_out_nid = ALC268_DIGOUT_NID,
13916 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13917 .channel_mode = alc268_modes,
13918 .input_mux = &alc268_capture_source,
13919 },
13920#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013921};
13922
13923static int patch_alc268(struct hda_codec *codec)
13924{
13925 struct alc_spec *spec;
13926 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013927 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013928
Julia Lawallef86f582009-12-19 08:18:03 +010013929 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013930 if (spec == NULL)
13931 return -ENOMEM;
13932
13933 codec->spec = spec;
13934
13935 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13936 alc268_models,
13937 alc268_cfg_tbl);
13938
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013939 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13940 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013941 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013942
Kailang Yanga361d842007-06-05 12:30:55 +020013943 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013944 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13945 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013946 board_config = ALC268_AUTO;
13947 }
13948
13949 if (board_config == ALC268_AUTO) {
13950 /* automatic parse from the BIOS config */
13951 err = alc268_parse_auto_config(codec);
13952 if (err < 0) {
13953 alc_free(codec);
13954 return err;
13955 } else if (!err) {
13956 printk(KERN_INFO
13957 "hda_codec: Cannot set up configuration "
13958 "from BIOS. Using base mode...\n");
13959 board_config = ALC268_3ST;
13960 }
13961 }
13962
13963 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020013964 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020013965
Kailang Yanga361d842007-06-05 12:30:55 +020013966 spec->stream_analog_playback = &alc268_pcm_analog_playback;
13967 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010013968 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020013969
Kailang Yanga361d842007-06-05 12:30:55 +020013970 spec->stream_digital_playback = &alc268_pcm_digital_playback;
13971
Takashi Iwai22971e32009-02-10 11:56:44 +010013972 has_beep = 0;
13973 for (i = 0; i < spec->num_mixers; i++) {
13974 if (spec->mixers[i] == alc268_beep_mixer) {
13975 has_beep = 1;
13976 break;
13977 }
13978 }
13979
13980 if (has_beep) {
13981 err = snd_hda_attach_beep_device(codec, 0x1);
13982 if (err < 0) {
13983 alc_free(codec);
13984 return err;
13985 }
13986 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
13987 /* override the amp caps for beep generator */
13988 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013989 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
13990 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
13991 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
13992 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010013993 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013994
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013995 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013996 /* check whether NID 0x07 is valid */
13997 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010013998 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020013999
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014000 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014001 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014002 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014003 if (spec->auto_mic ||
14004 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014005 spec->adc_nids = alc268_adc_nids_alt;
14006 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014007 if (spec->auto_mic)
14008 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014009 if (spec->auto_mic || spec->input_mux->num_items == 1)
14010 add_mixer(spec, alc268_capture_nosrc_mixer);
14011 else
14012 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014013 } else {
14014 spec->adc_nids = alc268_adc_nids;
14015 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014016 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014017 }
Takashi Iwai85860c02008-02-19 15:00:15 +010014018 /* set default input source */
14019 for (i = 0; i < spec->num_adc_nids; i++)
14020 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
14021 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030014022 i < spec->num_mux_defs ?
14023 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010014024 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020014025 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014026
14027 spec->vmaster_nid = 0x02;
14028
Kailang Yanga361d842007-06-05 12:30:55 +020014029 codec->patch_ops = alc_patch_ops;
14030 if (board_config == ALC268_AUTO)
14031 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014032
Kailang Yangbf1b0222010-10-21 08:49:56 +020014033 alc_init_jacks(codec);
14034
Kailang Yanga361d842007-06-05 12:30:55 +020014035 return 0;
14036}
14037
14038/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014039 * ALC269 channel source setting (2 channel)
14040 */
14041#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14042
14043#define alc269_dac_nids alc260_dac_nids
14044
14045static hda_nid_t alc269_adc_nids[1] = {
14046 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014047 0x08,
14048};
14049
Takashi Iwaie01bf502008-08-21 16:25:07 +020014050static hda_nid_t alc269_capsrc_nids[1] = {
14051 0x23,
14052};
14053
Kailang Yang84898e82010-02-04 14:16:14 +010014054static hda_nid_t alc269vb_adc_nids[1] = {
14055 /* ADC1 */
14056 0x09,
14057};
14058
14059static hda_nid_t alc269vb_capsrc_nids[1] = {
14060 0x22,
14061};
14062
Takashi Iwai66946352010-03-29 17:21:45 +020014063static hda_nid_t alc269_adc_candidates[] = {
14064 0x08, 0x09, 0x07,
14065};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014066
Kailang Yangf6a92242007-12-13 16:52:54 +010014067#define alc269_modes alc260_modes
14068#define alc269_capture_source alc880_lg_lw_capture_source
14069
14070static struct snd_kcontrol_new alc269_base_mixer[] = {
14071 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14072 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14073 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14074 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14075 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14076 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14077 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14078 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14079 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14080 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
14081 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14082 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14083 { } /* end */
14084};
14085
Kailang Yang60db6b52008-08-26 13:13:00 +020014086static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14087 /* output mixer control */
14088 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14089 {
14090 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14091 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014092 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014093 .info = snd_hda_mixer_amp_switch_info,
14094 .get = snd_hda_mixer_amp_switch_get,
14095 .put = alc268_acer_master_sw_put,
14096 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14097 },
14098 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14099 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14100 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14101 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14102 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14103 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014104 { }
14105};
14106
Tony Vroon64154832008-11-06 15:08:49 +000014107static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14108 /* output mixer control */
14109 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14110 {
14111 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14112 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014113 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014114 .info = snd_hda_mixer_amp_switch_info,
14115 .get = snd_hda_mixer_amp_switch_get,
14116 .put = alc268_acer_master_sw_put,
14117 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14118 },
14119 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14120 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
14121 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14122 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14123 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
14124 HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
14125 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14126 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
14127 HDA_CODEC_VOLUME("Dock Mic Boost", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014128 { }
14129};
14130
Kailang Yang84898e82010-02-04 14:16:14 +010014131static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014132 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014133 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014134 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014135 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014136 { } /* end */
14137};
14138
Kailang Yang84898e82010-02-04 14:16:14 +010014139static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14140 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14141 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14142 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14143 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14144 { } /* end */
14145};
14146
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014147static struct snd_kcontrol_new alc269_asus_mixer[] = {
14148 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14149 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14150 { } /* end */
14151};
14152
Kailang Yangf6a92242007-12-13 16:52:54 +010014153/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014154static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14155 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14156 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
14157 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14158 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14159 { } /* end */
14160};
14161
14162static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014163 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14164 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014165 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14166 { } /* end */
14167};
14168
Kailang Yang84898e82010-02-04 14:16:14 +010014169static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14170 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14171 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14172 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14173 HDA_CODEC_VOLUME("IntMic Boost", 0x19, 0, HDA_INPUT),
14174 { } /* end */
14175};
14176
14177static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14178 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14179 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
14180 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
14181 { } /* end */
14182};
14183
Takashi Iwai26f5df22008-11-03 17:39:46 +010014184/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014185#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014186
Kailang Yang60db6b52008-08-26 13:13:00 +020014187static struct hda_verb alc269_quanta_fl1_verbs[] = {
14188 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14189 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14190 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14191 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14192 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14193 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14194 { }
14195};
14196
Tony Vroon64154832008-11-06 15:08:49 +000014197static struct hda_verb alc269_lifebook_verbs[] = {
14198 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14199 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14200 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14201 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14202 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14203 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14204 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14205 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14206 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14207 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14208 { }
14209};
14210
Kailang Yang60db6b52008-08-26 13:13:00 +020014211/* toggle speaker-output according to the hp-jack state */
14212static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14213{
14214 unsigned int present;
14215 unsigned char bits;
14216
Wu Fengguang864f92b2009-11-18 12:38:02 +080014217 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014218 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014219 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014220 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014221 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014222 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014223
14224 snd_hda_codec_write(codec, 0x20, 0,
14225 AC_VERB_SET_COEF_INDEX, 0x0c);
14226 snd_hda_codec_write(codec, 0x20, 0,
14227 AC_VERB_SET_PROC_COEF, 0x680);
14228
14229 snd_hda_codec_write(codec, 0x20, 0,
14230 AC_VERB_SET_COEF_INDEX, 0x0c);
14231 snd_hda_codec_write(codec, 0x20, 0,
14232 AC_VERB_SET_PROC_COEF, 0x480);
14233}
14234
Tony Vroon64154832008-11-06 15:08:49 +000014235/* toggle speaker-output according to the hp-jacks state */
14236static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14237{
14238 unsigned int present;
14239 unsigned char bits;
14240
14241 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014242 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014243
14244 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014245 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014246
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014247 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014248 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014249 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014250 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014251 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014252
14253 snd_hda_codec_write(codec, 0x20, 0,
14254 AC_VERB_SET_COEF_INDEX, 0x0c);
14255 snd_hda_codec_write(codec, 0x20, 0,
14256 AC_VERB_SET_PROC_COEF, 0x680);
14257
14258 snd_hda_codec_write(codec, 0x20, 0,
14259 AC_VERB_SET_COEF_INDEX, 0x0c);
14260 snd_hda_codec_write(codec, 0x20, 0,
14261 AC_VERB_SET_PROC_COEF, 0x480);
14262}
14263
Tony Vroon64154832008-11-06 15:08:49 +000014264static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14265{
14266 unsigned int present_laptop;
14267 unsigned int present_dock;
14268
Wu Fengguang864f92b2009-11-18 12:38:02 +080014269 present_laptop = snd_hda_jack_detect(codec, 0x18);
14270 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014271
14272 /* Laptop mic port overrides dock mic port, design decision */
14273 if (present_dock)
14274 snd_hda_codec_write(codec, 0x23, 0,
14275 AC_VERB_SET_CONNECT_SEL, 0x3);
14276 if (present_laptop)
14277 snd_hda_codec_write(codec, 0x23, 0,
14278 AC_VERB_SET_CONNECT_SEL, 0x0);
14279 if (!present_dock && !present_laptop)
14280 snd_hda_codec_write(codec, 0x23, 0,
14281 AC_VERB_SET_CONNECT_SEL, 0x1);
14282}
14283
Kailang Yang60db6b52008-08-26 13:13:00 +020014284static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14285 unsigned int res)
14286{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014287 switch (res >> 26) {
14288 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014289 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014290 break;
14291 case ALC880_MIC_EVENT:
14292 alc_mic_automute(codec);
14293 break;
14294 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014295}
14296
Tony Vroon64154832008-11-06 15:08:49 +000014297static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14298 unsigned int res)
14299{
14300 if ((res >> 26) == ALC880_HP_EVENT)
14301 alc269_lifebook_speaker_automute(codec);
14302 if ((res >> 26) == ALC880_MIC_EVENT)
14303 alc269_lifebook_mic_autoswitch(codec);
14304}
14305
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014306static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14307{
14308 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014309 spec->autocfg.hp_pins[0] = 0x15;
14310 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014311 spec->ext_mic.pin = 0x18;
14312 spec->ext_mic.mux_idx = 0;
14313 spec->int_mic.pin = 0x19;
14314 spec->int_mic.mux_idx = 1;
14315 spec->auto_mic = 1;
14316}
14317
Kailang Yang60db6b52008-08-26 13:13:00 +020014318static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14319{
14320 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014321 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014322}
14323
Tony Vroon64154832008-11-06 15:08:49 +000014324static void alc269_lifebook_init_hook(struct hda_codec *codec)
14325{
14326 alc269_lifebook_speaker_automute(codec);
14327 alc269_lifebook_mic_autoswitch(codec);
14328}
14329
Kailang Yang84898e82010-02-04 14:16:14 +010014330static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014331 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14332 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14333 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14334 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14335 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14336 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14337 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14338 {}
14339};
14340
Kailang Yang84898e82010-02-04 14:16:14 +010014341static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014342 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14343 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14344 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14345 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14346 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14347 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14348 {}
14349};
14350
Kailang Yang84898e82010-02-04 14:16:14 +010014351static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14352 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14353 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14354 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14355 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14356 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14357 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14358 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14359 {}
14360};
14361
14362static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14363 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14364 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14365 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14366 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14367 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14368 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14369 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14370 {}
14371};
14372
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014373static struct hda_verb alc271_acer_dmic_verbs[] = {
14374 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14375 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14376 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14377 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14378 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14379 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14380 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14381 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14382 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14383 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14384 { }
14385};
14386
Kailang Yang60db6b52008-08-26 13:13:00 +020014387/* toggle speaker-output according to the hp-jack state */
14388static void alc269_speaker_automute(struct hda_codec *codec)
14389{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014390 struct alc_spec *spec = codec->spec;
14391 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014392 unsigned int present;
14393 unsigned char bits;
14394
Kailang Yangebb83ee2009-12-17 12:23:00 +010014395 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014396 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014397 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014398 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014399 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014400 HDA_AMP_MUTE, bits);
Kailang Yangbf1b0222010-10-21 08:49:56 +020014401 alc_report_jack(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014402}
14403
Kailang Yang60db6b52008-08-26 13:13:00 +020014404/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014405static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014406 unsigned int res)
14407{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014408 switch (res >> 26) {
14409 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014410 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014411 break;
14412 case ALC880_MIC_EVENT:
14413 alc_mic_automute(codec);
14414 break;
14415 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014416}
14417
Kailang Yang226b1ec2010-04-09 11:01:20 +020014418static void alc269_laptop_amic_setup(struct hda_codec *codec)
14419{
14420 struct alc_spec *spec = codec->spec;
14421 spec->autocfg.hp_pins[0] = 0x15;
14422 spec->autocfg.speaker_pins[0] = 0x14;
14423 spec->ext_mic.pin = 0x18;
14424 spec->ext_mic.mux_idx = 0;
14425 spec->int_mic.pin = 0x19;
14426 spec->int_mic.mux_idx = 1;
14427 spec->auto_mic = 1;
14428}
14429
Kailang Yang84898e82010-02-04 14:16:14 +010014430static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014431{
14432 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014433 spec->autocfg.hp_pins[0] = 0x15;
14434 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014435 spec->ext_mic.pin = 0x18;
14436 spec->ext_mic.mux_idx = 0;
14437 spec->int_mic.pin = 0x12;
14438 spec->int_mic.mux_idx = 5;
14439 spec->auto_mic = 1;
14440}
14441
Kailang Yang226b1ec2010-04-09 11:01:20 +020014442static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014443{
14444 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014445 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014446 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014447 spec->ext_mic.pin = 0x18;
14448 spec->ext_mic.mux_idx = 0;
14449 spec->int_mic.pin = 0x19;
14450 spec->int_mic.mux_idx = 1;
14451 spec->auto_mic = 1;
14452}
14453
Kailang Yang226b1ec2010-04-09 11:01:20 +020014454static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14455{
14456 struct alc_spec *spec = codec->spec;
14457 spec->autocfg.hp_pins[0] = 0x21;
14458 spec->autocfg.speaker_pins[0] = 0x14;
14459 spec->ext_mic.pin = 0x18;
14460 spec->ext_mic.mux_idx = 0;
14461 spec->int_mic.pin = 0x12;
14462 spec->int_mic.mux_idx = 6;
14463 spec->auto_mic = 1;
14464}
14465
Kailang Yang84898e82010-02-04 14:16:14 +010014466static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014467{
14468 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014469 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014470}
14471
Kailang Yangf6a92242007-12-13 16:52:54 +010014472/*
14473 * generic initialization of ADC, input mixers and output mixers
14474 */
14475static struct hda_verb alc269_init_verbs[] = {
14476 /*
14477 * Unmute ADC0 and set the default input to mic-in
14478 */
Kailang Yang84898e82010-02-04 14:16:14 +010014479 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014480
14481 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014482 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014483 */
14484 /* set vol=0 to output mixers */
14485 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14486 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14487
14488 /* set up input amps for analog loopback */
14489 /* Amp Indices: DAC = 0, mixer = 1 */
14490 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14491 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14492 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14493 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14494 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14495 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14496
14497 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14498 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14499 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14500 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14501 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14502 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14503 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14504
14505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14506 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014507
Kailang Yang84898e82010-02-04 14:16:14 +010014508 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014509 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14510 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014511 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014512
14513 /* set EAPD */
14514 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014515 { }
14516};
14517
14518static struct hda_verb alc269vb_init_verbs[] = {
14519 /*
14520 * Unmute ADC0 and set the default input to mic-in
14521 */
14522 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14523
14524 /*
14525 * Set up output mixers (0x02 - 0x03)
14526 */
14527 /* set vol=0 to output mixers */
14528 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14529 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14530
14531 /* set up input amps for analog loopback */
14532 /* Amp Indices: DAC = 0, mixer = 1 */
14533 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14534 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14535 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14536 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14537 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14538 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14539
14540 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14541 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14542 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14543 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14544 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14545 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14546 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14547
14548 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14549 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14550
14551 /* FIXME: use Mux-type input source selection */
14552 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14553 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14554 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14555
14556 /* set EAPD */
14557 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014558 { }
14559};
14560
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014561#define alc269_auto_create_multi_out_ctls \
14562 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014563#define alc269_auto_create_input_ctls \
14564 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014565
14566#ifdef CONFIG_SND_HDA_POWER_SAVE
14567#define alc269_loopbacks alc880_loopbacks
14568#endif
14569
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014570/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014571#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14572#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14573#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14574#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14575
Takashi Iwaif03d3112009-03-05 14:18:16 +010014576static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14577 .substreams = 1,
14578 .channels_min = 2,
14579 .channels_max = 8,
14580 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14581 /* NID is set in alc_build_pcms */
14582 .ops = {
14583 .open = alc880_playback_pcm_open,
14584 .prepare = alc880_playback_pcm_prepare,
14585 .cleanup = alc880_playback_pcm_cleanup
14586 },
14587};
14588
14589static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14590 .substreams = 1,
14591 .channels_min = 2,
14592 .channels_max = 2,
14593 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14594 /* NID is set in alc_build_pcms */
14595};
14596
Takashi Iwaiad358792010-03-30 18:00:59 +020014597#ifdef CONFIG_SND_HDA_POWER_SAVE
14598static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14599{
14600 switch (codec->subsystem_id) {
14601 case 0x103c1586:
14602 return 1;
14603 }
14604 return 0;
14605}
14606
14607static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14608{
14609 /* update mute-LED according to the speaker mute state */
14610 if (nid == 0x01 || nid == 0x14) {
14611 int pinval;
14612 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14613 HDA_AMP_MUTE)
14614 pinval = 0x24;
14615 else
14616 pinval = 0x20;
14617 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014618 snd_hda_codec_update_cache(codec, 0x19, 0,
14619 AC_VERB_SET_PIN_WIDGET_CONTROL,
14620 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014621 }
14622 return alc_check_power_status(codec, nid);
14623}
14624#endif /* CONFIG_SND_HDA_POWER_SAVE */
14625
Takashi Iwai840b64c2010-07-13 22:49:01 +020014626static int alc275_setup_dual_adc(struct hda_codec *codec)
14627{
14628 struct alc_spec *spec = codec->spec;
14629
14630 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14631 return 0;
14632 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14633 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14634 if (spec->ext_mic.pin <= 0x12) {
14635 spec->private_adc_nids[0] = 0x08;
14636 spec->private_adc_nids[1] = 0x11;
14637 spec->private_capsrc_nids[0] = 0x23;
14638 spec->private_capsrc_nids[1] = 0x22;
14639 } else {
14640 spec->private_adc_nids[0] = 0x11;
14641 spec->private_adc_nids[1] = 0x08;
14642 spec->private_capsrc_nids[0] = 0x22;
14643 spec->private_capsrc_nids[1] = 0x23;
14644 }
14645 spec->adc_nids = spec->private_adc_nids;
14646 spec->capsrc_nids = spec->private_capsrc_nids;
14647 spec->num_adc_nids = 2;
14648 spec->dual_adc_switch = 1;
14649 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14650 spec->adc_nids[0], spec->adc_nids[1]);
14651 return 1;
14652 }
14653 return 0;
14654}
14655
Takashi Iwaid433a672010-09-20 15:11:54 +020014656/* different alc269-variants */
14657enum {
14658 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014659 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014660 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014661 ALC269_TYPE_ALC269VB,
14662 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014663 ALC269_TYPE_ALC271X,
14664};
14665
Kailang Yangf6a92242007-12-13 16:52:54 +010014666/*
14667 * BIOS auto configuration
14668 */
14669static int alc269_parse_auto_config(struct hda_codec *codec)
14670{
14671 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014672 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014673 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14674
14675 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14676 alc269_ignore);
14677 if (err < 0)
14678 return err;
14679
14680 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14681 if (err < 0)
14682 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014683 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14684 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14685 else
14686 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14687 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014688 if (err < 0)
14689 return err;
14690
14691 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14692
Takashi Iwai757899a2010-07-30 10:48:14 +020014693 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014694
Takashi Iwai603c4012008-07-30 15:01:44 +020014695 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014696 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014697
Takashi Iwaid433a672010-09-20 15:11:54 +020014698 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014699 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014700 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014701 } else {
14702 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014703 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014704 }
14705
Kailang Yangf6a92242007-12-13 16:52:54 +010014706 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014707 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014708
14709 if (!alc275_setup_dual_adc(codec))
14710 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14711 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014712
Takashi Iwaie01bf502008-08-21 16:25:07 +020014713 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014714 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014715 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14716 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014717
14718 err = alc_auto_add_mic_boost(codec);
14719 if (err < 0)
14720 return err;
14721
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014722 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014723 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014724
Kailang Yangf6a92242007-12-13 16:52:54 +010014725 return 1;
14726}
14727
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014728#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14729#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014730#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14731
14732
14733/* init callback for auto-configuration model -- overriding the default init */
14734static void alc269_auto_init(struct hda_codec *codec)
14735{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014736 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014737 alc269_auto_init_multi_out(codec);
14738 alc269_auto_init_hp_out(codec);
14739 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014740 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014741 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014742 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014743}
14744
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014745#ifdef SND_HDA_NEEDS_RESUME
14746static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14747{
14748 int val = alc_read_coef_idx(codec, 0x04);
14749 if (power_up)
14750 val |= 1 << 11;
14751 else
14752 val &= ~(1 << 11);
14753 alc_write_coef_idx(codec, 0x04, val);
14754}
14755
Kailang Yang977ddd62010-09-15 10:02:29 +020014756#ifdef CONFIG_SND_HDA_POWER_SAVE
14757static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14758{
14759 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014760
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014761 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14762 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014763 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014764 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014765 msleep(150);
14766 }
14767
14768 alc_shutup(codec);
14769 if (spec && spec->power_hook)
14770 spec->power_hook(codec);
14771 return 0;
14772}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014773#endif /* CONFIG_SND_HDA_POWER_SAVE */
14774
Kailang Yang977ddd62010-09-15 10:02:29 +020014775static int alc269_resume(struct hda_codec *codec)
14776{
Kailang Yang977ddd62010-09-15 10:02:29 +020014777 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014778 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014779 msleep(150);
14780 }
14781
14782 codec->patch_ops.init(codec);
14783
14784 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014785 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014786 msleep(200);
14787 }
14788
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014789 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14790 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014791
14792 snd_hda_codec_resume_amp(codec);
14793 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014794 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014795 return 0;
14796}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014797#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014798
Takashi Iwaiff818c22010-04-12 08:59:25 +020014799enum {
14800 ALC269_FIXUP_SONY_VAIO,
David Henningsson145a9022010-09-16 10:07:53 +020014801 ALC269_FIXUP_DELL_M101Z,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014802};
14803
Takashi Iwaiff818c22010-04-12 08:59:25 +020014804static const struct alc_fixup alc269_fixups[] = {
14805 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020014806 .verbs = (const struct hda_verb[]) {
14807 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14808 {}
14809 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014810 },
David Henningsson145a9022010-09-16 10:07:53 +020014811 [ALC269_FIXUP_DELL_M101Z] = {
14812 .verbs = (const struct hda_verb[]) {
14813 /* Enables internal speaker */
14814 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14815 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14816 {}
14817 }
14818 },
Takashi Iwaiff818c22010-04-12 08:59:25 +020014819};
14820
14821static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwaiabdd8f52010-09-21 17:38:14 +020014822 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014823 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014824 {}
14825};
14826
14827
Kailang Yangf6a92242007-12-13 16:52:54 +010014828/*
14829 * configuration and preset
14830 */
14831static const char *alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014832 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014833 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014834 [ALC269_AMIC] = "laptop-amic",
14835 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014836 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014837 [ALC269_LIFEBOOK] = "lifebook",
14838 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014839};
14840
14841static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014842 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014843 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014844 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014845 ALC269_AMIC),
14846 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14847 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14848 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14849 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14850 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14851 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14852 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14853 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14854 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
14855 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82Jv", ALC269_AMIC),
14856 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14857 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14858 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14859 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14860 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14861 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14862 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14863 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14864 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14865 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14866 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14867 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14868 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14869 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14870 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14871 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14872 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14873 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14874 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14875 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14876 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14877 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14878 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14879 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14880 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14881 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014882 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014883 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014884 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014885 ALC269_DMIC),
14886 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14887 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014888 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014889 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014890 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14891 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14892 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14893 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14894 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14895 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010014896 {}
14897};
14898
14899static struct alc_config_preset alc269_presets[] = {
14900 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010014901 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010014902 .init_verbs = { alc269_init_verbs },
14903 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14904 .dac_nids = alc269_dac_nids,
14905 .hp_nid = 0x03,
14906 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14907 .channel_mode = alc269_modes,
14908 .input_mux = &alc269_capture_source,
14909 },
Kailang Yang60db6b52008-08-26 13:13:00 +020014910 [ALC269_QUANTA_FL1] = {
14911 .mixers = { alc269_quanta_fl1_mixer },
14912 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
14913 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14914 .dac_nids = alc269_dac_nids,
14915 .hp_nid = 0x03,
14916 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14917 .channel_mode = alc269_modes,
14918 .input_mux = &alc269_capture_source,
14919 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014920 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020014921 .init_hook = alc269_quanta_fl1_init_hook,
14922 },
Kailang Yang84898e82010-02-04 14:16:14 +010014923 [ALC269_AMIC] = {
14924 .mixers = { alc269_laptop_mixer },
14925 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014926 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014927 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014928 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14929 .dac_nids = alc269_dac_nids,
14930 .hp_nid = 0x03,
14931 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14932 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014933 .unsol_event = alc269_laptop_unsol_event,
14934 .setup = alc269_laptop_amic_setup,
14935 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014936 },
Kailang Yang84898e82010-02-04 14:16:14 +010014937 [ALC269_DMIC] = {
14938 .mixers = { alc269_laptop_mixer },
14939 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020014940 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014941 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020014942 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14943 .dac_nids = alc269_dac_nids,
14944 .hp_nid = 0x03,
14945 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14946 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014947 .unsol_event = alc269_laptop_unsol_event,
14948 .setup = alc269_laptop_dmic_setup,
14949 .init_hook = alc269_laptop_inithook,
14950 },
14951 [ALC269VB_AMIC] = {
14952 .mixers = { alc269vb_laptop_mixer },
14953 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
14954 .init_verbs = { alc269vb_init_verbs,
14955 alc269vb_laptop_amic_init_verbs },
14956 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14957 .dac_nids = alc269_dac_nids,
14958 .hp_nid = 0x03,
14959 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14960 .channel_mode = alc269_modes,
14961 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020014962 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010014963 .init_hook = alc269_laptop_inithook,
14964 },
14965 [ALC269VB_DMIC] = {
14966 .mixers = { alc269vb_laptop_mixer },
14967 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
14968 .init_verbs = { alc269vb_init_verbs,
14969 alc269vb_laptop_dmic_init_verbs },
14970 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14971 .dac_nids = alc269_dac_nids,
14972 .hp_nid = 0x03,
14973 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14974 .channel_mode = alc269_modes,
14975 .unsol_event = alc269_laptop_unsol_event,
14976 .setup = alc269vb_laptop_dmic_setup,
14977 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020014978 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014979 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010014980 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010014981 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014982 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010014983 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010014984 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14985 .dac_nids = alc269_dac_nids,
14986 .hp_nid = 0x03,
14987 .num_channel_mode = ARRAY_SIZE(alc269_modes),
14988 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010014989 .unsol_event = alc269_laptop_unsol_event,
14990 .setup = alc269_laptop_dmic_setup,
14991 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010014992 },
Tony Vroon64154832008-11-06 15:08:49 +000014993 [ALC269_LIFEBOOK] = {
14994 .mixers = { alc269_lifebook_mixer },
14995 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
14996 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
14997 .dac_nids = alc269_dac_nids,
14998 .hp_nid = 0x03,
14999 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15000 .channel_mode = alc269_modes,
15001 .input_mux = &alc269_capture_source,
15002 .unsol_event = alc269_lifebook_unsol_event,
15003 .init_hook = alc269_lifebook_init_hook,
15004 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015005 [ALC271_ACER] = {
15006 .mixers = { alc269_asus_mixer },
15007 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15008 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15009 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15010 .dac_nids = alc269_dac_nids,
15011 .adc_nids = alc262_dmic_adc_nids,
15012 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15013 .capsrc_nids = alc262_dmic_capsrc_nids,
15014 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15015 .channel_mode = alc269_modes,
15016 .input_mux = &alc269_capture_source,
15017 .dig_out_nid = ALC880_DIGOUT_NID,
15018 .unsol_event = alc_sku_unsol_event,
15019 .setup = alc269vb_laptop_dmic_setup,
15020 .init_hook = alc_inithook,
15021 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015022};
15023
Kailang Yang977ddd62010-09-15 10:02:29 +020015024static int alc269_fill_coef(struct hda_codec *codec)
15025{
15026 int val;
15027
15028 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15029 alc_write_coef_idx(codec, 0xf, 0x960b);
15030 alc_write_coef_idx(codec, 0xe, 0x8817);
15031 }
15032
15033 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15034 alc_write_coef_idx(codec, 0xf, 0x960b);
15035 alc_write_coef_idx(codec, 0xe, 0x8814);
15036 }
15037
15038 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15039 val = alc_read_coef_idx(codec, 0x04);
15040 /* Power up output pin */
15041 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15042 }
15043
15044 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15045 val = alc_read_coef_idx(codec, 0xd);
15046 if ((val & 0x0c00) >> 10 != 0x1) {
15047 /* Capless ramp up clock control */
15048 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15049 }
15050 val = alc_read_coef_idx(codec, 0x17);
15051 if ((val & 0x01c0) >> 6 != 0x4) {
15052 /* Class D power on reset */
15053 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15054 }
15055 }
15056 return 0;
15057}
15058
Kailang Yangf6a92242007-12-13 16:52:54 +010015059static int patch_alc269(struct hda_codec *codec)
15060{
15061 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015062 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015063 int err;
15064
15065 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15066 if (spec == NULL)
15067 return -ENOMEM;
15068
15069 codec->spec = spec;
15070
Kailang Yangda00c242010-03-19 11:23:45 +010015071 alc_auto_parse_customize_define(codec);
15072
Kailang Yang48c88e82010-11-23 08:56:16 +010015073 coef = alc_read_coef_idx(codec, 0);
15074 if ((coef & 0x00f0) == 0x0010) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015075 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
Takashi Iwaid433a672010-09-20 15:11:54 +020015076 spec->cdefine.platform_type == 1) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015077 alc_codec_rename(codec, "ALC271X");
Takashi Iwaid433a672010-09-20 15:11:54 +020015078 spec->codec_variant = ALC269_TYPE_ALC271X;
Kailang Yang48c88e82010-11-23 08:56:16 +010015079 } else if ((coef & 0xf000) == 0x1000) {
15080 spec->codec_variant = ALC269_TYPE_ALC270;
15081 } else if ((coef & 0xf000) == 0x2000) {
Kailang Yangc027ddc2010-03-19 11:33:06 +010015082 alc_codec_rename(codec, "ALC259");
Takashi Iwaid433a672010-09-20 15:11:54 +020015083 spec->codec_variant = ALC269_TYPE_ALC259;
Kailang Yang48c88e82010-11-23 08:56:16 +010015084 } else if ((coef & 0xf000) == 0x3000) {
15085 alc_codec_rename(codec, "ALC258");
15086 spec->codec_variant = ALC269_TYPE_ALC258;
15087 } else {
15088 alc_codec_rename(codec, "ALC269VB");
15089 spec->codec_variant = ALC269_TYPE_ALC269VB;
Takashi Iwaid433a672010-09-20 15:11:54 +020015090 }
Kailang Yangc027ddc2010-03-19 11:33:06 +010015091 } else
15092 alc_fix_pll_init(codec, 0x20, 0x04, 15);
Kailang Yang274693f2009-12-03 10:07:50 +010015093
Kailang Yang977ddd62010-09-15 10:02:29 +020015094 alc269_fill_coef(codec);
15095
Kailang Yangf6a92242007-12-13 16:52:54 +010015096 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15097 alc269_models,
15098 alc269_cfg_tbl);
15099
15100 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015101 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15102 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015103 board_config = ALC269_AUTO;
15104 }
15105
Takashi Iwaiff818c22010-04-12 08:59:25 +020015106 if (board_config == ALC269_AUTO)
15107 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 1);
15108
Kailang Yangf6a92242007-12-13 16:52:54 +010015109 if (board_config == ALC269_AUTO) {
15110 /* automatic parse from the BIOS config */
15111 err = alc269_parse_auto_config(codec);
15112 if (err < 0) {
15113 alc_free(codec);
15114 return err;
15115 } else if (!err) {
15116 printk(KERN_INFO
15117 "hda_codec: Cannot set up configuration "
15118 "from BIOS. Using base mode...\n");
15119 board_config = ALC269_BASIC;
15120 }
15121 }
15122
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015123 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015124 err = snd_hda_attach_beep_device(codec, 0x1);
15125 if (err < 0) {
15126 alc_free(codec);
15127 return err;
15128 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015129 }
15130
Kailang Yangf6a92242007-12-13 16:52:54 +010015131 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015132 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015133
Kailang Yang84898e82010-02-04 14:16:14 +010015134 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015135 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15136 * fix the sample rate of analog I/O to 44.1kHz
15137 */
15138 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15139 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015140 } else if (spec->dual_adc_switch) {
15141 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15142 /* switch ADC dynamically */
15143 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015144 } else {
15145 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15146 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15147 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015148 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15149 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15150
Takashi Iwai66946352010-03-29 17:21:45 +020015151 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015152 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015153 spec->adc_nids = alc269_adc_nids;
15154 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15155 spec->capsrc_nids = alc269_capsrc_nids;
15156 } else {
15157 spec->adc_nids = alc269vb_adc_nids;
15158 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15159 spec->capsrc_nids = alc269vb_capsrc_nids;
15160 }
Kailang Yang84898e82010-02-04 14:16:14 +010015161 }
15162
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015163 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015164 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015165 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015166 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015167
Takashi Iwaiff818c22010-04-12 08:59:25 +020015168 if (board_config == ALC269_AUTO)
15169 alc_pick_fixup(codec, alc269_fixup_tbl, alc269_fixups, 0);
15170
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015171 spec->vmaster_nid = 0x02;
15172
Kailang Yangf6a92242007-12-13 16:52:54 +010015173 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015174#ifdef CONFIG_SND_HDA_POWER_SAVE
15175 codec->patch_ops.suspend = alc269_suspend;
15176#endif
15177#ifdef SND_HDA_NEEDS_RESUME
15178 codec->patch_ops.resume = alc269_resume;
15179#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015180 if (board_config == ALC269_AUTO)
15181 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015182
15183 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015184#ifdef CONFIG_SND_HDA_POWER_SAVE
15185 if (!spec->loopback.amplist)
15186 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015187 if (alc269_mic2_for_mute_led(codec))
15188 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015189#endif
15190
15191 return 0;
15192}
15193
15194/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015195 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15196 */
15197
15198/*
15199 * set the path ways for 2 channel output
15200 * need to set the codec line out and mic 1 pin widgets to inputs
15201 */
15202static struct hda_verb alc861_threestack_ch2_init[] = {
15203 /* set pin widget 1Ah (line in) for input */
15204 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015205 /* set pin widget 18h (mic1/2) for input, for mic also enable
15206 * the vref
15207 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015208 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15209
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015210 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15211#if 0
15212 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15213 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15214#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015215 { } /* end */
15216};
15217/*
15218 * 6ch mode
15219 * need to set the codec line out and mic 1 pin widgets to outputs
15220 */
15221static struct hda_verb alc861_threestack_ch6_init[] = {
15222 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15223 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15224 /* set pin widget 18h (mic1) for output (CLFE)*/
15225 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15226
15227 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015228 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015229
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015230 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15231#if 0
15232 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15233 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15234#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015235 { } /* end */
15236};
15237
15238static struct hda_channel_mode alc861_threestack_modes[2] = {
15239 { 2, alc861_threestack_ch2_init },
15240 { 6, alc861_threestack_ch6_init },
15241};
Takashi Iwai22309c32006-08-09 16:57:28 +020015242/* Set mic1 as input and unmute the mixer */
15243static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15244 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15245 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15246 { } /* end */
15247};
15248/* Set mic1 as output and mute mixer */
15249static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15250 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15251 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15252 { } /* end */
15253};
15254
15255static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15256 { 2, alc861_uniwill_m31_ch2_init },
15257 { 4, alc861_uniwill_m31_ch4_init },
15258};
Kailang Yangdf694da2005-12-05 19:42:22 +010015259
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015260/* Set mic1 and line-in as input and unmute the mixer */
15261static struct hda_verb alc861_asus_ch2_init[] = {
15262 /* set pin widget 1Ah (line in) for input */
15263 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015264 /* set pin widget 18h (mic1/2) for input, for mic also enable
15265 * the vref
15266 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015267 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15268
15269 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15270#if 0
15271 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15272 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15273#endif
15274 { } /* end */
15275};
15276/* Set mic1 nad line-in as output and mute mixer */
15277static struct hda_verb alc861_asus_ch6_init[] = {
15278 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15279 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15280 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15281 /* set pin widget 18h (mic1) for output (CLFE)*/
15282 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15283 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15284 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15285 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15286
15287 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15288#if 0
15289 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15290 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15291#endif
15292 { } /* end */
15293};
15294
15295static struct hda_channel_mode alc861_asus_modes[2] = {
15296 { 2, alc861_asus_ch2_init },
15297 { 6, alc861_asus_ch6_init },
15298};
15299
Kailang Yangdf694da2005-12-05 19:42:22 +010015300/* patch-ALC861 */
15301
15302static struct snd_kcontrol_new alc861_base_mixer[] = {
15303 /* output mixer control */
15304 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15305 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15306 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15307 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15308 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15309
15310 /*Input mixer control */
15311 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15312 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15313 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15314 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15315 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15316 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15317 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15318 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15319 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15320 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015321
Kailang Yangdf694da2005-12-05 19:42:22 +010015322 { } /* end */
15323};
15324
15325static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15326 /* output mixer control */
15327 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15328 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15329 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15330 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15331 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15332
15333 /* Input mixer control */
15334 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15335 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15336 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15337 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15338 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15339 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15340 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15341 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15342 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15343 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015344
Kailang Yangdf694da2005-12-05 19:42:22 +010015345 {
15346 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15347 .name = "Channel Mode",
15348 .info = alc_ch_mode_info,
15349 .get = alc_ch_mode_get,
15350 .put = alc_ch_mode_put,
15351 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15352 },
15353 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015354};
15355
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015356static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015357 /* output mixer control */
15358 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15359 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15360 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015361
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015362 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015363};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015364
Takashi Iwai22309c32006-08-09 16:57:28 +020015365static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15366 /* output mixer control */
15367 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15368 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15369 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15370 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15371 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15372
15373 /* Input mixer control */
15374 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15375 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15376 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15377 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15378 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15379 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15380 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15381 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15382 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15383 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015384
Takashi Iwai22309c32006-08-09 16:57:28 +020015385 {
15386 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15387 .name = "Channel Mode",
15388 .info = alc_ch_mode_info,
15389 .get = alc_ch_mode_get,
15390 .put = alc_ch_mode_put,
15391 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15392 },
15393 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015394};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015395
15396static struct snd_kcontrol_new alc861_asus_mixer[] = {
15397 /* output mixer control */
15398 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15399 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15400 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15401 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15402 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15403
15404 /* Input mixer control */
15405 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15406 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15407 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15408 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15409 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15410 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15411 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15412 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15413 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015414 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15415
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015416 {
15417 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15418 .name = "Channel Mode",
15419 .info = alc_ch_mode_info,
15420 .get = alc_ch_mode_get,
15421 .put = alc_ch_mode_put,
15422 .private_value = ARRAY_SIZE(alc861_asus_modes),
15423 },
15424 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015425};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015426
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015427/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015428static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015429 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15430 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015431 { }
15432};
15433
Kailang Yangdf694da2005-12-05 19:42:22 +010015434/*
15435 * generic initialization of ADC, input mixers and output mixers
15436 */
15437static struct hda_verb alc861_base_init_verbs[] = {
15438 /*
15439 * Unmute ADC0 and set the default input to mic-in
15440 */
15441 /* port-A for surround (rear panel) */
15442 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15443 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15444 /* port-B for mic-in (rear panel) with vref */
15445 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15446 /* port-C for line-in (rear panel) */
15447 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15448 /* port-D for Front */
15449 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15450 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15451 /* port-E for HP out (front panel) */
15452 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15453 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015454 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015455 /* port-F for mic-in (front panel) with vref */
15456 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15457 /* port-G for CLFE (rear panel) */
15458 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15459 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15460 /* port-H for side (rear panel) */
15461 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15462 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15463 /* CD-in */
15464 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15465 /* route front mic to ADC1*/
15466 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15467 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015468
Kailang Yangdf694da2005-12-05 19:42:22 +010015469 /* Unmute DAC0~3 & spdif out*/
15470 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15471 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15472 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15473 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15474 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015475
Kailang Yangdf694da2005-12-05 19:42:22 +010015476 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15477 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15478 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15479 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15480 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015481
Kailang Yangdf694da2005-12-05 19:42:22 +010015482 /* Unmute Stereo Mixer 15 */
15483 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15484 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15485 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015486 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015487
15488 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15489 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15490 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15491 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15492 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15493 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15494 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15495 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015496 /* hp used DAC 3 (Front) */
15497 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015498 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15499
15500 { }
15501};
15502
15503static struct hda_verb alc861_threestack_init_verbs[] = {
15504 /*
15505 * Unmute ADC0 and set the default input to mic-in
15506 */
15507 /* port-A for surround (rear panel) */
15508 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15509 /* port-B for mic-in (rear panel) with vref */
15510 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15511 /* port-C for line-in (rear panel) */
15512 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15513 /* port-D for Front */
15514 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15515 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15516 /* port-E for HP out (front panel) */
15517 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15518 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015519 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015520 /* port-F for mic-in (front panel) with vref */
15521 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15522 /* port-G for CLFE (rear panel) */
15523 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15524 /* port-H for side (rear panel) */
15525 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15526 /* CD-in */
15527 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15528 /* route front mic to ADC1*/
15529 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15530 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15531 /* Unmute DAC0~3 & spdif out*/
15532 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15533 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15534 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15535 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15536 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015537
Kailang Yangdf694da2005-12-05 19:42:22 +010015538 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15539 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15540 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15541 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15542 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015543
Kailang Yangdf694da2005-12-05 19:42:22 +010015544 /* Unmute Stereo Mixer 15 */
15545 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15546 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15547 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015548 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015549
15550 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15551 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15552 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15553 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15554 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15555 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15556 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15557 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015558 /* hp used DAC 3 (Front) */
15559 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015560 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15561 { }
15562};
Takashi Iwai22309c32006-08-09 16:57:28 +020015563
15564static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15565 /*
15566 * Unmute ADC0 and set the default input to mic-in
15567 */
15568 /* port-A for surround (rear panel) */
15569 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15570 /* port-B for mic-in (rear panel) with vref */
15571 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15572 /* port-C for line-in (rear panel) */
15573 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15574 /* port-D for Front */
15575 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15576 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15577 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015578 /* this has to be set to VREF80 */
15579 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015580 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015581 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015582 /* port-F for mic-in (front panel) with vref */
15583 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15584 /* port-G for CLFE (rear panel) */
15585 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15586 /* port-H for side (rear panel) */
15587 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15588 /* CD-in */
15589 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15590 /* route front mic to ADC1*/
15591 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15592 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15593 /* Unmute DAC0~3 & spdif out*/
15594 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15595 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15596 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15597 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15598 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015599
Takashi Iwai22309c32006-08-09 16:57:28 +020015600 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15601 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15602 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15603 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15604 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015605
Takashi Iwai22309c32006-08-09 16:57:28 +020015606 /* Unmute Stereo Mixer 15 */
15607 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15608 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15609 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015610 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015611
15612 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15613 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15614 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15615 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15616 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15617 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15618 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15619 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015620 /* hp used DAC 3 (Front) */
15621 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015622 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15623 { }
15624};
15625
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015626static struct hda_verb alc861_asus_init_verbs[] = {
15627 /*
15628 * Unmute ADC0 and set the default input to mic-in
15629 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015630 /* port-A for surround (rear panel)
15631 * according to codec#0 this is the HP jack
15632 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015633 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15634 /* route front PCM to HP */
15635 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15636 /* port-B for mic-in (rear panel) with vref */
15637 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15638 /* port-C for line-in (rear panel) */
15639 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15640 /* port-D for Front */
15641 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15642 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15643 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015644 /* this has to be set to VREF80 */
15645 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015646 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015647 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015648 /* port-F for mic-in (front panel) with vref */
15649 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15650 /* port-G for CLFE (rear panel) */
15651 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15652 /* port-H for side (rear panel) */
15653 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15654 /* CD-in */
15655 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15656 /* route front mic to ADC1*/
15657 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15658 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15659 /* Unmute DAC0~3 & spdif out*/
15660 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15661 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15662 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15663 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15664 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15665 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15666 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15667 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15668 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15669 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015670
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015671 /* Unmute Stereo Mixer 15 */
15672 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15673 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15674 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015675 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015676
15677 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15678 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15679 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15680 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15681 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15682 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15683 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15684 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015685 /* hp used DAC 3 (Front) */
15686 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015687 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15688 { }
15689};
15690
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015691/* additional init verbs for ASUS laptops */
15692static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15693 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15694 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15695 { }
15696};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015697
Kailang Yangdf694da2005-12-05 19:42:22 +010015698/*
15699 * generic initialization of ADC, input mixers and output mixers
15700 */
15701static struct hda_verb alc861_auto_init_verbs[] = {
15702 /*
15703 * Unmute ADC0 and set the default input to mic-in
15704 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015705 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015706 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015707
Kailang Yangdf694da2005-12-05 19:42:22 +010015708 /* Unmute DAC0~3 & spdif out*/
15709 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15710 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15711 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15712 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15713 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015714
Kailang Yangdf694da2005-12-05 19:42:22 +010015715 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15716 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15717 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15718 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15719 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015720
Kailang Yangdf694da2005-12-05 19:42:22 +010015721 /* Unmute Stereo Mixer 15 */
15722 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15723 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15724 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15725 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15726
Takashi Iwai1c209302009-07-22 15:17:45 +020015727 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15728 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15729 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15730 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15731 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15732 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15733 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15734 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015735
15736 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15737 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015738 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15739 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015740 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15741 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015742 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15743 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015744
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015745 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015746
15747 { }
15748};
15749
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015750static struct hda_verb alc861_toshiba_init_verbs[] = {
15751 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015752
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015753 { }
15754};
15755
15756/* toggle speaker-output according to the hp-jack state */
15757static void alc861_toshiba_automute(struct hda_codec *codec)
15758{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015759 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015760
Takashi Iwai47fd8302007-08-10 17:11:07 +020015761 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15762 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15763 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15764 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015765}
15766
15767static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15768 unsigned int res)
15769{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015770 if ((res >> 26) == ALC880_HP_EVENT)
15771 alc861_toshiba_automute(codec);
15772}
15773
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015774/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015775#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15776#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15777#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15778#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15779
15780
15781#define ALC861_DIGOUT_NID 0x07
15782
15783static struct hda_channel_mode alc861_8ch_modes[1] = {
15784 { 8, NULL }
15785};
15786
15787static hda_nid_t alc861_dac_nids[4] = {
15788 /* front, surround, clfe, side */
15789 0x03, 0x06, 0x05, 0x04
15790};
15791
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015792static hda_nid_t alc660_dac_nids[3] = {
15793 /* front, clfe, surround */
15794 0x03, 0x05, 0x06
15795};
15796
Kailang Yangdf694da2005-12-05 19:42:22 +010015797static hda_nid_t alc861_adc_nids[1] = {
15798 /* ADC0-2 */
15799 0x08,
15800};
15801
15802static struct hda_input_mux alc861_capture_source = {
15803 .num_items = 5,
15804 .items = {
15805 { "Mic", 0x0 },
15806 { "Front Mic", 0x3 },
15807 { "Line", 0x1 },
15808 { "CD", 0x4 },
15809 { "Mixer", 0x5 },
15810 },
15811};
15812
Takashi Iwai1c209302009-07-22 15:17:45 +020015813static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15814{
15815 struct alc_spec *spec = codec->spec;
15816 hda_nid_t mix, srcs[5];
15817 int i, j, num;
15818
15819 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15820 return 0;
15821 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15822 if (num < 0)
15823 return 0;
15824 for (i = 0; i < num; i++) {
15825 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015826 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015827 if (type != AC_WID_AUD_OUT)
15828 continue;
15829 for (j = 0; j < spec->multiout.num_dacs; j++)
15830 if (spec->multiout.dac_nids[j] == srcs[i])
15831 break;
15832 if (j >= spec->multiout.num_dacs)
15833 return srcs[i];
15834 }
15835 return 0;
15836}
15837
Kailang Yangdf694da2005-12-05 19:42:22 +010015838/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015839static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015840 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015841{
Takashi Iwai1c209302009-07-22 15:17:45 +020015842 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015843 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015844 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015845
15846 spec->multiout.dac_nids = spec->private_dac_nids;
15847 for (i = 0; i < cfg->line_outs; i++) {
15848 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015849 dac = alc861_look_for_dac(codec, nid);
15850 if (!dac)
15851 continue;
15852 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015853 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015854 return 0;
15855}
15856
Takashi Iwai1c209302009-07-22 15:17:45 +020015857static int alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15858 hda_nid_t nid, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015859{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020015860 return add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015861 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15862}
15863
15864/* add playback controls from the parsed DAC table */
15865static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15866 const struct auto_pin_cfg *cfg)
15867{
15868 struct alc_spec *spec = codec->spec;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015869 static const char *chname[4] = {
15870 "Front", "Surround", NULL /*CLFE*/, "Side"
15871 };
Kailang Yangdf694da2005-12-05 19:42:22 +010015872 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015873 int i, err;
15874
15875 if (cfg->line_outs == 1) {
15876 const char *pfx = NULL;
15877 if (!cfg->hp_outs)
15878 pfx = "Master";
15879 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
15880 pfx = "Speaker";
15881 if (pfx) {
15882 nid = spec->multiout.dac_nids[0];
15883 return alc861_create_out_sw(codec, pfx, nid, 3);
15884 }
15885 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015886
15887 for (i = 0; i < cfg->line_outs; i++) {
15888 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015889 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015890 continue;
Takashi Iwai1c209302009-07-22 15:17:45 +020015891 if (i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015892 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015893 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015894 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015895 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015896 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015897 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015898 return err;
15899 } else {
Takashi Iwai1c209302009-07-22 15:17:45 +020015900 err = alc861_create_out_sw(codec, chname[i], nid, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015901 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015902 return err;
15903 }
15904 }
15905 return 0;
15906}
15907
Takashi Iwai1c209302009-07-22 15:17:45 +020015908static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015909{
Takashi Iwai1c209302009-07-22 15:17:45 +020015910 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015911 int err;
15912 hda_nid_t nid;
15913
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015914 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010015915 return 0;
15916
15917 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020015918 nid = alc861_look_for_dac(codec, pin);
15919 if (nid) {
15920 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
15921 if (err < 0)
15922 return err;
15923 spec->multiout.hp_nid = nid;
15924 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015925 }
15926 return 0;
15927}
15928
15929/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020015930static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015931 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015932{
Takashi Iwai05f5f472009-08-25 13:10:18 +020015933 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010015934}
15935
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015936static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
15937 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020015938 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010015939{
Takashi Iwai1c209302009-07-22 15:17:45 +020015940 hda_nid_t mix, srcs[5];
15941 int i, num;
15942
Jacek Luczak564c5be2008-05-03 18:41:23 +020015943 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
15944 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020015945 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020015946 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020015947 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
15948 return;
15949 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15950 if (num < 0)
15951 return;
15952 for (i = 0; i < num; i++) {
15953 unsigned int mute;
15954 if (srcs[i] == dac || srcs[i] == 0x15)
15955 mute = AMP_IN_UNMUTE(i);
15956 else
15957 mute = AMP_IN_MUTE(i);
15958 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
15959 mute);
15960 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015961}
15962
15963static void alc861_auto_init_multi_out(struct hda_codec *codec)
15964{
15965 struct alc_spec *spec = codec->spec;
15966 int i;
15967
15968 for (i = 0; i < spec->autocfg.line_outs; i++) {
15969 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015970 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010015971 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020015972 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015973 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015974 }
15975}
15976
15977static void alc861_auto_init_hp_out(struct hda_codec *codec)
15978{
15979 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015980
Takashi Iwai15870f02009-10-05 08:25:13 +020015981 if (spec->autocfg.hp_outs)
15982 alc861_auto_set_output_and_unmute(codec,
15983 spec->autocfg.hp_pins[0],
15984 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020015985 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020015986 if (spec->autocfg.speaker_outs)
15987 alc861_auto_set_output_and_unmute(codec,
15988 spec->autocfg.speaker_pins[0],
15989 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020015990 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010015991}
15992
15993static void alc861_auto_init_analog_input(struct hda_codec *codec)
15994{
15995 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015996 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010015997 int i;
15998
Takashi Iwai66ceeb62010-08-30 13:05:52 +020015999 for (i = 0; i < cfg->num_inputs; i++) {
16000 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016001 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016002 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016003 }
16004}
16005
16006/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016007/* return 1 if successful, 0 if the proper config is not found,
16008 * or a negative error code
16009 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016010static int alc861_parse_auto_config(struct hda_codec *codec)
16011{
16012 struct alc_spec *spec = codec->spec;
16013 int err;
16014 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16015
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016016 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16017 alc861_ignore);
16018 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016019 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016020 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016021 return 0; /* can't find valid BIOS pin config */
16022
Takashi Iwai1c209302009-07-22 15:17:45 +020016023 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016024 if (err < 0)
16025 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016026 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016027 if (err < 0)
16028 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016029 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016030 if (err < 0)
16031 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016032 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016033 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016034 return err;
16035
16036 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16037
Takashi Iwai757899a2010-07-30 10:48:14 +020016038 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016039
Takashi Iwai603c4012008-07-30 15:01:44 +020016040 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016041 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016042
Takashi Iwaid88897e2008-10-31 15:01:37 +010016043 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016044
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016045 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016046 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016047
16048 spec->adc_nids = alc861_adc_nids;
16049 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016050 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016051
Kailang Yang6227cdc2010-02-25 08:36:52 +010016052 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016053
Kailang Yangdf694da2005-12-05 19:42:22 +010016054 return 1;
16055}
16056
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016057/* additional initialization for auto-configuration model */
16058static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016059{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016060 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016061 alc861_auto_init_multi_out(codec);
16062 alc861_auto_init_hp_out(codec);
16063 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016064 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016065 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016066 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016067}
16068
Takashi Iwaicb53c622007-08-10 17:21:45 +020016069#ifdef CONFIG_SND_HDA_POWER_SAVE
16070static struct hda_amp_list alc861_loopbacks[] = {
16071 { 0x15, HDA_INPUT, 0 },
16072 { 0x15, HDA_INPUT, 1 },
16073 { 0x15, HDA_INPUT, 2 },
16074 { 0x15, HDA_INPUT, 3 },
16075 { } /* end */
16076};
16077#endif
16078
Kailang Yangdf694da2005-12-05 19:42:22 +010016079
16080/*
16081 * configuration and preset
16082 */
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016083static const char *alc861_models[ALC861_MODEL_LAST] = {
16084 [ALC861_3ST] = "3stack",
16085 [ALC660_3ST] = "3stack-660",
16086 [ALC861_3ST_DIG] = "3stack-dig",
16087 [ALC861_6ST_DIG] = "6stack-dig",
16088 [ALC861_UNIWILL_M31] = "uniwill-m31",
16089 [ALC861_TOSHIBA] = "toshiba",
16090 [ALC861_ASUS] = "asus",
16091 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16092 [ALC861_AUTO] = "auto",
16093};
16094
16095static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016096 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016097 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16098 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16099 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016100 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016101 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016102 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016103 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16104 * Any other models that need this preset?
16105 */
16106 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016107 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16108 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016109 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16110 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16111 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16112 /* FIXME: the below seems conflict */
16113 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16114 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16115 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016116 {}
16117};
16118
16119static struct alc_config_preset alc861_presets[] = {
16120 [ALC861_3ST] = {
16121 .mixers = { alc861_3ST_mixer },
16122 .init_verbs = { alc861_threestack_init_verbs },
16123 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16124 .dac_nids = alc861_dac_nids,
16125 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16126 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016127 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016128 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16129 .adc_nids = alc861_adc_nids,
16130 .input_mux = &alc861_capture_source,
16131 },
16132 [ALC861_3ST_DIG] = {
16133 .mixers = { alc861_base_mixer },
16134 .init_verbs = { alc861_threestack_init_verbs },
16135 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16136 .dac_nids = alc861_dac_nids,
16137 .dig_out_nid = ALC861_DIGOUT_NID,
16138 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16139 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016140 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016141 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16142 .adc_nids = alc861_adc_nids,
16143 .input_mux = &alc861_capture_source,
16144 },
16145 [ALC861_6ST_DIG] = {
16146 .mixers = { alc861_base_mixer },
16147 .init_verbs = { alc861_base_init_verbs },
16148 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16149 .dac_nids = alc861_dac_nids,
16150 .dig_out_nid = ALC861_DIGOUT_NID,
16151 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16152 .channel_mode = alc861_8ch_modes,
16153 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16154 .adc_nids = alc861_adc_nids,
16155 .input_mux = &alc861_capture_source,
16156 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016157 [ALC660_3ST] = {
16158 .mixers = { alc861_3ST_mixer },
16159 .init_verbs = { alc861_threestack_init_verbs },
16160 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16161 .dac_nids = alc660_dac_nids,
16162 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16163 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016164 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016165 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16166 .adc_nids = alc861_adc_nids,
16167 .input_mux = &alc861_capture_source,
16168 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016169 [ALC861_UNIWILL_M31] = {
16170 .mixers = { alc861_uniwill_m31_mixer },
16171 .init_verbs = { alc861_uniwill_m31_init_verbs },
16172 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16173 .dac_nids = alc861_dac_nids,
16174 .dig_out_nid = ALC861_DIGOUT_NID,
16175 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16176 .channel_mode = alc861_uniwill_m31_modes,
16177 .need_dac_fix = 1,
16178 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16179 .adc_nids = alc861_adc_nids,
16180 .input_mux = &alc861_capture_source,
16181 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016182 [ALC861_TOSHIBA] = {
16183 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016184 .init_verbs = { alc861_base_init_verbs,
16185 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016186 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16187 .dac_nids = alc861_dac_nids,
16188 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16189 .channel_mode = alc883_3ST_2ch_modes,
16190 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16191 .adc_nids = alc861_adc_nids,
16192 .input_mux = &alc861_capture_source,
16193 .unsol_event = alc861_toshiba_unsol_event,
16194 .init_hook = alc861_toshiba_automute,
16195 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016196 [ALC861_ASUS] = {
16197 .mixers = { alc861_asus_mixer },
16198 .init_verbs = { alc861_asus_init_verbs },
16199 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16200 .dac_nids = alc861_dac_nids,
16201 .dig_out_nid = ALC861_DIGOUT_NID,
16202 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16203 .channel_mode = alc861_asus_modes,
16204 .need_dac_fix = 1,
16205 .hp_nid = 0x06,
16206 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16207 .adc_nids = alc861_adc_nids,
16208 .input_mux = &alc861_capture_source,
16209 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016210 [ALC861_ASUS_LAPTOP] = {
16211 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16212 .init_verbs = { alc861_asus_init_verbs,
16213 alc861_asus_laptop_init_verbs },
16214 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16215 .dac_nids = alc861_dac_nids,
16216 .dig_out_nid = ALC861_DIGOUT_NID,
16217 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16218 .channel_mode = alc883_3ST_2ch_modes,
16219 .need_dac_fix = 1,
16220 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16221 .adc_nids = alc861_adc_nids,
16222 .input_mux = &alc861_capture_source,
16223 },
16224};
Kailang Yangdf694da2005-12-05 19:42:22 +010016225
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016226/* Pin config fixes */
16227enum {
16228 PINFIX_FSC_AMILO_PI1505,
16229};
16230
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016231static const struct alc_fixup alc861_fixups[] = {
16232 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020016233 .pins = (const struct alc_pincfg[]) {
16234 { 0x0b, 0x0221101f }, /* HP */
16235 { 0x0f, 0x90170310 }, /* speaker */
16236 { }
16237 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016238 },
16239};
16240
16241static struct snd_pci_quirk alc861_fixup_tbl[] = {
16242 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16243 {}
16244};
Kailang Yangdf694da2005-12-05 19:42:22 +010016245
16246static int patch_alc861(struct hda_codec *codec)
16247{
16248 struct alc_spec *spec;
16249 int board_config;
16250 int err;
16251
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016252 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016253 if (spec == NULL)
16254 return -ENOMEM;
16255
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016256 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016257
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016258 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16259 alc861_models,
16260 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016261
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016262 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016263 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16264 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016265 board_config = ALC861_AUTO;
16266 }
16267
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016268 if (board_config == ALC861_AUTO)
16269 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 1);
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016270
Kailang Yangdf694da2005-12-05 19:42:22 +010016271 if (board_config == ALC861_AUTO) {
16272 /* automatic parse from the BIOS config */
16273 err = alc861_parse_auto_config(codec);
16274 if (err < 0) {
16275 alc_free(codec);
16276 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016277 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016278 printk(KERN_INFO
16279 "hda_codec: Cannot set up configuration "
16280 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016281 board_config = ALC861_3ST_DIG;
16282 }
16283 }
16284
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016285 err = snd_hda_attach_beep_device(codec, 0x23);
16286 if (err < 0) {
16287 alc_free(codec);
16288 return err;
16289 }
16290
Kailang Yangdf694da2005-12-05 19:42:22 +010016291 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016292 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016293
Kailang Yangdf694da2005-12-05 19:42:22 +010016294 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16295 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16296
Kailang Yangdf694da2005-12-05 19:42:22 +010016297 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16298 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16299
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016300 if (!spec->cap_mixer)
16301 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016302 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16303
Takashi Iwai2134ea42008-01-10 16:53:55 +010016304 spec->vmaster_nid = 0x03;
16305
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016306 if (board_config == ALC861_AUTO)
16307 alc_pick_fixup(codec, alc861_fixup_tbl, alc861_fixups, 0);
16308
Kailang Yangdf694da2005-12-05 19:42:22 +010016309 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016310 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016311 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016312#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016313 spec->power_hook = alc_power_eapd;
16314#endif
16315 }
16316#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016317 if (!spec->loopback.amplist)
16318 spec->loopback.amplist = alc861_loopbacks;
16319#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016320
Kailang Yangdf694da2005-12-05 19:42:22 +010016321 return 0;
16322}
16323
16324/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016325 * ALC861-VD support
16326 *
16327 * Based on ALC882
16328 *
16329 * In addition, an independent DAC
16330 */
16331#define ALC861VD_DIGOUT_NID 0x06
16332
16333static hda_nid_t alc861vd_dac_nids[4] = {
16334 /* front, surr, clfe, side surr */
16335 0x02, 0x03, 0x04, 0x05
16336};
16337
16338/* dac_nids for ALC660vd are in a different order - according to
16339 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016340 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016341 * of ALC660vd codecs, but for now there is only 3stack mixer
16342 * - and it is the same as in 861vd.
16343 * adc_nids in ALC660vd are (is) the same as in 861vd
16344 */
16345static hda_nid_t alc660vd_dac_nids[3] = {
16346 /* front, rear, clfe, rear_surr */
16347 0x02, 0x04, 0x03
16348};
16349
16350static hda_nid_t alc861vd_adc_nids[1] = {
16351 /* ADC0 */
16352 0x09,
16353};
16354
Takashi Iwaie1406342008-02-11 18:32:32 +010016355static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16356
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016357/* input MUX */
16358/* FIXME: should be a matrix-type input source selection */
16359static struct hda_input_mux alc861vd_capture_source = {
16360 .num_items = 4,
16361 .items = {
16362 { "Mic", 0x0 },
16363 { "Front Mic", 0x1 },
16364 { "Line", 0x2 },
16365 { "CD", 0x4 },
16366 },
16367};
16368
Kailang Yang272a5272007-05-14 11:00:38 +020016369static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016370 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016371 .items = {
Tobin Davisb419f342008-03-07 11:57:51 +010016372 { "Ext Mic", 0x0 },
16373 { "Int Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016374 },
16375};
16376
Kailang Yangd1a991a2007-08-15 16:21:59 +020016377static struct hda_input_mux alc861vd_hp_capture_source = {
16378 .num_items = 2,
16379 .items = {
16380 { "Front Mic", 0x0 },
16381 { "ATAPI Mic", 0x1 },
16382 },
16383};
16384
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016385/*
16386 * 2ch mode
16387 */
16388static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16389 { 2, NULL }
16390};
16391
16392/*
16393 * 6ch mode
16394 */
16395static struct hda_verb alc861vd_6stack_ch6_init[] = {
16396 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16397 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16398 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16399 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16400 { } /* end */
16401};
16402
16403/*
16404 * 8ch mode
16405 */
16406static struct hda_verb alc861vd_6stack_ch8_init[] = {
16407 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16408 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16409 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16410 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16411 { } /* end */
16412};
16413
16414static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16415 { 6, alc861vd_6stack_ch6_init },
16416 { 8, alc861vd_6stack_ch8_init },
16417};
16418
16419static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16420 {
16421 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16422 .name = "Channel Mode",
16423 .info = alc_ch_mode_info,
16424 .get = alc_ch_mode_get,
16425 .put = alc_ch_mode_put,
16426 },
16427 { } /* end */
16428};
16429
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016430/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16431 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16432 */
16433static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16434 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16435 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16436
16437 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16438 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16439
16440 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16441 HDA_OUTPUT),
16442 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16443 HDA_OUTPUT),
16444 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16445 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16446
16447 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16448 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16449
16450 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16451
16452 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16453 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16454 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16455
16456 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16457 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16458 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16459
16460 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16461 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16462
16463 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16464 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16465
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016466 { } /* end */
16467};
16468
16469static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16470 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16471 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16472
16473 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16474
16475 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16476 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16477 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16478
16479 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16480 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16481 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16482
16483 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16484 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16485
16486 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16487 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16488
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016489 { } /* end */
16490};
16491
Kailang Yangbdd148a2007-05-08 15:19:08 +020016492static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16493 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16494 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16495 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16496
16497 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16498
16499 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
16500 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16501 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16502
16503 HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
16504 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16505 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16506
16507 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16508 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16509
16510 { } /* end */
16511};
16512
Tobin Davisb419f342008-03-07 11:57:51 +010016513/* Pin assignment: Speaker=0x14, HP = 0x15,
16514 * Ext Mic=0x18, Int Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016515 */
16516static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016517 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16518 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016519 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16520 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisb419f342008-03-07 11:57:51 +010016521 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
16522 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16523 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16524 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
16525 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16526 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016527 { } /* end */
16528};
16529
Kailang Yangd1a991a2007-08-15 16:21:59 +020016530/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16531 * Front Mic=0x18, ATAPI Mic = 0x19,
16532 */
16533static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16534 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16535 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16536 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16537 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16538 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16539 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16540 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16541 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016542
Kailang Yangd1a991a2007-08-15 16:21:59 +020016543 { } /* end */
16544};
16545
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016546/*
16547 * generic initialization of ADC, input mixers and output mixers
16548 */
16549static struct hda_verb alc861vd_volume_init_verbs[] = {
16550 /*
16551 * Unmute ADC0 and set the default input to mic-in
16552 */
16553 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16554 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16555
16556 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16557 * the analog-loopback mixer widget
16558 */
16559 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016560 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16561 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16562 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16563 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16564 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016565
16566 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016567 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16568 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16569 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016570 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016571
16572 /*
16573 * Set up output mixers (0x02 - 0x05)
16574 */
16575 /* set vol=0 to output mixers */
16576 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16577 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16578 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16579 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16580
16581 /* set up input amps for analog loopback */
16582 /* Amp Indices: DAC = 0, mixer = 1 */
16583 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16584 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16585 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16586 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16587 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16588 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16589 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16590 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16591
16592 { }
16593};
16594
16595/*
16596 * 3-stack pin configuration:
16597 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16598 */
16599static struct hda_verb alc861vd_3stack_init_verbs[] = {
16600 /*
16601 * Set pin mode and muting
16602 */
16603 /* set front pin widgets 0x14 for output */
16604 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16605 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16606 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16607
16608 /* Mic (rear) pin: input vref at 80% */
16609 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16610 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16611 /* Front Mic pin: input vref at 80% */
16612 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16613 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16614 /* Line In pin: input */
16615 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16616 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16617 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16618 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16619 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16620 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16621 /* CD pin widget for input */
16622 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16623
16624 { }
16625};
16626
16627/*
16628 * 6-stack pin configuration:
16629 */
16630static struct hda_verb alc861vd_6stack_init_verbs[] = {
16631 /*
16632 * Set pin mode and muting
16633 */
16634 /* set front pin widgets 0x14 for output */
16635 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16636 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16637 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16638
16639 /* Rear Pin: output 1 (0x0d) */
16640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16641 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16642 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16643 /* CLFE Pin: output 2 (0x0e) */
16644 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16645 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16646 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16647 /* Side Pin: output 3 (0x0f) */
16648 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16649 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16650 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16651
16652 /* Mic (rear) pin: input vref at 80% */
16653 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16654 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16655 /* Front Mic pin: input vref at 80% */
16656 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16657 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16658 /* Line In pin: input */
16659 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16660 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16661 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16662 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16663 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16664 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16665 /* CD pin widget for input */
16666 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16667
16668 { }
16669};
16670
Kailang Yangbdd148a2007-05-08 15:19:08 +020016671static struct hda_verb alc861vd_eapd_verbs[] = {
16672 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16673 { }
16674};
16675
Kailang Yangf9423e72008-05-27 12:32:25 +020016676static struct hda_verb alc660vd_eapd_verbs[] = {
16677 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16678 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16679 { }
16680};
16681
Kailang Yangbdd148a2007-05-08 15:19:08 +020016682static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16683 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16684 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16685 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16686 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016687 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016688 {}
16689};
16690
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016691static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016692{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016693 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016694 spec->autocfg.hp_pins[0] = 0x1b;
16695 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016696}
16697
16698static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16699{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016700 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016701 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016702}
16703
16704static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16705 unsigned int res)
16706{
16707 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016708 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016709 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016710 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016711 default:
16712 alc_automute_amp_unsol_event(codec, res);
16713 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016714 }
16715}
16716
Kailang Yang272a5272007-05-14 11:00:38 +020016717static struct hda_verb alc861vd_dallas_verbs[] = {
16718 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16719 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16720 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16721 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16722
16723 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16724 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16725 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16726 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16727 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16728 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16729 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16730 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016731
Kailang Yang272a5272007-05-14 11:00:38 +020016732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16733 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16734 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16735 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16736 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16737 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16738 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16739 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16740
16741 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16742 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16743 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16744 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16745 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16746 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16747 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16748 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16749
16750 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16751 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16752 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16753 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16754
16755 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016756 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016757 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16758
16759 { } /* end */
16760};
16761
16762/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016763static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016764{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016765 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016766
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016767 spec->autocfg.hp_pins[0] = 0x15;
16768 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016769}
16770
Takashi Iwaicb53c622007-08-10 17:21:45 +020016771#ifdef CONFIG_SND_HDA_POWER_SAVE
16772#define alc861vd_loopbacks alc880_loopbacks
16773#endif
16774
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016775/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016776#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16777#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16778#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16779#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16780
16781/*
16782 * configuration and preset
16783 */
16784static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
16785 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016786 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016787 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016788 [ALC861VD_3ST] = "3stack",
16789 [ALC861VD_3ST_DIG] = "3stack-digout",
16790 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016791 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016792 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016793 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016794 [ALC861VD_AUTO] = "auto",
16795};
16796
16797static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016798 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16799 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016800 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016801 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016802 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016803 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016804 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016805 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016806 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016807 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016808 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016809 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016810 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016811 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016812 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016813 {}
16814};
16815
16816static struct alc_config_preset alc861vd_presets[] = {
16817 [ALC660VD_3ST] = {
16818 .mixers = { alc861vd_3st_mixer },
16819 .init_verbs = { alc861vd_volume_init_verbs,
16820 alc861vd_3stack_init_verbs },
16821 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16822 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016823 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16824 .channel_mode = alc861vd_3stack_2ch_modes,
16825 .input_mux = &alc861vd_capture_source,
16826 },
Mike Crash6963f842007-06-25 12:12:51 +020016827 [ALC660VD_3ST_DIG] = {
16828 .mixers = { alc861vd_3st_mixer },
16829 .init_verbs = { alc861vd_volume_init_verbs,
16830 alc861vd_3stack_init_verbs },
16831 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16832 .dac_nids = alc660vd_dac_nids,
16833 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016834 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16835 .channel_mode = alc861vd_3stack_2ch_modes,
16836 .input_mux = &alc861vd_capture_source,
16837 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016838 [ALC861VD_3ST] = {
16839 .mixers = { alc861vd_3st_mixer },
16840 .init_verbs = { alc861vd_volume_init_verbs,
16841 alc861vd_3stack_init_verbs },
16842 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16843 .dac_nids = alc861vd_dac_nids,
16844 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16845 .channel_mode = alc861vd_3stack_2ch_modes,
16846 .input_mux = &alc861vd_capture_source,
16847 },
16848 [ALC861VD_3ST_DIG] = {
16849 .mixers = { alc861vd_3st_mixer },
16850 .init_verbs = { alc861vd_volume_init_verbs,
16851 alc861vd_3stack_init_verbs },
16852 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16853 .dac_nids = alc861vd_dac_nids,
16854 .dig_out_nid = ALC861VD_DIGOUT_NID,
16855 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16856 .channel_mode = alc861vd_3stack_2ch_modes,
16857 .input_mux = &alc861vd_capture_source,
16858 },
16859 [ALC861VD_6ST_DIG] = {
16860 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16861 .init_verbs = { alc861vd_volume_init_verbs,
16862 alc861vd_6stack_init_verbs },
16863 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16864 .dac_nids = alc861vd_dac_nids,
16865 .dig_out_nid = ALC861VD_DIGOUT_NID,
16866 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16867 .channel_mode = alc861vd_6stack_modes,
16868 .input_mux = &alc861vd_capture_source,
16869 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016870 [ALC861VD_LENOVO] = {
16871 .mixers = { alc861vd_lenovo_mixer },
16872 .init_verbs = { alc861vd_volume_init_verbs,
16873 alc861vd_3stack_init_verbs,
16874 alc861vd_eapd_verbs,
16875 alc861vd_lenovo_unsol_verbs },
16876 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16877 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016878 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16879 .channel_mode = alc861vd_3stack_2ch_modes,
16880 .input_mux = &alc861vd_capture_source,
16881 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016882 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016883 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016884 },
Kailang Yang272a5272007-05-14 11:00:38 +020016885 [ALC861VD_DALLAS] = {
16886 .mixers = { alc861vd_dallas_mixer },
16887 .init_verbs = { alc861vd_dallas_verbs },
16888 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16889 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016890 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16891 .channel_mode = alc861vd_3stack_2ch_modes,
16892 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016893 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016894 .setup = alc861vd_dallas_setup,
16895 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016896 },
16897 [ALC861VD_HP] = {
16898 .mixers = { alc861vd_hp_mixer },
16899 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
16900 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16901 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016902 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016903 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16904 .channel_mode = alc861vd_3stack_2ch_modes,
16905 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016906 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016907 .setup = alc861vd_dallas_setup,
16908 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020016909 },
Takashi Iwai13c94742008-11-05 08:06:08 +010016910 [ALC660VD_ASUS_V1S] = {
16911 .mixers = { alc861vd_lenovo_mixer },
16912 .init_verbs = { alc861vd_volume_init_verbs,
16913 alc861vd_3stack_init_verbs,
16914 alc861vd_eapd_verbs,
16915 alc861vd_lenovo_unsol_verbs },
16916 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16917 .dac_nids = alc660vd_dac_nids,
16918 .dig_out_nid = ALC861VD_DIGOUT_NID,
16919 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16920 .channel_mode = alc861vd_3stack_2ch_modes,
16921 .input_mux = &alc861vd_capture_source,
16922 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016923 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016924 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010016925 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016926};
16927
16928/*
16929 * BIOS auto configuration
16930 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016931static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
16932 const struct auto_pin_cfg *cfg)
16933{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020016934 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020016935}
16936
16937
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016938static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
16939 hda_nid_t nid, int pin_type, int dac_idx)
16940{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016941 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016942}
16943
16944static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
16945{
16946 struct alc_spec *spec = codec->spec;
16947 int i;
16948
16949 for (i = 0; i <= HDA_SIDE; i++) {
16950 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016951 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016952 if (nid)
16953 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016954 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016955 }
16956}
16957
16958
16959static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
16960{
16961 struct alc_spec *spec = codec->spec;
16962 hda_nid_t pin;
16963
16964 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016965 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016966 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016967 pin = spec->autocfg.speaker_pins[0];
16968 if (pin)
16969 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016970}
16971
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016972#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
16973
16974static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
16975{
16976 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016977 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016978 int i;
16979
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016980 for (i = 0; i < cfg->num_inputs; i++) {
16981 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016982 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020016983 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010016984 if (nid != ALC861VD_PIN_CD_NID &&
16985 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016986 snd_hda_codec_write(codec, nid, 0,
16987 AC_VERB_SET_AMP_GAIN_MUTE,
16988 AMP_OUT_MUTE);
16989 }
16990 }
16991}
16992
Takashi Iwaif511b012008-08-15 16:46:42 +020016993#define alc861vd_auto_init_input_src alc882_auto_init_input_src
16994
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016995#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
16996#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
16997
16998/* add playback controls from the parsed DAC table */
16999/* Based on ALC880 version. But ALC861VD has separate,
17000 * different NIDs for mute/unmute switch and volume control */
17001static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17002 const struct auto_pin_cfg *cfg)
17003{
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017004 static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
17005 hda_nid_t nid_v, nid_s;
17006 int i, err;
17007
17008 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017009 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017010 continue;
17011 nid_v = alc861vd_idx_to_mixer_vol(
17012 alc880_dac_to_idx(
17013 spec->multiout.dac_nids[i]));
17014 nid_s = alc861vd_idx_to_mixer_switch(
17015 alc880_dac_to_idx(
17016 spec->multiout.dac_nids[i]));
17017
17018 if (i == 2) {
17019 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017020 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17021 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017022 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17023 HDA_OUTPUT));
17024 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017025 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017026 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17027 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017028 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17029 HDA_OUTPUT));
17030 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017031 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017032 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17033 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017034 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17035 HDA_INPUT));
17036 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017037 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017038 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17039 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017040 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17041 HDA_INPUT));
17042 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017043 return err;
17044 } else {
Takashi Iwaia4fcd492009-08-25 16:12:15 +020017045 const char *pfx;
17046 if (cfg->line_outs == 1 &&
17047 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
17048 if (!cfg->hp_pins)
17049 pfx = "Speaker";
17050 else
17051 pfx = "PCM";
17052 } else
17053 pfx = chname[i];
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017054 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017055 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17056 HDA_OUTPUT));
17057 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017058 return err;
Takashi Iwaia4fcd492009-08-25 16:12:15 +020017059 if (cfg->line_outs == 1 &&
17060 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
17061 pfx = "Speaker";
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017062 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017063 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017064 HDA_INPUT));
17065 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017066 return err;
17067 }
17068 }
17069 return 0;
17070}
17071
17072/* add playback controls for speaker and HP outputs */
17073/* Based on ALC880 version. But ALC861VD has separate,
17074 * different NIDs for mute/unmute switch and volume control */
17075static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17076 hda_nid_t pin, const char *pfx)
17077{
17078 hda_nid_t nid_v, nid_s;
17079 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017080
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017081 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017082 return 0;
17083
17084 if (alc880_is_fixed_pin(pin)) {
17085 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17086 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017087 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017088 spec->multiout.hp_nid = nid_v;
17089 else
17090 spec->multiout.extra_out_nid[0] = nid_v;
17091 /* control HP volume/switch on the output mixer amp */
17092 nid_v = alc861vd_idx_to_mixer_vol(
17093 alc880_fixed_pin_idx(pin));
17094 nid_s = alc861vd_idx_to_mixer_switch(
17095 alc880_fixed_pin_idx(pin));
17096
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017097 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017098 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17099 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017100 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017101 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017102 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17103 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017104 return err;
17105 } else if (alc880_is_multi_pin(pin)) {
17106 /* set manual connection */
17107 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017108 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017109 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17110 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017111 return err;
17112 }
17113 return 0;
17114}
17115
17116/* parse the BIOS configuration and set up the alc_spec
17117 * return 1 if successful, 0 if the proper config is not found,
17118 * or a negative error code
17119 * Based on ALC880 version - had to change it to override
17120 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17121static int alc861vd_parse_auto_config(struct hda_codec *codec)
17122{
17123 struct alc_spec *spec = codec->spec;
17124 int err;
17125 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17126
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017127 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17128 alc861vd_ignore);
17129 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017130 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017131 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017132 return 0; /* can't find valid BIOS pin config */
17133
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017134 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17135 if (err < 0)
17136 return err;
17137 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17138 if (err < 0)
17139 return err;
17140 err = alc861vd_auto_create_extra_out(spec,
17141 spec->autocfg.speaker_pins[0],
17142 "Speaker");
17143 if (err < 0)
17144 return err;
17145 err = alc861vd_auto_create_extra_out(spec,
17146 spec->autocfg.hp_pins[0],
17147 "Headphone");
17148 if (err < 0)
17149 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017150 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017151 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017152 return err;
17153
17154 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17155
Takashi Iwai757899a2010-07-30 10:48:14 +020017156 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017157
Takashi Iwai603c4012008-07-30 15:01:44 +020017158 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017159 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017160
Takashi Iwaid88897e2008-10-31 15:01:37 +010017161 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017162
17163 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017164 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017165
Takashi Iwai776e1842007-08-29 15:07:11 +020017166 err = alc_auto_add_mic_boost(codec);
17167 if (err < 0)
17168 return err;
17169
Kailang Yang6227cdc2010-02-25 08:36:52 +010017170 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017171
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017172 return 1;
17173}
17174
17175/* additional initialization for auto-configuration model */
17176static void alc861vd_auto_init(struct hda_codec *codec)
17177{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017178 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017179 alc861vd_auto_init_multi_out(codec);
17180 alc861vd_auto_init_hp_out(codec);
17181 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017182 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017183 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017184 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017185 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017186}
17187
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017188enum {
17189 ALC660VD_FIX_ASUS_GPIO1
17190};
17191
17192/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017193static const struct alc_fixup alc861vd_fixups[] = {
17194 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwai73413b12010-08-30 09:39:57 +020017195 .verbs = (const struct hda_verb[]) {
17196 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17197 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17198 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17199 { }
17200 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017201 },
17202};
17203
17204static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17205 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17206 {}
17207};
17208
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017209static int patch_alc861vd(struct hda_codec *codec)
17210{
17211 struct alc_spec *spec;
17212 int err, board_config;
17213
17214 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17215 if (spec == NULL)
17216 return -ENOMEM;
17217
17218 codec->spec = spec;
17219
17220 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17221 alc861vd_models,
17222 alc861vd_cfg_tbl);
17223
17224 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017225 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17226 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017227 board_config = ALC861VD_AUTO;
17228 }
17229
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017230 if (board_config == ALC861VD_AUTO)
17231 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 1);
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017232
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017233 if (board_config == ALC861VD_AUTO) {
17234 /* automatic parse from the BIOS config */
17235 err = alc861vd_parse_auto_config(codec);
17236 if (err < 0) {
17237 alc_free(codec);
17238 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017239 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017240 printk(KERN_INFO
17241 "hda_codec: Cannot set up configuration "
17242 "from BIOS. Using base mode...\n");
17243 board_config = ALC861VD_3ST;
17244 }
17245 }
17246
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017247 err = snd_hda_attach_beep_device(codec, 0x23);
17248 if (err < 0) {
17249 alc_free(codec);
17250 return err;
17251 }
17252
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017253 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017254 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017255
Kailang Yang2f893282008-05-27 12:14:47 +020017256 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017257 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017258 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017259 }
17260
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017261 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17262 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17263
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017264 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17265 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17266
Takashi Iwaidd704692009-08-11 08:45:11 +020017267 if (!spec->adc_nids) {
17268 spec->adc_nids = alc861vd_adc_nids;
17269 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17270 }
17271 if (!spec->capsrc_nids)
17272 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017273
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017274 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017275 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017276
Takashi Iwai2134ea42008-01-10 16:53:55 +010017277 spec->vmaster_nid = 0x02;
17278
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017279 if (board_config == ALC861VD_AUTO)
17280 alc_pick_fixup(codec, alc861vd_fixup_tbl, alc861vd_fixups, 0);
17281
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017282 codec->patch_ops = alc_patch_ops;
17283
17284 if (board_config == ALC861VD_AUTO)
17285 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017286#ifdef CONFIG_SND_HDA_POWER_SAVE
17287 if (!spec->loopback.amplist)
17288 spec->loopback.amplist = alc861vd_loopbacks;
17289#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017290
17291 return 0;
17292}
17293
17294/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017295 * ALC662 support
17296 *
17297 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17298 * configuration. Each pin widget can choose any input DACs and a mixer.
17299 * Each ADC is connected from a mixer of all inputs. This makes possible
17300 * 6-channel independent captures.
17301 *
17302 * In addition, an independent DAC for the multi-playback (not used in this
17303 * driver yet).
17304 */
17305#define ALC662_DIGOUT_NID 0x06
17306#define ALC662_DIGIN_NID 0x0a
17307
17308static hda_nid_t alc662_dac_nids[4] = {
17309 /* front, rear, clfe, rear_surr */
17310 0x02, 0x03, 0x04
17311};
17312
Kailang Yang622e84c2009-04-21 07:39:04 +020017313static hda_nid_t alc272_dac_nids[2] = {
17314 0x02, 0x03
17315};
17316
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017317static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017318 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017319 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017320};
Takashi Iwaie1406342008-02-11 18:32:32 +010017321
Kailang Yang622e84c2009-04-21 07:39:04 +020017322static hda_nid_t alc272_adc_nids[1] = {
17323 /* ADC1-2 */
17324 0x08,
17325};
17326
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017327static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017328static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17329
Takashi Iwaie1406342008-02-11 18:32:32 +010017330
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017331/* input MUX */
17332/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017333static struct hda_input_mux alc662_capture_source = {
17334 .num_items = 4,
17335 .items = {
17336 { "Mic", 0x0 },
17337 { "Front Mic", 0x1 },
17338 { "Line", 0x2 },
17339 { "CD", 0x4 },
17340 },
17341};
17342
17343static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17344 .num_items = 2,
17345 .items = {
17346 { "Mic", 0x1 },
17347 { "Line", 0x2 },
17348 },
17349};
Kailang Yang291702f2007-10-16 14:28:03 +020017350
Kailang Yang6dda9f42008-05-27 12:05:31 +020017351static struct hda_input_mux alc663_capture_source = {
17352 .num_items = 3,
17353 .items = {
17354 { "Mic", 0x0 },
17355 { "Front Mic", 0x1 },
17356 { "Line", 0x2 },
17357 },
17358};
17359
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017360#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017361static struct hda_input_mux alc272_nc10_capture_source = {
17362 .num_items = 16,
17363 .items = {
17364 { "Autoselect Mic", 0x0 },
17365 { "Internal Mic", 0x1 },
17366 { "In-0x02", 0x2 },
17367 { "In-0x03", 0x3 },
17368 { "In-0x04", 0x4 },
17369 { "In-0x05", 0x5 },
17370 { "In-0x06", 0x6 },
17371 { "In-0x07", 0x7 },
17372 { "In-0x08", 0x8 },
17373 { "In-0x09", 0x9 },
17374 { "In-0x0a", 0x0a },
17375 { "In-0x0b", 0x0b },
17376 { "In-0x0c", 0x0c },
17377 { "In-0x0d", 0x0d },
17378 { "In-0x0e", 0x0e },
17379 { "In-0x0f", 0x0f },
17380 },
17381};
17382#endif
17383
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017384/*
17385 * 2ch mode
17386 */
17387static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17388 { 2, NULL }
17389};
17390
17391/*
17392 * 2ch mode
17393 */
17394static struct hda_verb alc662_3ST_ch2_init[] = {
17395 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17396 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17397 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17398 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17399 { } /* end */
17400};
17401
17402/*
17403 * 6ch mode
17404 */
17405static struct hda_verb alc662_3ST_ch6_init[] = {
17406 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17407 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17408 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17409 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17410 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17411 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17412 { } /* end */
17413};
17414
17415static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17416 { 2, alc662_3ST_ch2_init },
17417 { 6, alc662_3ST_ch6_init },
17418};
17419
17420/*
17421 * 2ch mode
17422 */
17423static struct hda_verb alc662_sixstack_ch6_init[] = {
17424 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17425 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17426 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17427 { } /* end */
17428};
17429
17430/*
17431 * 6ch mode
17432 */
17433static struct hda_verb alc662_sixstack_ch8_init[] = {
17434 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17435 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17436 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17437 { } /* end */
17438};
17439
17440static struct hda_channel_mode alc662_5stack_modes[2] = {
17441 { 2, alc662_sixstack_ch6_init },
17442 { 6, alc662_sixstack_ch8_init },
17443};
17444
17445/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17446 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17447 */
17448
17449static struct snd_kcontrol_new alc662_base_mixer[] = {
17450 /* output mixer control */
17451 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017452 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017453 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017454 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017455 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17456 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017457 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17458 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017459 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17460
17461 /*Input mixer control */
17462 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17463 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17464 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17465 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17466 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17467 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17468 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17469 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017470 { } /* end */
17471};
17472
17473static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17474 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017475 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017476 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17477 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17478 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17479 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17480 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17481 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17482 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17483 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17484 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017485 { } /* end */
17486};
17487
17488static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17489 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017490 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017491 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017492 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017493 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17494 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017495 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17496 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017497 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17498 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17499 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17500 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17501 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17502 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17503 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17504 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17505 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017506 { } /* end */
17507};
17508
17509static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17510 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17511 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017512 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17513 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017514 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17515 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17516 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17517 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17518 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017519 { } /* end */
17520};
17521
Kailang Yang291702f2007-10-16 14:28:03 +020017522static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017523 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17524 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017525
17526 HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
17527 HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17528 HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17529
17530 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
17531 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17532 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17533 { } /* end */
17534};
17535
Kailang Yang8c427222008-01-10 13:03:59 +010017536static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017537 ALC262_HIPPO_MASTER_SWITCH,
17538 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017539 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017540 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17541 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017542 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17543 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17544 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17545 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17546 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17547 { } /* end */
17548};
17549
Kailang Yangf1d4e282008-08-26 14:03:29 +020017550static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17551 .ops = &snd_hda_bind_vol,
17552 .values = {
17553 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17554 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17555 0
17556 },
17557};
17558
17559static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17560 .ops = &snd_hda_bind_sw,
17561 .values = {
17562 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17563 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17564 0
17565 },
17566};
17567
Kailang Yang6dda9f42008-05-27 12:05:31 +020017568static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017569 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17570 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17571 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17572 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17573 { } /* end */
17574};
17575
17576static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17577 .ops = &snd_hda_bind_sw,
17578 .values = {
17579 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17580 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17581 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17582 0
17583 },
17584};
17585
17586static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17587 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17588 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17589 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17590 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17591 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17592 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17593
17594 { } /* end */
17595};
17596
17597static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17598 .ops = &snd_hda_bind_sw,
17599 .values = {
17600 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17601 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17602 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17603 0
17604 },
17605};
17606
17607static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17608 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17609 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17610 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17611 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17612 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17613 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17614 { } /* end */
17615};
17616
17617static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017618 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17619 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017620 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17621 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17622 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17623 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17624 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17625 { } /* end */
17626};
17627
17628static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17629 .ops = &snd_hda_bind_vol,
17630 .values = {
17631 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17632 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17633 0
17634 },
17635};
17636
17637static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17638 .ops = &snd_hda_bind_sw,
17639 .values = {
17640 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17641 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17642 0
17643 },
17644};
17645
17646static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17647 HDA_BIND_VOL("Master Playback Volume",
17648 &alc663_asus_two_bind_master_vol),
17649 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17650 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017651 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17652 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17653 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017654 { } /* end */
17655};
17656
17657static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17658 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17659 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17660 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17661 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17662 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17663 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017664 { } /* end */
17665};
17666
17667static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17668 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17669 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17670 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17671 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17672 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17673
17674 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17675 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17676 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17677 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17678 { } /* end */
17679};
17680
17681static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17682 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17683 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17684 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17685
17686 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17687 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17688 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17689 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17690 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17691 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17692 { } /* end */
17693};
17694
Kailang Yangebb83ee2009-12-17 12:23:00 +010017695static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17696 .ops = &snd_hda_bind_sw,
17697 .values = {
17698 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17699 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17700 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17701 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17702 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17703 0
17704 },
17705};
17706
17707static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17708 .ops = &snd_hda_bind_sw,
17709 .values = {
17710 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17711 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17712 0
17713 },
17714};
17715
17716static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17717 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17718 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17719 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17720 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17721 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17722 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17723 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17724 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17725 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17726 { } /* end */
17727};
17728
17729static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17730 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17731 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17732 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17733 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17734 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17735 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17736 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17737 { } /* end */
17738};
17739
17740
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017741static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17742 {
17743 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17744 .name = "Channel Mode",
17745 .info = alc_ch_mode_info,
17746 .get = alc_ch_mode_get,
17747 .put = alc_ch_mode_put,
17748 },
17749 { } /* end */
17750};
17751
17752static struct hda_verb alc662_init_verbs[] = {
17753 /* ADC: mute amp left and right */
17754 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17755 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017756
Kailang Yangb60dd392007-09-20 12:50:29 +020017757 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17758 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17759 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17760 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17761 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17762 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017763
17764 /* Front Pin: output 0 (0x0c) */
17765 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17766 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17767
17768 /* Rear Pin: output 1 (0x0d) */
17769 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17770 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17771
17772 /* CLFE Pin: output 2 (0x0e) */
17773 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17774 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17775
17776 /* Mic (rear) pin: input vref at 80% */
17777 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17778 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17779 /* Front Mic pin: input vref at 80% */
17780 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17781 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17782 /* Line In pin: input */
17783 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17784 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17785 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17786 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17787 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17788 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17789 /* CD pin widget for input */
17790 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17791
17792 /* FIXME: use matrix-type input source selection */
17793 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17794 /* Input mixer */
17795 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017796 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017797
17798 /* always trun on EAPD */
17799 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17800 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17801
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017802 { }
17803};
17804
Kailang Yangcec27c82010-02-04 14:18:18 +010017805static struct hda_verb alc663_init_verbs[] = {
17806 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17807 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17808 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17809 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17810 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17811 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17812 { }
17813};
17814
17815static struct hda_verb alc272_init_verbs[] = {
17816 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17817 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17818 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17819 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17820 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17821 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17822 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17823 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17824 { }
17825};
17826
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017827static struct hda_verb alc662_sue_init_verbs[] = {
17828 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17829 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017830 {}
17831};
17832
17833static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17834 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17835 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17836 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017837};
17838
Kailang Yang8c427222008-01-10 13:03:59 +010017839/* Set Unsolicited Event*/
17840static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17841 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17842 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17843 {}
17844};
17845
Kailang Yang6dda9f42008-05-27 12:05:31 +020017846static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017847 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17848 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017849 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17850 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017851 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17852 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17853 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017854 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17855 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17856 {}
17857};
17858
Kailang Yangf1d4e282008-08-26 14:03:29 +020017859static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17860 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17861 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17862 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17863 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17864 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17865 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17866 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17867 {}
17868};
17869
17870static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17871 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17872 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17873 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17874 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17875 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17876 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17877 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17878 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17879 {}
17880};
17881
17882static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17883 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17884 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17885 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17886 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17887 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17888 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17889 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17890 {}
17891};
17892
17893static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17894 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17895 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17896 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17897 {0x21, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17898 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17899 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17900 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
17901 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17902 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17903 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17904 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17905 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17906 {}
17907};
17908
17909static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
17910 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17911 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17912 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17913 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17914 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17915 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17916 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17917 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17918 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17919 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17920 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17921 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17922 {}
17923};
17924
Kailang Yang6dda9f42008-05-27 12:05:31 +020017925static struct hda_verb alc663_g71v_init_verbs[] = {
17926 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17927 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
17928 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
17929
17930 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17931 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17932 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17933
17934 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17935 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
17936 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
17937 {}
17938};
17939
17940static struct hda_verb alc663_g50v_init_verbs[] = {
17941 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17942 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17943 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17944
17945 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17946 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17947 {}
17948};
17949
Kailang Yangf1d4e282008-08-26 14:03:29 +020017950static struct hda_verb alc662_ecs_init_verbs[] = {
17951 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
17952 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17953 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17954 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17955 {}
17956};
17957
Kailang Yang622e84c2009-04-21 07:39:04 +020017958static struct hda_verb alc272_dell_zm1_init_verbs[] = {
17959 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17960 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17961 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17962 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17963 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17964 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17965 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17966 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17967 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17968 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17969 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17970 {}
17971};
17972
17973static struct hda_verb alc272_dell_init_verbs[] = {
17974 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17975 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17976 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17977 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17978 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17979 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17980 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17981 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17982 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
17983 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17984 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17985 {}
17986};
17987
Kailang Yangebb83ee2009-12-17 12:23:00 +010017988static struct hda_verb alc663_mode7_init_verbs[] = {
17989 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17990 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17991 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17992 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17993 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17994 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17995 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
17996 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17997 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17998 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17999 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18000 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18001 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18002 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18003 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18004 {}
18005};
18006
18007static struct hda_verb alc663_mode8_init_verbs[] = {
18008 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18009 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18010 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18011 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18012 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18013 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18014 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18015 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18016 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18017 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18018 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18019 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18020 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18021 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18022 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18023 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18024 {}
18025};
18026
Kailang Yangf1d4e282008-08-26 14:03:29 +020018027static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18028 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18029 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18030 { } /* end */
18031};
18032
Kailang Yang622e84c2009-04-21 07:39:04 +020018033static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18034 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18035 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18036 { } /* end */
18037};
18038
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018039static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18040{
18041 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018042 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018043
Wu Fengguang864f92b2009-11-18 12:38:02 +080018044 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018045 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018046
Takashi Iwai47fd8302007-08-10 17:11:07 +020018047 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18048 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018049}
18050
18051static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18052{
18053 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018054 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018055
Wu Fengguang864f92b2009-11-18 12:38:02 +080018056 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018057 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018058
Takashi Iwai47fd8302007-08-10 17:11:07 +020018059 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18060 HDA_AMP_MUTE, bits);
18061 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18062 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018063}
18064
18065static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18066 unsigned int res)
18067{
18068 if ((res >> 26) == ALC880_HP_EVENT)
18069 alc662_lenovo_101e_all_automute(codec);
18070 if ((res >> 26) == ALC880_FRONT_EVENT)
18071 alc662_lenovo_101e_ispeaker_automute(codec);
18072}
18073
Kailang Yang291702f2007-10-16 14:28:03 +020018074/* unsolicited event for HP jack sensing */
18075static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18076 unsigned int res)
18077{
Kailang Yang291702f2007-10-16 14:28:03 +020018078 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018079 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018080 else
18081 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018082}
18083
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018084static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018085{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018086 struct alc_spec *spec = codec->spec;
18087
18088 alc262_hippo1_setup(codec);
18089 spec->ext_mic.pin = 0x18;
18090 spec->ext_mic.mux_idx = 0;
18091 spec->int_mic.pin = 0x19;
18092 spec->int_mic.mux_idx = 1;
18093 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018094}
18095
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018096static void alc662_eeepc_inithook(struct hda_codec *codec)
18097{
18098 alc262_hippo_automute(codec);
18099 alc_mic_automute(codec);
18100}
18101
18102static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018103{
Takashi Iwai42171c12009-05-08 14:11:43 +020018104 struct alc_spec *spec = codec->spec;
18105
18106 spec->autocfg.hp_pins[0] = 0x14;
18107 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018108}
18109
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018110#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18111
Kailang Yang6dda9f42008-05-27 12:05:31 +020018112static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18113{
18114 unsigned int present;
18115 unsigned char bits;
18116
Wu Fengguang864f92b2009-11-18 12:38:02 +080018117 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018118 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018119 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018120 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018121 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018122 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018123}
18124
18125static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18126{
18127 unsigned int present;
18128 unsigned char bits;
18129
Wu Fengguang864f92b2009-11-18 12:38:02 +080018130 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018131 bits = present ? HDA_AMP_MUTE : 0;
18132 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018133 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018134 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018135 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018136 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018137 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018138 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018139 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018140}
18141
18142static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18143{
18144 unsigned int present;
18145 unsigned char bits;
18146
Wu Fengguang864f92b2009-11-18 12:38:02 +080018147 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018148 bits = present ? HDA_AMP_MUTE : 0;
18149 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018150 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018151 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018152 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018153 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018154 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018155 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018156 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018157}
18158
18159static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18160{
18161 unsigned int present;
18162 unsigned char bits;
18163
Wu Fengguang864f92b2009-11-18 12:38:02 +080018164 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018165 bits = present ? 0 : PIN_OUT;
18166 snd_hda_codec_write(codec, 0x14, 0,
18167 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18168}
18169
18170static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18171{
18172 unsigned int present1, present2;
18173
Wu Fengguang864f92b2009-11-18 12:38:02 +080018174 present1 = snd_hda_jack_detect(codec, 0x21);
18175 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018176
18177 if (present1 || present2) {
18178 snd_hda_codec_write_cache(codec, 0x14, 0,
18179 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18180 } else {
18181 snd_hda_codec_write_cache(codec, 0x14, 0,
18182 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18183 }
18184}
18185
18186static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18187{
18188 unsigned int present1, present2;
18189
Wu Fengguang864f92b2009-11-18 12:38:02 +080018190 present1 = snd_hda_jack_detect(codec, 0x1b);
18191 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018192
18193 if (present1 || present2) {
18194 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018195 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018196 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018197 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018198 } else {
18199 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018200 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018201 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018202 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018203 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018204}
18205
Kailang Yangebb83ee2009-12-17 12:23:00 +010018206static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18207{
18208 unsigned int present1, present2;
18209
18210 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18211 AC_VERB_GET_PIN_SENSE, 0)
18212 & AC_PINSENSE_PRESENCE;
18213 present2 = snd_hda_codec_read(codec, 0x21, 0,
18214 AC_VERB_GET_PIN_SENSE, 0)
18215 & AC_PINSENSE_PRESENCE;
18216
18217 if (present1 || present2) {
18218 snd_hda_codec_write_cache(codec, 0x14, 0,
18219 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18220 snd_hda_codec_write_cache(codec, 0x17, 0,
18221 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18222 } else {
18223 snd_hda_codec_write_cache(codec, 0x14, 0,
18224 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18225 snd_hda_codec_write_cache(codec, 0x17, 0,
18226 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18227 }
18228}
18229
18230static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18231{
18232 unsigned int present1, present2;
18233
18234 present1 = snd_hda_codec_read(codec, 0x21, 0,
18235 AC_VERB_GET_PIN_SENSE, 0)
18236 & AC_PINSENSE_PRESENCE;
18237 present2 = snd_hda_codec_read(codec, 0x15, 0,
18238 AC_VERB_GET_PIN_SENSE, 0)
18239 & AC_PINSENSE_PRESENCE;
18240
18241 if (present1 || present2) {
18242 snd_hda_codec_write_cache(codec, 0x14, 0,
18243 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18244 snd_hda_codec_write_cache(codec, 0x17, 0,
18245 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18246 } else {
18247 snd_hda_codec_write_cache(codec, 0x14, 0,
18248 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18249 snd_hda_codec_write_cache(codec, 0x17, 0,
18250 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18251 }
18252}
18253
Kailang Yang6dda9f42008-05-27 12:05:31 +020018254static void alc663_m51va_unsol_event(struct hda_codec *codec,
18255 unsigned int res)
18256{
18257 switch (res >> 26) {
18258 case ALC880_HP_EVENT:
18259 alc663_m51va_speaker_automute(codec);
18260 break;
18261 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018262 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018263 break;
18264 }
18265}
18266
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018267static void alc663_m51va_setup(struct hda_codec *codec)
18268{
18269 struct alc_spec *spec = codec->spec;
18270 spec->ext_mic.pin = 0x18;
18271 spec->ext_mic.mux_idx = 0;
18272 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018273 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018274 spec->auto_mic = 1;
18275}
18276
Kailang Yang6dda9f42008-05-27 12:05:31 +020018277static void alc663_m51va_inithook(struct hda_codec *codec)
18278{
18279 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018280 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018281}
18282
Kailang Yangf1d4e282008-08-26 14:03:29 +020018283/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018284#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018285
18286static void alc663_mode1_setup(struct hda_codec *codec)
18287{
18288 struct alc_spec *spec = codec->spec;
18289 spec->ext_mic.pin = 0x18;
18290 spec->ext_mic.mux_idx = 0;
18291 spec->int_mic.pin = 0x19;
18292 spec->int_mic.mux_idx = 1;
18293 spec->auto_mic = 1;
18294}
18295
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018296#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018297
Kailang Yangf1d4e282008-08-26 14:03:29 +020018298/* ***************** Mode2 ******************************/
18299static void alc662_mode2_unsol_event(struct hda_codec *codec,
18300 unsigned int res)
18301{
18302 switch (res >> 26) {
18303 case ALC880_HP_EVENT:
18304 alc662_f5z_speaker_automute(codec);
18305 break;
18306 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018307 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018308 break;
18309 }
18310}
18311
Kailang Yangebb83ee2009-12-17 12:23:00 +010018312#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018313
Kailang Yangf1d4e282008-08-26 14:03:29 +020018314static void alc662_mode2_inithook(struct hda_codec *codec)
18315{
18316 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018317 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018318}
18319/* ***************** Mode3 ******************************/
18320static void alc663_mode3_unsol_event(struct hda_codec *codec,
18321 unsigned int res)
18322{
18323 switch (res >> 26) {
18324 case ALC880_HP_EVENT:
18325 alc663_two_hp_m1_speaker_automute(codec);
18326 break;
18327 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018328 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018329 break;
18330 }
18331}
18332
Kailang Yangebb83ee2009-12-17 12:23:00 +010018333#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018334
Kailang Yangf1d4e282008-08-26 14:03:29 +020018335static void alc663_mode3_inithook(struct hda_codec *codec)
18336{
18337 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018338 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018339}
18340/* ***************** Mode4 ******************************/
18341static void alc663_mode4_unsol_event(struct hda_codec *codec,
18342 unsigned int res)
18343{
18344 switch (res >> 26) {
18345 case ALC880_HP_EVENT:
18346 alc663_21jd_two_speaker_automute(codec);
18347 break;
18348 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018349 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018350 break;
18351 }
18352}
18353
Kailang Yangebb83ee2009-12-17 12:23:00 +010018354#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018355
Kailang Yangf1d4e282008-08-26 14:03:29 +020018356static void alc663_mode4_inithook(struct hda_codec *codec)
18357{
18358 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018359 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018360}
18361/* ***************** Mode5 ******************************/
18362static void alc663_mode5_unsol_event(struct hda_codec *codec,
18363 unsigned int res)
18364{
18365 switch (res >> 26) {
18366 case ALC880_HP_EVENT:
18367 alc663_15jd_two_speaker_automute(codec);
18368 break;
18369 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018370 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018371 break;
18372 }
18373}
18374
Kailang Yangebb83ee2009-12-17 12:23:00 +010018375#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018376
Kailang Yangf1d4e282008-08-26 14:03:29 +020018377static void alc663_mode5_inithook(struct hda_codec *codec)
18378{
18379 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018380 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018381}
18382/* ***************** Mode6 ******************************/
18383static void alc663_mode6_unsol_event(struct hda_codec *codec,
18384 unsigned int res)
18385{
18386 switch (res >> 26) {
18387 case ALC880_HP_EVENT:
18388 alc663_two_hp_m2_speaker_automute(codec);
18389 break;
18390 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018391 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018392 break;
18393 }
18394}
18395
Kailang Yangebb83ee2009-12-17 12:23:00 +010018396#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018397
Kailang Yangf1d4e282008-08-26 14:03:29 +020018398static void alc663_mode6_inithook(struct hda_codec *codec)
18399{
18400 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018401 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018402}
18403
Kailang Yangebb83ee2009-12-17 12:23:00 +010018404/* ***************** Mode7 ******************************/
18405static void alc663_mode7_unsol_event(struct hda_codec *codec,
18406 unsigned int res)
18407{
18408 switch (res >> 26) {
18409 case ALC880_HP_EVENT:
18410 alc663_two_hp_m7_speaker_automute(codec);
18411 break;
18412 case ALC880_MIC_EVENT:
18413 alc_mic_automute(codec);
18414 break;
18415 }
18416}
18417
18418#define alc663_mode7_setup alc663_mode1_setup
18419
18420static void alc663_mode7_inithook(struct hda_codec *codec)
18421{
18422 alc663_two_hp_m7_speaker_automute(codec);
18423 alc_mic_automute(codec);
18424}
18425
18426/* ***************** Mode8 ******************************/
18427static void alc663_mode8_unsol_event(struct hda_codec *codec,
18428 unsigned int res)
18429{
18430 switch (res >> 26) {
18431 case ALC880_HP_EVENT:
18432 alc663_two_hp_m8_speaker_automute(codec);
18433 break;
18434 case ALC880_MIC_EVENT:
18435 alc_mic_automute(codec);
18436 break;
18437 }
18438}
18439
18440#define alc663_mode8_setup alc663_m51va_setup
18441
18442static void alc663_mode8_inithook(struct hda_codec *codec)
18443{
18444 alc663_two_hp_m8_speaker_automute(codec);
18445 alc_mic_automute(codec);
18446}
18447
Kailang Yang6dda9f42008-05-27 12:05:31 +020018448static void alc663_g71v_hp_automute(struct hda_codec *codec)
18449{
18450 unsigned int present;
18451 unsigned char bits;
18452
Wu Fengguang864f92b2009-11-18 12:38:02 +080018453 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018454 bits = present ? HDA_AMP_MUTE : 0;
18455 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18456 HDA_AMP_MUTE, bits);
18457 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18458 HDA_AMP_MUTE, bits);
18459}
18460
18461static void alc663_g71v_front_automute(struct hda_codec *codec)
18462{
18463 unsigned int present;
18464 unsigned char bits;
18465
Wu Fengguang864f92b2009-11-18 12:38:02 +080018466 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018467 bits = present ? HDA_AMP_MUTE : 0;
18468 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18469 HDA_AMP_MUTE, bits);
18470}
18471
18472static void alc663_g71v_unsol_event(struct hda_codec *codec,
18473 unsigned int res)
18474{
18475 switch (res >> 26) {
18476 case ALC880_HP_EVENT:
18477 alc663_g71v_hp_automute(codec);
18478 break;
18479 case ALC880_FRONT_EVENT:
18480 alc663_g71v_front_automute(codec);
18481 break;
18482 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018483 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018484 break;
18485 }
18486}
18487
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018488#define alc663_g71v_setup alc663_m51va_setup
18489
Kailang Yang6dda9f42008-05-27 12:05:31 +020018490static void alc663_g71v_inithook(struct hda_codec *codec)
18491{
18492 alc663_g71v_front_automute(codec);
18493 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018494 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018495}
18496
18497static void alc663_g50v_unsol_event(struct hda_codec *codec,
18498 unsigned int res)
18499{
18500 switch (res >> 26) {
18501 case ALC880_HP_EVENT:
18502 alc663_m51va_speaker_automute(codec);
18503 break;
18504 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018505 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018506 break;
18507 }
18508}
18509
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018510#define alc663_g50v_setup alc663_m51va_setup
18511
Kailang Yang6dda9f42008-05-27 12:05:31 +020018512static void alc663_g50v_inithook(struct hda_codec *codec)
18513{
18514 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018515 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018516}
18517
Kailang Yangf1d4e282008-08-26 14:03:29 +020018518static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18519 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018520 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018521
18522 HDA_CODEC_VOLUME("e-Mic/LineIn Boost", 0x18, 0, HDA_INPUT),
18523 HDA_CODEC_VOLUME("e-Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18524 HDA_CODEC_MUTE("e-Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
18525
18526 HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
18527 HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18528 HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18529 { } /* end */
18530};
18531
Chris Pockelé9541ba12009-05-12 08:08:53 +020018532static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18533 /* Master Playback automatically created from Speaker and Headphone */
18534 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18535 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18536 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18537 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18538
18539 HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18540 HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
18541 HDA_CODEC_VOLUME("Ext Mic Boost", 0x18, 0, HDA_INPUT),
18542
18543 HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18544 HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
18545 HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
18546 { } /* end */
18547};
18548
Takashi Iwaicb53c622007-08-10 17:21:45 +020018549#ifdef CONFIG_SND_HDA_POWER_SAVE
18550#define alc662_loopbacks alc880_loopbacks
18551#endif
18552
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018553
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018554/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018555#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18556#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18557#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18558#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18559
18560/*
18561 * configuration and preset
18562 */
18563static const char *alc662_models[ALC662_MODEL_LAST] = {
18564 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18565 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18566 [ALC662_3ST_6ch] = "3stack-6ch",
18567 [ALC662_5ST_DIG] = "6stack-dig",
18568 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018569 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018570 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018571 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018572 [ALC663_ASUS_M51VA] = "m51va",
18573 [ALC663_ASUS_G71V] = "g71v",
18574 [ALC663_ASUS_H13] = "h13",
18575 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018576 [ALC663_ASUS_MODE1] = "asus-mode1",
18577 [ALC662_ASUS_MODE2] = "asus-mode2",
18578 [ALC663_ASUS_MODE3] = "asus-mode3",
18579 [ALC663_ASUS_MODE4] = "asus-mode4",
18580 [ALC663_ASUS_MODE5] = "asus-mode5",
18581 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018582 [ALC663_ASUS_MODE7] = "asus-mode7",
18583 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018584 [ALC272_DELL] = "dell",
18585 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018586 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018587 [ALC662_AUTO] = "auto",
18588};
18589
18590static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018591 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018592 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18593 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018594 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18595 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018596 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018597 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18598 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18599 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18600 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018601 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18602 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018603 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018604 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18605 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18606 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18607 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18608 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018609 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018610 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18611 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018612 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18613 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18614 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18615 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018616 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018617 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18618 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18619 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018620 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18621 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18622 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18623 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018624 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018625 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18626 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018627 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018628 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18629 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18630 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018631 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018632 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018633 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18634 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018635 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18636 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18637 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018638 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018639 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18640 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018641 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018642 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018643 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018644 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18645 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18646 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018647 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018648 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18649 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018650 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018651 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018652 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018653 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018654 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18655 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018656 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018657 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018658 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18659 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018660 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018661 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018662 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018663 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018664 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018665 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018666 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18667 ALC663_ASUS_H13),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018668 {}
18669};
18670
18671static struct alc_config_preset alc662_presets[] = {
18672 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018673 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018674 .init_verbs = { alc662_init_verbs },
18675 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18676 .dac_nids = alc662_dac_nids,
18677 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018678 .dig_in_nid = ALC662_DIGIN_NID,
18679 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18680 .channel_mode = alc662_3ST_2ch_modes,
18681 .input_mux = &alc662_capture_source,
18682 },
18683 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018684 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018685 .init_verbs = { alc662_init_verbs },
18686 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18687 .dac_nids = alc662_dac_nids,
18688 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018689 .dig_in_nid = ALC662_DIGIN_NID,
18690 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18691 .channel_mode = alc662_3ST_6ch_modes,
18692 .need_dac_fix = 1,
18693 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018694 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018695 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018696 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018697 .init_verbs = { alc662_init_verbs },
18698 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18699 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018700 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18701 .channel_mode = alc662_3ST_6ch_modes,
18702 .need_dac_fix = 1,
18703 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018704 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018705 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018706 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018707 .init_verbs = { alc662_init_verbs },
18708 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18709 .dac_nids = alc662_dac_nids,
18710 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018711 .dig_in_nid = ALC662_DIGIN_NID,
18712 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18713 .channel_mode = alc662_5stack_modes,
18714 .input_mux = &alc662_capture_source,
18715 },
18716 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018717 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018718 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18719 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18720 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018721 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18722 .channel_mode = alc662_3ST_2ch_modes,
18723 .input_mux = &alc662_lenovo_101e_capture_source,
18724 .unsol_event = alc662_lenovo_101e_unsol_event,
18725 .init_hook = alc662_lenovo_101e_all_automute,
18726 },
Kailang Yang291702f2007-10-16 14:28:03 +020018727 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018728 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018729 .init_verbs = { alc662_init_verbs,
18730 alc662_eeepc_sue_init_verbs },
18731 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18732 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018733 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18734 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018735 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018736 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018737 .init_hook = alc662_eeepc_inithook,
18738 },
Kailang Yang8c427222008-01-10 13:03:59 +010018739 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018740 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018741 alc662_chmode_mixer },
18742 .init_verbs = { alc662_init_verbs,
18743 alc662_eeepc_ep20_sue_init_verbs },
18744 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18745 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018746 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18747 .channel_mode = alc662_3ST_6ch_modes,
18748 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018749 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018750 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018751 .init_hook = alc662_eeepc_ep20_inithook,
18752 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018753 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018754 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018755 .init_verbs = { alc662_init_verbs,
18756 alc662_ecs_init_verbs },
18757 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18758 .dac_nids = alc662_dac_nids,
18759 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18760 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018761 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018762 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018763 .init_hook = alc662_eeepc_inithook,
18764 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018765 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018766 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018767 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18768 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18769 .dac_nids = alc662_dac_nids,
18770 .dig_out_nid = ALC662_DIGOUT_NID,
18771 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18772 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018773 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018774 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018775 .init_hook = alc663_m51va_inithook,
18776 },
18777 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018778 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018779 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18780 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18781 .dac_nids = alc662_dac_nids,
18782 .dig_out_nid = ALC662_DIGOUT_NID,
18783 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18784 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018785 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018786 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018787 .init_hook = alc663_g71v_inithook,
18788 },
18789 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018790 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018791 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18792 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18793 .dac_nids = alc662_dac_nids,
18794 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18795 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018796 .unsol_event = alc663_m51va_unsol_event,
18797 .init_hook = alc663_m51va_inithook,
18798 },
18799 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018800 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018801 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18802 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18803 .dac_nids = alc662_dac_nids,
18804 .dig_out_nid = ALC662_DIGOUT_NID,
18805 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18806 .channel_mode = alc662_3ST_6ch_modes,
18807 .input_mux = &alc663_capture_source,
18808 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018809 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018810 .init_hook = alc663_g50v_inithook,
18811 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018812 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018813 .mixers = { alc663_m51va_mixer },
18814 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018815 .init_verbs = { alc662_init_verbs,
18816 alc663_21jd_amic_init_verbs },
18817 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18818 .hp_nid = 0x03,
18819 .dac_nids = alc662_dac_nids,
18820 .dig_out_nid = ALC662_DIGOUT_NID,
18821 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18822 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018823 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018824 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018825 .init_hook = alc663_mode1_inithook,
18826 },
18827 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018828 .mixers = { alc662_1bjd_mixer },
18829 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018830 .init_verbs = { alc662_init_verbs,
18831 alc662_1bjd_amic_init_verbs },
18832 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18833 .dac_nids = alc662_dac_nids,
18834 .dig_out_nid = ALC662_DIGOUT_NID,
18835 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18836 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018837 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018838 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018839 .init_hook = alc662_mode2_inithook,
18840 },
18841 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018842 .mixers = { alc663_two_hp_m1_mixer },
18843 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018844 .init_verbs = { alc662_init_verbs,
18845 alc663_two_hp_amic_m1_init_verbs },
18846 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18847 .hp_nid = 0x03,
18848 .dac_nids = alc662_dac_nids,
18849 .dig_out_nid = ALC662_DIGOUT_NID,
18850 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18851 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018852 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018853 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018854 .init_hook = alc663_mode3_inithook,
18855 },
18856 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018857 .mixers = { alc663_asus_21jd_clfe_mixer },
18858 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018859 .init_verbs = { alc662_init_verbs,
18860 alc663_21jd_amic_init_verbs},
18861 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18862 .hp_nid = 0x03,
18863 .dac_nids = alc662_dac_nids,
18864 .dig_out_nid = ALC662_DIGOUT_NID,
18865 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18866 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018867 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018868 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018869 .init_hook = alc663_mode4_inithook,
18870 },
18871 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018872 .mixers = { alc663_asus_15jd_clfe_mixer },
18873 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018874 .init_verbs = { alc662_init_verbs,
18875 alc663_15jd_amic_init_verbs },
18876 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18877 .hp_nid = 0x03,
18878 .dac_nids = alc662_dac_nids,
18879 .dig_out_nid = ALC662_DIGOUT_NID,
18880 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18881 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018882 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018883 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018884 .init_hook = alc663_mode5_inithook,
18885 },
18886 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018887 .mixers = { alc663_two_hp_m2_mixer },
18888 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018889 .init_verbs = { alc662_init_verbs,
18890 alc663_two_hp_amic_m2_init_verbs },
18891 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18892 .hp_nid = 0x03,
18893 .dac_nids = alc662_dac_nids,
18894 .dig_out_nid = ALC662_DIGOUT_NID,
18895 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18896 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018897 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018898 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018899 .init_hook = alc663_mode6_inithook,
18900 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010018901 [ALC663_ASUS_MODE7] = {
18902 .mixers = { alc663_mode7_mixer },
18903 .cap_mixer = alc662_auto_capture_mixer,
18904 .init_verbs = { alc662_init_verbs,
18905 alc663_mode7_init_verbs },
18906 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18907 .hp_nid = 0x03,
18908 .dac_nids = alc662_dac_nids,
18909 .dig_out_nid = ALC662_DIGOUT_NID,
18910 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18911 .channel_mode = alc662_3ST_2ch_modes,
18912 .unsol_event = alc663_mode7_unsol_event,
18913 .setup = alc663_mode7_setup,
18914 .init_hook = alc663_mode7_inithook,
18915 },
18916 [ALC663_ASUS_MODE8] = {
18917 .mixers = { alc663_mode8_mixer },
18918 .cap_mixer = alc662_auto_capture_mixer,
18919 .init_verbs = { alc662_init_verbs,
18920 alc663_mode8_init_verbs },
18921 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18922 .hp_nid = 0x03,
18923 .dac_nids = alc662_dac_nids,
18924 .dig_out_nid = ALC662_DIGOUT_NID,
18925 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18926 .channel_mode = alc662_3ST_2ch_modes,
18927 .unsol_event = alc663_mode8_unsol_event,
18928 .setup = alc663_mode8_setup,
18929 .init_hook = alc663_mode8_inithook,
18930 },
Kailang Yang622e84c2009-04-21 07:39:04 +020018931 [ALC272_DELL] = {
18932 .mixers = { alc663_m51va_mixer },
18933 .cap_mixer = alc272_auto_capture_mixer,
18934 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
18935 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18936 .dac_nids = alc662_dac_nids,
18937 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18938 .adc_nids = alc272_adc_nids,
18939 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
18940 .capsrc_nids = alc272_capsrc_nids,
18941 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018942 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018943 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018944 .init_hook = alc663_m51va_inithook,
18945 },
18946 [ALC272_DELL_ZM1] = {
18947 .mixers = { alc663_m51va_mixer },
18948 .cap_mixer = alc662_auto_capture_mixer,
18949 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
18950 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18951 .dac_nids = alc662_dac_nids,
18952 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18953 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020018954 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020018955 .capsrc_nids = alc662_capsrc_nids,
18956 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020018957 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018958 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020018959 .init_hook = alc663_m51va_inithook,
18960 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020018961 [ALC272_SAMSUNG_NC10] = {
18962 .mixers = { alc272_nc10_mixer },
18963 .init_verbs = { alc662_init_verbs,
18964 alc663_21jd_amic_init_verbs },
18965 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
18966 .dac_nids = alc272_dac_nids,
18967 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18968 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018969 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020018970 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018971 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020018972 .init_hook = alc663_mode4_inithook,
18973 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018974};
18975
18976
18977/*
18978 * BIOS auto configuration
18979 */
18980
Takashi Iwai7085ec12009-10-02 09:03:58 +020018981/* convert from MIX nid to DAC */
18982static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
18983{
18984 if (nid == 0x0f)
18985 return 0x02;
18986 else if (nid >= 0x0c && nid <= 0x0e)
18987 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010018988 else if (nid == 0x26) /* ALC887-VD has this DAC too */
18989 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020018990 else
18991 return 0;
18992}
18993
18994/* get MIX nid connected to the given pin targeted to DAC */
18995static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
18996 hda_nid_t dac)
18997{
David Henningssoncc1c4522010-11-24 14:17:47 +010018998 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020018999 int i, num;
19000
19001 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19002 for (i = 0; i < num; i++) {
19003 if (alc662_mix_to_dac(mix[i]) == dac)
19004 return mix[i];
19005 }
19006 return 0;
19007}
19008
19009/* look for an empty DAC slot */
19010static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19011{
19012 struct alc_spec *spec = codec->spec;
19013 hda_nid_t srcs[5];
19014 int i, j, num;
19015
19016 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19017 if (num < 0)
19018 return 0;
19019 for (i = 0; i < num; i++) {
19020 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19021 if (!nid)
19022 continue;
19023 for (j = 0; j < spec->multiout.num_dacs; j++)
19024 if (spec->multiout.dac_nids[j] == nid)
19025 break;
19026 if (j >= spec->multiout.num_dacs)
19027 return nid;
19028 }
19029 return 0;
19030}
19031
19032/* fill in the dac_nids table from the parsed pin configuration */
19033static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19034 const struct auto_pin_cfg *cfg)
19035{
19036 struct alc_spec *spec = codec->spec;
19037 int i;
19038 hda_nid_t dac;
19039
19040 spec->multiout.dac_nids = spec->private_dac_nids;
19041 for (i = 0; i < cfg->line_outs; i++) {
19042 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19043 if (!dac)
19044 continue;
19045 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19046 }
19047 return 0;
19048}
19049
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019050static inline int alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019051 hda_nid_t nid, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019052{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019053 return add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019054 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19055}
19056
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019057static inline int alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019058 hda_nid_t nid, unsigned int chs)
19059{
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019060 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019061 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19062}
19063
19064#define alc662_add_stereo_vol(spec, pfx, nid) \
19065 alc662_add_vol_ctl(spec, pfx, nid, 3)
19066#define alc662_add_stereo_sw(spec, pfx, nid) \
19067 alc662_add_sw_ctl(spec, pfx, nid, 3)
19068
19069/* add playback controls from the parsed DAC table */
19070static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19071 const struct auto_pin_cfg *cfg)
19072{
19073 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019074 static const char *chname[4] = {
19075 "Front", "Surround", NULL /*CLFE*/, "Side"
19076 };
Takashi Iwai7085ec12009-10-02 09:03:58 +020019077 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019078 int i, err;
19079
19080 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019081 nid = spec->multiout.dac_nids[i];
19082 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019083 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019084 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19085 if (!mix)
19086 continue;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019087 if (i == 2) {
19088 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019089 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019090 if (err < 0)
19091 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019092 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019093 if (err < 0)
19094 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019095 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019096 if (err < 0)
19097 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019098 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019099 if (err < 0)
19100 return err;
19101 } else {
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019102 const char *pfx;
19103 if (cfg->line_outs == 1 &&
19104 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019105 if (cfg->hp_outs)
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019106 pfx = "Speaker";
19107 else
19108 pfx = "PCM";
19109 } else
19110 pfx = chname[i];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019111 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019112 if (err < 0)
19113 return err;
Takashi Iwai0d884cb2009-08-25 16:14:35 +020019114 if (cfg->line_outs == 1 &&
19115 cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19116 pfx = "Speaker";
Takashi Iwai7085ec12009-10-02 09:03:58 +020019117 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019118 if (err < 0)
19119 return err;
19120 }
19121 }
19122 return 0;
19123}
19124
19125/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019126/* return DAC nid if any new DAC is assigned */
19127static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019128 const char *pfx)
19129{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019130 struct alc_spec *spec = codec->spec;
19131 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019132 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019133
19134 if (!pin)
19135 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019136 nid = alc662_look_for_dac(codec, pin);
19137 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019138 /* the corresponding DAC is already occupied */
19139 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19140 return 0; /* no way */
19141 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019142 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019143 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19144 }
19145
19146 mix = alc662_dac_to_mix(codec, pin, nid);
19147 if (!mix)
19148 return 0;
19149 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19150 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019151 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019152 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19153 if (err < 0)
19154 return err;
19155 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019156}
19157
19158/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019159#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019160 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019161
19162static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19163 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019164 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019165{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019166 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019167 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019168
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019169 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019170 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019171 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19172 if (num <= 1)
19173 return;
19174 for (i = 0; i < num; i++) {
19175 if (alc662_mix_to_dac(srcs[i]) != dac)
19176 continue;
19177 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19178 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019179 }
19180}
19181
19182static void alc662_auto_init_multi_out(struct hda_codec *codec)
19183{
19184 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019185 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019186 int i;
19187
19188 for (i = 0; i <= HDA_SIDE; i++) {
19189 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19190 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019191 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019192 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019193 }
19194}
19195
19196static void alc662_auto_init_hp_out(struct hda_codec *codec)
19197{
19198 struct alc_spec *spec = codec->spec;
19199 hda_nid_t pin;
19200
19201 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019202 if (pin)
19203 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19204 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019205 pin = spec->autocfg.speaker_pins[0];
19206 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019207 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19208 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019209}
19210
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019211#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19212
19213static void alc662_auto_init_analog_input(struct hda_codec *codec)
19214{
19215 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019216 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019217 int i;
19218
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019219 for (i = 0; i < cfg->num_inputs; i++) {
19220 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019221 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019222 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019223 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019224 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019225 snd_hda_codec_write(codec, nid, 0,
19226 AC_VERB_SET_AMP_GAIN_MUTE,
19227 AMP_OUT_MUTE);
19228 }
19229 }
19230}
19231
Takashi Iwaif511b012008-08-15 16:46:42 +020019232#define alc662_auto_init_input_src alc882_auto_init_input_src
19233
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019234static int alc662_parse_auto_config(struct hda_codec *codec)
19235{
19236 struct alc_spec *spec = codec->spec;
19237 int err;
19238 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19239
19240 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19241 alc662_ignore);
19242 if (err < 0)
19243 return err;
19244 if (!spec->autocfg.line_outs)
19245 return 0; /* can't find valid BIOS pin config */
19246
Takashi Iwai7085ec12009-10-02 09:03:58 +020019247 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019248 if (err < 0)
19249 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019250 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019251 if (err < 0)
19252 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019253 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019254 spec->autocfg.speaker_pins[0],
19255 "Speaker");
19256 if (err < 0)
19257 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019258 if (err)
19259 spec->multiout.extra_out_nid[0] = err;
19260 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019261 "Headphone");
19262 if (err < 0)
19263 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019264 if (err)
19265 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019266 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019267 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019268 return err;
19269
19270 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19271
Takashi Iwai757899a2010-07-30 10:48:14 +020019272 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019273
Takashi Iwai603c4012008-07-30 15:01:44 +020019274 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019275 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019276
19277 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019278 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019279
Kailang Yangcec27c82010-02-04 14:18:18 +010019280 add_verb(spec, alc662_init_verbs);
19281 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019282 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019283 add_verb(spec, alc663_init_verbs);
19284
19285 if (codec->vendor_id == 0x10ec0272)
19286 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019287
19288 err = alc_auto_add_mic_boost(codec);
19289 if (err < 0)
19290 return err;
19291
Kailang Yang6227cdc2010-02-25 08:36:52 +010019292 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19293 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19294 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19295 else
19296 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019297
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019298 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019299}
19300
19301/* additional initialization for auto-configuration model */
19302static void alc662_auto_init(struct hda_codec *codec)
19303{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019304 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019305 alc662_auto_init_multi_out(codec);
19306 alc662_auto_init_hp_out(codec);
19307 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019308 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019309 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019310 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019311 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019312}
19313
Todd Broch6be79482010-12-07 16:51:05 -080019314static void alc272_fixup_mario(struct hda_codec *codec,
19315 const struct alc_fixup *fix, int pre_init) {
19316 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19317 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19318 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19319 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19320 (0 << AC_AMPCAP_MUTE_SHIFT)))
19321 printk(KERN_WARNING
19322 "hda_codec: failed to override amp caps for NID 0x2\n");
19323}
19324
David Henningsson6cb3b702010-09-09 08:51:44 +020019325enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019326 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019327 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019328 ALC272_FIXUP_MARIO,
David Henningsson6cb3b702010-09-09 08:51:44 +020019329};
19330
19331static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019332 [ALC662_FIXUP_ASPIRE] = {
19333 .pins = (const struct alc_pincfg[]) {
19334 { 0x15, 0x99130112 }, /* subwoofer */
19335 { }
19336 }
19337 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019338 [ALC662_FIXUP_IDEAPAD] = {
19339 .pins = (const struct alc_pincfg[]) {
19340 { 0x17, 0x99130112 }, /* subwoofer */
19341 { }
19342 }
19343 },
Todd Broch6be79482010-12-07 16:51:05 -080019344 [ALC272_FIXUP_MARIO] = {
19345 .func = alc272_fixup_mario,
19346 }
David Henningsson6cb3b702010-09-09 08:51:44 +020019347};
19348
19349static struct snd_pci_quirk alc662_fixup_tbl[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019350 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019351 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019352 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019353 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
19354 {}
19355};
19356
Todd Broch6be79482010-12-07 16:51:05 -080019357static const struct alc_model_fixup alc662_fixup_models[] = {
19358 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19359 {}
19360};
David Henningsson6cb3b702010-09-09 08:51:44 +020019361
19362
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019363static int patch_alc662(struct hda_codec *codec)
19364{
19365 struct alc_spec *spec;
19366 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019367 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019368
19369 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19370 if (!spec)
19371 return -ENOMEM;
19372
19373 codec->spec = spec;
19374
Kailang Yangda00c242010-03-19 11:23:45 +010019375 alc_auto_parse_customize_define(codec);
19376
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019377 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19378
Kailang Yang693194f2010-10-21 08:51:48 +020019379 coef = alc_read_coef_idx(codec, 0);
19380 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019381 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019382 else if (coef & (1 << 14) &&
19383 codec->bus->pci->subsystem_vendor == 0x1025 &&
19384 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019385 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019386 else if (coef == 0x4011)
19387 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019388
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019389 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19390 alc662_models,
19391 alc662_cfg_tbl);
19392 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019393 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19394 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019395 board_config = ALC662_AUTO;
19396 }
19397
19398 if (board_config == ALC662_AUTO) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019399 alc_pick_fixup(codec, alc662_fixup_tbl, alc662_fixups, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019400 /* automatic parse from the BIOS config */
19401 err = alc662_parse_auto_config(codec);
19402 if (err < 0) {
19403 alc_free(codec);
19404 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019405 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019406 printk(KERN_INFO
19407 "hda_codec: Cannot set up configuration "
19408 "from BIOS. Using base mode...\n");
19409 board_config = ALC662_3ST_2ch_DIG;
19410 }
19411 }
19412
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019413 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019414 err = snd_hda_attach_beep_device(codec, 0x1);
19415 if (err < 0) {
19416 alc_free(codec);
19417 return err;
19418 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019419 }
19420
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019421 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019422 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019423
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019424 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19425 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19426
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019427 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19428 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19429
Takashi Iwaidd704692009-08-11 08:45:11 +020019430 if (!spec->adc_nids) {
19431 spec->adc_nids = alc662_adc_nids;
19432 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19433 }
19434 if (!spec->capsrc_nids)
19435 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019436
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019437 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019438 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019439
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019440 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019441 switch (codec->vendor_id) {
19442 case 0x10ec0662:
19443 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19444 break;
19445 case 0x10ec0272:
19446 case 0x10ec0663:
19447 case 0x10ec0665:
19448 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19449 break;
19450 case 0x10ec0273:
19451 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19452 break;
19453 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019454 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019455 spec->vmaster_nid = 0x02;
19456
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019457 codec->patch_ops = alc_patch_ops;
David Henningsson6cb3b702010-09-09 08:51:44 +020019458 if (board_config == ALC662_AUTO) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019459 spec->init_hook = alc662_auto_init;
Todd Broch6be79482010-12-07 16:51:05 -080019460 alc_pick_fixup_model(codec, alc662_fixup_models,
19461 alc662_fixup_tbl, alc662_fixups, 0);
David Henningsson6cb3b702010-09-09 08:51:44 +020019462 }
19463
Kailang Yangbf1b0222010-10-21 08:49:56 +020019464 alc_init_jacks(codec);
19465
Takashi Iwaicb53c622007-08-10 17:21:45 +020019466#ifdef CONFIG_SND_HDA_POWER_SAVE
19467 if (!spec->loopback.amplist)
19468 spec->loopback.amplist = alc662_loopbacks;
19469#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019470
19471 return 0;
19472}
19473
Kailang Yang274693f2009-12-03 10:07:50 +010019474static int patch_alc888(struct hda_codec *codec)
19475{
19476 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19477 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019478 if (codec->vendor_id == 0x10ec0887)
19479 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19480 else
19481 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019482 if (!codec->chip_name) {
19483 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019484 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019485 }
19486 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019487 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019488 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019489}
19490
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019491/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019492 * ALC680 support
19493 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019494#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019495#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19496#define alc680_modes alc260_modes
19497
19498static hda_nid_t alc680_dac_nids[3] = {
19499 /* Lout1, Lout2, hp */
19500 0x02, 0x03, 0x04
19501};
19502
19503static hda_nid_t alc680_adc_nids[3] = {
19504 /* ADC0-2 */
19505 /* DMIC, MIC, Line-in*/
19506 0x07, 0x08, 0x09
19507};
19508
Kailang Yangc69aefa2010-08-17 10:39:22 +020019509/*
19510 * Analog capture ADC cgange
19511 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019512static void alc680_rec_autoswitch(struct hda_codec *codec)
19513{
19514 struct alc_spec *spec = codec->spec;
19515 struct auto_pin_cfg *cfg = &spec->autocfg;
19516 int pin_found = 0;
19517 int type_found = AUTO_PIN_LAST;
19518 hda_nid_t nid;
19519 int i;
19520
19521 for (i = 0; i < cfg->num_inputs; i++) {
19522 nid = cfg->inputs[i].pin;
19523 if (!(snd_hda_query_pin_caps(codec, nid) &
19524 AC_PINCAP_PRES_DETECT))
19525 continue;
19526 if (snd_hda_jack_detect(codec, nid)) {
19527 if (cfg->inputs[i].type < type_found) {
19528 type_found = cfg->inputs[i].type;
19529 pin_found = nid;
19530 }
19531 }
19532 }
19533
19534 nid = 0x07;
19535 if (pin_found)
19536 snd_hda_get_connections(codec, pin_found, &nid, 1);
19537
19538 if (nid != spec->cur_adc)
19539 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19540 spec->cur_adc = nid;
19541 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19542 spec->cur_adc_format);
19543}
19544
Kailang Yangc69aefa2010-08-17 10:39:22 +020019545static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19546 struct hda_codec *codec,
19547 unsigned int stream_tag,
19548 unsigned int format,
19549 struct snd_pcm_substream *substream)
19550{
19551 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019552
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019553 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019554 spec->cur_adc_stream_tag = stream_tag;
19555 spec->cur_adc_format = format;
19556
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019557 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019558 return 0;
19559}
19560
19561static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19562 struct hda_codec *codec,
19563 struct snd_pcm_substream *substream)
19564{
19565 snd_hda_codec_cleanup_stream(codec, 0x07);
19566 snd_hda_codec_cleanup_stream(codec, 0x08);
19567 snd_hda_codec_cleanup_stream(codec, 0x09);
19568 return 0;
19569}
19570
19571static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19572 .substreams = 1, /* can be overridden */
19573 .channels_min = 2,
19574 .channels_max = 2,
19575 /* NID is set in alc_build_pcms */
19576 .ops = {
19577 .prepare = alc680_capture_pcm_prepare,
19578 .cleanup = alc680_capture_pcm_cleanup
19579 },
19580};
19581
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019582static struct snd_kcontrol_new alc680_base_mixer[] = {
19583 /* output mixer control */
19584 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19585 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19586 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19587 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019588 HDA_CODEC_VOLUME("Int Mic Boost", 0x12, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019589 HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
Kailang Yangc69aefa2010-08-17 10:39:22 +020019590 HDA_CODEC_VOLUME("Line In Boost", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019591 { }
19592};
19593
Kailang Yangc69aefa2010-08-17 10:39:22 +020019594static struct hda_bind_ctls alc680_bind_cap_vol = {
19595 .ops = &snd_hda_bind_vol,
19596 .values = {
19597 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19598 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19599 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19600 0
19601 },
19602};
19603
19604static struct hda_bind_ctls alc680_bind_cap_switch = {
19605 .ops = &snd_hda_bind_sw,
19606 .values = {
19607 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19608 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19609 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19610 0
19611 },
19612};
19613
19614static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19615 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19616 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019617 { } /* end */
19618};
19619
19620/*
19621 * generic initialization of ADC, input mixers and output mixers
19622 */
19623static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019624 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19625 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19626 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019627
Kailang Yangc69aefa2010-08-17 10:39:22 +020019628 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19629 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19630 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19631 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19632 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19633 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019634
19635 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19636 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19637 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19638 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19639 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019640
19641 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19642 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019643 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019644
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019645 { }
19646};
19647
Kailang Yangc69aefa2010-08-17 10:39:22 +020019648/* toggle speaker-output according to the hp-jack state */
19649static void alc680_base_setup(struct hda_codec *codec)
19650{
19651 struct alc_spec *spec = codec->spec;
19652
19653 spec->autocfg.hp_pins[0] = 0x16;
19654 spec->autocfg.speaker_pins[0] = 0x14;
19655 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019656 spec->autocfg.num_inputs = 2;
19657 spec->autocfg.inputs[0].pin = 0x18;
19658 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19659 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019660 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019661}
19662
19663static void alc680_unsol_event(struct hda_codec *codec,
19664 unsigned int res)
19665{
19666 if ((res >> 26) == ALC880_HP_EVENT)
19667 alc_automute_amp(codec);
19668 if ((res >> 26) == ALC880_MIC_EVENT)
19669 alc680_rec_autoswitch(codec);
19670}
19671
19672static void alc680_inithook(struct hda_codec *codec)
19673{
19674 alc_automute_amp(codec);
19675 alc680_rec_autoswitch(codec);
19676}
19677
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019678/* create input playback/capture controls for the given pin */
19679static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19680 const char *ctlname, int idx)
19681{
19682 hda_nid_t dac;
19683 int err;
19684
19685 switch (nid) {
19686 case 0x14:
19687 dac = 0x02;
19688 break;
19689 case 0x15:
19690 dac = 0x03;
19691 break;
19692 case 0x16:
19693 dac = 0x04;
19694 break;
19695 default:
19696 return 0;
19697 }
19698 if (spec->multiout.dac_nids[0] != dac &&
19699 spec->multiout.dac_nids[1] != dac) {
19700 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19701 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19702 HDA_OUTPUT));
19703 if (err < 0)
19704 return err;
19705
19706 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19707 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19708
19709 if (err < 0)
19710 return err;
19711 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19712 }
19713
19714 return 0;
19715}
19716
19717/* add playback controls from the parsed DAC table */
19718static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19719 const struct auto_pin_cfg *cfg)
19720{
19721 hda_nid_t nid;
19722 int err;
19723
19724 spec->multiout.dac_nids = spec->private_dac_nids;
19725
19726 nid = cfg->line_out_pins[0];
19727 if (nid) {
19728 const char *name;
19729 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19730 name = "Speaker";
19731 else
19732 name = "Front";
19733 err = alc680_new_analog_output(spec, nid, name, 0);
19734 if (err < 0)
19735 return err;
19736 }
19737
19738 nid = cfg->speaker_pins[0];
19739 if (nid) {
19740 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19741 if (err < 0)
19742 return err;
19743 }
19744 nid = cfg->hp_pins[0];
19745 if (nid) {
19746 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19747 if (err < 0)
19748 return err;
19749 }
19750
19751 return 0;
19752}
19753
19754static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19755 hda_nid_t nid, int pin_type)
19756{
19757 alc_set_pin_output(codec, nid, pin_type);
19758}
19759
19760static void alc680_auto_init_multi_out(struct hda_codec *codec)
19761{
19762 struct alc_spec *spec = codec->spec;
19763 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19764 if (nid) {
19765 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19766 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19767 }
19768}
19769
19770static void alc680_auto_init_hp_out(struct hda_codec *codec)
19771{
19772 struct alc_spec *spec = codec->spec;
19773 hda_nid_t pin;
19774
19775 pin = spec->autocfg.hp_pins[0];
19776 if (pin)
19777 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19778 pin = spec->autocfg.speaker_pins[0];
19779 if (pin)
19780 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19781}
19782
19783/* pcm configuration: identical with ALC880 */
19784#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19785#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19786#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19787#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019788#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019789
19790/*
19791 * BIOS auto configuration
19792 */
19793static int alc680_parse_auto_config(struct hda_codec *codec)
19794{
19795 struct alc_spec *spec = codec->spec;
19796 int err;
19797 static hda_nid_t alc680_ignore[] = { 0 };
19798
19799 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19800 alc680_ignore);
19801 if (err < 0)
19802 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019803
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019804 if (!spec->autocfg.line_outs) {
19805 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19806 spec->multiout.max_channels = 2;
19807 spec->no_analog = 1;
19808 goto dig_only;
19809 }
19810 return 0; /* can't find valid BIOS pin config */
19811 }
19812 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19813 if (err < 0)
19814 return err;
19815
19816 spec->multiout.max_channels = 2;
19817
19818 dig_only:
19819 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019820 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019821 if (spec->kctls.list)
19822 add_mixer(spec, spec->kctls.list);
19823
19824 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019825
19826 err = alc_auto_add_mic_boost(codec);
19827 if (err < 0)
19828 return err;
19829
19830 return 1;
19831}
19832
19833#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19834
19835/* init callback for auto-configuration model -- overriding the default init */
19836static void alc680_auto_init(struct hda_codec *codec)
19837{
19838 struct alc_spec *spec = codec->spec;
19839 alc680_auto_init_multi_out(codec);
19840 alc680_auto_init_hp_out(codec);
19841 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019842 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019843 if (spec->unsol_event)
19844 alc_inithook(codec);
19845}
19846
19847/*
19848 * configuration and preset
19849 */
19850static const char *alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019851 [ALC680_BASE] = "base",
19852 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019853};
19854
19855static struct snd_pci_quirk alc680_cfg_tbl[] = {
19856 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19857 {}
19858};
19859
19860static struct alc_config_preset alc680_presets[] = {
19861 [ALC680_BASE] = {
19862 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019863 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019864 .init_verbs = { alc680_init_verbs },
19865 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19866 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019867 .dig_out_nid = ALC680_DIGOUT_NID,
19868 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19869 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019870 .unsol_event = alc680_unsol_event,
19871 .setup = alc680_base_setup,
19872 .init_hook = alc680_inithook,
19873
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019874 },
19875};
19876
19877static int patch_alc680(struct hda_codec *codec)
19878{
19879 struct alc_spec *spec;
19880 int board_config;
19881 int err;
19882
19883 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19884 if (spec == NULL)
19885 return -ENOMEM;
19886
19887 codec->spec = spec;
19888
19889 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
19890 alc680_models,
19891 alc680_cfg_tbl);
19892
19893 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
19894 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19895 codec->chip_name);
19896 board_config = ALC680_AUTO;
19897 }
19898
19899 if (board_config == ALC680_AUTO) {
19900 /* automatic parse from the BIOS config */
19901 err = alc680_parse_auto_config(codec);
19902 if (err < 0) {
19903 alc_free(codec);
19904 return err;
19905 } else if (!err) {
19906 printk(KERN_INFO
19907 "hda_codec: Cannot set up configuration "
19908 "from BIOS. Using base mode...\n");
19909 board_config = ALC680_BASE;
19910 }
19911 }
19912
19913 if (board_config != ALC680_AUTO)
19914 setup_preset(codec, &alc680_presets[board_config]);
19915
19916 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019917 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019918 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019919 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019920
19921 if (!spec->adc_nids) {
19922 spec->adc_nids = alc680_adc_nids;
19923 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
19924 }
19925
19926 if (!spec->cap_mixer)
19927 set_capture_mixer(codec);
19928
19929 spec->vmaster_nid = 0x02;
19930
19931 codec->patch_ops = alc_patch_ops;
19932 if (board_config == ALC680_AUTO)
19933 spec->init_hook = alc680_auto_init;
19934
19935 return 0;
19936}
19937
19938/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070019939 * patch entries
19940 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019941static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070019942 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019943 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019944 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020019945 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010019946 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019947 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020019948 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019949 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019950 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019951 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019952 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
19953 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
19954 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019955 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019956 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019957 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
19958 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020019959 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010019960 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010019961 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019962 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010019963 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019964 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019965 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020019966 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019967 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020019968 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019969 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010019970 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010019971 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020019972 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020019973 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019974 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020019975 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010019976 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070019977 {} /* terminator */
19978};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010019979
19980MODULE_ALIAS("snd-hda-codec-id:10ec*");
19981
19982MODULE_LICENSE("GPL");
19983MODULE_DESCRIPTION("Realtek HD-audio codec");
19984
19985static struct hda_codec_preset_list realtek_list = {
19986 .preset = snd_hda_preset_realtek,
19987 .owner = THIS_MODULE,
19988};
19989
19990static int __init patch_realtek_init(void)
19991{
19992 return snd_hda_add_codec_preset(&realtek_list);
19993}
19994
19995static void __exit patch_realtek_exit(void)
19996{
19997 snd_hda_delete_codec_preset(&realtek_list);
19998}
19999
20000module_init(patch_realtek_init)
20001module_exit(patch_realtek_exit)