blob: 24bbc47dcea2cb549b1ae05fe42a72ce37511c5e [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
285#define MUX_IDX_UNDEF ((unsigned char)-1)
286
Kailang Yangda00c242010-03-19 11:23:45 +0100287struct alc_customize_define {
288 unsigned int sku_cfg;
289 unsigned char port_connectivity;
290 unsigned char check_sum;
291 unsigned char customization;
292 unsigned char external_amp;
293 unsigned int enable_pcbeep:1;
294 unsigned int platform_type:1;
295 unsigned int swap:1;
296 unsigned int override:1;
David Henningsson90622912010-10-14 14:50:18 +0200297 unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
Kailang Yangda00c242010-03-19 11:23:45 +0100298};
299
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100300struct alc_fixup;
301
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302struct alc_spec {
303 /* codec parameterization */
Kailang Yangdf694da2005-12-05 19:42:22 +0100304 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 unsigned int num_mixers;
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100306 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Takashi Iwai45bdd1c2009-02-06 16:11:25 +0100307 unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308
Takashi Iwai2d9c6482009-10-13 08:06:55 +0200309 const struct hda_verb *init_verbs[10]; /* initialization verbs
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200310 * don't forget NULL
311 * termination!
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200312 */
313 unsigned int num_init_verbs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200315 char stream_name_analog[32]; /* analog PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 struct hda_pcm_stream *stream_analog_playback;
317 struct hda_pcm_stream *stream_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +0100318 struct hda_pcm_stream *stream_analog_alt_playback;
319 struct hda_pcm_stream *stream_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
Takashi Iwaiaa563af2009-07-31 10:05:11 +0200321 char stream_name_digital[32]; /* digital PCM stream */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 struct hda_pcm_stream *stream_digital_playback;
323 struct hda_pcm_stream *stream_digital_capture;
324
325 /* playback */
Takashi Iwai16ded522005-06-10 19:58:24 +0200326 struct hda_multi_out multiout; /* playback set-up
327 * max_channels, dacs must be set
328 * dig_out_nid and hp_nid are optional
329 */
Takashi Iwai63300792008-01-24 15:31:36 +0100330 hda_nid_t alt_dac_nid;
Takashi Iwai6a05ac42009-02-13 11:19:09 +0100331 hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */
Takashi Iwai8c441982009-01-20 18:30:20 +0100332 int dig_out_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333
334 /* capture */
335 unsigned int num_adc_nids;
336 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100337 hda_nid_t *capsrc_nids;
Takashi Iwai16ded522005-06-10 19:58:24 +0200338 hda_nid_t dig_in_nid; /* digital-in NID; optional */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339
Takashi Iwai840b64c2010-07-13 22:49:01 +0200340 /* capture setup for dynamic dual-adc switch */
341 unsigned int cur_adc_idx;
342 hda_nid_t cur_adc;
343 unsigned int cur_adc_stream_tag;
344 unsigned int cur_adc_format;
345
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 /* capture source */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200347 unsigned int num_mux_defs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 const struct hda_input_mux *input_mux;
349 unsigned int cur_mux[3];
Takashi Iwai6c819492009-08-10 18:47:44 +0200350 struct alc_mic_route ext_mic;
351 struct alc_mic_route int_mic;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 /* channel model */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100354 const struct hda_channel_mode *channel_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 int num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200356 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200357 int const_channel_count;
358 int ext_channel_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
360 /* PCM information */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100361 struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
Takashi Iwai41e41f12005-06-08 14:48:49 +0200362
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200363 /* dynamic controls, init_verbs and input_mux */
364 struct auto_pin_cfg autocfg;
Kailang Yangda00c242010-03-19 11:23:45 +0100365 struct alc_customize_define cdefine;
Takashi Iwai603c4012008-07-30 15:01:44 +0200366 struct snd_array kctls;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -0200367 struct hda_input_mux private_imux[3];
Takashi Iwai41923e42007-10-22 17:20:10 +0200368 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai4953550a2009-06-30 15:28:30 +0200369 hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS];
370 hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS];
Takashi Iwai834be882006-03-01 14:16:17 +0100371
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100372 /* hooks */
373 void (*init_hook)(struct hda_codec *codec);
374 void (*unsol_event)(struct hda_codec *codec, unsigned int res);
Hector Martinf5de24b2009-12-20 22:51:31 +0100375#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -0500376 void (*power_hook)(struct hda_codec *codec);
Hector Martinf5de24b2009-12-20 22:51:31 +0100377#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100378
Takashi Iwai834be882006-03-01 14:16:17 +0100379 /* for pin sensing */
380 unsigned int sense_updated: 1;
381 unsigned int jack_present: 1;
Takashi Iwaibec15c32008-01-28 18:16:30 +0100382 unsigned int master_sw: 1;
Takashi Iwai6c819492009-08-10 18:47:44 +0200383 unsigned int auto_mic:1;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200384
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100385 /* other flags */
386 unsigned int no_analog :1; /* digital I/O only */
Takashi Iwai840b64c2010-07-13 22:49:01 +0200387 unsigned int dual_adc_switch:1; /* switch ADCs (for ALC275) */
Takashi Iwai4a79ba32009-04-22 16:31:35 +0200388 int init_amp;
Takashi Iwaid433a672010-09-20 15:11:54 +0200389 int codec_variant; /* flag for other variants */
Takashi Iwaie64f14f2009-01-20 18:32:55 +0100390
Takashi Iwai2134ea42008-01-10 16:53:55 +0100391 /* for virtual master */
392 hda_nid_t vmaster_nid;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200393#ifdef CONFIG_SND_HDA_POWER_SAVE
394 struct hda_loopback_check loopback;
395#endif
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200396
397 /* for PLL fix */
398 hda_nid_t pll_nid;
399 unsigned int pll_coef_idx, pll_coef_bit;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +0100400
401 /* fix-up list */
402 int fixup_id;
403 const struct alc_fixup *fixup_list;
404 const char *fixup_name;
Kailang Yangdf694da2005-12-05 19:42:22 +0100405};
406
407/*
408 * configuration template - to be copied to the spec instance
409 */
410struct alc_config_preset {
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200411 struct snd_kcontrol_new *mixers[5]; /* should be identical size
412 * with spec
413 */
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100414 struct snd_kcontrol_new *cap_mixer; /* capture mixer */
Kailang Yangdf694da2005-12-05 19:42:22 +0100415 const struct hda_verb *init_verbs[5];
416 unsigned int num_dacs;
417 hda_nid_t *dac_nids;
418 hda_nid_t dig_out_nid; /* optional */
419 hda_nid_t hp_nid; /* optional */
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800420 hda_nid_t *slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100421 unsigned int num_adc_nids;
422 hda_nid_t *adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100423 hda_nid_t *capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100424 hda_nid_t dig_in_nid;
425 unsigned int num_channel_mode;
426 const struct hda_channel_mode *channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200427 int need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200428 int const_channel_count;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200429 unsigned int num_mux_defs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100430 const struct hda_input_mux *input_mux;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100431 void (*unsol_event)(struct hda_codec *, unsigned int);
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200432 void (*setup)(struct hda_codec *);
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100433 void (*init_hook)(struct hda_codec *);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200434#ifdef CONFIG_SND_HDA_POWER_SAVE
435 struct hda_amp_list *loopbacks;
Daniel T Chenc97259d2009-12-27 18:52:08 -0500436 void (*power_hook)(struct hda_codec *codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +0200437#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438};
439
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440
441/*
442 * input MUX handling
443 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200444static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
445 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446{
447 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
448 struct alc_spec *spec = codec->spec;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200449 unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
450 if (mux_idx >= spec->num_mux_defs)
451 mux_idx = 0;
Takashi Iwai53111142010-03-08 12:13:07 +0100452 if (!spec->input_mux[mux_idx].num_items && mux_idx > 0)
453 mux_idx = 0;
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200454 return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455}
456
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200457static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
458 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459{
460 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
461 struct alc_spec *spec = codec->spec;
462 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
463
464 ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
465 return 0;
466}
467
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200468static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
469 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470{
471 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
472 struct alc_spec *spec = codec->spec;
Takashi Iwaicd896c32008-11-18 12:36:33 +0100473 const struct hda_input_mux *imux;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
Takashi Iwaicd896c32008-11-18 12:36:33 +0100475 unsigned int mux_idx;
Takashi Iwaie1406342008-02-11 18:32:32 +0100476 hda_nid_t nid = spec->capsrc_nids ?
477 spec->capsrc_nids[adc_idx] : spec->adc_nids[adc_idx];
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200478 unsigned int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
Takashi Iwaicd896c32008-11-18 12:36:33 +0100480 mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
481 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +0100482 if (!imux->num_items && mux_idx > 0)
483 imux = &spec->input_mux[0];
Takashi Iwaicd896c32008-11-18 12:36:33 +0100484
Takashi Iwaia22d5432009-07-27 12:54:26 +0200485 type = get_wcaps_type(get_wcaps(codec, nid));
Takashi Iwai0169b6b2009-06-22 10:50:19 +0200486 if (type == AC_WID_AUD_MIX) {
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100487 /* Matrix-mixer style (e.g. ALC882) */
488 unsigned int *cur_val = &spec->cur_mux[adc_idx];
489 unsigned int i, idx;
490
491 idx = ucontrol->value.enumerated.item[0];
492 if (idx >= imux->num_items)
493 idx = imux->num_items - 1;
494 if (*cur_val == idx)
495 return 0;
496 for (i = 0; i < imux->num_items; i++) {
497 unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
498 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
499 imux->items[i].index,
500 HDA_AMP_MUTE, v);
501 }
502 *cur_val = idx;
503 return 1;
504 } else {
505 /* MUX style (e.g. ALC880) */
Takashi Iwaicd896c32008-11-18 12:36:33 +0100506 return snd_hda_input_mux_put(codec, imux, ucontrol, nid,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +0100507 &spec->cur_mux[adc_idx]);
508 }
509}
Takashi Iwaie9edcee2005-06-13 14:16:38 +0200510
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511/*
512 * channel mode setting
513 */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200514static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
515 struct snd_ctl_elem_info *uinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516{
517 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
518 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100519 return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
520 spec->num_channel_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521}
522
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200523static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
524 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525{
526 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
527 struct alc_spec *spec = codec->spec;
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +0100528 return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200529 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200530 spec->ext_channel_count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531}
532
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200533static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
534 struct snd_ctl_elem_value *ucontrol)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535{
536 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
537 struct alc_spec *spec = codec->spec;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200538 int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
539 spec->num_channel_mode,
Hector Martin3b315d72009-06-02 10:54:19 +0200540 &spec->ext_channel_count);
541 if (err >= 0 && !spec->const_channel_count) {
542 spec->multiout.max_channels = spec->ext_channel_count;
543 if (spec->need_dac_fix)
544 spec->multiout.num_dacs = spec->multiout.max_channels / 2;
545 }
Takashi Iwai4e195a72006-07-28 14:47:34 +0200546 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547}
548
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549/*
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100550 * Control the mode of pin widget settings via the mixer. "pc" is used
Kailang Yangea1fb292008-08-26 12:58:38 +0200551 * instead of "%" to avoid consequences of accidently treating the % as
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100552 * being part of a format specifier. Maximum allowed length of a value is
553 * 63 characters plus NULL terminator.
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100554 *
555 * Note: some retasking pin complexes seem to ignore requests for input
556 * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
557 * are requested. Therefore order this list so that this behaviour will not
558 * cause problems when mixer clients move through the enum sequentially.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200559 * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
560 * March 2006.
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200561 */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100562static char *alc_pin_mode_names[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100563 "Mic 50pc bias", "Mic 80pc bias",
564 "Line in", "Line out", "Headphone out",
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100565};
566static unsigned char alc_pin_mode_values[] = {
Jonathan Woithe7cf51e482006-02-09 12:01:26 +0100567 PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100568};
569/* The control can present all 5 options, or it can limit the options based
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200570 * in the pin being assumed to be exclusively an input or an output pin. In
571 * addition, "input" pins may or may not process the mic bias option
572 * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
573 * accept requests for bias as of chip versions up to March 2006) and/or
574 * wiring in the computer.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100575 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200576#define ALC_PIN_DIR_IN 0x00
577#define ALC_PIN_DIR_OUT 0x01
578#define ALC_PIN_DIR_INOUT 0x02
579#define ALC_PIN_DIR_IN_NOMICBIAS 0x03
580#define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100581
Kailang Yangea1fb292008-08-26 12:58:38 +0200582/* Info about the pin modes supported by the different pin direction modes.
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100583 * For each direction the minimum and maximum values are given.
584 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200585static signed char alc_pin_mode_dir_info[5][2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100586 { 0, 2 }, /* ALC_PIN_DIR_IN */
587 { 3, 4 }, /* ALC_PIN_DIR_OUT */
588 { 0, 4 }, /* ALC_PIN_DIR_INOUT */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200589 { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
590 { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100591};
592#define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
593#define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
594#define alc_pin_mode_n_items(_dir) \
595 (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
596
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200597static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
598 struct snd_ctl_elem_info *uinfo)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200599{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100600 unsigned int item_num = uinfo->value.enumerated.item;
601 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
602
603 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200604 uinfo->count = 1;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100605 uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
606
607 if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
608 item_num = alc_pin_mode_min(dir);
609 strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200610 return 0;
611}
612
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200613static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
614 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200615{
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100616 unsigned int i;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200617 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
618 hda_nid_t nid = kcontrol->private_value & 0xffff;
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100619 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200620 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200621 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
622 AC_VERB_GET_PIN_WIDGET_CONTROL,
623 0x00);
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200624
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100625 /* Find enumerated value for current pinctl setting */
626 i = alc_pin_mode_min(dir);
Roel Kluin4b35d2ca2009-08-02 13:30:45 +0200627 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100628 i++;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200629 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100630 return 0;
631}
632
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200633static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
634 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100635{
636 signed int change;
637 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
638 hda_nid_t nid = kcontrol->private_value & 0xffff;
639 unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
640 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200641 unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
642 AC_VERB_GET_PIN_WIDGET_CONTROL,
643 0x00);
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100644
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200645 if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100646 val = alc_pin_mode_min(dir);
647
648 change = pinctl != alc_pin_mode_values[val];
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100649 if (change) {
650 /* Set pin mode to that requested */
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200651 snd_hda_codec_write_cache(codec, nid, 0,
652 AC_VERB_SET_PIN_WIDGET_CONTROL,
653 alc_pin_mode_values[val]);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100654
Kailang Yangea1fb292008-08-26 12:58:38 +0200655 /* Also enable the retasking pin's input/output as required
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100656 * for the requested pin mode. Enum values of 2 or less are
657 * input modes.
658 *
659 * Dynamically switching the input/output buffers probably
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200660 * reduces noise slightly (particularly on input) so we'll
661 * do it. However, having both input and output buffers
662 * enabled simultaneously doesn't seem to be problematic if
663 * this turns out to be necessary in the future.
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100664 */
665 if (val <= 2) {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200666 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
667 HDA_AMP_MUTE, HDA_AMP_MUTE);
668 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
669 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100670 } else {
Takashi Iwai47fd8302007-08-10 17:11:07 +0200671 snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
672 HDA_AMP_MUTE, HDA_AMP_MUTE);
673 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
674 HDA_AMP_MUTE, 0);
Jonathan Woithecdcd9262006-02-28 11:36:42 +0100675 }
676 }
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200677 return change;
678}
679
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100680#define ALC_PIN_MODE(xname, nid, dir) \
Jonathan Woithea9430dd2005-09-16 19:12:48 +0200681 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100682 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe4c5186e2006-02-09 11:53:48 +0100683 .info = alc_pin_mode_info, \
684 .get = alc_pin_mode_get, \
685 .put = alc_pin_mode_put, \
686 .private_value = nid | (dir<<16) }
Kailang Yangdf694da2005-12-05 19:42:22 +0100687
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100688/* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
689 * together using a mask with more than one bit set. This control is
690 * currently used only by the ALC260 test model. At this stage they are not
691 * needed for any "production" models.
692 */
693#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200694#define alc_gpio_data_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200695
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200696static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
697 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100698{
699 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
700 hda_nid_t nid = kcontrol->private_value & 0xffff;
701 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
702 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200703 unsigned int val = snd_hda_codec_read(codec, nid, 0,
704 AC_VERB_GET_GPIO_DATA, 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100705
706 *valp = (val & mask) != 0;
707 return 0;
708}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200709static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
710 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100711{
712 signed int change;
713 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
714 hda_nid_t nid = kcontrol->private_value & 0xffff;
715 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
716 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200717 unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
718 AC_VERB_GET_GPIO_DATA,
719 0x00);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100720
721 /* Set/unset the masked GPIO bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200722 change = (val == 0 ? 0 : mask) != (gpio_data & mask);
723 if (val == 0)
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100724 gpio_data &= ~mask;
725 else
726 gpio_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200727 snd_hda_codec_write_cache(codec, nid, 0,
728 AC_VERB_SET_GPIO_DATA, gpio_data);
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100729
730 return change;
731}
732#define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
733 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100734 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe5c8f8582006-02-28 11:43:27 +0100735 .info = alc_gpio_data_info, \
736 .get = alc_gpio_data_get, \
737 .put = alc_gpio_data_put, \
738 .private_value = nid | (mask<<16) }
739#endif /* CONFIG_SND_DEBUG */
740
Jonathan Woithe92621f12006-02-28 11:47:47 +0100741/* A switch control to allow the enabling of the digital IO pins on the
742 * ALC260. This is incredibly simplistic; the intention of this control is
743 * to provide something in the test model allowing digital outputs to be
744 * identified if present. If models are found which can utilise these
745 * outputs a more complete mixer control can be devised for those models if
746 * necessary.
747 */
748#ifdef CONFIG_SND_DEBUG
Takashi Iwaia5ce8892007-07-23 15:42:26 +0200749#define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200750
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200751static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
752 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100753{
754 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
755 hda_nid_t nid = kcontrol->private_value & 0xffff;
756 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
757 long *valp = ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200758 unsigned int val = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100759 AC_VERB_GET_DIGI_CONVERT_1, 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100760
761 *valp = (val & mask) != 0;
762 return 0;
763}
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200764static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
765 struct snd_ctl_elem_value *ucontrol)
Jonathan Woithe92621f12006-02-28 11:47:47 +0100766{
767 signed int change;
768 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
769 hda_nid_t nid = kcontrol->private_value & 0xffff;
770 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
771 long val = *ucontrol->value.integer.value;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200772 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
Andrew Paprocki3982d172007-12-19 12:13:44 +0100773 AC_VERB_GET_DIGI_CONVERT_1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200774 0x00);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100775
776 /* Set/unset the masked control bit(s) as needed */
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200777 change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100778 if (val==0)
779 ctrl_data &= ~mask;
780 else
781 ctrl_data |= mask;
Takashi Iwai82beb8f2007-08-10 17:09:26 +0200782 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
783 ctrl_data);
Jonathan Woithe92621f12006-02-28 11:47:47 +0100784
785 return change;
786}
787#define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
788 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100789 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithe92621f12006-02-28 11:47:47 +0100790 .info = alc_spdif_ctrl_info, \
791 .get = alc_spdif_ctrl_get, \
792 .put = alc_spdif_ctrl_put, \
793 .private_value = nid | (mask<<16) }
794#endif /* CONFIG_SND_DEBUG */
795
Jonathan Woithef8225f62008-01-08 12:16:54 +0100796/* A switch control to allow the enabling EAPD digital outputs on the ALC26x.
797 * Again, this is only used in the ALC26x test models to help identify when
798 * the EAPD line must be asserted for features to work.
799 */
800#ifdef CONFIG_SND_DEBUG
801#define alc_eapd_ctrl_info snd_ctl_boolean_mono_info
802
803static int alc_eapd_ctrl_get(struct snd_kcontrol *kcontrol,
804 struct snd_ctl_elem_value *ucontrol)
805{
806 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
807 hda_nid_t nid = kcontrol->private_value & 0xffff;
808 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
809 long *valp = ucontrol->value.integer.value;
810 unsigned int val = snd_hda_codec_read(codec, nid, 0,
811 AC_VERB_GET_EAPD_BTLENABLE, 0x00);
812
813 *valp = (val & mask) != 0;
814 return 0;
815}
816
817static int alc_eapd_ctrl_put(struct snd_kcontrol *kcontrol,
818 struct snd_ctl_elem_value *ucontrol)
819{
820 int change;
821 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
822 hda_nid_t nid = kcontrol->private_value & 0xffff;
823 unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
824 long val = *ucontrol->value.integer.value;
825 unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
826 AC_VERB_GET_EAPD_BTLENABLE,
827 0x00);
828
829 /* Set/unset the masked control bit(s) as needed */
830 change = (!val ? 0 : mask) != (ctrl_data & mask);
831 if (!val)
832 ctrl_data &= ~mask;
833 else
834 ctrl_data |= mask;
835 snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
836 ctrl_data);
837
838 return change;
839}
840
841#define ALC_EAPD_CTRL_SWITCH(xname, nid, mask) \
842 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +0100843 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Jonathan Woithef8225f62008-01-08 12:16:54 +0100844 .info = alc_eapd_ctrl_info, \
845 .get = alc_eapd_ctrl_get, \
846 .put = alc_eapd_ctrl_put, \
847 .private_value = nid | (mask<<16) }
848#endif /* CONFIG_SND_DEBUG */
849
Kailang Yangdf694da2005-12-05 19:42:22 +0100850/*
Takashi Iwai23f0c042009-02-26 13:03:58 +0100851 * set up the input pin config (depending on the given auto-pin type)
852 */
853static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid,
854 int auto_pin_type)
855{
856 unsigned int val = PIN_IN;
857
Takashi Iwai86e29592010-09-09 14:50:17 +0200858 if (auto_pin_type == AUTO_PIN_MIC) {
Takashi Iwai23f0c042009-02-26 13:03:58 +0100859 unsigned int pincap;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200860 unsigned int oldval;
861 oldval = snd_hda_codec_read(codec, nid, 0,
862 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
Takashi Iwai1327a322009-03-23 13:07:47 +0100863 pincap = snd_hda_query_pin_caps(codec, nid);
Takashi Iwai23f0c042009-02-26 13:03:58 +0100864 pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
Takashi Iwai954a29c2010-07-30 10:55:44 +0200865 /* if the default pin setup is vref50, we give it priority */
866 if ((pincap & AC_PINCAP_VREF_80) && oldval != PIN_VREF50)
Takashi Iwai23f0c042009-02-26 13:03:58 +0100867 val = PIN_VREF80;
Takashi Iwai461c6c32009-05-25 08:06:02 +0200868 else if (pincap & AC_PINCAP_VREF_50)
869 val = PIN_VREF50;
870 else if (pincap & AC_PINCAP_VREF_100)
871 val = PIN_VREF100;
872 else if (pincap & AC_PINCAP_VREF_GRD)
873 val = PIN_VREFGRD;
Takashi Iwai23f0c042009-02-26 13:03:58 +0100874 }
875 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, val);
876}
877
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200878static void alc_fixup_autocfg_pin_nums(struct hda_codec *codec)
879{
880 struct alc_spec *spec = codec->spec;
881 struct auto_pin_cfg *cfg = &spec->autocfg;
882
883 if (!cfg->line_outs) {
884 while (cfg->line_outs < AUTO_CFG_MAX_OUTS &&
885 cfg->line_out_pins[cfg->line_outs])
886 cfg->line_outs++;
887 }
888 if (!cfg->speaker_outs) {
889 while (cfg->speaker_outs < AUTO_CFG_MAX_OUTS &&
890 cfg->speaker_pins[cfg->speaker_outs])
891 cfg->speaker_outs++;
892 }
893 if (!cfg->hp_outs) {
894 while (cfg->hp_outs < AUTO_CFG_MAX_OUTS &&
895 cfg->hp_pins[cfg->hp_outs])
896 cfg->hp_outs++;
897 }
898}
899
Takashi Iwai23f0c042009-02-26 13:03:58 +0100900/*
Takashi Iwaid88897e2008-10-31 15:01:37 +0100901 */
902static void add_mixer(struct alc_spec *spec, struct snd_kcontrol_new *mix)
903{
904 if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
905 return;
906 spec->mixers[spec->num_mixers++] = mix;
907}
908
909static void add_verb(struct alc_spec *spec, const struct hda_verb *verb)
910{
911 if (snd_BUG_ON(spec->num_init_verbs >= ARRAY_SIZE(spec->init_verbs)))
912 return;
913 spec->init_verbs[spec->num_init_verbs++] = verb;
914}
915
916/*
Kailang Yangdf694da2005-12-05 19:42:22 +0100917 * set up from the preset table
918 */
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200919static void setup_preset(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200920 const struct alc_config_preset *preset)
Kailang Yangdf694da2005-12-05 19:42:22 +0100921{
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200922 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +0100923 int i;
924
925 for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100926 add_mixer(spec, preset->mixers[i]);
Takashi Iwaif9e336f2008-10-31 16:37:07 +0100927 spec->cap_mixer = preset->cap_mixer;
Takashi Iwai9c7f8522006-06-28 15:08:22 +0200928 for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
929 i++)
Takashi Iwaid88897e2008-10-31 15:01:37 +0100930 add_verb(spec, preset->init_verbs[i]);
Kailang Yangea1fb292008-08-26 12:58:38 +0200931
Kailang Yangdf694da2005-12-05 19:42:22 +0100932 spec->channel_mode = preset->channel_mode;
933 spec->num_channel_mode = preset->num_channel_mode;
Takashi Iwai4e195a72006-07-28 14:47:34 +0200934 spec->need_dac_fix = preset->need_dac_fix;
Hector Martin3b315d72009-06-02 10:54:19 +0200935 spec->const_channel_count = preset->const_channel_count;
Kailang Yangdf694da2005-12-05 19:42:22 +0100936
Hector Martin3b315d72009-06-02 10:54:19 +0200937 if (preset->const_channel_count)
938 spec->multiout.max_channels = preset->const_channel_count;
939 else
940 spec->multiout.max_channels = spec->channel_mode[0].channels;
941 spec->ext_channel_count = spec->channel_mode[0].channels;
Kailang Yangdf694da2005-12-05 19:42:22 +0100942
943 spec->multiout.num_dacs = preset->num_dacs;
944 spec->multiout.dac_nids = preset->dac_nids;
945 spec->multiout.dig_out_nid = preset->dig_out_nid;
Wu Fengguangb25c9da2009-02-06 15:02:27 +0800946 spec->multiout.slave_dig_outs = preset->slave_dig_outs;
Kailang Yangdf694da2005-12-05 19:42:22 +0100947 spec->multiout.hp_nid = preset->hp_nid;
Kailang Yangea1fb292008-08-26 12:58:38 +0200948
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200949 spec->num_mux_defs = preset->num_mux_defs;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +0200950 if (!spec->num_mux_defs)
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +0200951 spec->num_mux_defs = 1;
Kailang Yangdf694da2005-12-05 19:42:22 +0100952 spec->input_mux = preset->input_mux;
953
954 spec->num_adc_nids = preset->num_adc_nids;
955 spec->adc_nids = preset->adc_nids;
Takashi Iwaie1406342008-02-11 18:32:32 +0100956 spec->capsrc_nids = preset->capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +0100957 spec->dig_in_nid = preset->dig_in_nid;
Takashi Iwaiae6b8132006-03-03 16:47:17 +0100958
959 spec->unsol_event = preset->unsol_event;
960 spec->init_hook = preset->init_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200961#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +0100962 spec->power_hook = preset->power_hook;
Takashi Iwaicb53c622007-08-10 17:21:45 +0200963 spec->loopback.amplist = preset->loopbacks;
964#endif
Takashi Iwaie9c364c2009-08-11 17:16:13 +0200965
966 if (preset->setup)
967 preset->setup(codec);
Takashi Iwaif6837bb2010-09-20 14:56:32 +0200968
969 alc_fixup_autocfg_pin_nums(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +0100970}
971
Kailang Yangbc9f98a2007-04-12 13:06:07 +0200972/* Enable GPIO mask and set output */
973static struct hda_verb alc_gpio1_init_verbs[] = {
974 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
975 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
976 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
977 { }
978};
979
980static struct hda_verb alc_gpio2_init_verbs[] = {
981 {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
982 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
983 {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
984 { }
985};
986
Kailang Yangbdd148a2007-05-08 15:19:08 +0200987static struct hda_verb alc_gpio3_init_verbs[] = {
988 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
989 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
990 {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
991 { }
992};
993
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +0200994/*
995 * Fix hardware PLL issue
996 * On some codecs, the analog PLL gating control must be off while
997 * the default value is 1.
998 */
999static void alc_fix_pll(struct hda_codec *codec)
1000{
1001 struct alc_spec *spec = codec->spec;
1002 unsigned int val;
1003
1004 if (!spec->pll_nid)
1005 return;
1006 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1007 spec->pll_coef_idx);
1008 val = snd_hda_codec_read(codec, spec->pll_nid, 0,
1009 AC_VERB_GET_PROC_COEF, 0);
1010 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
1011 spec->pll_coef_idx);
1012 snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
1013 val & ~(1 << spec->pll_coef_bit));
1014}
1015
1016static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
1017 unsigned int coef_idx, unsigned int coef_bit)
1018{
1019 struct alc_spec *spec = codec->spec;
1020 spec->pll_nid = nid;
1021 spec->pll_coef_idx = coef_idx;
1022 spec->pll_coef_bit = coef_bit;
1023 alc_fix_pll(codec);
1024}
1025
Kailang Yang9ad0e492010-09-14 23:22:00 +02001026static int alc_init_jacks(struct hda_codec *codec)
1027{
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001028#ifdef CONFIG_SND_HDA_INPUT_JACK
Kailang Yang9ad0e492010-09-14 23:22:00 +02001029 struct alc_spec *spec = codec->spec;
1030 int err;
1031 unsigned int hp_nid = spec->autocfg.hp_pins[0];
1032 unsigned int mic_nid = spec->ext_mic.pin;
1033
Takashi Iwai265a0242010-09-21 11:26:21 +02001034 if (hp_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001035 err = snd_hda_input_jack_add(codec, hp_nid,
1036 SND_JACK_HEADPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001037 if (err < 0)
1038 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001039 snd_hda_input_jack_report(codec, hp_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001040 }
Kailang Yang9ad0e492010-09-14 23:22:00 +02001041
Takashi Iwai265a0242010-09-21 11:26:21 +02001042 if (mic_nid) {
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001043 err = snd_hda_input_jack_add(codec, mic_nid,
1044 SND_JACK_MICROPHONE, NULL);
Takashi Iwai265a0242010-09-21 11:26:21 +02001045 if (err < 0)
1046 return err;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001047 snd_hda_input_jack_report(codec, mic_nid);
Takashi Iwai265a0242010-09-21 11:26:21 +02001048 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001049#endif /* CONFIG_SND_HDA_INPUT_JACK */
Kailang Yang9ad0e492010-09-14 23:22:00 +02001050 return 0;
1051}
Kailang Yang9ad0e492010-09-14 23:22:00 +02001052
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001053static void alc_automute_speaker(struct hda_codec *codec, int pinctl)
Kailang Yangc9b58002007-10-16 14:30:01 +02001054{
1055 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001056 unsigned int mute;
1057 hda_nid_t nid;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001058 int i;
Kailang Yangc9b58002007-10-16 14:30:01 +02001059
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001060 spec->jack_present = 0;
1061 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
1062 nid = spec->autocfg.hp_pins[i];
1063 if (!nid)
1064 break;
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001065 snd_hda_input_jack_report(codec, nid);
David Henningssonf0ce2792011-02-28 15:58:07 +01001066 spec->jack_present |= snd_hda_jack_detect(codec, nid);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001067 }
1068
1069 mute = spec->jack_present ? HDA_AMP_MUTE : 0;
1070 /* Toggle internal speakers muting */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001071 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
1072 nid = spec->autocfg.speaker_pins[i];
1073 if (!nid)
1074 break;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001075 if (pinctl) {
1076 snd_hda_codec_write(codec, nid, 0,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001077 AC_VERB_SET_PIN_WIDGET_CONTROL,
1078 spec->jack_present ? 0 : PIN_OUT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001079 } else {
1080 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
1081 HDA_AMP_MUTE, mute);
1082 }
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001083 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001084}
1085
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001086static void alc_automute_pin(struct hda_codec *codec)
1087{
1088 alc_automute_speaker(codec, 1);
1089}
1090
Takashi Iwai6c819492009-08-10 18:47:44 +02001091static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
1092 hda_nid_t nid)
1093{
1094 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
1095 int i, nums;
1096
1097 nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
1098 for (i = 0; i < nums; i++)
1099 if (conn[i] == nid)
1100 return i;
1101 return -1;
1102}
1103
Takashi Iwai840b64c2010-07-13 22:49:01 +02001104/* switch the current ADC according to the jack state */
1105static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec)
1106{
1107 struct alc_spec *spec = codec->spec;
1108 unsigned int present;
1109 hda_nid_t new_adc;
1110
1111 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
1112 if (present)
1113 spec->cur_adc_idx = 1;
1114 else
1115 spec->cur_adc_idx = 0;
1116 new_adc = spec->adc_nids[spec->cur_adc_idx];
1117 if (spec->cur_adc && spec->cur_adc != new_adc) {
1118 /* stream is running, let's swap the current ADC */
Takashi Iwaif0cea792010-08-13 11:56:53 +02001119 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
Takashi Iwai840b64c2010-07-13 22:49:01 +02001120 spec->cur_adc = new_adc;
1121 snd_hda_codec_setup_stream(codec, new_adc,
1122 spec->cur_adc_stream_tag, 0,
1123 spec->cur_adc_format);
1124 }
1125}
1126
Kailang Yang7fb0d782008-10-15 11:12:35 +02001127static void alc_mic_automute(struct hda_codec *codec)
1128{
1129 struct alc_spec *spec = codec->spec;
Takashi Iwai6c819492009-08-10 18:47:44 +02001130 struct alc_mic_route *dead, *alive;
1131 unsigned int present, type;
1132 hda_nid_t cap_nid;
Kailang Yang7fb0d782008-10-15 11:12:35 +02001133
Takashi Iwaib59bdf32009-08-11 09:47:30 +02001134 if (!spec->auto_mic)
1135 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001136 if (!spec->int_mic.pin || !spec->ext_mic.pin)
1137 return;
1138 if (snd_BUG_ON(!spec->adc_nids))
1139 return;
1140
Takashi Iwai840b64c2010-07-13 22:49:01 +02001141 if (spec->dual_adc_switch) {
1142 alc_dual_mic_adc_auto_switch(codec);
1143 return;
1144 }
1145
Takashi Iwai6c819492009-08-10 18:47:44 +02001146 cap_nid = spec->capsrc_nids ? spec->capsrc_nids[0] : spec->adc_nids[0];
1147
Wu Fengguang864f92b2009-11-18 12:38:02 +08001148 present = snd_hda_jack_detect(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001149 if (present) {
1150 alive = &spec->ext_mic;
1151 dead = &spec->int_mic;
1152 } else {
1153 alive = &spec->int_mic;
1154 dead = &spec->ext_mic;
1155 }
1156
Takashi Iwai6c819492009-08-10 18:47:44 +02001157 type = get_wcaps_type(get_wcaps(codec, cap_nid));
1158 if (type == AC_WID_AUD_MIX) {
1159 /* Matrix-mixer style (e.g. ALC882) */
1160 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1161 alive->mux_idx,
1162 HDA_AMP_MUTE, 0);
1163 snd_hda_codec_amp_stereo(codec, cap_nid, HDA_INPUT,
1164 dead->mux_idx,
1165 HDA_AMP_MUTE, HDA_AMP_MUTE);
1166 } else {
1167 /* MUX style (e.g. ALC880) */
1168 snd_hda_codec_write_cache(codec, cap_nid, 0,
1169 AC_VERB_SET_CONNECT_SEL,
1170 alive->mux_idx);
1171 }
Takashi Iwaicd372fb2011-03-03 14:40:14 +01001172 snd_hda_input_jack_report(codec, spec->ext_mic.pin);
Takashi Iwai6c819492009-08-10 18:47:44 +02001173
1174 /* FIXME: analog mixer */
Kailang Yang7fb0d782008-10-15 11:12:35 +02001175}
1176
Kailang Yangc9b58002007-10-16 14:30:01 +02001177/* unsolicited event for HP jack sensing */
1178static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
1179{
1180 if (codec->vendor_id == 0x10ec0880)
1181 res >>= 28;
1182 else
1183 res >>= 26;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001184 switch (res) {
1185 case ALC880_HP_EVENT:
1186 alc_automute_pin(codec);
1187 break;
1188 case ALC880_MIC_EVENT:
Kailang Yang7fb0d782008-10-15 11:12:35 +02001189 alc_mic_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001190 break;
1191 }
Kailang Yang7fb0d782008-10-15 11:12:35 +02001192}
1193
1194static void alc_inithook(struct hda_codec *codec)
1195{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001196 alc_automute_pin(codec);
Kailang Yang7fb0d782008-10-15 11:12:35 +02001197 alc_mic_automute(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001198}
1199
Kailang Yangf9423e72008-05-27 12:32:25 +02001200/* additional initialization for ALC888 variants */
1201static void alc888_coef_init(struct hda_codec *codec)
1202{
1203 unsigned int tmp;
1204
1205 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
1206 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1207 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
Takashi Iwai37db6232009-03-05 09:40:16 +01001208 if ((tmp & 0xf0) == 0x20)
Kailang Yangf9423e72008-05-27 12:32:25 +02001209 /* alc888S-VC */
1210 snd_hda_codec_read(codec, 0x20, 0,
1211 AC_VERB_SET_PROC_COEF, 0x830);
1212 else
1213 /* alc888-VB */
1214 snd_hda_codec_read(codec, 0x20, 0,
1215 AC_VERB_SET_PROC_COEF, 0x3030);
1216}
1217
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001218static void alc889_coef_init(struct hda_codec *codec)
1219{
1220 unsigned int tmp;
1221
1222 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1223 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
1224 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
1225 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
1226}
1227
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001228/* turn on/off EAPD control (only if available) */
1229static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
1230{
1231 if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
1232 return;
1233 if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
1234 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
1235 on ? 2 : 0);
1236}
1237
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001238static void alc_auto_init_amp(struct hda_codec *codec, int type)
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001239{
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001240 unsigned int tmp;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001241
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001242 switch (type) {
1243 case ALC_INIT_GPIO1:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001244 snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
1245 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001246 case ALC_INIT_GPIO2:
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001247 snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
1248 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001249 case ALC_INIT_GPIO3:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001250 snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
1251 break;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001252 case ALC_INIT_DEFAULT:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001253 switch (codec->vendor_id) {
Kailang Yangc9b58002007-10-16 14:30:01 +02001254 case 0x10ec0260:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001255 set_eapd(codec, 0x0f, 1);
1256 set_eapd(codec, 0x10, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001257 break;
1258 case 0x10ec0262:
Kailang Yangbdd148a2007-05-08 15:19:08 +02001259 case 0x10ec0267:
1260 case 0x10ec0268:
Kailang Yangc9b58002007-10-16 14:30:01 +02001261 case 0x10ec0269:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001262 case 0x10ec0270:
Takashi Iwaic6e8f2d2009-02-06 12:45:52 +01001263 case 0x10ec0272:
Kailang Yangf9423e72008-05-27 12:32:25 +02001264 case 0x10ec0660:
1265 case 0x10ec0662:
1266 case 0x10ec0663:
Kailang Yangc9b58002007-10-16 14:30:01 +02001267 case 0x10ec0862:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001268 case 0x10ec0889:
Takashi Iwai3fb4a502010-01-19 15:46:37 +01001269 set_eapd(codec, 0x14, 1);
1270 set_eapd(codec, 0x15, 1);
Kailang Yangc9b58002007-10-16 14:30:01 +02001271 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +02001272 }
Kailang Yangc9b58002007-10-16 14:30:01 +02001273 switch (codec->vendor_id) {
1274 case 0x10ec0260:
1275 snd_hda_codec_write(codec, 0x1a, 0,
1276 AC_VERB_SET_COEF_INDEX, 7);
1277 tmp = snd_hda_codec_read(codec, 0x1a, 0,
1278 AC_VERB_GET_PROC_COEF, 0);
1279 snd_hda_codec_write(codec, 0x1a, 0,
1280 AC_VERB_SET_COEF_INDEX, 7);
1281 snd_hda_codec_write(codec, 0x1a, 0,
1282 AC_VERB_SET_PROC_COEF,
1283 tmp | 0x2010);
1284 break;
1285 case 0x10ec0262:
1286 case 0x10ec0880:
1287 case 0x10ec0882:
1288 case 0x10ec0883:
1289 case 0x10ec0885:
Takashi Iwai4a5a4c52009-02-06 12:46:59 +01001290 case 0x10ec0887:
Takashi Iwai20a3a052008-05-23 17:52:53 +02001291 case 0x10ec0889:
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02001292 alc889_coef_init(codec);
Kailang Yangc9b58002007-10-16 14:30:01 +02001293 break;
Kailang Yangf9423e72008-05-27 12:32:25 +02001294 case 0x10ec0888:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001295 alc888_coef_init(codec);
Kailang Yangf9423e72008-05-27 12:32:25 +02001296 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001297#if 0 /* XXX: This may cause the silent output on speaker on some machines */
Kailang Yangc9b58002007-10-16 14:30:01 +02001298 case 0x10ec0267:
1299 case 0x10ec0268:
1300 snd_hda_codec_write(codec, 0x20, 0,
1301 AC_VERB_SET_COEF_INDEX, 7);
1302 tmp = snd_hda_codec_read(codec, 0x20, 0,
1303 AC_VERB_GET_PROC_COEF, 0);
1304 snd_hda_codec_write(codec, 0x20, 0,
Kailang Yangea1fb292008-08-26 12:58:38 +02001305 AC_VERB_SET_COEF_INDEX, 7);
Kailang Yangc9b58002007-10-16 14:30:01 +02001306 snd_hda_codec_write(codec, 0x20, 0,
1307 AC_VERB_SET_PROC_COEF,
1308 tmp | 0x3000);
1309 break;
Takashi Iwai0aea7782010-01-25 15:44:11 +01001310#endif /* XXX */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001311 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001312 break;
1313 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001314}
Kailang Yangea1fb292008-08-26 12:58:38 +02001315
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001316static void alc_init_auto_hp(struct hda_codec *codec)
1317{
1318 struct alc_spec *spec = codec->spec;
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001319 struct auto_pin_cfg *cfg = &spec->autocfg;
1320 int i;
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001321
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001322 if (!cfg->hp_pins[0]) {
1323 if (cfg->line_out_type != AUTO_PIN_HP_OUT)
Kailang Yangc9b58002007-10-16 14:30:01 +02001324 return;
1325 }
1326
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001327 if (!cfg->speaker_pins[0]) {
1328 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT)
1329 return;
1330 memcpy(cfg->speaker_pins, cfg->line_out_pins,
1331 sizeof(cfg->speaker_pins));
1332 cfg->speaker_outs = cfg->line_outs;
1333 }
1334
1335 if (!cfg->hp_pins[0]) {
1336 memcpy(cfg->hp_pins, cfg->line_out_pins,
1337 sizeof(cfg->hp_pins));
1338 cfg->hp_outs = cfg->line_outs;
1339 }
1340
1341 for (i = 0; i < cfg->hp_outs; i++) {
1342 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
1343 cfg->hp_pins[i]);
1344 snd_hda_codec_write_cache(codec, cfg->hp_pins[i], 0,
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001345 AC_VERB_SET_UNSOLICITED_ENABLE,
1346 AC_USRSP_EN | ALC880_HP_EVENT);
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001347 }
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001348 spec->unsol_event = alc_sku_unsol_event;
1349}
1350
Takashi Iwai6c819492009-08-10 18:47:44 +02001351static void alc_init_auto_mic(struct hda_codec *codec)
1352{
1353 struct alc_spec *spec = codec->spec;
1354 struct auto_pin_cfg *cfg = &spec->autocfg;
1355 hda_nid_t fixed, ext;
1356 int i;
1357
1358 /* there must be only two mic inputs exclusively */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001359 for (i = 0; i < cfg->num_inputs; i++)
Takashi Iwai86e29592010-09-09 14:50:17 +02001360 if (cfg->inputs[i].type >= AUTO_PIN_LINE_IN)
Takashi Iwai6c819492009-08-10 18:47:44 +02001361 return;
1362
1363 fixed = ext = 0;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02001364 for (i = 0; i < cfg->num_inputs; i++) {
1365 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai6c819492009-08-10 18:47:44 +02001366 unsigned int defcfg;
Takashi Iwai6c819492009-08-10 18:47:44 +02001367 defcfg = snd_hda_codec_get_pincfg(codec, nid);
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001368 switch (snd_hda_get_input_pin_attr(defcfg)) {
1369 case INPUT_PIN_ATTR_INT:
Takashi Iwai6c819492009-08-10 18:47:44 +02001370 if (fixed)
1371 return; /* already occupied */
1372 fixed = nid;
1373 break;
Takashi Iwai99ae28b2010-09-17 14:42:34 +02001374 case INPUT_PIN_ATTR_UNUSED:
1375 return; /* invalid entry */
1376 default:
Takashi Iwai6c819492009-08-10 18:47:44 +02001377 if (ext)
1378 return; /* already occupied */
1379 ext = nid;
1380 break;
Takashi Iwai6c819492009-08-10 18:47:44 +02001381 }
1382 }
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01001383 if (!ext || !fixed)
1384 return;
Takashi Iwai6c819492009-08-10 18:47:44 +02001385 if (!(get_wcaps(codec, ext) & AC_WCAP_UNSOL_CAP))
1386 return; /* no unsol support */
1387 snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x\n",
1388 ext, fixed);
1389 spec->ext_mic.pin = ext;
1390 spec->int_mic.pin = fixed;
1391 spec->ext_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1392 spec->int_mic.mux_idx = MUX_IDX_UNDEF; /* set later */
1393 spec->auto_mic = 1;
1394 snd_hda_codec_write_cache(codec, spec->ext_mic.pin, 0,
1395 AC_VERB_SET_UNSOLICITED_ENABLE,
1396 AC_USRSP_EN | ALC880_MIC_EVENT);
1397 spec->unsol_event = alc_sku_unsol_event;
1398}
1399
David Henningsson90622912010-10-14 14:50:18 +02001400/* Could be any non-zero and even value. When used as fixup, tells
1401 * the driver to ignore any present sku defines.
1402 */
1403#define ALC_FIXUP_SKU_IGNORE (2)
1404
Kailang Yangda00c242010-03-19 11:23:45 +01001405static int alc_auto_parse_customize_define(struct hda_codec *codec)
1406{
1407 unsigned int ass, tmp, i;
Takashi Iwai7fb56222010-03-22 17:09:47 +01001408 unsigned nid = 0;
Kailang Yangda00c242010-03-19 11:23:45 +01001409 struct alc_spec *spec = codec->spec;
1410
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001411 spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
1412
David Henningsson90622912010-10-14 14:50:18 +02001413 if (spec->cdefine.fixup) {
1414 ass = spec->cdefine.sku_cfg;
1415 if (ass == ALC_FIXUP_SKU_IGNORE)
1416 return -1;
1417 goto do_sku;
1418 }
1419
Kailang Yangda00c242010-03-19 11:23:45 +01001420 ass = codec->subsystem_id & 0xffff;
Takashi Iwaib6cbe512010-07-28 17:43:36 +02001421 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
Kailang Yangda00c242010-03-19 11:23:45 +01001422 goto do_sku;
1423
1424 nid = 0x1d;
1425 if (codec->vendor_id == 0x10ec0260)
1426 nid = 0x17;
1427 ass = snd_hda_codec_get_pincfg(codec, nid);
1428
1429 if (!(ass & 1)) {
1430 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1431 codec->chip_name, ass);
1432 return -1;
1433 }
1434
1435 /* check sum */
1436 tmp = 0;
1437 for (i = 1; i < 16; i++) {
1438 if ((ass >> i) & 1)
1439 tmp++;
1440 }
1441 if (((ass >> 16) & 0xf) != tmp)
1442 return -1;
1443
1444 spec->cdefine.port_connectivity = ass >> 30;
1445 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1446 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1447 spec->cdefine.customization = ass >> 8;
1448do_sku:
1449 spec->cdefine.sku_cfg = ass;
1450 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1451 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1452 spec->cdefine.swap = (ass & 0x2) >> 1;
1453 spec->cdefine.override = ass & 0x1;
1454
1455 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1456 nid, spec->cdefine.sku_cfg);
1457 snd_printd("SKU: port_connectivity=0x%x\n",
1458 spec->cdefine.port_connectivity);
1459 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1460 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1461 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1462 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1463 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1464 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1465 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1466
1467 return 0;
1468}
1469
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001470/* check subsystem ID and set up device-specific initialization;
1471 * return 1 if initialized, 0 if invalid SSID
1472 */
1473/* 32-bit subsystem ID for BIOS loading in HD Audio codec.
1474 * 31 ~ 16 : Manufacture ID
1475 * 15 ~ 8 : SKU ID
1476 * 7 ~ 0 : Assembly ID
1477 * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
1478 */
1479static int alc_subsystem_id(struct hda_codec *codec,
1480 hda_nid_t porta, hda_nid_t porte,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001481 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001482{
1483 unsigned int ass, tmp, i;
1484 unsigned nid;
1485 struct alc_spec *spec = codec->spec;
1486
David Henningsson90622912010-10-14 14:50:18 +02001487 if (spec->cdefine.fixup) {
1488 ass = spec->cdefine.sku_cfg;
1489 if (ass == ALC_FIXUP_SKU_IGNORE)
1490 return 0;
1491 goto do_sku;
1492 }
1493
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001494 ass = codec->subsystem_id & 0xffff;
1495 if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
1496 goto do_sku;
1497
1498 /* invalid SSID, check the special NID pin defcfg instead */
1499 /*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04001500 * 31~30 : port connectivity
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001501 * 29~21 : reserve
1502 * 20 : PCBEEP input
1503 * 19~16 : Check sum (15:1)
1504 * 15~1 : Custom
1505 * 0 : override
1506 */
1507 nid = 0x1d;
1508 if (codec->vendor_id == 0x10ec0260)
1509 nid = 0x17;
1510 ass = snd_hda_codec_get_pincfg(codec, nid);
1511 snd_printd("realtek: No valid SSID, "
1512 "checking pincfg 0x%08x for NID 0x%x\n",
Takashi Iwaicb6605c2009-04-28 13:03:19 +02001513 ass, nid);
Kailang Yang6227cdc2010-02-25 08:36:52 +01001514 if (!(ass & 1))
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001515 return 0;
1516 if ((ass >> 30) != 1) /* no physical connection */
1517 return 0;
1518
1519 /* check sum */
1520 tmp = 0;
1521 for (i = 1; i < 16; i++) {
1522 if ((ass >> i) & 1)
1523 tmp++;
1524 }
1525 if (((ass >> 16) & 0xf) != tmp)
1526 return 0;
1527do_sku:
1528 snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
1529 ass & 0xffff, codec->vendor_id);
1530 /*
1531 * 0 : override
1532 * 1 : Swap Jack
1533 * 2 : 0 --> Desktop, 1 --> Laptop
1534 * 3~5 : External Amplifier control
1535 * 7~6 : Reserved
1536 */
1537 tmp = (ass & 0x38) >> 3; /* external Amp control */
1538 switch (tmp) {
1539 case 1:
1540 spec->init_amp = ALC_INIT_GPIO1;
1541 break;
1542 case 3:
1543 spec->init_amp = ALC_INIT_GPIO2;
1544 break;
1545 case 7:
1546 spec->init_amp = ALC_INIT_GPIO3;
1547 break;
1548 case 5:
Takashi Iwai5a8cfb42010-11-26 17:11:18 +01001549 default:
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001550 spec->init_amp = ALC_INIT_DEFAULT;
1551 break;
1552 }
1553
1554 /* is laptop or Desktop and enable the function "Mute internal speaker
1555 * when the external headphone out jack is plugged"
1556 */
1557 if (!(ass & 0x8000))
1558 return 1;
1559 /*
1560 * 10~8 : Jack location
1561 * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
1562 * 14~13: Resvered
1563 * 15 : 1 --> enable the function "Mute internal speaker
1564 * when the external headphone out jack is plugged"
1565 */
Kailang Yangc9b58002007-10-16 14:30:01 +02001566 if (!spec->autocfg.hp_pins[0]) {
Takashi Iwai01d48252009-10-06 13:21:54 +02001567 hda_nid_t nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001568 tmp = (ass >> 11) & 0x3; /* HP to chassis */
1569 if (tmp == 0)
Takashi Iwai01d48252009-10-06 13:21:54 +02001570 nid = porta;
Kailang Yangc9b58002007-10-16 14:30:01 +02001571 else if (tmp == 1)
Takashi Iwai01d48252009-10-06 13:21:54 +02001572 nid = porte;
Kailang Yangc9b58002007-10-16 14:30:01 +02001573 else if (tmp == 2)
Takashi Iwai01d48252009-10-06 13:21:54 +02001574 nid = portd;
Kailang Yang6227cdc2010-02-25 08:36:52 +01001575 else if (tmp == 3)
1576 nid = porti;
Kailang Yangc9b58002007-10-16 14:30:01 +02001577 else
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001578 return 1;
Takashi Iwai01d48252009-10-06 13:21:54 +02001579 for (i = 0; i < spec->autocfg.line_outs; i++)
1580 if (spec->autocfg.line_out_pins[i] == nid)
1581 return 1;
1582 spec->autocfg.hp_pins[0] = nid;
Kailang Yangc9b58002007-10-16 14:30:01 +02001583 }
1584
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001585 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001586 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001587 return 1;
1588}
Kailang Yangea1fb292008-08-26 12:58:38 +02001589
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001590static void alc_ssid_check(struct hda_codec *codec,
Kailang Yang6227cdc2010-02-25 08:36:52 +01001591 hda_nid_t porta, hda_nid_t porte,
1592 hda_nid_t portd, hda_nid_t porti)
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001593{
Kailang Yang6227cdc2010-02-25 08:36:52 +01001594 if (!alc_subsystem_id(codec, porta, porte, portd, porti)) {
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001595 struct alc_spec *spec = codec->spec;
1596 snd_printd("realtek: "
1597 "Enable default setup for auto mode as fallback\n");
1598 spec->init_amp = ALC_INIT_DEFAULT;
1599 alc_init_auto_hp(codec);
Takashi Iwai6c819492009-08-10 18:47:44 +02001600 alc_init_auto_mic(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02001601 }
Kailang Yangbc9f98a2007-04-12 13:06:07 +02001602}
1603
Takashi Iwai41e41f12005-06-08 14:48:49 +02001604/*
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001605 * Fix-up pin default configurations and add default verbs
Takashi Iwaif95474e2007-07-10 00:47:43 +02001606 */
1607
1608struct alc_pincfg {
1609 hda_nid_t nid;
1610 u32 val;
1611};
1612
Todd Broche1eb5f12010-12-06 11:19:51 -08001613struct alc_model_fixup {
1614 const int id;
1615 const char *name;
1616};
1617
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001618struct alc_fixup {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001619 int type;
Takashi Iwai361fe6e2011-01-14 09:55:32 +01001620 bool chained;
1621 int chain_id;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001622 union {
1623 unsigned int sku;
1624 const struct alc_pincfg *pins;
1625 const struct hda_verb *verbs;
1626 void (*func)(struct hda_codec *codec,
1627 const struct alc_fixup *fix,
1628 int action);
1629 } v;
Takashi Iwaif8f25ba2009-10-06 08:31:29 +02001630};
1631
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001632enum {
1633 ALC_FIXUP_INVALID,
1634 ALC_FIXUP_SKU,
1635 ALC_FIXUP_PINS,
1636 ALC_FIXUP_VERBS,
1637 ALC_FIXUP_FUNC,
1638};
Takashi Iwaif95474e2007-07-10 00:47:43 +02001639
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001640enum {
1641 ALC_FIXUP_ACT_PRE_PROBE,
1642 ALC_FIXUP_ACT_PROBE,
Takashi Iwai58701122011-01-13 15:41:45 +01001643 ALC_FIXUP_ACT_INIT,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001644};
1645
1646static void alc_apply_fixup(struct hda_codec *codec, int action)
1647{
1648 struct alc_spec *spec = codec->spec;
1649 int id = spec->fixup_id;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001650#ifdef CONFIG_SND_DEBUG_VERBOSE
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001651 const char *modelname = spec->fixup_name;
Takashi Iwaiaa1d0c52011-01-19 17:27:58 +01001652#endif
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001653 int depth = 0;
1654
1655 if (!spec->fixup_list)
1656 return;
1657
1658 while (id >= 0) {
1659 const struct alc_fixup *fix = spec->fixup_list + id;
1660 const struct alc_pincfg *cfg;
1661
1662 switch (fix->type) {
1663 case ALC_FIXUP_SKU:
1664 if (action != ALC_FIXUP_ACT_PRE_PROBE || !fix->v.sku)
1665 break;;
1666 snd_printdd(KERN_INFO "hda_codec: %s: "
1667 "Apply sku override for %s\n",
1668 codec->chip_name, modelname);
1669 spec->cdefine.sku_cfg = fix->v.sku;
1670 spec->cdefine.fixup = 1;
1671 break;
1672 case ALC_FIXUP_PINS:
1673 cfg = fix->v.pins;
1674 if (action != ALC_FIXUP_ACT_PRE_PROBE || !cfg)
1675 break;
1676 snd_printdd(KERN_INFO "hda_codec: %s: "
1677 "Apply pincfg for %s\n",
1678 codec->chip_name, modelname);
1679 for (; cfg->nid; cfg++)
1680 snd_hda_codec_set_pincfg(codec, cfg->nid,
1681 cfg->val);
1682 break;
1683 case ALC_FIXUP_VERBS:
1684 if (action != ALC_FIXUP_ACT_PROBE || !fix->v.verbs)
1685 break;
1686 snd_printdd(KERN_INFO "hda_codec: %s: "
1687 "Apply fix-verbs for %s\n",
1688 codec->chip_name, modelname);
1689 add_verb(codec->spec, fix->v.verbs);
1690 break;
1691 case ALC_FIXUP_FUNC:
1692 if (!fix->v.func)
1693 break;
1694 snd_printdd(KERN_INFO "hda_codec: %s: "
1695 "Apply fix-func for %s\n",
1696 codec->chip_name, modelname);
1697 fix->v.func(codec, fix, action);
1698 break;
1699 default:
1700 snd_printk(KERN_ERR "hda_codec: %s: "
1701 "Invalid fixup type %d\n",
1702 codec->chip_name, fix->type);
1703 break;
1704 }
1705 if (!fix[id].chained)
1706 break;
1707 if (++depth > 10)
1708 break;
1709 id = fix[id].chain_id;
Takashi Iwai9d578832010-11-22 13:29:19 +01001710 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001711}
1712
Todd Broche1eb5f12010-12-06 11:19:51 -08001713static void alc_pick_fixup(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001714 const struct alc_model_fixup *models,
1715 const struct snd_pci_quirk *quirk,
1716 const struct alc_fixup *fixlist)
Todd Broche1eb5f12010-12-06 11:19:51 -08001717{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001718 struct alc_spec *spec = codec->spec;
1719 int id = -1;
1720 const char *name = NULL;
Todd Broche1eb5f12010-12-06 11:19:51 -08001721
Todd Broche1eb5f12010-12-06 11:19:51 -08001722 if (codec->modelname && models) {
1723 while (models->name) {
1724 if (!strcmp(codec->modelname, models->name)) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001725 id = models->id;
1726 name = models->name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001727 break;
1728 }
1729 models++;
1730 }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01001731 }
1732 if (id < 0) {
1733 quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
1734 if (quirk) {
1735 id = quirk->value;
1736#ifdef CONFIG_SND_DEBUG_VERBOSE
1737 name = quirk->name;
1738#endif
1739 }
1740 }
1741
1742 spec->fixup_id = id;
1743 if (id >= 0) {
1744 spec->fixup_list = fixlist;
1745 spec->fixup_name = name;
Todd Broche1eb5f12010-12-06 11:19:51 -08001746 }
Takashi Iwaif95474e2007-07-10 00:47:43 +02001747}
1748
Kailang Yang274693f2009-12-03 10:07:50 +01001749static int alc_read_coef_idx(struct hda_codec *codec,
1750 unsigned int coef_idx)
1751{
1752 unsigned int val;
1753 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1754 coef_idx);
1755 val = snd_hda_codec_read(codec, 0x20, 0,
1756 AC_VERB_GET_PROC_COEF, 0);
1757 return val;
1758}
1759
Kailang Yang977ddd62010-09-15 10:02:29 +02001760static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
1761 unsigned int coef_val)
1762{
1763 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
1764 coef_idx);
1765 snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
1766 coef_val);
1767}
1768
Takashi Iwai757899a2010-07-30 10:48:14 +02001769/* set right pin controls for digital I/O */
1770static void alc_auto_init_digital(struct hda_codec *codec)
1771{
1772 struct alc_spec *spec = codec->spec;
1773 int i;
1774 hda_nid_t pin;
1775
1776 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1777 pin = spec->autocfg.dig_out_pins[i];
1778 if (pin) {
1779 snd_hda_codec_write(codec, pin, 0,
1780 AC_VERB_SET_PIN_WIDGET_CONTROL,
1781 PIN_OUT);
1782 }
1783 }
1784 pin = spec->autocfg.dig_in_pin;
1785 if (pin)
1786 snd_hda_codec_write(codec, pin, 0,
1787 AC_VERB_SET_PIN_WIDGET_CONTROL,
1788 PIN_IN);
1789}
1790
1791/* parse digital I/Os and set up NIDs in BIOS auto-parse mode */
1792static void alc_auto_parse_digital(struct hda_codec *codec)
1793{
1794 struct alc_spec *spec = codec->spec;
1795 int i, err;
1796 hda_nid_t dig_nid;
1797
1798 /* support multiple SPDIFs; the secondary is set up as a slave */
1799 for (i = 0; i < spec->autocfg.dig_outs; i++) {
1800 err = snd_hda_get_connections(codec,
1801 spec->autocfg.dig_out_pins[i],
1802 &dig_nid, 1);
1803 if (err < 0)
1804 continue;
1805 if (!i) {
1806 spec->multiout.dig_out_nid = dig_nid;
1807 spec->dig_out_type = spec->autocfg.dig_out_type[0];
1808 } else {
1809 spec->multiout.slave_dig_outs = spec->slave_dig_outs;
1810 if (i >= ARRAY_SIZE(spec->slave_dig_outs) - 1)
1811 break;
1812 spec->slave_dig_outs[i - 1] = dig_nid;
1813 }
1814 }
1815
1816 if (spec->autocfg.dig_in_pin) {
Takashi Iwai01fdf182010-09-24 09:09:42 +02001817 dig_nid = codec->start_nid;
1818 for (i = 0; i < codec->num_nodes; i++, dig_nid++) {
1819 unsigned int wcaps = get_wcaps(codec, dig_nid);
1820 if (get_wcaps_type(wcaps) != AC_WID_AUD_IN)
1821 continue;
1822 if (!(wcaps & AC_WCAP_DIGITAL))
1823 continue;
1824 if (!(wcaps & AC_WCAP_CONN_LIST))
1825 continue;
1826 err = get_connection_index(codec, dig_nid,
1827 spec->autocfg.dig_in_pin);
1828 if (err >= 0) {
1829 spec->dig_in_nid = dig_nid;
1830 break;
1831 }
1832 }
Takashi Iwai757899a2010-07-30 10:48:14 +02001833 }
1834}
1835
Takashi Iwaif95474e2007-07-10 00:47:43 +02001836/*
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001837 * ALC888
1838 */
1839
1840/*
1841 * 2ch mode
1842 */
1843static struct hda_verb alc888_4ST_ch2_intel_init[] = {
1844/* Mic-in jack as mic in */
1845 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1846 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1847/* Line-in jack as Line in */
1848 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
1849 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1850/* Line-Out as Front */
1851 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1852 { } /* end */
1853};
1854
1855/*
1856 * 4ch mode
1857 */
1858static struct hda_verb alc888_4ST_ch4_intel_init[] = {
1859/* Mic-in jack as mic in */
1860 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
1861 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
1862/* Line-in jack as Surround */
1863 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1864 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1865/* Line-Out as Front */
1866 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00},
1867 { } /* end */
1868};
1869
1870/*
1871 * 6ch mode
1872 */
1873static struct hda_verb alc888_4ST_ch6_intel_init[] = {
1874/* Mic-in jack as CLFE */
1875 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1876 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1877/* Line-in jack as Surround */
1878 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1879 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1880/* Line-Out as CLFE (workaround because Mic-in is not loud enough) */
1881 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1882 { } /* end */
1883};
1884
1885/*
1886 * 8ch mode
1887 */
1888static struct hda_verb alc888_4ST_ch8_intel_init[] = {
1889/* Mic-in jack as CLFE */
1890 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1891 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1892/* Line-in jack as Surround */
1893 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
1894 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
1895/* Line-Out as Side */
1896 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1897 { } /* end */
1898};
1899
1900static struct hda_channel_mode alc888_4ST_8ch_intel_modes[4] = {
1901 { 2, alc888_4ST_ch2_intel_init },
1902 { 4, alc888_4ST_ch4_intel_init },
1903 { 6, alc888_4ST_ch6_intel_init },
1904 { 8, alc888_4ST_ch8_intel_init },
1905};
1906
1907/*
1908 * ALC888 Fujitsu Siemens Amillo xa3530
1909 */
1910
1911static struct hda_verb alc888_fujitsu_xa3530_verbs[] = {
1912/* Front Mic: set to PIN_IN (empty by default) */
1913 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1914/* Connect Internal HP to Front */
1915 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1916 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1917 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
1918/* Connect Bass HP to Front */
1919 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1920 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1921 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
1922/* Connect Line-Out side jack (SPDIF) to Side */
1923 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1924 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1925 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
1926/* Connect Mic jack to CLFE */
1927 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1928 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1929 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
1930/* Connect Line-in jack to Surround */
1931 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1932 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1933 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
1934/* Connect HP out jack to Front */
1935 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
1936 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
1937 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
1938/* Enable unsolicited event for HP jack and Line-out jack */
1939 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1940 {0x17, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1941 {}
1942};
1943
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001944static void alc_automute_amp(struct hda_codec *codec)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001945{
Takashi Iwaibb35feb2010-09-08 15:30:49 +02001946 alc_automute_speaker(codec, 0);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001947}
1948
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001949static void alc_automute_amp_unsol_event(struct hda_codec *codec,
1950 unsigned int res)
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001951{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001952 if (codec->vendor_id == 0x10ec0880)
1953 res >>= 28;
1954 else
1955 res >>= 26;
1956 if (res == ALC880_HP_EVENT)
1957 alc_automute_amp(codec);
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001958}
1959
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001960static void alc889_automute_setup(struct hda_codec *codec)
Wu Fengguang6732bd02009-07-30 09:19:14 +02001961{
1962 struct alc_spec *spec = codec->spec;
1963
1964 spec->autocfg.hp_pins[0] = 0x15;
1965 spec->autocfg.speaker_pins[0] = 0x14;
1966 spec->autocfg.speaker_pins[1] = 0x16;
1967 spec->autocfg.speaker_pins[2] = 0x17;
1968 spec->autocfg.speaker_pins[3] = 0x19;
1969 spec->autocfg.speaker_pins[4] = 0x1a;
Wu Fengguang6732bd02009-07-30 09:19:14 +02001970}
1971
1972static void alc889_intel_init_hook(struct hda_codec *codec)
1973{
1974 alc889_coef_init(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001975 alc_automute_amp(codec);
Wu Fengguang6732bd02009-07-30 09:19:14 +02001976}
1977
Takashi Iwai4f5d17062009-08-11 18:17:46 +02001978static void alc888_fujitsu_xa3530_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001979{
1980 struct alc_spec *spec = codec->spec;
1981
1982 spec->autocfg.hp_pins[0] = 0x17; /* line-out */
1983 spec->autocfg.hp_pins[1] = 0x1b; /* hp */
1984 spec->autocfg.speaker_pins[0] = 0x14; /* speaker */
1985 spec->autocfg.speaker_pins[1] = 0x15; /* bass */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02001986}
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001987
1988/*
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001989 * ALC888 Acer Aspire 4930G model
1990 */
1991
1992static struct hda_verb alc888_acer_aspire_4930g_verbs[] = {
1993/* Front Mic: set to PIN_IN (empty by default) */
1994 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
1995/* Unselect Front Mic by default in input mixer 3 */
1996 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Vincent Petryef8ef5f2008-11-23 11:31:41 +08001997/* Enable unsolicited event for HP jack */
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08001998 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
1999/* Connect Internal HP to front */
2000 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2001 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2002 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2003/* Connect HP out to front */
2004 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2005 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2006 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie2e93292011-01-12 08:03:39 +01002007 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002008 { }
2009};
2010
Hector Martin3b315d72009-06-02 10:54:19 +02002011/*
Tony Vroond2fd4b02009-06-21 00:40:10 +01002012 * ALC888 Acer Aspire 6530G model
2013 */
2014
2015static struct hda_verb alc888_acer_aspire_6530g_verbs[] = {
Tony Vroond1284182010-04-05 16:30:43 +01002016/* Route to built-in subwoofer as well as speakers */
2017 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2018 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
2019 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
2020 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002021/* Bias voltage on for external mic port */
2022 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
Emilio López320d5922009-06-25 08:18:44 +02002023/* Front Mic: set to PIN_IN (empty by default) */
2024 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2025/* Unselect Front Mic by default in input mixer 3 */
2026 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002027/* Enable unsolicited event for HP jack */
2028 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2029/* Enable speaker output */
2030 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2031 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Tony Vroond1284182010-04-05 16:30:43 +01002032 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002033/* Enable headphone output */
2034 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2035 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2036 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Tony Vroond1284182010-04-05 16:30:43 +01002037 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
Tony Vroond2fd4b02009-06-21 00:40:10 +01002038 { }
2039};
2040
2041/*
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002042 *ALC888 Acer Aspire 7730G model
2043 */
2044
2045static struct hda_verb alc888_acer_aspire_7730G_verbs[] = {
2046/* Bias voltage on for external mic port */
2047 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN | PIN_VREF80},
2048/* Front Mic: set to PIN_IN (empty by default) */
2049 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2050/* Unselect Front Mic by default in input mixer 3 */
2051 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2052/* Enable unsolicited event for HP jack */
2053 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2054/* Enable speaker output */
2055 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2056 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2057 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
2058/* Enable headphone output */
2059 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
2060 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2061 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2062 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
2063/*Enable internal subwoofer */
2064 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2065 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2066 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
2067 {0x17, AC_VERB_SET_EAPD_BTLENABLE, 2},
2068 { }
2069};
2070
2071/*
Hector Martin018df412009-06-04 00:13:40 +02002072 * ALC889 Acer Aspire 8930G model
Hector Martin3b315d72009-06-02 10:54:19 +02002073 */
2074
Hector Martin018df412009-06-04 00:13:40 +02002075static struct hda_verb alc889_acer_aspire_8930g_verbs[] = {
Hector Martin3b315d72009-06-02 10:54:19 +02002076/* Front Mic: set to PIN_IN (empty by default) */
2077 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
2078/* Unselect Front Mic by default in input mixer 3 */
2079 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0xb)},
2080/* Enable unsolicited event for HP jack */
2081 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
2082/* Connect Internal Front to Front */
2083 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2084 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2085 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
2086/* Connect Internal Rear to Rear */
2087 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2088 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2089 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
2090/* Connect Internal CLFE to CLFE */
2091 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
2092 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2093 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
2094/* Connect HP out to Front */
Hector Martin018df412009-06-04 00:13:40 +02002095 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | PIN_HP},
Hector Martin3b315d72009-06-02 10:54:19 +02002096 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
2097 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
2098/* Enable all DACs */
2099/* DAC DISABLE/MUTE 1? */
2100/* setting bits 1-5 disables DAC nids 0x02-0x06 apparently. Init=0x38 */
2101 {0x20, AC_VERB_SET_COEF_INDEX, 0x03},
2102 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
2103/* DAC DISABLE/MUTE 2? */
2104/* some bit here disables the other DACs. Init=0x4900 */
2105 {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
2106 {0x20, AC_VERB_SET_PROC_COEF, 0x0000},
Hector Martin018df412009-06-04 00:13:40 +02002107/* DMIC fix
2108 * This laptop has a stereo digital microphone. The mics are only 1cm apart
2109 * which makes the stereo useless. However, either the mic or the ALC889
2110 * makes the signal become a difference/sum signal instead of standard
2111 * stereo, which is annoying. So instead we flip this bit which makes the
2112 * codec replicate the sum signal to both channels, turning it into a
2113 * normal mono mic.
2114 */
2115/* DMIC_CONTROL? Init value = 0x0001 */
2116 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
2117 {0x20, AC_VERB_SET_PROC_COEF, 0x0003},
Hector Martin3b315d72009-06-02 10:54:19 +02002118 { }
2119};
2120
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002121static struct hda_input_mux alc888_2_capture_sources[2] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002122 /* Front mic only available on one ADC */
2123 {
2124 .num_items = 4,
2125 .items = {
2126 { "Mic", 0x0 },
2127 { "Line", 0x2 },
2128 { "CD", 0x4 },
2129 { "Front Mic", 0xb },
2130 },
2131 },
2132 {
2133 .num_items = 3,
2134 .items = {
2135 { "Mic", 0x0 },
2136 { "Line", 0x2 },
2137 { "CD", 0x4 },
2138 },
2139 }
2140};
2141
Tony Vroond2fd4b02009-06-21 00:40:10 +01002142static struct hda_input_mux alc888_acer_aspire_6530_sources[2] = {
2143 /* Interal mic only available on one ADC */
2144 {
Tony Vroon684a8842009-06-26 09:27:50 +01002145 .num_items = 5,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002146 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002147 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002148 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002149 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002150 { "Input Mix", 0xa },
David Henningsson28c4edb2010-12-20 14:24:29 +01002151 { "Internal Mic", 0xb },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002152 },
2153 },
2154 {
Tony Vroon684a8842009-06-26 09:27:50 +01002155 .num_items = 4,
Tony Vroond2fd4b02009-06-21 00:40:10 +01002156 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +01002157 { "Mic", 0x0 },
Tony Vroon684a8842009-06-26 09:27:50 +01002158 { "Line In", 0x2 },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002159 { "CD", 0x4 },
Tony Vroon684a8842009-06-26 09:27:50 +01002160 { "Input Mix", 0xa },
Tony Vroond2fd4b02009-06-21 00:40:10 +01002161 },
2162 }
2163};
2164
Hector Martin018df412009-06-04 00:13:40 +02002165static struct hda_input_mux alc889_capture_sources[3] = {
2166 /* Digital mic only available on first "ADC" */
2167 {
2168 .num_items = 5,
2169 .items = {
2170 { "Mic", 0x0 },
2171 { "Line", 0x2 },
2172 { "CD", 0x4 },
2173 { "Front Mic", 0xb },
2174 { "Input Mix", 0xa },
2175 },
2176 },
2177 {
2178 .num_items = 4,
2179 .items = {
2180 { "Mic", 0x0 },
2181 { "Line", 0x2 },
2182 { "CD", 0x4 },
2183 { "Input Mix", 0xa },
2184 },
2185 },
2186 {
2187 .num_items = 4,
2188 .items = {
2189 { "Mic", 0x0 },
2190 { "Line", 0x2 },
2191 { "CD", 0x4 },
2192 { "Input Mix", 0xa },
2193 },
2194 }
2195};
2196
Vincent Petryef8ef5f2008-11-23 11:31:41 +08002197static struct snd_kcontrol_new alc888_base_mixer[] = {
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002198 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2199 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2200 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2201 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2202 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2203 HDA_OUTPUT),
2204 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2205 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2206 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2207 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
2208 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
2209 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2210 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2211 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2212 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2213 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002214 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002215 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002216 { } /* end */
2217};
2218
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002219static struct snd_kcontrol_new alc888_acer_aspire_4930g_mixer[] = {
2220 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2221 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2222 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2223 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002224 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002225 HDA_OUTPUT),
Łukasz Wojniłowicz786c51f2011-02-24 10:03:31 +01002226 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2227 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2228 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2229 HDA_CODEC_VOLUME_MONO("Internal LFE Playback Volume", 0x0f, 1, 0x0, HDA_OUTPUT),
2230 HDA_BIND_MUTE_MONO("Internal LFE Playback Switch", 0x0f, 1, 2, HDA_INPUT),
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +01002231 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2232 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2233 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2234 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2235 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2236 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
2237 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2238 { } /* end */
2239};
2240
Hector Martin556eea92009-12-20 22:51:23 +01002241static struct snd_kcontrol_new alc889_acer_aspire_8930g_mixer[] = {
2242 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2243 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
2244 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2245 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
2246 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
2247 HDA_OUTPUT),
2248 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2249 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2250 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2251 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2252 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2253 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01002254 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hector Martin556eea92009-12-20 22:51:23 +01002255 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2256 { } /* end */
2257};
2258
2259
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002260static void alc888_acer_aspire_4930g_setup(struct hda_codec *codec)
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002261{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002262 struct alc_spec *spec = codec->spec;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002263
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02002264 spec->autocfg.hp_pins[0] = 0x15;
2265 spec->autocfg.speaker_pins[0] = 0x14;
Łukasz Wojniłowicz7cef4cf2009-11-20 12:14:35 +01002266 spec->autocfg.speaker_pins[1] = 0x16;
2267 spec->autocfg.speaker_pins[2] = 0x17;
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002268}
2269
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002270static void alc888_acer_aspire_6530g_setup(struct hda_codec *codec)
Emilio López320d5922009-06-25 08:18:44 +02002271{
2272 struct alc_spec *spec = codec->spec;
2273
2274 spec->autocfg.hp_pins[0] = 0x15;
2275 spec->autocfg.speaker_pins[0] = 0x14;
2276 spec->autocfg.speaker_pins[1] = 0x16;
2277 spec->autocfg.speaker_pins[2] = 0x17;
Emilio López320d5922009-06-25 08:18:44 +02002278}
2279
Denis Kuplyakovd9477202010-11-24 06:01:09 +01002280static void alc888_acer_aspire_7730g_setup(struct hda_codec *codec)
2281{
2282 struct alc_spec *spec = codec->spec;
2283
2284 spec->autocfg.hp_pins[0] = 0x15;
2285 spec->autocfg.speaker_pins[0] = 0x14;
2286 spec->autocfg.speaker_pins[1] = 0x16;
2287 spec->autocfg.speaker_pins[2] = 0x17;
2288}
2289
Takashi Iwai4f5d17062009-08-11 18:17:46 +02002290static void alc889_acer_aspire_8930g_setup(struct hda_codec *codec)
Hector Martin3b315d72009-06-02 10:54:19 +02002291{
2292 struct alc_spec *spec = codec->spec;
2293
2294 spec->autocfg.hp_pins[0] = 0x15;
2295 spec->autocfg.speaker_pins[0] = 0x14;
2296 spec->autocfg.speaker_pins[1] = 0x16;
2297 spec->autocfg.speaker_pins[2] = 0x1b;
Hector Martin3b315d72009-06-02 10:54:19 +02002298}
2299
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08002300/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002301 * ALC880 3-stack model
2302 *
2303 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002304 * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
2305 * F-Mic = 0x1b, HP = 0x19
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 */
2307
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002308static hda_nid_t alc880_dac_nids[4] = {
2309 /* front, rear, clfe, rear_surr */
2310 0x02, 0x05, 0x04, 0x03
2311};
2312
2313static hda_nid_t alc880_adc_nids[3] = {
2314 /* ADC0-2 */
2315 0x07, 0x08, 0x09,
2316};
2317
2318/* The datasheet says the node 0x07 is connected from inputs,
2319 * but it shows zero connection in the real implementation on some devices.
Kailang Yangdf694da2005-12-05 19:42:22 +01002320 * Note: this is a 915GAV bug, fixed on 915GLV
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002322static hda_nid_t alc880_adc_nids_alt[2] = {
2323 /* ADC1-2 */
2324 0x08, 0x09,
2325};
2326
2327#define ALC880_DIGOUT_NID 0x06
2328#define ALC880_DIGIN_NID 0x0a
2329
2330static struct hda_input_mux alc880_capture_source = {
2331 .num_items = 4,
2332 .items = {
2333 { "Mic", 0x0 },
2334 { "Front Mic", 0x3 },
2335 { "Line", 0x2 },
2336 { "CD", 0x4 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337 },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002338};
2339
2340/* channel source setting (2/6 channel selection for 3-stack) */
2341/* 2ch mode */
2342static struct hda_verb alc880_threestack_ch2_init[] = {
2343 /* set line-in to input, mute it */
2344 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2345 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
2346 /* set mic-in to input vref 80%, mute it */
2347 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
2348 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349 { } /* end */
2350};
2351
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002352/* 6ch mode */
2353static struct hda_verb alc880_threestack_ch6_init[] = {
2354 /* set line-in to output, unmute it */
2355 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2356 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2357 /* set mic-in to output, unmute it */
2358 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2359 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2360 { } /* end */
2361};
2362
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002363static struct hda_channel_mode alc880_threestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002364 { 2, alc880_threestack_ch2_init },
2365 { 6, alc880_threestack_ch6_init },
2366};
2367
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002368static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02002369 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002370 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002371 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002372 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02002373 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2374 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002375 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2376 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002377 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2378 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2379 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2380 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2381 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2382 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2383 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
2384 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385 HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002386 {
2387 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2388 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002389 .info = alc_ch_mode_info,
2390 .get = alc_ch_mode_get,
2391 .put = alc_ch_mode_put,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002392 },
2393 { } /* end */
2394};
2395
2396/* capture mixer elements */
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002397static int alc_cap_vol_info(struct snd_kcontrol *kcontrol,
2398 struct snd_ctl_elem_info *uinfo)
2399{
2400 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2401 struct alc_spec *spec = codec->spec;
2402 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002403
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002404 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002405 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2406 HDA_INPUT);
2407 err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002408 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002409 return err;
2410}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002412static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
2413 unsigned int size, unsigned int __user *tlv)
2414{
2415 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2416 struct alc_spec *spec = codec->spec;
2417 int err;
2418
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002419 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002420 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0,
2421 HDA_INPUT);
2422 err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002423 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002424 return err;
2425}
2426
2427typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol,
2428 struct snd_ctl_elem_value *ucontrol);
2429
2430static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol,
2431 struct snd_ctl_elem_value *ucontrol,
2432 getput_call_t func)
2433{
2434 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
2435 struct alc_spec *spec = codec->spec;
2436 unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
2437 int err;
2438
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002439 mutex_lock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002440 kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx],
2441 3, 0, HDA_INPUT);
2442 err = func(kcontrol, ucontrol);
Wu Fengguang5a9e02e2009-01-09 16:45:24 +08002443 mutex_unlock(&codec->control_mutex);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002444 return err;
2445}
2446
2447static int alc_cap_vol_get(struct snd_kcontrol *kcontrol,
2448 struct snd_ctl_elem_value *ucontrol)
2449{
2450 return alc_cap_getput_caller(kcontrol, ucontrol,
2451 snd_hda_mixer_amp_volume_get);
2452}
2453
2454static int alc_cap_vol_put(struct snd_kcontrol *kcontrol,
2455 struct snd_ctl_elem_value *ucontrol)
2456{
2457 return alc_cap_getput_caller(kcontrol, ucontrol,
2458 snd_hda_mixer_amp_volume_put);
2459}
2460
2461/* capture mixer elements */
2462#define alc_cap_sw_info snd_ctl_boolean_stereo_info
2463
2464static int alc_cap_sw_get(struct snd_kcontrol *kcontrol,
2465 struct snd_ctl_elem_value *ucontrol)
2466{
2467 return alc_cap_getput_caller(kcontrol, ucontrol,
2468 snd_hda_mixer_amp_switch_get);
2469}
2470
2471static int alc_cap_sw_put(struct snd_kcontrol *kcontrol,
2472 struct snd_ctl_elem_value *ucontrol)
2473{
2474 return alc_cap_getput_caller(kcontrol, ucontrol,
2475 snd_hda_mixer_amp_switch_put);
2476}
2477
Takashi Iwaia23b6882009-03-23 15:21:36 +01002478#define _DEFINE_CAPMIX(num) \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002479 { \
2480 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2481 .name = "Capture Switch", \
2482 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
2483 .count = num, \
2484 .info = alc_cap_sw_info, \
2485 .get = alc_cap_sw_get, \
2486 .put = alc_cap_sw_put, \
2487 }, \
2488 { \
2489 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2490 .name = "Capture Volume", \
2491 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \
2492 SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
2493 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \
2494 .count = num, \
2495 .info = alc_cap_vol_info, \
2496 .get = alc_cap_vol_get, \
2497 .put = alc_cap_vol_put, \
2498 .tlv = { .c = alc_cap_vol_tlv }, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002499 }
2500
2501#define _DEFINE_CAPSRC(num) \
Takashi Iwai3c3e9892008-10-31 17:48:56 +01002502 { \
2503 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2504 /* .name = "Capture Source", */ \
2505 .name = "Input Source", \
2506 .count = num, \
2507 .info = alc_mux_enum_info, \
2508 .get = alc_mux_enum_get, \
2509 .put = alc_mux_enum_put, \
Takashi Iwaia23b6882009-03-23 15:21:36 +01002510 }
2511
2512#define DEFINE_CAPMIX(num) \
2513static struct snd_kcontrol_new alc_capture_mixer ## num[] = { \
2514 _DEFINE_CAPMIX(num), \
2515 _DEFINE_CAPSRC(num), \
2516 { } /* end */ \
2517}
2518
2519#define DEFINE_CAPMIX_NOSRC(num) \
2520static struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \
2521 _DEFINE_CAPMIX(num), \
2522 { } /* end */ \
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002523}
2524
2525/* up to three ADCs */
2526DEFINE_CAPMIX(1);
2527DEFINE_CAPMIX(2);
2528DEFINE_CAPMIX(3);
Takashi Iwaia23b6882009-03-23 15:21:36 +01002529DEFINE_CAPMIX_NOSRC(1);
2530DEFINE_CAPMIX_NOSRC(2);
2531DEFINE_CAPMIX_NOSRC(3);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002532
2533/*
2534 * ALC880 5-stack model
2535 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002536 * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
2537 * Side = 0x02 (0xd)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002538 * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
2539 * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
2540 */
2541
2542/* additional mixers to alc880_three_stack_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002543static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002544 HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002545 HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546 { } /* end */
2547};
2548
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002549/* channel source setting (6/8 channel selection for 5-stack) */
2550/* 6ch mode */
2551static struct hda_verb alc880_fivestack_ch6_init[] = {
2552 /* set line-in to input, mute it */
2553 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
2554 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02002555 { } /* end */
2556};
2557
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002558/* 8ch mode */
2559static struct hda_verb alc880_fivestack_ch8_init[] = {
2560 /* set line-in to output, unmute it */
2561 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
2562 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
2563 { } /* end */
2564};
2565
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002566static struct hda_channel_mode alc880_fivestack_modes[2] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002567 { 6, alc880_fivestack_ch6_init },
2568 { 8, alc880_fivestack_ch8_init },
2569};
2570
2571
2572/*
2573 * ALC880 6-stack model
2574 *
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002575 * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
2576 * Side = 0x05 (0x0f)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002577 * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
2578 * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
2579 */
2580
2581static hda_nid_t alc880_6st_dac_nids[4] = {
2582 /* front, rear, clfe, rear_surr */
2583 0x02, 0x03, 0x04, 0x05
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02002584};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002585
2586static struct hda_input_mux alc880_6stack_capture_source = {
2587 .num_items = 4,
2588 .items = {
2589 { "Mic", 0x0 },
2590 { "Front Mic", 0x1 },
2591 { "Line", 0x2 },
2592 { "CD", 0x4 },
2593 },
2594};
2595
2596/* fixed 8-channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002597static struct hda_channel_mode alc880_sixstack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002598 { 8, NULL },
2599};
2600
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002601static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002602 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002603 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002604 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002605 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002606 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2607 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002608 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2609 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002610 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002611 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002612 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2613 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2614 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2615 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2616 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2617 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2618 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2619 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002620 {
2621 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2622 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002623 .info = alc_ch_mode_info,
2624 .get = alc_ch_mode_get,
2625 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002626 },
2627 { } /* end */
2628};
2629
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002630
2631/*
2632 * ALC880 W810 model
2633 *
2634 * W810 has rear IO for:
2635 * Front (DAC 02)
2636 * Surround (DAC 03)
2637 * Center/LFE (DAC 04)
2638 * Digital out (06)
2639 *
2640 * The system also has a pair of internal speakers, and a headphone jack.
2641 * These are both connected to Line2 on the codec, hence to DAC 02.
Kailang Yangea1fb292008-08-26 12:58:38 +02002642 *
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002643 * There is a variable resistor to control the speaker or headphone
2644 * volume. This is a hardware-only device without a software API.
2645 *
2646 * Plugging headphones in will disable the internal speakers. This is
2647 * implemented in hardware, not via the driver using jack sense. In
2648 * a similar fashion, plugging into the rear socket marked "front" will
2649 * disable both the speakers and headphones.
2650 *
2651 * For input, there's a microphone jack, and an "audio in" jack.
2652 * These may not do anything useful with this driver yet, because I
2653 * haven't setup any initialization verbs for these yet...
2654 */
2655
2656static hda_nid_t alc880_w810_dac_nids[3] = {
2657 /* front, rear/surround, clfe */
2658 0x02, 0x03, 0x04
2659};
2660
2661/* fixed 6 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002662static struct hda_channel_mode alc880_w810_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002663 { 6, NULL }
2664};
2665
2666/* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002667static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002668 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002669 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002670 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002671 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002672 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2673 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002674 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2675 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002676 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2677 { } /* end */
2678};
2679
2680
2681/*
2682 * Z710V model
2683 *
2684 * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002685 * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
2686 * Line = 0x1a
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002687 */
2688
2689static hda_nid_t alc880_z71v_dac_nids[1] = {
2690 0x02
2691};
2692#define ALC880_Z71V_HP_DAC 0x03
2693
2694/* fixed 2 channels */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01002695static struct hda_channel_mode alc880_2_jack_modes[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002696 { 2, NULL }
2697};
2698
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002699static struct snd_kcontrol_new alc880_z71v_mixer[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002700 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002701 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002702 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002703 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002704 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2705 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2706 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2707 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2708 { } /* end */
2709};
2710
2711
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002712/*
2713 * ALC880 F1734 model
2714 *
2715 * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
2716 * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
2717 */
2718
2719static hda_nid_t alc880_f1734_dac_nids[1] = {
2720 0x03
2721};
2722#define ALC880_F1734_HP_DAC 0x02
2723
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002724static struct snd_kcontrol_new alc880_f1734_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002725 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002726 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01002727 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2728 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002729 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2730 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai937b4162008-02-11 14:52:36 +01002731 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2732 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002733 { } /* end */
2734};
2735
Takashi Iwai937b4162008-02-11 14:52:36 +01002736static struct hda_input_mux alc880_f1734_capture_source = {
2737 .num_items = 2,
2738 .items = {
2739 { "Mic", 0x1 },
2740 { "CD", 0x4 },
2741 },
2742};
2743
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002744
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002745/*
2746 * ALC880 ASUS model
2747 *
2748 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2749 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2750 * Mic = 0x18, Line = 0x1a
2751 */
2752
2753#define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
2754#define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
2755
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002756static struct snd_kcontrol_new alc880_asus_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002757 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002758 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002759 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002760 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002761 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2762 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01002763 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2764 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002765 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2766 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2767 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2768 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2769 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2770 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002771 {
2772 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2773 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01002774 .info = alc_ch_mode_info,
2775 .get = alc_ch_mode_get,
2776 .put = alc_ch_mode_put,
Takashi Iwai16ded522005-06-10 19:58:24 +02002777 },
2778 { } /* end */
2779};
2780
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002781/*
2782 * ALC880 ASUS W1V model
2783 *
2784 * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
2785 * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
2786 * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
2787 */
2788
2789/* additional mixers to alc880_asus_mixer */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01002790static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
Takashi Iwai16ded522005-06-10 19:58:24 +02002791 HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
2792 HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02002793 { } /* end */
2794};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002795
Kailang Yangdf694da2005-12-05 19:42:22 +01002796/* TCL S700 */
2797static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
2798 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2799 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
2800 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
2801 HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
2802 HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
2803 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
2804 HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
2805 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
2806 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01002807 { } /* end */
2808};
2809
Kailang Yangccc656c2006-10-17 12:32:26 +02002810/* Uniwill */
2811static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002812 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2813 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2814 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2815 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002816 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
2817 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
2818 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
2819 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
2820 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2821 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
2822 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
2823 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
2824 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2825 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2826 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2827 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002828 {
2829 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2830 .name = "Channel Mode",
2831 .info = alc_ch_mode_info,
2832 .get = alc_ch_mode_get,
2833 .put = alc_ch_mode_put,
2834 },
2835 { } /* end */
2836};
2837
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002838static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
2839 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2840 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2841 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2842 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
2843 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
2844 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +01002845 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2846 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01002847 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
2848 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01002849 { } /* end */
2850};
2851
Kailang Yangccc656c2006-10-17 12:32:26 +02002852static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002853 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
2854 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
2855 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
2856 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02002857 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
2858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
2859 { } /* end */
2860};
2861
Linus Torvalds1da177e2005-04-16 15:20:36 -07002862/*
Takashi Iwai2134ea42008-01-10 16:53:55 +01002863 * virtual master controls
2864 */
2865
2866/*
2867 * slave controls for virtual master
2868 */
Takashi Iwaiea734962011-01-17 11:29:34 +01002869static const char * const alc_slave_vols[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002870 "Front Playback Volume",
2871 "Surround Playback Volume",
2872 "Center Playback Volume",
2873 "LFE Playback Volume",
2874 "Side Playback Volume",
2875 "Headphone Playback Volume",
2876 "Speaker Playback Volume",
2877 "Mono Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002878 "Line-Out Playback Volume",
Takashi Iwai26f5df22008-11-03 17:39:46 +01002879 "PCM Playback Volume",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002880 NULL,
2881};
2882
Takashi Iwaiea734962011-01-17 11:29:34 +01002883static const char * const alc_slave_sws[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002884 "Front Playback Switch",
2885 "Surround Playback Switch",
2886 "Center Playback Switch",
2887 "LFE Playback Switch",
2888 "Side Playback Switch",
2889 "Headphone Playback Switch",
2890 "Speaker Playback Switch",
2891 "Mono Playback Switch",
Takashi Iwaiedb54a52008-01-29 12:47:02 +01002892 "IEC958 Playback Switch",
Takashi Iwai23033b22009-12-08 12:36:52 +01002893 "Line-Out Playback Switch",
2894 "PCM Playback Switch",
Takashi Iwai2134ea42008-01-10 16:53:55 +01002895 NULL,
2896};
2897
2898/*
Takashi Iwaie9edcee2005-06-13 14:16:38 +02002899 * build control elements
Linus Torvalds1da177e2005-04-16 15:20:36 -07002900 */
Takashi Iwai603c4012008-07-30 15:01:44 +02002901
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002902#define NID_MAPPING (-1)
2903
2904#define SUBDEV_SPEAKER_ (0 << 6)
2905#define SUBDEV_HP_ (1 << 6)
2906#define SUBDEV_LINE_ (2 << 6)
2907#define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f))
2908#define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f))
2909#define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f))
2910
Takashi Iwai603c4012008-07-30 15:01:44 +02002911static void alc_free_kctls(struct hda_codec *codec);
2912
Takashi Iwai67d634c2009-11-16 15:35:59 +01002913#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002914/* additional beep mixers; the actual parameters are overwritten at build */
2915static struct snd_kcontrol_new alc_beep_mixer[] = {
2916 HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
Jaroslav Kysela123c07a2009-10-21 14:48:23 +02002917 HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002918 { } /* end */
2919};
Takashi Iwai67d634c2009-11-16 15:35:59 +01002920#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002921
Linus Torvalds1da177e2005-04-16 15:20:36 -07002922static int alc_build_controls(struct hda_codec *codec)
2923{
2924 struct alc_spec *spec = codec->spec;
Takashi Iwai2f44f842010-06-22 11:12:32 +02002925 struct snd_kcontrol *kctl = NULL;
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002926 struct snd_kcontrol_new *knew;
2927 int i, j, err;
2928 unsigned int u;
2929 hda_nid_t nid;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002930
2931 for (i = 0; i < spec->num_mixers; i++) {
2932 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
2933 if (err < 0)
2934 return err;
2935 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01002936 if (spec->cap_mixer) {
2937 err = snd_hda_add_new_ctls(codec, spec->cap_mixer);
2938 if (err < 0)
2939 return err;
2940 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941 if (spec->multiout.dig_out_nid) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02002942 err = snd_hda_create_spdif_out_ctls(codec,
2943 spec->multiout.dig_out_nid);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002944 if (err < 0)
2945 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002946 if (!spec->no_analog) {
2947 err = snd_hda_create_spdif_share_sw(codec,
2948 &spec->multiout);
2949 if (err < 0)
2950 return err;
2951 spec->multiout.share_spdif = 1;
2952 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002953 }
2954 if (spec->dig_in_nid) {
2955 err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
2956 if (err < 0)
2957 return err;
2958 }
Takashi Iwai2134ea42008-01-10 16:53:55 +01002959
Takashi Iwai67d634c2009-11-16 15:35:59 +01002960#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002961 /* create beep controls if needed */
2962 if (spec->beep_amp) {
2963 struct snd_kcontrol_new *knew;
2964 for (knew = alc_beep_mixer; knew->name; knew++) {
2965 struct snd_kcontrol *kctl;
2966 kctl = snd_ctl_new1(knew, codec);
2967 if (!kctl)
2968 return -ENOMEM;
2969 kctl->private_value = spec->beep_amp;
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01002970 err = snd_hda_ctl_add(codec, 0, kctl);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002971 if (err < 0)
2972 return err;
2973 }
2974 }
Takashi Iwai67d634c2009-11-16 15:35:59 +01002975#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01002976
Takashi Iwai2134ea42008-01-10 16:53:55 +01002977 /* if we have no master control, let's create it */
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002978 if (!spec->no_analog &&
2979 !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002980 unsigned int vmaster_tlv[4];
Takashi Iwai2134ea42008-01-10 16:53:55 +01002981 snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002982 HDA_OUTPUT, vmaster_tlv);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002983 err = snd_hda_add_vmaster(codec, "Master Playback Volume",
Takashi Iwai1c82ed12008-02-18 13:05:50 +01002984 vmaster_tlv, alc_slave_vols);
Takashi Iwai2134ea42008-01-10 16:53:55 +01002985 if (err < 0)
2986 return err;
2987 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +01002988 if (!spec->no_analog &&
2989 !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
Takashi Iwai2134ea42008-01-10 16:53:55 +01002990 err = snd_hda_add_vmaster(codec, "Master Playback Switch",
2991 NULL, alc_slave_sws);
2992 if (err < 0)
2993 return err;
2994 }
2995
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01002996 /* assign Capture Source enums to NID */
Takashi Iwaifbe618f2010-06-11 11:24:58 +02002997 if (spec->capsrc_nids || spec->adc_nids) {
2998 kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
2999 if (!kctl)
3000 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
3001 for (i = 0; kctl && i < kctl->count; i++) {
3002 hda_nid_t *nids = spec->capsrc_nids;
3003 if (!nids)
3004 nids = spec->adc_nids;
3005 err = snd_hda_add_nid(codec, kctl, i, nids[i]);
3006 if (err < 0)
3007 return err;
3008 }
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01003009 }
3010 if (spec->cap_mixer) {
3011 const char *kname = kctl ? kctl->id.name : NULL;
3012 for (knew = spec->cap_mixer; knew->name; knew++) {
3013 if (kname && strcmp(knew->name, kname) == 0)
3014 continue;
3015 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3016 for (i = 0; kctl && i < kctl->count; i++) {
3017 err = snd_hda_add_nid(codec, kctl, i,
3018 spec->adc_nids[i]);
3019 if (err < 0)
3020 return err;
3021 }
3022 }
3023 }
3024
3025 /* other nid->control mapping */
3026 for (i = 0; i < spec->num_mixers; i++) {
3027 for (knew = spec->mixers[i]; knew->name; knew++) {
3028 if (knew->iface != NID_MAPPING)
3029 continue;
3030 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
3031 if (kctl == NULL)
3032 continue;
3033 u = knew->subdevice;
3034 for (j = 0; j < 4; j++, u >>= 8) {
3035 nid = u & 0x3f;
3036 if (nid == 0)
3037 continue;
3038 switch (u & 0xc0) {
3039 case SUBDEV_SPEAKER_:
3040 nid = spec->autocfg.speaker_pins[nid];
3041 break;
3042 case SUBDEV_LINE_:
3043 nid = spec->autocfg.line_out_pins[nid];
3044 break;
3045 case SUBDEV_HP_:
3046 nid = spec->autocfg.hp_pins[nid];
3047 break;
3048 default:
3049 continue;
3050 }
3051 err = snd_hda_add_nid(codec, kctl, 0, nid);
3052 if (err < 0)
3053 return err;
3054 }
3055 u = knew->private_value;
3056 for (j = 0; j < 4; j++, u >>= 8) {
3057 nid = u & 0xff;
3058 if (nid == 0)
3059 continue;
3060 err = snd_hda_add_nid(codec, kctl, 0, nid);
3061 if (err < 0)
3062 return err;
3063 }
3064 }
3065 }
Takashi Iwaibae84e72010-03-22 08:30:20 +01003066
3067 alc_free_kctls(codec); /* no longer needed */
3068
Linus Torvalds1da177e2005-04-16 15:20:36 -07003069 return 0;
3070}
3071
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003072
Linus Torvalds1da177e2005-04-16 15:20:36 -07003073/*
3074 * initialize the codec volumes, etc
3075 */
3076
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003077/*
3078 * generic initialization of ADC, input mixers and output mixers
3079 */
3080static struct hda_verb alc880_volume_init_verbs[] = {
3081 /*
3082 * Unmute ADC0-2 and set the default input to mic-in
3083 */
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003084 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003085 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003086 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003087 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02003088 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003089 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003091 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
3092 * mixer widget
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003093 * Note: PASD motherboards uses the Line In 2 as the input for front
3094 * panel mic (mic 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003095 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003096 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02003097 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3098 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
3099 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
3100 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
3101 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3102 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3103 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003104
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003105 /*
3106 * Set up output mixers (0x0c - 0x0f)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003107 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003108 /* set vol=0 to output mixers */
3109 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3110 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3111 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3112 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3113 /* set up input amps for analog loopback */
3114 /* Amp Indices: DAC = 0, mixer = 1 */
Takashi Iwai05acb862005-06-10 19:50:25 +02003115 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3116 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003117 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3118 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003119 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3120 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai05acb862005-06-10 19:50:25 +02003121 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3122 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003123
3124 { }
3125};
3126
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003127/*
3128 * 3-stack pin configuration:
3129 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
3130 */
3131static struct hda_verb alc880_pin_3stack_init_verbs[] = {
3132 /*
3133 * preset connection lists of input pins
3134 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3135 */
3136 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3137 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3138 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3139
3140 /*
3141 * Set pin mode and muting
3142 */
3143 /* set front pin widgets 0x14 for output */
3144 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3145 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3146 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3147 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3148 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3149 /* Mic2 (as headphone out) for HP output */
3150 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3151 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3152 /* Line In pin widget for input */
3153 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3154 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3155 /* Line2 (as front mic) pin widget for input and vref at 80% */
3156 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3157 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3158 /* CD pin widget for input */
3159 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3160
3161 { }
3162};
3163
3164/*
3165 * 5-stack pin configuration:
3166 * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
3167 * line-in/side = 0x1a, f-mic = 0x1b
3168 */
3169static struct hda_verb alc880_pin_5stack_init_verbs[] = {
3170 /*
3171 * preset connection lists of input pins
3172 * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
3173 */
3174 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3175 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
3176
3177 /*
3178 * Set pin mode and muting
3179 */
3180 /* set pin widgets 0x14-0x17 for output */
Takashi Iwai05acb862005-06-10 19:50:25 +02003181 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3182 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3183 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3184 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003185 /* unmute pins for output (no gain on this amp) */
3186 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3188 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3189 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3190
Linus Torvalds1da177e2005-04-16 15:20:36 -07003191 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02003192 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003193 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3194 /* Mic2 (as headphone out) for HP output */
3195 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003196 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003197 /* Line In pin widget for input */
3198 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3199 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3200 /* Line2 (as front mic) pin widget for input and vref at 80% */
3201 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3202 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3203 /* CD pin widget for input */
3204 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003205
3206 { }
3207};
3208
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003209/*
3210 * W810 pin configuration:
3211 * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
3212 */
3213static struct hda_verb alc880_pin_w810_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003214 /* hphone/speaker input selector: front DAC */
3215 {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
3216
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003217 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3218 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3219 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3220 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3221 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3222 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3223
3224 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai05acb862005-06-10 19:50:25 +02003225 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07003226
Linus Torvalds1da177e2005-04-16 15:20:36 -07003227 { }
3228};
3229
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003230/*
3231 * Z71V pin configuration:
3232 * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
3233 */
3234static struct hda_verb alc880_pin_z71v_init_verbs[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02003235 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003236 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai05acb862005-06-10 19:50:25 +02003237 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003238 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003239
Takashi Iwai16ded522005-06-10 19:58:24 +02003240 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003241 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003242 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003243 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaidfc0ff62005-05-12 14:31:49 +02003244
3245 { }
3246};
3247
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003248/*
3249 * 6-stack pin configuration:
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003250 * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
3251 * f-mic = 0x19, line = 0x1a, HP = 0x1b
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003252 */
3253static struct hda_verb alc880_pin_6stack_init_verbs[] = {
3254 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3255
Takashi Iwai16ded522005-06-10 19:58:24 +02003256 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003257 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003258 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003259 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003260 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003261 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003262 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003263 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3264
Takashi Iwai16ded522005-06-10 19:58:24 +02003265 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003266 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003267 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003268 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003269 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003270 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003271 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai16ded522005-06-10 19:58:24 +02003272 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai16ded522005-06-10 19:58:24 +02003273 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003274
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003275 { }
3276};
Takashi Iwai16ded522005-06-10 19:58:24 +02003277
Kailang Yangccc656c2006-10-17 12:32:26 +02003278/*
3279 * Uniwill pin configuration:
3280 * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
3281 * line = 0x1a
3282 */
3283static struct hda_verb alc880_uniwill_init_verbs[] = {
3284 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3285
3286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3287 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3288 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3289 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3290 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3291 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3292 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3293 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3294 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3295 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3296 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3297 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3298 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3299 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3300
3301 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3302 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3303 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3304 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3305 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3306 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3307 /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
3308 /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
3309 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3310
3311 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3312 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
3313
3314 { }
3315};
3316
3317/*
3318* Uniwill P53
Kailang Yangea1fb292008-08-26 12:58:38 +02003319* HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
Kailang Yangccc656c2006-10-17 12:32:26 +02003320 */
3321static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
3322 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3323
3324 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3325 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3326 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3327 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3328 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3329 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3330 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3331 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3332 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3333 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3334 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
3335 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
3336
3337 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3339 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3340 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3343
3344 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3345 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
3346
3347 { }
3348};
3349
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01003350static struct hda_verb alc880_beep_init_verbs[] = {
3351 { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
3352 { }
3353};
3354
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003355/* auto-toggle front mic */
Anisse Astiereeb43382010-12-16 12:19:47 +01003356static void alc88x_simple_mic_automute(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003357{
3358 unsigned int present;
3359 unsigned char bits;
Kailang Yangccc656c2006-10-17 12:32:26 +02003360
Wu Fengguang864f92b2009-11-18 12:38:02 +08003361 present = snd_hda_jack_detect(codec, 0x18);
Takashi Iwai47fd8302007-08-10 17:11:07 +02003362 bits = present ? HDA_AMP_MUTE : 0;
3363 snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003364}
3365
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003366static void alc880_uniwill_setup(struct hda_codec *codec)
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003367{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003368 struct alc_spec *spec = codec->spec;
3369
3370 spec->autocfg.hp_pins[0] = 0x14;
3371 spec->autocfg.speaker_pins[0] = 0x15;
3372 spec->autocfg.speaker_pins[0] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003373}
3374
3375static void alc880_uniwill_init_hook(struct hda_codec *codec)
3376{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003377 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01003378 alc88x_simple_mic_automute(codec);
Kailang Yangccc656c2006-10-17 12:32:26 +02003379}
3380
3381static void alc880_uniwill_unsol_event(struct hda_codec *codec,
3382 unsigned int res)
3383{
3384 /* Looks like the unsol event is incompatible with the standard
3385 * definition. 4bit tag is placed at 28 bit!
3386 */
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003387 switch (res >> 28) {
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003388 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01003389 alc88x_simple_mic_automute(codec);
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003390 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003391 default:
3392 alc_automute_amp_unsol_event(codec, res);
3393 break;
Takashi Iwai458a4fa2007-05-05 12:18:40 +02003394 }
Kailang Yangccc656c2006-10-17 12:32:26 +02003395}
3396
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003397static void alc880_uniwill_p53_setup(struct hda_codec *codec)
Kailang Yangccc656c2006-10-17 12:32:26 +02003398{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003399 struct alc_spec *spec = codec->spec;
Kailang Yangccc656c2006-10-17 12:32:26 +02003400
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003401 spec->autocfg.hp_pins[0] = 0x14;
3402 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yangccc656c2006-10-17 12:32:26 +02003403}
3404
3405static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
3406{
3407 unsigned int present;
Kailang Yangea1fb292008-08-26 12:58:38 +02003408
Kailang Yangccc656c2006-10-17 12:32:26 +02003409 present = snd_hda_codec_read(codec, 0x21, 0,
Takashi Iwai47fd8302007-08-10 17:11:07 +02003410 AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
3411 present &= HDA_AMP_VOLMASK;
3412 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
3413 HDA_AMP_VOLMASK, present);
3414 snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
3415 HDA_AMP_VOLMASK, present);
Kailang Yangccc656c2006-10-17 12:32:26 +02003416}
Takashi Iwai47fd8302007-08-10 17:11:07 +02003417
Kailang Yangccc656c2006-10-17 12:32:26 +02003418static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
3419 unsigned int res)
3420{
3421 /* Looks like the unsol event is incompatible with the standard
3422 * definition. 4bit tag is placed at 28 bit!
3423 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02003424 if ((res >> 28) == ALC880_DCVOL_EVENT)
Kailang Yangccc656c2006-10-17 12:32:26 +02003425 alc880_uniwill_p53_dcvol_automute(codec);
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003426 else
3427 alc_automute_amp_unsol_event(codec, res);
Kailang Yangccc656c2006-10-17 12:32:26 +02003428}
3429
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003430/*
3431 * F1734 pin configuration:
3432 * HP = 0x14, speaker-out = 0x15, mic = 0x18
3433 */
3434static struct hda_verb alc880_pin_f1734_init_verbs[] = {
Michael Gruberee7a9c72008-03-10 11:30:59 +01003435 {0x07, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003436 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3437 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3438 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3439 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3440
3441 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3442 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3443 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3444 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3445
3446 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3447 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Michael Gruberee7a9c72008-03-10 11:30:59 +01003448 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003449 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3450 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3451 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3452 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3453 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3454 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai16ded522005-06-10 19:58:24 +02003455
Takashi Iwai937b4162008-02-11 14:52:36 +01003456 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
3457 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_DCVOL_EVENT},
3458
Takashi Iwai16ded522005-06-10 19:58:24 +02003459 { }
3460};
3461
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003462/*
3463 * ASUS pin configuration:
3464 * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
3465 */
3466static struct hda_verb alc880_pin_asus_init_verbs[] = {
3467 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
3468 {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
3469 {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
3470 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
3471
3472 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3473 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3474 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3475 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3476 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3477 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3478 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3479 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3480
3481 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3482 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3483 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3484 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3485 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3486 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3487 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3488 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3489 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangea1fb292008-08-26 12:58:38 +02003490
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003491 { }
3492};
3493
3494/* Enable GPIO mask and set output */
Kailang Yangbc9f98a2007-04-12 13:06:07 +02003495#define alc880_gpio1_init_verbs alc_gpio1_init_verbs
3496#define alc880_gpio2_init_verbs alc_gpio2_init_verbs
David Heidelberger64a8be72009-06-08 16:15:18 +02003497#define alc880_gpio3_init_verbs alc_gpio3_init_verbs
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003498
Kailang Yangdf694da2005-12-05 19:42:22 +01003499/* Clevo m520g init */
3500static struct hda_verb alc880_pin_clevo_init_verbs[] = {
3501 /* headphone output */
3502 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3503 /* line-out */
3504 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3505 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3506 /* Line-in */
3507 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3508 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3509 /* CD */
3510 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3511 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3512 /* Mic1 (rear panel) */
3513 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3514 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3515 /* Mic2 (front panel) */
3516 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3517 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3518 /* headphone */
3519 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3520 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3521 /* change to EAPD mode */
3522 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3523 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3524
3525 { }
3526};
3527
3528static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
Takashi Iwai4b146cb2006-07-28 14:42:36 +02003529 /* change to EAPD mode */
3530 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3531 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3532
Kailang Yangdf694da2005-12-05 19:42:22 +01003533 /* Headphone output */
3534 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3535 /* Front output*/
3536 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3537 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
3538
3539 /* Line In pin widget for input */
3540 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3541 /* CD pin widget for input */
3542 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3543 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3544 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3545
3546 /* change to EAPD mode */
3547 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3548 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
3549
3550 { }
3551};
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003552
3553/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003554 * LG m1 express dual
3555 *
3556 * Pin assignment:
3557 * Rear Line-In/Out (blue): 0x14
3558 * Build-in Mic-In: 0x15
3559 * Speaker-out: 0x17
3560 * HP-Out (green): 0x1b
3561 * Mic-In/Out (red): 0x19
3562 * SPDIF-Out: 0x1e
3563 */
3564
3565/* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
3566static hda_nid_t alc880_lg_dac_nids[3] = {
3567 0x05, 0x02, 0x03
3568};
3569
3570/* seems analog CD is not working */
3571static struct hda_input_mux alc880_lg_capture_source = {
3572 .num_items = 3,
3573 .items = {
3574 { "Mic", 0x1 },
3575 { "Line", 0x5 },
3576 { "Internal Mic", 0x6 },
3577 },
3578};
3579
3580/* 2,4,6 channel modes */
3581static struct hda_verb alc880_lg_ch2_init[] = {
3582 /* set line-in and mic-in to input */
3583 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
3584 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3585 { }
3586};
3587
3588static struct hda_verb alc880_lg_ch4_init[] = {
3589 /* set line-in to out and mic-in to input */
3590 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3591 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
3592 { }
3593};
3594
3595static struct hda_verb alc880_lg_ch6_init[] = {
3596 /* set line-in and mic-in to output */
3597 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3598 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
3599 { }
3600};
3601
3602static struct hda_channel_mode alc880_lg_ch_modes[3] = {
3603 { 2, alc880_lg_ch2_init },
3604 { 4, alc880_lg_ch4_init },
3605 { 6, alc880_lg_ch6_init },
3606};
3607
3608static struct snd_kcontrol_new alc880_lg_mixer[] = {
Takashi Iwai2134ea42008-01-10 16:53:55 +01003609 HDA_CODEC_VOLUME("Front Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3610 HDA_BIND_MUTE("Front Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003611 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3612 HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
3613 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
3614 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
3615 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
3616 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
3617 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3618 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
3619 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
3620 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
3621 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
3622 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
3623 {
3624 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3625 .name = "Channel Mode",
3626 .info = alc_ch_mode_info,
3627 .get = alc_ch_mode_get,
3628 .put = alc_ch_mode_put,
3629 },
3630 { } /* end */
3631};
3632
3633static struct hda_verb alc880_lg_init_verbs[] = {
3634 /* set capture source to mic-in */
3635 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3637 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3638 /* mute all amp mixer inputs */
3639 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003640 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
3641 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003642 /* line-in to input */
3643 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
3644 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3645 /* built-in mic */
3646 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3647 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3648 /* speaker-out */
3649 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3650 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3651 /* mic-in to input */
3652 {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
3653 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3654 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3655 /* HP-out */
3656 {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
3657 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3658 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3659 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003660 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003661 { }
3662};
3663
3664/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003665static void alc880_lg_setup(struct hda_codec *codec)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003666{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003667 struct alc_spec *spec = codec->spec;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003668
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003669 spec->autocfg.hp_pins[0] = 0x1b;
3670 spec->autocfg.speaker_pins[0] = 0x17;
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003671}
3672
3673/*
Takashi Iwaid6815182006-03-23 16:06:23 +01003674 * LG LW20
3675 *
3676 * Pin assignment:
3677 * Speaker-out: 0x14
3678 * Mic-In: 0x18
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003679 * Built-in Mic-In: 0x19
3680 * Line-In: 0x1b
3681 * HP-Out: 0x1a
Takashi Iwaid6815182006-03-23 16:06:23 +01003682 * SPDIF-Out: 0x1e
3683 */
3684
Takashi Iwaid6815182006-03-23 16:06:23 +01003685static struct hda_input_mux alc880_lg_lw_capture_source = {
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003686 .num_items = 3,
Takashi Iwaid6815182006-03-23 16:06:23 +01003687 .items = {
3688 { "Mic", 0x0 },
3689 { "Internal Mic", 0x1 },
Claudio Matsuokae4f41da2007-07-13 11:51:06 +02003690 { "Line In", 0x2 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003691 },
3692};
3693
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003694#define alc880_lg_lw_modes alc880_threestack_modes
3695
Takashi Iwaid6815182006-03-23 16:06:23 +01003696static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003697 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3698 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
3699 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
3700 HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
3701 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
3702 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
3703 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
3704 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
3705 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
3706 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwaid6815182006-03-23 16:06:23 +01003707 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3708 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3709 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
3710 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003711 {
3712 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
3713 .name = "Channel Mode",
3714 .info = alc_ch_mode_info,
3715 .get = alc_ch_mode_get,
3716 .put = alc_ch_mode_put,
3717 },
Takashi Iwaid6815182006-03-23 16:06:23 +01003718 { } /* end */
3719};
3720
3721static struct hda_verb alc880_lg_lw_init_verbs[] = {
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02003722 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3723 {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
3724 {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
3725
Takashi Iwaid6815182006-03-23 16:06:23 +01003726 /* set capture source to mic-in */
3727 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3728 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
3729 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwaicb53c622007-08-10 17:21:45 +02003730 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Takashi Iwaid6815182006-03-23 16:06:23 +01003731 /* speaker-out */
3732 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3733 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3734 /* HP-out */
Takashi Iwaid6815182006-03-23 16:06:23 +01003735 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3736 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3737 /* mic-in to input */
3738 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3739 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3740 /* built-in mic */
3741 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3742 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3743 /* jack sense */
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003744 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaid6815182006-03-23 16:06:23 +01003745 { }
3746};
3747
3748/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003749static void alc880_lg_lw_setup(struct hda_codec *codec)
Takashi Iwaid6815182006-03-23 16:06:23 +01003750{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003751 struct alc_spec *spec = codec->spec;
Takashi Iwaid6815182006-03-23 16:06:23 +01003752
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003753 spec->autocfg.hp_pins[0] = 0x1b;
3754 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwaid6815182006-03-23 16:06:23 +01003755}
3756
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003757static struct snd_kcontrol_new alc880_medion_rim_mixer[] = {
3758 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
3759 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
3760 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
3761 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
3762 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
3763 HDA_CODEC_MUTE("Internal Playback Switch", 0x0b, 0x1, HDA_INPUT),
3764 { } /* end */
3765};
3766
3767static struct hda_input_mux alc880_medion_rim_capture_source = {
3768 .num_items = 2,
3769 .items = {
3770 { "Mic", 0x0 },
3771 { "Internal Mic", 0x1 },
3772 },
3773};
3774
3775static struct hda_verb alc880_medion_rim_init_verbs[] = {
3776 {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
3777
3778 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3779 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3780
3781 /* Mic1 (rear panel) pin widget for input and vref at 80% */
3782 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3783 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3784 /* Mic2 (as headphone out) for HP output */
3785 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
3786 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3787 /* Internal Speaker */
3788 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3789 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
3790
3791 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
3792 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
3793
3794 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
3795 { }
3796};
3797
3798/* toggle speaker-output according to the hp-jack state */
3799static void alc880_medion_rim_automute(struct hda_codec *codec)
3800{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003801 struct alc_spec *spec = codec->spec;
3802 alc_automute_amp(codec);
3803 /* toggle EAPD */
3804 if (spec->jack_present)
Takashi Iwaidf99cd32008-04-25 15:25:04 +02003805 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
3806 else
3807 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2);
3808}
3809
3810static void alc880_medion_rim_unsol_event(struct hda_codec *codec,
3811 unsigned int res)
3812{
3813 /* Looks like the unsol event is incompatible with the standard
3814 * definition. 4bit tag is placed at 28 bit!
3815 */
3816 if ((res >> 28) == ALC880_HP_EVENT)
3817 alc880_medion_rim_automute(codec);
3818}
3819
Takashi Iwai4f5d17062009-08-11 18:17:46 +02003820static void alc880_medion_rim_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003821{
3822 struct alc_spec *spec = codec->spec;
3823
3824 spec->autocfg.hp_pins[0] = 0x14;
3825 spec->autocfg.speaker_pins[0] = 0x1b;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02003826}
3827
Takashi Iwaicb53c622007-08-10 17:21:45 +02003828#ifdef CONFIG_SND_HDA_POWER_SAVE
3829static struct hda_amp_list alc880_loopbacks[] = {
3830 { 0x0b, HDA_INPUT, 0 },
3831 { 0x0b, HDA_INPUT, 1 },
3832 { 0x0b, HDA_INPUT, 2 },
3833 { 0x0b, HDA_INPUT, 3 },
3834 { 0x0b, HDA_INPUT, 4 },
3835 { } /* end */
3836};
3837
3838static struct hda_amp_list alc880_lg_loopbacks[] = {
3839 { 0x0b, HDA_INPUT, 1 },
3840 { 0x0b, HDA_INPUT, 6 },
3841 { 0x0b, HDA_INPUT, 7 },
3842 { } /* end */
3843};
3844#endif
3845
Takashi Iwaid6815182006-03-23 16:06:23 +01003846/*
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003847 * Common callbacks
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003848 */
Takashi Iwai16ded522005-06-10 19:58:24 +02003849
Linus Torvalds1da177e2005-04-16 15:20:36 -07003850static int alc_init(struct hda_codec *codec)
3851{
3852 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003853 unsigned int i;
3854
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003855 alc_fix_pll(codec);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02003856 alc_auto_init_amp(codec, spec->init_amp);
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +02003857
Takashi Iwaie9edcee2005-06-13 14:16:38 +02003858 for (i = 0; i < spec->num_init_verbs; i++)
3859 snd_hda_sequence_write(codec, spec->init_verbs[i]);
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003860
3861 if (spec->init_hook)
3862 spec->init_hook(codec);
3863
Takashi Iwai58701122011-01-13 15:41:45 +01003864 alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT);
3865
Takashi Iwai9e5341b2010-09-21 09:57:06 +02003866 hda_call_check_power_status(codec, 0x01);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003867 return 0;
3868}
3869
Takashi Iwaiae6b8132006-03-03 16:47:17 +01003870static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
3871{
3872 struct alc_spec *spec = codec->spec;
3873
3874 if (spec->unsol_event)
3875 spec->unsol_event(codec, res);
3876}
3877
Takashi Iwaicb53c622007-08-10 17:21:45 +02003878#ifdef CONFIG_SND_HDA_POWER_SAVE
3879static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
3880{
3881 struct alc_spec *spec = codec->spec;
3882 return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
3883}
3884#endif
3885
Linus Torvalds1da177e2005-04-16 15:20:36 -07003886/*
3887 * Analog playback callbacks
3888 */
3889static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
3890 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003891 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003892{
3893 struct alc_spec *spec = codec->spec;
Takashi Iwai9a081602008-02-12 18:37:26 +01003894 return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
3895 hinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003896}
3897
3898static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3899 struct hda_codec *codec,
3900 unsigned int stream_tag,
3901 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003902 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003903{
3904 struct alc_spec *spec = codec->spec;
Takashi Iwai9c7f8522006-06-28 15:08:22 +02003905 return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
3906 stream_tag, format, substream);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003907}
3908
3909static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3910 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003911 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003912{
3913 struct alc_spec *spec = codec->spec;
3914 return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
3915}
3916
3917/*
3918 * Digital out
3919 */
3920static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
3921 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003922 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003923{
3924 struct alc_spec *spec = codec->spec;
3925 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
3926}
3927
Takashi Iwai6b97eb42007-04-05 14:51:48 +02003928static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
3929 struct hda_codec *codec,
3930 unsigned int stream_tag,
3931 unsigned int format,
3932 struct snd_pcm_substream *substream)
3933{
3934 struct alc_spec *spec = codec->spec;
3935 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
3936 stream_tag, format, substream);
3937}
3938
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01003939static int alc880_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
3940 struct hda_codec *codec,
3941 struct snd_pcm_substream *substream)
3942{
3943 struct alc_spec *spec = codec->spec;
3944 return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
3945}
3946
Linus Torvalds1da177e2005-04-16 15:20:36 -07003947static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
3948 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003949 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003950{
3951 struct alc_spec *spec = codec->spec;
3952 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
3953}
3954
3955/*
3956 * Analog capture
3957 */
Takashi Iwai63300792008-01-24 15:31:36 +01003958static int alc880_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003959 struct hda_codec *codec,
3960 unsigned int stream_tag,
3961 unsigned int format,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003962 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003963{
3964 struct alc_spec *spec = codec->spec;
3965
Takashi Iwai63300792008-01-24 15:31:36 +01003966 snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1],
Linus Torvalds1da177e2005-04-16 15:20:36 -07003967 stream_tag, 0, format);
3968 return 0;
3969}
3970
Takashi Iwai63300792008-01-24 15:31:36 +01003971static int alc880_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003972 struct hda_codec *codec,
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01003973 struct snd_pcm_substream *substream)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003974{
3975 struct alc_spec *spec = codec->spec;
3976
Takashi Iwai888afa12008-03-18 09:57:50 +01003977 snd_hda_codec_cleanup_stream(codec,
3978 spec->adc_nids[substream->number + 1]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003979 return 0;
3980}
3981
Takashi Iwai840b64c2010-07-13 22:49:01 +02003982/* analog capture with dynamic dual-adc changes */
3983static int dualmic_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
3984 struct hda_codec *codec,
3985 unsigned int stream_tag,
3986 unsigned int format,
3987 struct snd_pcm_substream *substream)
3988{
3989 struct alc_spec *spec = codec->spec;
3990 spec->cur_adc = spec->adc_nids[spec->cur_adc_idx];
3991 spec->cur_adc_stream_tag = stream_tag;
3992 spec->cur_adc_format = format;
3993 snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
3994 return 0;
3995}
3996
3997static int dualmic_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
3998 struct hda_codec *codec,
3999 struct snd_pcm_substream *substream)
4000{
4001 struct alc_spec *spec = codec->spec;
4002 snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
4003 spec->cur_adc = 0;
4004 return 0;
4005}
4006
4007static struct hda_pcm_stream dualmic_pcm_analog_capture = {
4008 .substreams = 1,
4009 .channels_min = 2,
4010 .channels_max = 2,
4011 .nid = 0, /* fill later */
4012 .ops = {
4013 .prepare = dualmic_capture_pcm_prepare,
4014 .cleanup = dualmic_capture_pcm_cleanup
4015 },
4016};
Linus Torvalds1da177e2005-04-16 15:20:36 -07004017
4018/*
4019 */
4020static struct hda_pcm_stream alc880_pcm_analog_playback = {
4021 .substreams = 1,
4022 .channels_min = 2,
4023 .channels_max = 8,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004024 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004025 .ops = {
4026 .open = alc880_playback_pcm_open,
4027 .prepare = alc880_playback_pcm_prepare,
4028 .cleanup = alc880_playback_pcm_cleanup
4029 },
4030};
4031
4032static struct hda_pcm_stream alc880_pcm_analog_capture = {
Takashi Iwai63300792008-01-24 15:31:36 +01004033 .substreams = 1,
4034 .channels_min = 2,
4035 .channels_max = 2,
4036 /* NID is set in alc_build_pcms */
4037};
4038
4039static struct hda_pcm_stream alc880_pcm_analog_alt_playback = {
4040 .substreams = 1,
4041 .channels_min = 2,
4042 .channels_max = 2,
4043 /* NID is set in alc_build_pcms */
4044};
4045
4046static struct hda_pcm_stream alc880_pcm_analog_alt_capture = {
4047 .substreams = 2, /* can be overridden */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004048 .channels_min = 2,
4049 .channels_max = 2,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004050 /* NID is set in alc_build_pcms */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004051 .ops = {
Takashi Iwai63300792008-01-24 15:31:36 +01004052 .prepare = alc880_alt_capture_pcm_prepare,
4053 .cleanup = alc880_alt_capture_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004054 },
4055};
4056
4057static struct hda_pcm_stream alc880_pcm_digital_playback = {
4058 .substreams = 1,
4059 .channels_min = 2,
4060 .channels_max = 2,
4061 /* NID is set in alc_build_pcms */
4062 .ops = {
4063 .open = alc880_dig_playback_pcm_open,
Takashi Iwai6b97eb42007-04-05 14:51:48 +02004064 .close = alc880_dig_playback_pcm_close,
Takashi Iwai9b5f12e2009-02-13 11:47:37 +01004065 .prepare = alc880_dig_playback_pcm_prepare,
4066 .cleanup = alc880_dig_playback_pcm_cleanup
Linus Torvalds1da177e2005-04-16 15:20:36 -07004067 },
4068};
4069
4070static struct hda_pcm_stream alc880_pcm_digital_capture = {
4071 .substreams = 1,
4072 .channels_min = 2,
4073 .channels_max = 2,
4074 /* NID is set in alc_build_pcms */
4075};
4076
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004077/* Used by alc_build_pcms to flag that a PCM has no playback stream */
Takashi Iwai63300792008-01-24 15:31:36 +01004078static struct hda_pcm_stream alc_pcm_null_stream = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01004079 .substreams = 0,
4080 .channels_min = 0,
4081 .channels_max = 0,
4082};
4083
Linus Torvalds1da177e2005-04-16 15:20:36 -07004084static int alc_build_pcms(struct hda_codec *codec)
4085{
4086 struct alc_spec *spec = codec->spec;
4087 struct hda_pcm *info = spec->pcm_rec;
4088 int i;
4089
4090 codec->num_pcms = 1;
4091 codec->pcm_info = info;
4092
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004093 if (spec->no_analog)
4094 goto skip_analog;
4095
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004096 snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog),
4097 "%s Analog", codec->chip_name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004098 info->name = spec->stream_name_analog;
Kailang Yang274693f2009-12-03 10:07:50 +01004099
Takashi Iwai4a471b72005-12-07 13:56:29 +01004100 if (spec->stream_analog_playback) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004101 if (snd_BUG_ON(!spec->multiout.dac_nids))
4102 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004103 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
4104 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
4105 }
4106 if (spec->stream_analog_capture) {
Takashi Iwaida3cec32008-08-08 17:12:14 +02004107 if (snd_BUG_ON(!spec->adc_nids))
4108 return -EINVAL;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004109 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
4110 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
4111 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004112
Takashi Iwai4a471b72005-12-07 13:56:29 +01004113 if (spec->channel_mode) {
4114 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
4115 for (i = 0; i < spec->num_channel_mode; i++) {
4116 if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
4117 info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
4118 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07004119 }
4120 }
4121
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004122 skip_analog:
Takashi Iwaie08a0072006-09-07 17:52:14 +02004123 /* SPDIF for stream index #1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004124 if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
Takashi Iwai812a2cc2009-05-16 10:00:49 +02004125 snprintf(spec->stream_name_digital,
4126 sizeof(spec->stream_name_digital),
4127 "%s Digital", codec->chip_name);
Takashi Iwaie08a0072006-09-07 17:52:14 +02004128 codec->num_pcms = 2;
Wu Fengguangb25c9da2009-02-06 15:02:27 +08004129 codec->slave_dig_outs = spec->multiout.slave_dig_outs;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004130 info = spec->pcm_rec + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004131 info->name = spec->stream_name_digital;
Takashi Iwai8c441982009-01-20 18:30:20 +01004132 if (spec->dig_out_type)
4133 info->pcm_type = spec->dig_out_type;
4134 else
4135 info->pcm_type = HDA_PCM_TYPE_SPDIF;
Takashi Iwai4a471b72005-12-07 13:56:29 +01004136 if (spec->multiout.dig_out_nid &&
4137 spec->stream_digital_playback) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004138 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
4139 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
4140 }
Takashi Iwai4a471b72005-12-07 13:56:29 +01004141 if (spec->dig_in_nid &&
4142 spec->stream_digital_capture) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07004143 info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
4144 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
4145 }
Takashi Iwai963f8032008-08-11 10:04:40 +02004146 /* FIXME: do we need this for all Realtek codec models? */
4147 codec->spdif_status_reset = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07004148 }
4149
Takashi Iwaie64f14f2009-01-20 18:32:55 +01004150 if (spec->no_analog)
4151 return 0;
4152
Takashi Iwaie08a0072006-09-07 17:52:14 +02004153 /* If the use of more than one ADC is requested for the current
4154 * model, configure a second analog capture-only PCM.
4155 */
4156 /* Additional Analaog capture for index #2 */
Takashi Iwai63300792008-01-24 15:31:36 +01004157 if ((spec->alt_dac_nid && spec->stream_analog_alt_playback) ||
4158 (spec->num_adc_nids > 1 && spec->stream_analog_alt_capture)) {
Takashi Iwaie08a0072006-09-07 17:52:14 +02004159 codec->num_pcms = 3;
Takashi Iwaic06134d2006-10-11 18:49:13 +02004160 info = spec->pcm_rec + 2;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004161 info->name = spec->stream_name_analog;
Takashi Iwai63300792008-01-24 15:31:36 +01004162 if (spec->alt_dac_nid) {
4163 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4164 *spec->stream_analog_alt_playback;
4165 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
4166 spec->alt_dac_nid;
4167 } else {
4168 info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
4169 alc_pcm_null_stream;
4170 info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
4171 }
4172 if (spec->num_adc_nids > 1) {
4173 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4174 *spec->stream_analog_alt_capture;
4175 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
4176 spec->adc_nids[1];
4177 info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams =
4178 spec->num_adc_nids - 1;
4179 } else {
4180 info->stream[SNDRV_PCM_STREAM_CAPTURE] =
4181 alc_pcm_null_stream;
4182 info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0;
Takashi Iwaie08a0072006-09-07 17:52:14 +02004183 }
4184 }
4185
Linus Torvalds1da177e2005-04-16 15:20:36 -07004186 return 0;
4187}
4188
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004189static inline void alc_shutup(struct hda_codec *codec)
4190{
4191 snd_hda_shutup_pins(codec);
4192}
4193
Takashi Iwai603c4012008-07-30 15:01:44 +02004194static void alc_free_kctls(struct hda_codec *codec)
4195{
4196 struct alc_spec *spec = codec->spec;
4197
4198 if (spec->kctls.list) {
4199 struct snd_kcontrol_new *kctl = spec->kctls.list;
4200 int i;
4201 for (i = 0; i < spec->kctls.used; i++)
4202 kfree(kctl[i].name);
4203 }
4204 snd_array_free(&spec->kctls);
4205}
4206
Linus Torvalds1da177e2005-04-16 15:20:36 -07004207static void alc_free(struct hda_codec *codec)
4208{
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004209 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004210
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004211 if (!spec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004212 return;
4213
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004214 alc_shutup(codec);
Takashi Iwaicd372fb2011-03-03 14:40:14 +01004215 snd_hda_input_jack_free(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +02004216 alc_free_kctls(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004217 kfree(spec);
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09004218 snd_hda_detach_beep_device(codec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004219}
4220
Hector Martinf5de24b2009-12-20 22:51:31 +01004221#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -05004222static void alc_power_eapd(struct hda_codec *codec)
4223{
4224 /* We currently only handle front, HP */
4225 switch (codec->vendor_id) {
4226 case 0x10ec0260:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004227 set_eapd(codec, 0x0f, 0);
4228 set_eapd(codec, 0x10, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004229 break;
4230 case 0x10ec0262:
4231 case 0x10ec0267:
4232 case 0x10ec0268:
4233 case 0x10ec0269:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004234 case 0x10ec0270:
Daniel T Chenc97259d2009-12-27 18:52:08 -05004235 case 0x10ec0272:
4236 case 0x10ec0660:
4237 case 0x10ec0662:
4238 case 0x10ec0663:
4239 case 0x10ec0862:
4240 case 0x10ec0889:
Takashi Iwai9e4c8492010-01-19 15:53:43 +01004241 set_eapd(codec, 0x14, 0);
4242 set_eapd(codec, 0x15, 0);
Daniel T Chenc97259d2009-12-27 18:52:08 -05004243 break;
4244 }
4245}
4246
Hector Martinf5de24b2009-12-20 22:51:31 +01004247static int alc_suspend(struct hda_codec *codec, pm_message_t state)
4248{
4249 struct alc_spec *spec = codec->spec;
Takashi Iwaia4e09aa2009-12-27 11:22:24 +01004250 alc_shutup(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004251 if (spec && spec->power_hook)
Daniel T Chenc97259d2009-12-27 18:52:08 -05004252 spec->power_hook(codec);
Hector Martinf5de24b2009-12-20 22:51:31 +01004253 return 0;
4254}
4255#endif
4256
Takashi Iwaie044c392008-10-27 16:56:24 +01004257#ifdef SND_HDA_NEEDS_RESUME
Takashi Iwaie044c392008-10-27 16:56:24 +01004258static int alc_resume(struct hda_codec *codec)
4259{
Takashi Iwaie044c392008-10-27 16:56:24 +01004260 codec->patch_ops.init(codec);
4261 snd_hda_codec_resume_amp(codec);
4262 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +02004263 hda_call_check_power_status(codec, 0x01);
Takashi Iwaie044c392008-10-27 16:56:24 +01004264 return 0;
4265}
Takashi Iwaie044c392008-10-27 16:56:24 +01004266#endif
4267
Linus Torvalds1da177e2005-04-16 15:20:36 -07004268/*
4269 */
4270static struct hda_codec_ops alc_patch_ops = {
4271 .build_controls = alc_build_controls,
4272 .build_pcms = alc_build_pcms,
4273 .init = alc_init,
4274 .free = alc_free,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004275 .unsol_event = alc_unsol_event,
Takashi Iwaie044c392008-10-27 16:56:24 +01004276#ifdef SND_HDA_NEEDS_RESUME
4277 .resume = alc_resume,
4278#endif
Takashi Iwaicb53c622007-08-10 17:21:45 +02004279#ifdef CONFIG_SND_HDA_POWER_SAVE
Hector Martinf5de24b2009-12-20 22:51:31 +01004280 .suspend = alc_suspend,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004281 .check_power_status = alc_check_power_status,
4282#endif
Daniel T Chenc97259d2009-12-27 18:52:08 -05004283 .reboot_notify = alc_shutup,
Linus Torvalds1da177e2005-04-16 15:20:36 -07004284};
4285
Kailang Yangc027ddc2010-03-19 11:33:06 +01004286/* replace the codec chip_name with the given string */
4287static int alc_codec_rename(struct hda_codec *codec, const char *name)
4288{
4289 kfree(codec->chip_name);
4290 codec->chip_name = kstrdup(name, GFP_KERNEL);
4291 if (!codec->chip_name) {
4292 alc_free(codec);
4293 return -ENOMEM;
4294 }
4295 return 0;
4296}
4297
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004298/*
4299 * Test configuration for debugging
4300 *
4301 * Almost all inputs/outputs are enabled. I/O pins can be configured via
4302 * enum controls.
4303 */
4304#ifdef CONFIG_SND_DEBUG
4305static hda_nid_t alc880_test_dac_nids[4] = {
4306 0x02, 0x03, 0x04, 0x05
4307};
4308
4309static struct hda_input_mux alc880_test_capture_source = {
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004310 .num_items = 7,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004311 .items = {
4312 { "In-1", 0x0 },
4313 { "In-2", 0x1 },
4314 { "In-3", 0x2 },
4315 { "In-4", 0x3 },
4316 { "CD", 0x4 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004317 { "Front", 0x5 },
4318 { "Surround", 0x6 },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004319 },
4320};
4321
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01004322static struct hda_channel_mode alc880_test_modes[4] = {
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004323 { 2, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004324 { 4, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004325 { 6, NULL },
Takashi Iwaifd2c3262005-05-13 17:18:42 +02004326 { 8, NULL },
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004327};
4328
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004329static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
4330 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004331{
4332 static char *texts[] = {
4333 "N/A", "Line Out", "HP Out",
4334 "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
4335 };
4336 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4337 uinfo->count = 1;
4338 uinfo->value.enumerated.items = 8;
4339 if (uinfo->value.enumerated.item >= 8)
4340 uinfo->value.enumerated.item = 7;
4341 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4342 return 0;
4343}
4344
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004345static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
4346 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004347{
4348 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4349 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4350 unsigned int pin_ctl, item = 0;
4351
4352 pin_ctl = snd_hda_codec_read(codec, nid, 0,
4353 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4354 if (pin_ctl & AC_PINCTL_OUT_EN) {
4355 if (pin_ctl & AC_PINCTL_HP_EN)
4356 item = 2;
4357 else
4358 item = 1;
4359 } else if (pin_ctl & AC_PINCTL_IN_EN) {
4360 switch (pin_ctl & AC_PINCTL_VREFEN) {
4361 case AC_PINCTL_VREF_HIZ: item = 3; break;
4362 case AC_PINCTL_VREF_50: item = 4; break;
4363 case AC_PINCTL_VREF_GRD: item = 5; break;
4364 case AC_PINCTL_VREF_80: item = 6; break;
4365 case AC_PINCTL_VREF_100: item = 7; break;
4366 }
4367 }
4368 ucontrol->value.enumerated.item[0] = item;
4369 return 0;
4370}
4371
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004372static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
4373 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004374{
4375 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4376 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4377 static unsigned int ctls[] = {
4378 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
4379 AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
4380 AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
4381 AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
4382 AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
4383 AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
4384 };
4385 unsigned int old_ctl, new_ctl;
4386
4387 old_ctl = snd_hda_codec_read(codec, nid, 0,
4388 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
4389 new_ctl = ctls[ucontrol->value.enumerated.item[0]];
4390 if (old_ctl != new_ctl) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004391 int val;
4392 snd_hda_codec_write_cache(codec, nid, 0,
4393 AC_VERB_SET_PIN_WIDGET_CONTROL,
4394 new_ctl);
Takashi Iwai47fd8302007-08-10 17:11:07 +02004395 val = ucontrol->value.enumerated.item[0] >= 3 ?
4396 HDA_AMP_MUTE : 0;
4397 snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
4398 HDA_AMP_MUTE, val);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004399 return 1;
4400 }
4401 return 0;
4402}
4403
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004404static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
4405 struct snd_ctl_elem_info *uinfo)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004406{
4407 static char *texts[] = {
4408 "Front", "Surround", "CLFE", "Side"
4409 };
4410 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
4411 uinfo->count = 1;
4412 uinfo->value.enumerated.items = 4;
4413 if (uinfo->value.enumerated.item >= 4)
4414 uinfo->value.enumerated.item = 3;
4415 strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
4416 return 0;
4417}
4418
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004419static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
4420 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004421{
4422 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4423 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4424 unsigned int sel;
4425
4426 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
4427 ucontrol->value.enumerated.item[0] = sel & 3;
4428 return 0;
4429}
4430
Takashi Iwai9c7f8522006-06-28 15:08:22 +02004431static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
4432 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004433{
4434 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
4435 hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
4436 unsigned int sel;
4437
4438 sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
4439 if (ucontrol->value.enumerated.item[0] != sel) {
4440 sel = ucontrol->value.enumerated.item[0] & 3;
Takashi Iwai82beb8f2007-08-10 17:09:26 +02004441 snd_hda_codec_write_cache(codec, nid, 0,
4442 AC_VERB_SET_CONNECT_SEL, sel);
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004443 return 1;
4444 }
4445 return 0;
4446}
4447
4448#define PIN_CTL_TEST(xname,nid) { \
4449 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4450 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004451 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004452 .info = alc_test_pin_ctl_info, \
4453 .get = alc_test_pin_ctl_get, \
4454 .put = alc_test_pin_ctl_put, \
4455 .private_value = nid \
4456 }
4457
4458#define PIN_SRC_TEST(xname,nid) { \
4459 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
4460 .name = xname, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01004461 .subdevice = HDA_SUBDEV_NID_FLAG | nid, \
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004462 .info = alc_test_pin_src_info, \
4463 .get = alc_test_pin_src_get, \
4464 .put = alc_test_pin_src_put, \
4465 .private_value = nid \
4466 }
4467
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004468static struct snd_kcontrol_new alc880_test_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02004469 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
4470 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
4471 HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
4472 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01004473 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
4474 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
4475 HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
4476 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004477 PIN_CTL_TEST("Front Pin Mode", 0x14),
4478 PIN_CTL_TEST("Surround Pin Mode", 0x15),
4479 PIN_CTL_TEST("CLFE Pin Mode", 0x16),
4480 PIN_CTL_TEST("Side Pin Mode", 0x17),
4481 PIN_CTL_TEST("In-1 Pin Mode", 0x18),
4482 PIN_CTL_TEST("In-2 Pin Mode", 0x19),
4483 PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
4484 PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
4485 PIN_SRC_TEST("In-1 Pin Source", 0x18),
4486 PIN_SRC_TEST("In-2 Pin Source", 0x19),
4487 PIN_SRC_TEST("In-3 Pin Source", 0x1a),
4488 PIN_SRC_TEST("In-4 Pin Source", 0x1b),
4489 HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
4490 HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
4491 HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
4492 HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
4493 HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
4494 HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
4495 HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
4496 HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
4497 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
4498 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004499 {
4500 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
4501 .name = "Channel Mode",
Kailang Yangdf694da2005-12-05 19:42:22 +01004502 .info = alc_ch_mode_info,
4503 .get = alc_ch_mode_get,
4504 .put = alc_ch_mode_put,
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004505 },
4506 { } /* end */
4507};
4508
4509static struct hda_verb alc880_test_init_verbs[] = {
4510 /* Unmute inputs of 0x0c - 0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004511 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4512 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4513 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4514 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4515 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4516 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
4517 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
4518 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004519 /* Vol output for 0x0c-0x0f */
Takashi Iwai05acb862005-06-10 19:50:25 +02004520 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4521 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4522 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
4523 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004524 /* Set output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004525 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4526 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4527 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
4528 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004529 /* Unmute output pins 0x14-0x17 */
Takashi Iwai05acb862005-06-10 19:50:25 +02004530 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4531 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4532 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
4533 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004534 /* Set input pins 0x18-0x1c */
Takashi Iwai16ded522005-06-10 19:58:24 +02004535 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
4536 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwai05acb862005-06-10 19:50:25 +02004537 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4538 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
4539 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004540 /* Mute input pins 0x18-0x1b */
Takashi Iwai05acb862005-06-10 19:50:25 +02004541 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4542 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4543 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
4544 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004545 /* ADC set up */
Takashi Iwai05acb862005-06-10 19:50:25 +02004546 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004547 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004548 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004549 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004550 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02004551 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02004552 /* Analog input/passthru */
4553 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
4554 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
4555 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
4556 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
4557 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004558 { }
4559};
4560#endif
4561
Linus Torvalds1da177e2005-04-16 15:20:36 -07004562/*
4563 */
4564
Takashi Iwaiea734962011-01-17 11:29:34 +01004565static const char * const alc880_models[ALC880_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004566 [ALC880_3ST] = "3stack",
4567 [ALC880_TCL_S700] = "tcl",
4568 [ALC880_3ST_DIG] = "3stack-digout",
4569 [ALC880_CLEVO] = "clevo",
4570 [ALC880_5ST] = "5stack",
4571 [ALC880_5ST_DIG] = "5stack-digout",
4572 [ALC880_W810] = "w810",
4573 [ALC880_Z71V] = "z71v",
4574 [ALC880_6ST] = "6stack",
4575 [ALC880_6ST_DIG] = "6stack-digout",
4576 [ALC880_ASUS] = "asus",
4577 [ALC880_ASUS_W1V] = "asus-w1v",
4578 [ALC880_ASUS_DIG] = "asus-dig",
4579 [ALC880_ASUS_DIG2] = "asus-dig2",
4580 [ALC880_UNIWILL_DIG] = "uniwill",
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004581 [ALC880_UNIWILL_P53] = "uniwill-p53",
4582 [ALC880_FUJITSU] = "fujitsu",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004583 [ALC880_F1734] = "F1734",
4584 [ALC880_LG] = "lg",
4585 [ALC880_LG_LW] = "lg-lw",
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004586 [ALC880_MEDION_RIM] = "medion",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004587#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004588 [ALC880_TEST] = "test",
Takashi Iwai2fa522b2005-05-12 14:51:12 +02004589#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004590 [ALC880_AUTO] = "auto",
4591};
4592
4593static struct snd_pci_quirk alc880_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004594 SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004595 SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
4596 SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
4597 SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
4598 SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
4599 SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
4600 SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
4601 SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
4602 SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004603 SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
4604 SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004605 SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
4606 SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
4607 SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
4608 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
4609 SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
4610 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
4611 SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
4612 /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
4613 SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
4614 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
Travis Place186c3112008-05-20 11:54:41 +02004615 SND_PCI_QUIRK(0x1043, 0x814e, "ASUS P5GD1 w/SPDIF", ALC880_6ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004616 SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
4617 SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
4618 SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004619 SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_ASUS), /* default ASUS */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004620 SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004621 SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
4622 SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004623 SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
4624 SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004625 SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
4626 SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
4627 SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
4628 SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004629 SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
4630 SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004631 SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004632 SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004633 SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004634 SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004635 SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
4636 SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004637 SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004638 SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_MEDION_RIM),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004639 SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004640 SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004641 SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
Travis Place1d116042008-06-23 11:42:30 +02004642 SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FUJITSU),
Daniel T Chen33535412010-04-22 07:15:26 -04004643 SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_F1734),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004644 SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004645 SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004646 SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
Daniel T Chen77c4d5c2010-12-02 22:45:45 -05004647 SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004648 SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004649 SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004650 SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
4651 SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG), /* broken BIOS */
4652 SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
4653 SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004654 SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
4655 SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004656 SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004657 SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004658 SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
4659 SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01004660 SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
4661 SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
4662 SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +01004663 /* default Intel */
4664 SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01004665 SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
4666 SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
Linus Torvalds1da177e2005-04-16 15:20:36 -07004667 {}
4668};
4669
Takashi Iwai16ded522005-06-10 19:58:24 +02004670/*
Kailang Yangdf694da2005-12-05 19:42:22 +01004671 * ALC880 codec presets
Takashi Iwai16ded522005-06-10 19:58:24 +02004672 */
Takashi Iwai16ded522005-06-10 19:58:24 +02004673static struct alc_config_preset alc880_presets[] = {
4674 [ALC880_3ST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004675 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004676 .init_verbs = { alc880_volume_init_verbs,
4677 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004678 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004679 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004680 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4681 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004682 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004683 .input_mux = &alc880_capture_source,
4684 },
4685 [ALC880_3ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004686 .mixers = { alc880_three_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004687 .init_verbs = { alc880_volume_init_verbs,
4688 alc880_pin_3stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004689 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwai16ded522005-06-10 19:58:24 +02004690 .dac_nids = alc880_dac_nids,
4691 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004692 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4693 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004694 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004695 .input_mux = &alc880_capture_source,
4696 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004697 [ALC880_TCL_S700] = {
4698 .mixers = { alc880_tcl_s700_mixer },
4699 .init_verbs = { alc880_volume_init_verbs,
4700 alc880_pin_tcl_S700_init_verbs,
4701 alc880_gpio2_init_verbs },
4702 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4703 .dac_nids = alc880_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01004704 .adc_nids = alc880_adc_nids_alt, /* FIXME: correct? */
4705 .num_adc_nids = 1, /* single ADC */
Kailang Yangdf694da2005-12-05 19:42:22 +01004706 .hp_nid = 0x03,
4707 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4708 .channel_mode = alc880_2_jack_modes,
4709 .input_mux = &alc880_capture_source,
4710 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004711 [ALC880_5ST] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004712 .mixers = { alc880_three_stack_mixer,
4713 alc880_five_stack_mixer},
4714 .init_verbs = { alc880_volume_init_verbs,
4715 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004716 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4717 .dac_nids = alc880_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004718 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4719 .channel_mode = alc880_fivestack_modes,
4720 .input_mux = &alc880_capture_source,
4721 },
4722 [ALC880_5ST_DIG] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004723 .mixers = { alc880_three_stack_mixer,
4724 alc880_five_stack_mixer },
4725 .init_verbs = { alc880_volume_init_verbs,
4726 alc880_pin_5stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004727 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4728 .dac_nids = alc880_dac_nids,
4729 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004730 .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
4731 .channel_mode = alc880_fivestack_modes,
4732 .input_mux = &alc880_capture_source,
4733 },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004734 [ALC880_6ST] = {
4735 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004736 .init_verbs = { alc880_volume_init_verbs,
4737 alc880_pin_6stack_init_verbs },
Takashi Iwaib6482d42005-06-27 15:32:43 +02004738 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4739 .dac_nids = alc880_6st_dac_nids,
4740 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4741 .channel_mode = alc880_sixstack_modes,
4742 .input_mux = &alc880_6stack_capture_source,
4743 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004744 [ALC880_6ST_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004745 .mixers = { alc880_six_stack_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004746 .init_verbs = { alc880_volume_init_verbs,
4747 alc880_pin_6stack_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004748 .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
4749 .dac_nids = alc880_6st_dac_nids,
4750 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004751 .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
4752 .channel_mode = alc880_sixstack_modes,
4753 .input_mux = &alc880_6stack_capture_source,
4754 },
4755 [ALC880_W810] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004756 .mixers = { alc880_w810_base_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004757 .init_verbs = { alc880_volume_init_verbs,
4758 alc880_pin_w810_init_verbs,
Takashi Iwaib0af0de2005-06-21 14:49:19 +02004759 alc880_gpio2_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004760 .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
4761 .dac_nids = alc880_w810_dac_nids,
4762 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004763 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
4764 .channel_mode = alc880_w810_modes,
4765 .input_mux = &alc880_capture_source,
4766 },
4767 [ALC880_Z71V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004768 .mixers = { alc880_z71v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004769 .init_verbs = { alc880_volume_init_verbs,
4770 alc880_pin_z71v_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004771 .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
4772 .dac_nids = alc880_z71v_dac_nids,
4773 .dig_out_nid = ALC880_DIGOUT_NID,
4774 .hp_nid = 0x03,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004775 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4776 .channel_mode = alc880_2_jack_modes,
Takashi Iwai16ded522005-06-10 19:58:24 +02004777 .input_mux = &alc880_capture_source,
4778 },
4779 [ALC880_F1734] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004780 .mixers = { alc880_f1734_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004781 .init_verbs = { alc880_volume_init_verbs,
4782 alc880_pin_f1734_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004783 .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
4784 .dac_nids = alc880_f1734_dac_nids,
4785 .hp_nid = 0x02,
4786 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4787 .channel_mode = alc880_2_jack_modes,
Takashi Iwai937b4162008-02-11 14:52:36 +01004788 .input_mux = &alc880_f1734_capture_source,
4789 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004790 .setup = alc880_uniwill_p53_setup,
4791 .init_hook = alc_automute_amp,
Takashi Iwai16ded522005-06-10 19:58:24 +02004792 },
4793 [ALC880_ASUS] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004794 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004795 .init_verbs = { alc880_volume_init_verbs,
4796 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004797 alc880_gpio1_init_verbs },
4798 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4799 .dac_nids = alc880_asus_dac_nids,
4800 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4801 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004802 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004803 .input_mux = &alc880_capture_source,
4804 },
4805 [ALC880_ASUS_DIG] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004806 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004807 .init_verbs = { alc880_volume_init_verbs,
4808 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004809 alc880_gpio1_init_verbs },
4810 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4811 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004812 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004813 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4814 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004815 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004816 .input_mux = &alc880_capture_source,
4817 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004818 [ALC880_ASUS_DIG2] = {
4819 .mixers = { alc880_asus_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004820 .init_verbs = { alc880_volume_init_verbs,
4821 alc880_pin_asus_init_verbs,
Kailang Yangdf694da2005-12-05 19:42:22 +01004822 alc880_gpio2_init_verbs }, /* use GPIO2 */
4823 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4824 .dac_nids = alc880_asus_dac_nids,
4825 .dig_out_nid = ALC880_DIGOUT_NID,
4826 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4827 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004828 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004829 .input_mux = &alc880_capture_source,
4830 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004831 [ALC880_ASUS_W1V] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004832 .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004833 .init_verbs = { alc880_volume_init_verbs,
4834 alc880_pin_asus_init_verbs,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004835 alc880_gpio1_init_verbs },
4836 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4837 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004838 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004839 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4840 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004841 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004842 .input_mux = &alc880_capture_source,
4843 },
4844 [ALC880_UNIWILL_DIG] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004845 .mixers = { alc880_asus_mixer },
Kailang Yangccc656c2006-10-17 12:32:26 +02004846 .init_verbs = { alc880_volume_init_verbs,
4847 alc880_pin_asus_init_verbs },
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004848 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4849 .dac_nids = alc880_asus_dac_nids,
Takashi Iwai16ded522005-06-10 19:58:24 +02004850 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004851 .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
4852 .channel_mode = alc880_asus_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004853 .need_dac_fix = 1,
Takashi Iwai16ded522005-06-10 19:58:24 +02004854 .input_mux = &alc880_capture_source,
4855 },
Kailang Yangccc656c2006-10-17 12:32:26 +02004856 [ALC880_UNIWILL] = {
4857 .mixers = { alc880_uniwill_mixer },
4858 .init_verbs = { alc880_volume_init_verbs,
4859 alc880_uniwill_init_verbs },
4860 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4861 .dac_nids = alc880_asus_dac_nids,
4862 .dig_out_nid = ALC880_DIGOUT_NID,
4863 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4864 .channel_mode = alc880_threestack_modes,
4865 .need_dac_fix = 1,
4866 .input_mux = &alc880_capture_source,
4867 .unsol_event = alc880_uniwill_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004868 .setup = alc880_uniwill_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004869 .init_hook = alc880_uniwill_init_hook,
Kailang Yangccc656c2006-10-17 12:32:26 +02004870 },
4871 [ALC880_UNIWILL_P53] = {
4872 .mixers = { alc880_uniwill_p53_mixer },
4873 .init_verbs = { alc880_volume_init_verbs,
4874 alc880_uniwill_p53_init_verbs },
4875 .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
4876 .dac_nids = alc880_asus_dac_nids,
4877 .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004878 .channel_mode = alc880_threestack_modes,
4879 .input_mux = &alc880_capture_source,
4880 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004881 .setup = alc880_uniwill_p53_setup,
4882 .init_hook = alc_automute_amp,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004883 },
4884 [ALC880_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01004885 .mixers = { alc880_fujitsu_mixer },
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004886 .init_verbs = { alc880_volume_init_verbs,
4887 alc880_uniwill_p53_init_verbs,
4888 alc880_beep_init_verbs },
4889 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4890 .dac_nids = alc880_dac_nids,
Takashi Iwaid53d7d92007-08-20 15:20:02 +02004891 .dig_out_nid = ALC880_DIGOUT_NID,
Tobin Davis2cf9f0f2007-02-07 16:04:25 +01004892 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4893 .channel_mode = alc880_2_jack_modes,
Kailang Yangccc656c2006-10-17 12:32:26 +02004894 .input_mux = &alc880_capture_source,
4895 .unsol_event = alc880_uniwill_p53_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004896 .setup = alc880_uniwill_p53_setup,
4897 .init_hook = alc_automute_amp,
Kailang Yangccc656c2006-10-17 12:32:26 +02004898 },
Kailang Yangdf694da2005-12-05 19:42:22 +01004899 [ALC880_CLEVO] = {
4900 .mixers = { alc880_three_stack_mixer },
4901 .init_verbs = { alc880_volume_init_verbs,
4902 alc880_pin_clevo_init_verbs },
4903 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4904 .dac_nids = alc880_dac_nids,
4905 .hp_nid = 0x03,
4906 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
4907 .channel_mode = alc880_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004908 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +01004909 .input_mux = &alc880_capture_source,
4910 },
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004911 [ALC880_LG] = {
4912 .mixers = { alc880_lg_mixer },
4913 .init_verbs = { alc880_volume_init_verbs,
4914 alc880_lg_init_verbs },
4915 .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
4916 .dac_nids = alc880_lg_dac_nids,
4917 .dig_out_nid = ALC880_DIGOUT_NID,
4918 .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
4919 .channel_mode = alc880_lg_ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +02004920 .need_dac_fix = 1,
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004921 .input_mux = &alc880_lg_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004922 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004923 .setup = alc880_lg_setup,
4924 .init_hook = alc_automute_amp,
Takashi Iwaicb53c622007-08-10 17:21:45 +02004925#ifdef CONFIG_SND_HDA_POWER_SAVE
4926 .loopbacks = alc880_lg_loopbacks,
4927#endif
Takashi Iwaiae6b8132006-03-03 16:47:17 +01004928 },
Takashi Iwaid6815182006-03-23 16:06:23 +01004929 [ALC880_LG_LW] = {
4930 .mixers = { alc880_lg_lw_mixer },
4931 .init_verbs = { alc880_volume_init_verbs,
4932 alc880_lg_lw_init_verbs },
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004933 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
Takashi Iwaid6815182006-03-23 16:06:23 +01004934 .dac_nids = alc880_dac_nids,
4935 .dig_out_nid = ALC880_DIGOUT_NID,
Claudio Matsuoka0a8c5da2007-07-04 15:17:38 +02004936 .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
4937 .channel_mode = alc880_lg_lw_modes,
Takashi Iwaid6815182006-03-23 16:06:23 +01004938 .input_mux = &alc880_lg_lw_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02004939 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004940 .setup = alc880_lg_lw_setup,
4941 .init_hook = alc_automute_amp,
Takashi Iwaid6815182006-03-23 16:06:23 +01004942 },
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004943 [ALC880_MEDION_RIM] = {
4944 .mixers = { alc880_medion_rim_mixer },
4945 .init_verbs = { alc880_volume_init_verbs,
4946 alc880_medion_rim_init_verbs,
4947 alc_gpio2_init_verbs },
4948 .num_dacs = ARRAY_SIZE(alc880_dac_nids),
4949 .dac_nids = alc880_dac_nids,
4950 .dig_out_nid = ALC880_DIGOUT_NID,
4951 .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
4952 .channel_mode = alc880_2_jack_modes,
4953 .input_mux = &alc880_medion_rim_capture_source,
4954 .unsol_event = alc880_medion_rim_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +02004955 .setup = alc880_medion_rim_setup,
4956 .init_hook = alc880_medion_rim_automute,
Takashi Iwaidf99cd32008-04-25 15:25:04 +02004957 },
Takashi Iwai16ded522005-06-10 19:58:24 +02004958#ifdef CONFIG_SND_DEBUG
4959 [ALC880_TEST] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004960 .mixers = { alc880_test_mixer },
4961 .init_verbs = { alc880_test_init_verbs },
Takashi Iwai16ded522005-06-10 19:58:24 +02004962 .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
4963 .dac_nids = alc880_test_dac_nids,
4964 .dig_out_nid = ALC880_DIGOUT_NID,
Takashi Iwai16ded522005-06-10 19:58:24 +02004965 .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
4966 .channel_mode = alc880_test_modes,
4967 .input_mux = &alc880_test_capture_source,
4968 },
4969#endif
4970};
4971
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004972/*
4973 * Automatic parse of I/O pins from the BIOS configuration
4974 */
4975
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004976enum {
4977 ALC_CTL_WIDGET_VOL,
4978 ALC_CTL_WIDGET_MUTE,
4979 ALC_CTL_BIND_MUTE,
4980};
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004981static struct snd_kcontrol_new alc880_control_templates[] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004982 HDA_CODEC_VOLUME(NULL, 0, 0, 0),
4983 HDA_CODEC_MUTE(NULL, 0, 0, 0),
Takashi Iwai985be542005-11-02 18:26:49 +01004984 HDA_BIND_MUTE(NULL, 0, 0, 0),
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004985};
4986
4987/* add dynamic controls */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004988static int add_control(struct alc_spec *spec, int type, const char *name,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02004989 int cidx, unsigned long val)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004990{
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01004991 struct snd_kcontrol_new *knew;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004992
Takashi Iwai603c4012008-07-30 15:01:44 +02004993 snd_array_init(&spec->kctls, sizeof(*knew), 32);
4994 knew = snd_array_new(&spec->kctls);
4995 if (!knew)
4996 return -ENOMEM;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02004997 *knew = alc880_control_templates[type];
Paulo Marques543537b2005-06-23 00:09:02 -07004998 knew->name = kstrdup(name, GFP_KERNEL);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02004999 if (!knew->name)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005000 return -ENOMEM;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005001 knew->index = cidx;
Jaroslav Kysela4d02d1b2009-11-12 10:15:48 +01005002 if (get_amp_nid_(val))
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +01005003 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005004 knew->private_value = val;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005005 return 0;
5006}
5007
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005008static int add_control_with_pfx(struct alc_spec *spec, int type,
5009 const char *pfx, const char *dir,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005010 const char *sfx, int cidx, unsigned long val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005011{
5012 char name[32];
5013 snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx);
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005014 return add_control(spec, type, name, cidx, val);
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005015}
5016
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005017#define add_pb_vol_ctrl(spec, type, pfx, val) \
5018 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val)
5019#define add_pb_sw_ctrl(spec, type, pfx, val) \
5020 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val)
5021#define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \
5022 add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val)
5023#define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \
5024 add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val)
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005025
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005026#define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
5027#define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
5028#define alc880_is_multi_pin(nid) ((nid) >= 0x18)
5029#define alc880_multi_pin_idx(nid) ((nid) - 0x18)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005030#define alc880_idx_to_dac(nid) ((nid) + 0x02)
5031#define alc880_dac_to_idx(nid) ((nid) - 0x02)
5032#define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
5033#define alc880_idx_to_selector(nid) ((nid) + 0x10)
5034#define ALC880_PIN_CD_NID 0x1c
5035
5036/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005037static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
5038 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005039{
5040 hda_nid_t nid;
5041 int assigned[4];
5042 int i, j;
5043
5044 memset(assigned, 0, sizeof(assigned));
Takashi Iwaib0af0de2005-06-21 14:49:19 +02005045 spec->multiout.dac_nids = spec->private_dac_nids;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005046
5047 /* check the pins hardwired to audio widget */
5048 for (i = 0; i < cfg->line_outs; i++) {
5049 nid = cfg->line_out_pins[i];
5050 if (alc880_is_fixed_pin(nid)) {
5051 int idx = alc880_fixed_pin_idx(nid);
Libin Yang5014f192005-11-23 15:48:36 +01005052 spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005053 assigned[idx] = 1;
5054 }
5055 }
5056 /* left pins can be connect to any audio widget */
5057 for (i = 0; i < cfg->line_outs; i++) {
5058 nid = cfg->line_out_pins[i];
5059 if (alc880_is_fixed_pin(nid))
5060 continue;
5061 /* search for an empty channel */
5062 for (j = 0; j < cfg->line_outs; j++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005063 if (!assigned[j]) {
5064 spec->multiout.dac_nids[i] =
5065 alc880_idx_to_dac(j);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005066 assigned[j] = 1;
5067 break;
5068 }
5069 }
5070 }
5071 spec->multiout.num_dacs = cfg->line_outs;
5072 return 0;
5073}
5074
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005075static const char *alc_get_line_out_pfx(const struct auto_pin_cfg *cfg,
5076 bool can_be_master)
5077{
5078 if (!cfg->hp_outs && !cfg->speaker_outs && can_be_master)
5079 return "Master";
5080
5081 switch (cfg->line_out_type) {
5082 case AUTO_PIN_SPEAKER_OUT:
David Henningssonebbeb3d2011-03-04 14:08:30 +01005083 if (cfg->line_outs == 1)
5084 return "Speaker";
5085 break;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005086 case AUTO_PIN_HP_OUT:
5087 return "Headphone";
5088 default:
5089 if (cfg->line_outs == 1)
5090 return "PCM";
5091 break;
5092 }
5093 return NULL;
5094}
5095
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005096/* add playback controls from the parsed DAC table */
Kailang Yangdf694da2005-12-05 19:42:22 +01005097static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
5098 const struct auto_pin_cfg *cfg)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005099{
Takashi Iwaiea734962011-01-17 11:29:34 +01005100 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005101 "Front", "Surround", NULL /*CLFE*/, "Side"
5102 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005103 const char *pfx = alc_get_line_out_pfx(cfg, false);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005104 hda_nid_t nid;
5105 int i, err;
5106
5107 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005108 if (!spec->multiout.dac_nids[i])
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005109 continue;
5110 nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005111 if (!pfx && i == 2) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005112 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005113 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5114 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005115 HDA_COMPOSE_AMP_VAL(nid, 1, 0,
5116 HDA_OUTPUT));
5117 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005118 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005119 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
5120 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005121 HDA_COMPOSE_AMP_VAL(nid, 2, 0,
5122 HDA_OUTPUT));
5123 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005124 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005125 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5126 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005127 HDA_COMPOSE_AMP_VAL(nid, 1, 2,
5128 HDA_INPUT));
5129 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005130 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005131 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
5132 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005133 HDA_COMPOSE_AMP_VAL(nid, 2, 2,
5134 HDA_INPUT));
5135 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005136 return err;
5137 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005138 const char *name = pfx;
David Henningsson7e59e092011-03-04 14:22:25 +01005139 int index = i;
5140 if (!name) {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005141 name = chname[i];
David Henningsson7e59e092011-03-04 14:22:25 +01005142 index = 0;
5143 }
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005144 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
David Henningsson7e59e092011-03-04 14:22:25 +01005145 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005146 HDA_COMPOSE_AMP_VAL(nid, 3, 0,
5147 HDA_OUTPUT));
5148 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005149 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +01005150 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
David Henningsson7e59e092011-03-04 14:22:25 +01005151 name, index,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005152 HDA_COMPOSE_AMP_VAL(nid, 3, 2,
5153 HDA_INPUT));
5154 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005155 return err;
5156 }
5157 }
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005158 return 0;
5159}
5160
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005161/* add playback controls for speaker and HP outputs */
5162static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
5163 const char *pfx)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005164{
5165 hda_nid_t nid;
5166 int err;
5167
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005168 if (!pin)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005169 return 0;
5170
5171 if (alc880_is_fixed_pin(pin)) {
5172 nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
Takashi Iwai82bc9552006-03-21 11:24:42 +01005173 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005174 if (!spec->multiout.hp_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005175 spec->multiout.hp_nid = nid;
Takashi Iwai82bc9552006-03-21 11:24:42 +01005176 else
5177 spec->multiout.extra_out_nid[0] = nid;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005178 /* control HP volume/switch on the output mixer amp */
5179 nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005180 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005181 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
5182 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005183 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005184 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005185 HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
5186 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005187 return err;
5188 } else if (alc880_is_multi_pin(pin)) {
5189 /* set manual connection */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005190 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02005191 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005192 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
5193 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005194 return err;
5195 }
5196 return 0;
5197}
5198
5199/* create input playback/capture controls for the given pin */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005200static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005201 const char *ctlname, int ctlidx,
Kailang Yangdf694da2005-12-05 19:42:22 +01005202 int idx, hda_nid_t mix_nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005203{
Kailang Yangdf694da2005-12-05 19:42:22 +01005204 int err;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005205
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005206 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005207 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5208 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005209 return err;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005210 err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005211 HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
5212 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005213 return err;
5214 return 0;
5215}
5216
Takashi Iwai05f5f472009-08-25 13:10:18 +02005217static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005218{
Takashi Iwai05f5f472009-08-25 13:10:18 +02005219 unsigned int pincap = snd_hda_query_pin_caps(codec, nid);
5220 return (pincap & AC_PINCAP_IN) != 0;
5221}
5222
5223/* create playback/capture controls for input pins */
5224static int alc_auto_create_input_ctls(struct hda_codec *codec,
5225 const struct auto_pin_cfg *cfg,
5226 hda_nid_t mixer,
5227 hda_nid_t cap1, hda_nid_t cap2)
5228{
5229 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005230 struct hda_input_mux *imux = &spec->private_imux[0];
David Henningsson5322bf22011-01-05 11:03:56 +01005231 int i, err, idx, type_idx = 0;
5232 const char *prev_label = NULL;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005233
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005234 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai05f5f472009-08-25 13:10:18 +02005235 hda_nid_t pin;
Takashi Iwai10a20af2010-09-09 16:28:02 +02005236 const char *label;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005237
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005238 pin = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005239 if (!alc_is_input_pin(codec, pin))
5240 continue;
5241
David Henningsson5322bf22011-01-05 11:03:56 +01005242 label = hda_get_autocfg_input_label(codec, cfg, i);
5243 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005244 type_idx++;
5245 else
5246 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +01005247 prev_label = label;
5248
Takashi Iwai05f5f472009-08-25 13:10:18 +02005249 if (mixer) {
5250 idx = get_connection_index(codec, mixer, pin);
5251 if (idx >= 0) {
5252 err = new_analog_input(spec, pin,
Takashi Iwai10a20af2010-09-09 16:28:02 +02005253 label, type_idx,
5254 idx, mixer);
Takashi Iwai05f5f472009-08-25 13:10:18 +02005255 if (err < 0)
5256 return err;
5257 }
5258 }
5259
5260 if (!cap1)
5261 continue;
5262 idx = get_connection_index(codec, cap1, pin);
5263 if (idx < 0 && cap2)
5264 idx = get_connection_index(codec, cap2, pin);
Takashi Iwai10a20af2010-09-09 16:28:02 +02005265 if (idx >= 0)
5266 snd_hda_add_imux_item(imux, label, idx, NULL);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005267 }
5268 return 0;
5269}
5270
Takashi Iwai05f5f472009-08-25 13:10:18 +02005271static int alc880_auto_create_input_ctls(struct hda_codec *codec,
5272 const struct auto_pin_cfg *cfg)
5273{
5274 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x08, 0x09);
5275}
5276
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005277static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid,
5278 unsigned int pin_type)
5279{
5280 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
5281 pin_type);
5282 /* unmute pin */
Takashi Iwaid260cdf2008-02-13 17:19:35 +01005283 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
5284 AMP_OUT_UNMUTE);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005285}
5286
Kailang Yangdf694da2005-12-05 19:42:22 +01005287static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
5288 hda_nid_t nid, int pin_type,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005289 int dac_idx)
5290{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005291 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005292 /* need the manual connection? */
5293 if (alc880_is_multi_pin(nid)) {
5294 struct alc_spec *spec = codec->spec;
5295 int idx = alc880_multi_pin_idx(nid);
5296 snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
5297 AC_VERB_SET_CONNECT_SEL,
5298 alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
5299 }
5300}
5301
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005302static int get_pin_type(int line_out_type)
5303{
5304 if (line_out_type == AUTO_PIN_HP_OUT)
5305 return PIN_HP;
5306 else
5307 return PIN_OUT;
5308}
5309
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005310static void alc880_auto_init_multi_out(struct hda_codec *codec)
5311{
5312 struct alc_spec *spec = codec->spec;
5313 int i;
Kailang Yangea1fb292008-08-26 12:58:38 +02005314
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005315 for (i = 0; i < spec->autocfg.line_outs; i++) {
5316 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02005317 int pin_type = get_pin_type(spec->autocfg.line_out_type);
5318 alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005319 }
5320}
5321
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005322static void alc880_auto_init_extra_out(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005323{
5324 struct alc_spec *spec = codec->spec;
5325 hda_nid_t pin;
5326
Takashi Iwai82bc9552006-03-21 11:24:42 +01005327 pin = spec->autocfg.speaker_pins[0];
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005328 if (pin) /* connect to front */
5329 alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Takashi Iwaieb06ed82006-09-20 17:10:27 +02005330 pin = spec->autocfg.hp_pins[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005331 if (pin) /* connect to front */
5332 alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
5333}
5334
5335static void alc880_auto_init_analog_input(struct hda_codec *codec)
5336{
5337 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005338 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005339 int i;
5340
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005341 for (i = 0; i < cfg->num_inputs; i++) {
5342 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005343 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02005344 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01005345 if (nid != ALC880_PIN_CD_NID &&
5346 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005347 snd_hda_codec_write(codec, nid, 0,
5348 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005349 AMP_OUT_MUTE);
5350 }
5351 }
5352}
5353
Takashi Iwai7f311a42010-04-09 17:32:23 +02005354static void alc880_auto_init_input_src(struct hda_codec *codec)
5355{
5356 struct alc_spec *spec = codec->spec;
5357 int c;
5358
5359 for (c = 0; c < spec->num_adc_nids; c++) {
5360 unsigned int mux_idx;
5361 const struct hda_input_mux *imux;
5362 mux_idx = c >= spec->num_mux_defs ? 0 : c;
5363 imux = &spec->input_mux[mux_idx];
5364 if (!imux->num_items && mux_idx > 0)
5365 imux = &spec->input_mux[0];
5366 if (imux)
5367 snd_hda_codec_write(codec, spec->adc_nids[c], 0,
5368 AC_VERB_SET_CONNECT_SEL,
5369 imux->items[0].index);
5370 }
5371}
5372
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005373/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005374/* return 1 if successful, 0 if the proper config is not found,
5375 * or a negative error code
5376 */
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005377static int alc880_parse_auto_config(struct hda_codec *codec)
5378{
5379 struct alc_spec *spec = codec->spec;
Takashi Iwai757899a2010-07-30 10:48:14 +02005380 int err;
Kailang Yangdf694da2005-12-05 19:42:22 +01005381 static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005382
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005383 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
5384 alc880_ignore);
5385 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005386 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005387 if (!spec->autocfg.line_outs)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005388 return 0; /* can't find valid BIOS pin config */
Kailang Yangdf694da2005-12-05 19:42:22 +01005389
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005390 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
5391 if (err < 0)
5392 return err;
5393 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
5394 if (err < 0)
5395 return err;
5396 err = alc880_auto_create_extra_out(spec,
5397 spec->autocfg.speaker_pins[0],
5398 "Speaker");
5399 if (err < 0)
5400 return err;
5401 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
5402 "Headphone");
5403 if (err < 0)
5404 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +02005405 err = alc880_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005406 if (err < 0)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005407 return err;
5408
5409 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
5410
Takashi Iwai757899a2010-07-30 10:48:14 +02005411 alc_auto_parse_digital(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005412
Takashi Iwai603c4012008-07-30 15:01:44 +02005413 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01005414 add_mixer(spec, spec->kctls.list);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005415
Takashi Iwaid88897e2008-10-31 15:01:37 +01005416 add_verb(spec, alc880_volume_init_verbs);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005417
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005418 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02005419 spec->input_mux = &spec->private_imux[0];
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005420
Kailang Yang6227cdc2010-02-25 08:36:52 +01005421 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02005422
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005423 return 1;
5424}
5425
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005426/* additional initialization for auto-configuration model */
5427static void alc880_auto_init(struct hda_codec *codec)
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005428{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005429 struct alc_spec *spec = codec->spec;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005430 alc880_auto_init_multi_out(codec);
Takashi Iwai8d88bc32005-11-17 11:09:23 +01005431 alc880_auto_init_extra_out(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005432 alc880_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02005433 alc880_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02005434 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01005435 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02005436 alc_inithook(codec);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005437}
5438
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005439/* check the ADC/MUX contains all input pins; some ADC/MUX contains only
5440 * one of two digital mic pins, e.g. on ALC272
5441 */
5442static void fixup_automic_adc(struct hda_codec *codec)
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005443{
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005444 struct alc_spec *spec = codec->spec;
5445 int i;
5446
5447 for (i = 0; i < spec->num_adc_nids; i++) {
5448 hda_nid_t cap = spec->capsrc_nids ?
5449 spec->capsrc_nids[i] : spec->adc_nids[i];
5450 int iidx, eidx;
5451
5452 iidx = get_connection_index(codec, cap, spec->int_mic.pin);
5453 if (iidx < 0)
5454 continue;
5455 eidx = get_connection_index(codec, cap, spec->ext_mic.pin);
5456 if (eidx < 0)
5457 continue;
5458 spec->int_mic.mux_idx = iidx;
5459 spec->ext_mic.mux_idx = eidx;
5460 if (spec->capsrc_nids)
5461 spec->capsrc_nids += i;
5462 spec->adc_nids += i;
5463 spec->num_adc_nids = 1;
5464 return;
5465 }
5466 snd_printd(KERN_INFO "hda_codec: %s: "
5467 "No ADC/MUX containing both 0x%x and 0x%x pins\n",
5468 codec->chip_name, spec->int_mic.pin, spec->ext_mic.pin);
5469 spec->auto_mic = 0; /* disable auto-mic to be sure */
5470}
5471
Takashi Iwai748cce42010-08-04 07:37:39 +02005472/* select or unmute the given capsrc route */
5473static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap,
5474 int idx)
5475{
5476 if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) {
5477 snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx,
5478 HDA_AMP_MUTE, 0);
5479 } else {
5480 snd_hda_codec_write_cache(codec, cap, 0,
5481 AC_VERB_SET_CONNECT_SEL, idx);
5482 }
5483}
5484
Takashi Iwai840b64c2010-07-13 22:49:01 +02005485/* set the default connection to that pin */
5486static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin)
5487{
5488 struct alc_spec *spec = codec->spec;
5489 int i;
5490
5491 for (i = 0; i < spec->num_adc_nids; i++) {
5492 hda_nid_t cap = spec->capsrc_nids ?
5493 spec->capsrc_nids[i] : spec->adc_nids[i];
5494 int idx;
5495
5496 idx = get_connection_index(codec, cap, pin);
5497 if (idx < 0)
5498 continue;
Takashi Iwai748cce42010-08-04 07:37:39 +02005499 select_or_unmute_capsrc(codec, cap, idx);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005500 return i; /* return the found index */
5501 }
5502 return -1; /* not found */
5503}
5504
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005505/* choose the ADC/MUX containing the input pin and initialize the setup */
5506static void fixup_single_adc(struct hda_codec *codec)
5507{
5508 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005509 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005510 int i;
5511
5512 /* search for the input pin; there must be only one */
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005513 if (cfg->num_inputs != 1)
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005514 return;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005515 i = init_capsrc_for_pin(codec, cfg->inputs[0].pin);
Takashi Iwai840b64c2010-07-13 22:49:01 +02005516 if (i >= 0) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005517 /* use only this ADC */
5518 if (spec->capsrc_nids)
5519 spec->capsrc_nids += i;
5520 spec->adc_nids += i;
5521 spec->num_adc_nids = 1;
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005522 }
5523}
5524
Takashi Iwai840b64c2010-07-13 22:49:01 +02005525/* initialize dual adcs */
5526static void fixup_dual_adc_switch(struct hda_codec *codec)
5527{
5528 struct alc_spec *spec = codec->spec;
5529 init_capsrc_for_pin(codec, spec->ext_mic.pin);
5530 init_capsrc_for_pin(codec, spec->int_mic.pin);
5531}
5532
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005533static void set_capture_mixer(struct hda_codec *codec)
5534{
5535 struct alc_spec *spec = codec->spec;
Takashi Iwaia23b6882009-03-23 15:21:36 +01005536 static struct snd_kcontrol_new *caps[2][3] = {
5537 { alc_capture_mixer_nosrc1,
5538 alc_capture_mixer_nosrc2,
5539 alc_capture_mixer_nosrc3 },
5540 { alc_capture_mixer1,
5541 alc_capture_mixer2,
5542 alc_capture_mixer3 },
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005543 };
Takashi Iwaia23b6882009-03-23 15:21:36 +01005544 if (spec->num_adc_nids > 0 && spec->num_adc_nids <= 3) {
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005545 int mux = 0;
Takashi Iwai840b64c2010-07-13 22:49:01 +02005546 int num_adcs = spec->num_adc_nids;
5547 if (spec->dual_adc_switch)
5548 fixup_dual_adc_switch(codec);
5549 else if (spec->auto_mic)
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005550 fixup_automic_adc(codec);
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +01005551 else if (spec->input_mux) {
5552 if (spec->input_mux->num_items > 1)
5553 mux = 1;
5554 else if (spec->input_mux->num_items == 1)
5555 fixup_single_adc(codec);
5556 }
Takashi Iwai840b64c2010-07-13 22:49:01 +02005557 if (spec->dual_adc_switch)
5558 num_adcs = 1;
5559 spec->cap_mixer = caps[mux][num_adcs - 1];
Takashi Iwaia23b6882009-03-23 15:21:36 +01005560 }
Takashi Iwaif9e336f2008-10-31 16:37:07 +01005561}
5562
Takashi Iwai66946352010-03-29 17:21:45 +02005563/* fill adc_nids (and capsrc_nids) containing all active input pins */
5564static void fillup_priv_adc_nids(struct hda_codec *codec, hda_nid_t *nids,
5565 int num_nids)
5566{
5567 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005568 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai66946352010-03-29 17:21:45 +02005569 int n;
5570 hda_nid_t fallback_adc = 0, fallback_cap = 0;
5571
5572 for (n = 0; n < num_nids; n++) {
5573 hda_nid_t adc, cap;
5574 hda_nid_t conn[HDA_MAX_NUM_INPUTS];
5575 int nconns, i, j;
5576
5577 adc = nids[n];
5578 if (get_wcaps_type(get_wcaps(codec, adc)) != AC_WID_AUD_IN)
5579 continue;
5580 cap = adc;
5581 nconns = snd_hda_get_connections(codec, cap, conn,
5582 ARRAY_SIZE(conn));
5583 if (nconns == 1) {
5584 cap = conn[0];
5585 nconns = snd_hda_get_connections(codec, cap, conn,
5586 ARRAY_SIZE(conn));
5587 }
5588 if (nconns <= 0)
5589 continue;
5590 if (!fallback_adc) {
5591 fallback_adc = adc;
5592 fallback_cap = cap;
5593 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005594 for (i = 0; i < cfg->num_inputs; i++) {
5595 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai66946352010-03-29 17:21:45 +02005596 for (j = 0; j < nconns; j++) {
5597 if (conn[j] == nid)
5598 break;
5599 }
5600 if (j >= nconns)
5601 break;
5602 }
Takashi Iwai66ceeb62010-08-30 13:05:52 +02005603 if (i >= cfg->num_inputs) {
Takashi Iwai66946352010-03-29 17:21:45 +02005604 int num_adcs = spec->num_adc_nids;
5605 spec->private_adc_nids[num_adcs] = adc;
5606 spec->private_capsrc_nids[num_adcs] = cap;
5607 spec->num_adc_nids++;
5608 spec->adc_nids = spec->private_adc_nids;
5609 if (adc != cap)
5610 spec->capsrc_nids = spec->private_capsrc_nids;
5611 }
5612 }
5613 if (!spec->num_adc_nids) {
5614 printk(KERN_WARNING "hda_codec: %s: no valid ADC found;"
Takashi Iwai1f85d722010-03-30 07:48:05 +02005615 " using fallback 0x%x\n",
5616 codec->chip_name, fallback_adc);
Takashi Iwai66946352010-03-29 17:21:45 +02005617 spec->private_adc_nids[0] = fallback_adc;
5618 spec->adc_nids = spec->private_adc_nids;
5619 if (fallback_adc != fallback_cap) {
5620 spec->private_capsrc_nids[0] = fallback_cap;
5621 spec->capsrc_nids = spec->private_adc_nids;
5622 }
5623 }
5624}
5625
Takashi Iwai67d634c2009-11-16 15:35:59 +01005626#ifdef CONFIG_SND_HDA_INPUT_BEEP
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005627#define set_beep_amp(spec, nid, idx, dir) \
5628 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005629
5630static struct snd_pci_quirk beep_white_list[] = {
5631 SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
Takashi Iwai080dc7b2010-09-08 08:38:41 +02005632 SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
Takashi Iwaie096c8e2010-08-03 17:20:35 +02005633 SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005634 {}
5635};
5636
5637static inline int has_cdefine_beep(struct hda_codec *codec)
5638{
5639 struct alc_spec *spec = codec->spec;
5640 const struct snd_pci_quirk *q;
5641 q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
5642 if (q)
5643 return q->value;
5644 return spec->cdefine.enable_pcbeep;
5645}
Takashi Iwai67d634c2009-11-16 15:35:59 +01005646#else
5647#define set_beep_amp(spec, nid, idx, dir) /* NOP */
Takashi Iwaidc1eae22010-07-29 15:30:02 +02005648#define has_cdefine_beep(codec) 0
Takashi Iwai67d634c2009-11-16 15:35:59 +01005649#endif
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005650
5651/*
5652 * OK, here we have finally the patch for ALC880
5653 */
5654
Linus Torvalds1da177e2005-04-16 15:20:36 -07005655static int patch_alc880(struct hda_codec *codec)
5656{
5657 struct alc_spec *spec;
5658 int board_config;
Kailang Yangdf694da2005-12-05 19:42:22 +01005659 int err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005660
Takashi Iwaie560d8d2005-09-09 14:21:46 +02005661 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005662 if (spec == NULL)
5663 return -ENOMEM;
5664
5665 codec->spec = spec;
5666
Takashi Iwaif5fcc132006-11-24 17:07:44 +01005667 board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
5668 alc880_models,
5669 alc880_cfg_tbl);
5670 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02005671 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
5672 codec->chip_name);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005673 board_config = ALC880_AUTO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005674 }
5675
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005676 if (board_config == ALC880_AUTO) {
5677 /* automatic parse from the BIOS config */
5678 err = alc880_parse_auto_config(codec);
5679 if (err < 0) {
5680 alc_free(codec);
5681 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005682 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02005683 printk(KERN_INFO
5684 "hda_codec: Cannot set up configuration "
5685 "from BIOS. Using 3-stack mode...\n");
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005686 board_config = ALC880_3ST;
5687 }
5688 }
5689
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09005690 err = snd_hda_attach_beep_device(codec, 0x1);
5691 if (err < 0) {
5692 alc_free(codec);
5693 return err;
5694 }
5695
Kailang Yangdf694da2005-12-05 19:42:22 +01005696 if (board_config != ALC880_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02005697 setup_preset(codec, &alc880_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005698
Linus Torvalds1da177e2005-04-16 15:20:36 -07005699 spec->stream_analog_playback = &alc880_pcm_analog_playback;
5700 spec->stream_analog_capture = &alc880_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +01005701 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07005702
Linus Torvalds1da177e2005-04-16 15:20:36 -07005703 spec->stream_digital_playback = &alc880_pcm_digital_playback;
5704 spec->stream_digital_capture = &alc880_pcm_digital_capture;
5705
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005706 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005707 /* check whether NID 0x07 is valid */
Takashi Iwai54d17402005-11-21 16:33:22 +01005708 unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005709 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +02005710 wcap = get_wcaps_type(wcap);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005711 if (wcap != AC_WID_AUD_IN) {
5712 spec->adc_nids = alc880_adc_nids_alt;
5713 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005714 } else {
5715 spec->adc_nids = alc880_adc_nids;
5716 spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005717 }
5718 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02005719 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01005720 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Linus Torvalds1da177e2005-04-16 15:20:36 -07005721
Takashi Iwai2134ea42008-01-10 16:53:55 +01005722 spec->vmaster_nid = 0x0c;
5723
Linus Torvalds1da177e2005-04-16 15:20:36 -07005724 codec->patch_ops = alc_patch_ops;
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005725 if (board_config == ALC880_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01005726 spec->init_hook = alc880_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02005727#ifdef CONFIG_SND_HDA_POWER_SAVE
5728 if (!spec->loopback.amplist)
5729 spec->loopback.amplist = alc880_loopbacks;
5730#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07005731
5732 return 0;
5733}
5734
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005735
Linus Torvalds1da177e2005-04-16 15:20:36 -07005736/*
5737 * ALC260 support
5738 */
5739
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005740static hda_nid_t alc260_dac_nids[1] = {
5741 /* front */
5742 0x02,
5743};
5744
5745static hda_nid_t alc260_adc_nids[1] = {
5746 /* ADC0 */
5747 0x04,
5748};
5749
Kailang Yangdf694da2005-12-05 19:42:22 +01005750static hda_nid_t alc260_adc_nids_alt[1] = {
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005751 /* ADC1 */
5752 0x05,
5753};
5754
Jonathan Woithed57fdac2006-02-28 11:38:35 +01005755/* NIDs used when simultaneous access to both ADCs makes sense. Note that
5756 * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
5757 */
5758static hda_nid_t alc260_dual_adc_nids[2] = {
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01005759 /* ADC0, ADC1 */
5760 0x04, 0x05
5761};
5762
Takashi Iwaie9edcee2005-06-13 14:16:38 +02005763#define ALC260_DIGOUT_NID 0x03
5764#define ALC260_DIGIN_NID 0x06
5765
5766static struct hda_input_mux alc260_capture_source = {
5767 .num_items = 4,
5768 .items = {
5769 { "Mic", 0x0 },
5770 { "Front Mic", 0x1 },
5771 { "Line", 0x2 },
5772 { "CD", 0x4 },
5773 },
5774};
5775
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01005776/* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005777 * headphone jack and the internal CD lines since these are the only pins at
5778 * which audio can appear. For flexibility, also allow the option of
5779 * recording the mixer output on the second ADC (ADC0 doesn't have a
5780 * connection to the mixer output).
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005781 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005782static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
5783 {
5784 .num_items = 3,
5785 .items = {
5786 { "Mic/Line", 0x0 },
5787 { "CD", 0x4 },
5788 { "Headphone", 0x2 },
5789 },
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005790 },
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005791 {
5792 .num_items = 4,
5793 .items = {
5794 { "Mic/Line", 0x0 },
5795 { "CD", 0x4 },
5796 { "Headphone", 0x2 },
5797 { "Mixer", 0x5 },
5798 },
5799 },
5800
Jonathan Woithea9430dd2005-09-16 19:12:48 +02005801};
5802
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005803/* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
5804 * the Fujitsu S702x, but jacks are marked differently.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005805 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02005806static struct hda_input_mux alc260_acer_capture_sources[2] = {
5807 {
5808 .num_items = 4,
5809 .items = {
5810 { "Mic", 0x0 },
5811 { "Line", 0x2 },
5812 { "CD", 0x4 },
5813 { "Headphone", 0x5 },
5814 },
5815 },
5816 {
5817 .num_items = 5,
5818 .items = {
5819 { "Mic", 0x0 },
5820 { "Line", 0x2 },
5821 { "CD", 0x4 },
5822 { "Headphone", 0x6 },
5823 { "Mixer", 0x5 },
5824 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005825 },
5826};
Michael Schwingencc959482009-02-22 18:58:45 +01005827
5828/* Maxdata Favorit 100XS */
5829static struct hda_input_mux alc260_favorit100_capture_sources[2] = {
5830 {
5831 .num_items = 2,
5832 .items = {
5833 { "Line/Mic", 0x0 },
5834 { "CD", 0x4 },
5835 },
5836 },
5837 {
5838 .num_items = 3,
5839 .items = {
5840 { "Line/Mic", 0x0 },
5841 { "CD", 0x4 },
5842 { "Mixer", 0x5 },
5843 },
5844 },
5845};
5846
Linus Torvalds1da177e2005-04-16 15:20:36 -07005847/*
5848 * This is just place-holder, so there's something for alc_build_pcms to look
5849 * at when it calculates the maximum number of channels. ALC260 has no mixer
5850 * element which allows changing the channel mode, so the verb list is
5851 * never used.
5852 */
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01005853static struct hda_channel_mode alc260_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005854 { 2, NULL },
5855};
5856
Kailang Yangdf694da2005-12-05 19:42:22 +01005857
5858/* Mixer combinations
5859 *
5860 * basic: base_output + input + pc_beep + capture
5861 * HP: base_output + input + capture_alt
5862 * HP_3013: hp_3013 + input + capture
5863 * fujitsu: fujitsu + capture
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01005864 * acer: acer + capture
Kailang Yangdf694da2005-12-05 19:42:22 +01005865 */
5866
5867static struct snd_kcontrol_new alc260_base_output_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02005868 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01005869 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01005870 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5871 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5872 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5873 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5874 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02005875};
Kailang Yangdf694da2005-12-05 19:42:22 +01005876
5877static struct snd_kcontrol_new alc260_input_mixer[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07005878 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
5879 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
5880 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
5881 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
5882 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
5883 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
5884 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
5885 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07005886 { } /* end */
5887};
5888
Takashi Iwaibec15c32008-01-28 18:16:30 +01005889/* update HP, line and mono out pins according to the master switch */
5890static void alc260_hp_master_update(struct hda_codec *codec,
5891 hda_nid_t hp, hda_nid_t line,
5892 hda_nid_t mono)
5893{
5894 struct alc_spec *spec = codec->spec;
5895 unsigned int val = spec->master_sw ? PIN_HP : 0;
5896 /* change HP and line-out pins */
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005897 snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005898 val);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005899 snd_hda_codec_write(codec, line, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005900 val);
5901 /* mono (speaker) depending on the HP jack sense */
5902 val = (val && !spec->jack_present) ? PIN_OUT : 0;
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005903 snd_hda_codec_write(codec, mono, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005904 val);
5905}
5906
5907static int alc260_hp_master_sw_get(struct snd_kcontrol *kcontrol,
5908 struct snd_ctl_elem_value *ucontrol)
5909{
5910 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5911 struct alc_spec *spec = codec->spec;
5912 *ucontrol->value.integer.value = spec->master_sw;
5913 return 0;
5914}
5915
5916static int alc260_hp_master_sw_put(struct snd_kcontrol *kcontrol,
5917 struct snd_ctl_elem_value *ucontrol)
5918{
5919 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
5920 struct alc_spec *spec = codec->spec;
5921 int val = !!*ucontrol->value.integer.value;
5922 hda_nid_t hp, line, mono;
5923
5924 if (val == spec->master_sw)
5925 return 0;
5926 spec->master_sw = val;
5927 hp = (kcontrol->private_value >> 16) & 0xff;
5928 line = (kcontrol->private_value >> 8) & 0xff;
5929 mono = kcontrol->private_value & 0xff;
5930 alc260_hp_master_update(codec, hp, line, mono);
5931 return 1;
5932}
5933
5934static struct snd_kcontrol_new alc260_hp_output_mixer[] = {
5935 {
5936 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5937 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005938 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005939 .info = snd_ctl_boolean_mono_info,
5940 .get = alc260_hp_master_sw_get,
5941 .put = alc260_hp_master_sw_put,
5942 .private_value = (0x0f << 16) | (0x10 << 8) | 0x11
5943 },
5944 HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5945 HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
5946 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5947 HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
5948 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
5949 HDA_OUTPUT),
5950 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2, HDA_INPUT),
5951 { } /* end */
5952};
5953
5954static struct hda_verb alc260_hp_unsol_verbs[] = {
5955 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
5956 {},
5957};
5958
5959static void alc260_hp_automute(struct hda_codec *codec)
5960{
5961 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01005962
Wu Fengguang864f92b2009-11-18 12:38:02 +08005963 spec->jack_present = snd_hda_jack_detect(codec, 0x10);
Takashi Iwaibec15c32008-01-28 18:16:30 +01005964 alc260_hp_master_update(codec, 0x0f, 0x10, 0x11);
5965}
5966
5967static void alc260_hp_unsol_event(struct hda_codec *codec, unsigned int res)
5968{
5969 if ((res >> 26) == ALC880_HP_EVENT)
5970 alc260_hp_automute(codec);
5971}
5972
Kailang Yangdf694da2005-12-05 19:42:22 +01005973static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01005974 {
5975 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5976 .name = "Master Playback Switch",
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +01005977 .subdevice = HDA_SUBDEV_NID_FLAG | 0x11,
Takashi Iwaibec15c32008-01-28 18:16:30 +01005978 .info = snd_ctl_boolean_mono_info,
5979 .get = alc260_hp_master_sw_get,
5980 .put = alc260_hp_master_sw_put,
Takashi Iwai30cde0a2008-11-07 14:49:28 +01005981 .private_value = (0x15 << 16) | (0x10 << 8) | 0x11
Takashi Iwaibec15c32008-01-28 18:16:30 +01005982 },
Kailang Yangdf694da2005-12-05 19:42:22 +01005983 HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
5984 HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
5985 HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
5986 HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
5987 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
5988 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01005989 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
5990 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
Takashi Iwai16ded522005-06-10 19:58:24 +02005991 { } /* end */
5992};
5993
Kailang Yang3f878302008-08-26 13:02:23 +02005994static struct hda_bind_ctls alc260_dc7600_bind_master_vol = {
5995 .ops = &snd_hda_bind_vol,
5996 .values = {
5997 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_OUTPUT),
5998 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
5999 HDA_COMPOSE_AMP_VAL(0x0a, 3, 0, HDA_OUTPUT),
6000 0
6001 },
6002};
6003
6004static struct hda_bind_ctls alc260_dc7600_bind_switch = {
6005 .ops = &snd_hda_bind_sw,
6006 .values = {
6007 HDA_COMPOSE_AMP_VAL(0x11, 3, 0, HDA_OUTPUT),
6008 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
6009 0
6010 },
6011};
6012
6013static struct snd_kcontrol_new alc260_hp_dc7600_mixer[] = {
6014 HDA_BIND_VOL("Master Playback Volume", &alc260_dc7600_bind_master_vol),
6015 HDA_BIND_SW("LineOut Playback Switch", &alc260_dc7600_bind_switch),
6016 HDA_CODEC_MUTE("Speaker Playback Switch", 0x0f, 0x0, HDA_OUTPUT),
6017 HDA_CODEC_MUTE("Headphone Playback Switch", 0x10, 0x0, HDA_OUTPUT),
6018 { } /* end */
6019};
6020
Takashi Iwaibec15c32008-01-28 18:16:30 +01006021static struct hda_verb alc260_hp_3013_unsol_verbs[] = {
6022 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6023 {},
6024};
6025
6026static void alc260_hp_3013_automute(struct hda_codec *codec)
6027{
6028 struct alc_spec *spec = codec->spec;
Takashi Iwaibec15c32008-01-28 18:16:30 +01006029
Wu Fengguang864f92b2009-11-18 12:38:02 +08006030 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai30cde0a2008-11-07 14:49:28 +01006031 alc260_hp_master_update(codec, 0x15, 0x10, 0x11);
Takashi Iwaibec15c32008-01-28 18:16:30 +01006032}
6033
6034static void alc260_hp_3013_unsol_event(struct hda_codec *codec,
6035 unsigned int res)
6036{
6037 if ((res >> 26) == ALC880_HP_EVENT)
6038 alc260_hp_3013_automute(codec);
6039}
6040
Kailang Yang3f878302008-08-26 13:02:23 +02006041static void alc260_hp_3012_automute(struct hda_codec *codec)
6042{
Wu Fengguang864f92b2009-11-18 12:38:02 +08006043 unsigned int bits = snd_hda_jack_detect(codec, 0x10) ? 0 : PIN_OUT;
Kailang Yang3f878302008-08-26 13:02:23 +02006044
Kailang Yang3f878302008-08-26 13:02:23 +02006045 snd_hda_codec_write(codec, 0x0f, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6046 bits);
6047 snd_hda_codec_write(codec, 0x11, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6048 bits);
6049 snd_hda_codec_write(codec, 0x15, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
6050 bits);
6051}
6052
6053static void alc260_hp_3012_unsol_event(struct hda_codec *codec,
6054 unsigned int res)
6055{
6056 if ((res >> 26) == ALC880_HP_EVENT)
6057 alc260_hp_3012_automute(codec);
6058}
6059
6060/* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006061 * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
6062 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01006063static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006064 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01006065 HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006066 ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006067 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6068 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6069 HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
6070 HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006071 ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006072 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6073 HDA_BIND_MUTE("Speaker Playback Switch", 0x09, 2, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +01006074 { } /* end */
6075};
6076
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006077/* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
6078 * versions of the ALC260 don't act on requests to enable mic bias from NID
6079 * 0x0f (used to drive the headphone jack in these laptops). The ALC260
6080 * datasheet doesn't mention this restriction. At this stage it's not clear
6081 * whether this behaviour is intentional or is a hardware bug in chip
6082 * revisions available in early 2006. Therefore for now allow the
6083 * "Headphone Jack Mode" control to span all choices, but if it turns out
6084 * that the lack of mic bias for this NID is intentional we could change the
6085 * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6086 *
6087 * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
6088 * don't appear to make the mic bias available from the "line" jack, even
6089 * though the NID used for this jack (0x14) can supply it. The theory is
6090 * that perhaps Acer have included blocking capacitors between the ALC260
6091 * and the output jack. If this turns out to be the case for all such
6092 * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
6093 * to ALC_PIN_DIR_INOUT_NOMICBIAS.
Jonathan Woithebd869482006-11-28 11:35:52 +01006094 *
6095 * The C20x Tablet series have a mono internal speaker which is controlled
6096 * via the chip's Mono sum widget and pin complex, so include the necessary
6097 * controls for such models. On models without a "mono speaker" the control
6098 * won't do anything.
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006099 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006100static struct snd_kcontrol_new alc260_acer_mixer[] = {
6101 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6102 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006103 ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006104 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0a, 1, 0x0,
Jonathan Woithebd869482006-11-28 11:35:52 +01006105 HDA_OUTPUT),
Takashi Iwai31bffaa2008-02-27 16:10:44 +01006106 HDA_BIND_MUTE_MONO("Speaker Playback Switch", 0x0a, 1, 2,
Jonathan Woithebd869482006-11-28 11:35:52 +01006107 HDA_INPUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006108 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6109 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
6110 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6111 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6112 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6113 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6114 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6115 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006116 { } /* end */
6117};
6118
Michael Schwingencc959482009-02-22 18:58:45 +01006119/* Maxdata Favorit 100XS: one output and one input (0x12) jack
6120 */
6121static struct snd_kcontrol_new alc260_favorit100_mixer[] = {
6122 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6123 HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
6124 ALC_PIN_MODE("Output Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
6125 HDA_CODEC_VOLUME("Line/Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6126 HDA_CODEC_MUTE("Line/Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6127 ALC_PIN_MODE("Line/Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6128 { } /* end */
6129};
6130
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006131/* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
6132 * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
6133 */
6134static struct snd_kcontrol_new alc260_will_mixer[] = {
6135 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6136 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6137 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6138 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6139 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6140 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6141 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6142 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6143 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6144 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006145 { } /* end */
6146};
6147
6148/* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
6149 * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
6150 */
6151static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
6152 HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6153 HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
6154 HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
6155 HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
6156 ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
6157 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
6158 HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
6159 HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
6160 HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
6161 ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
6162 { } /* end */
6163};
6164
Kailang Yangdf694da2005-12-05 19:42:22 +01006165/*
6166 * initialization verbs
6167 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07006168static struct hda_verb alc260_init_verbs[] = {
6169 /* Line In pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006170 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006171 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02006172 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006173 /* Mic1 (rear panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006174 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006175 /* Mic2 (front panel) pin widget for input and vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02006176 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006177 /* LINE-2 is used for line-out in rear */
Takashi Iwai05acb862005-06-10 19:50:25 +02006178 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006179 /* select line-out */
Jonathan Woithefd56f2d2006-01-24 10:35:46 +01006180 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006181 /* LINE-OUT pin */
Takashi Iwai05acb862005-06-10 19:50:25 +02006182 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006183 /* enable HP */
Takashi Iwai05acb862005-06-10 19:50:25 +02006184 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006185 /* enable Mono */
Takashi Iwai05acb862005-06-10 19:50:25 +02006186 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6187 /* mute capture amp left and right */
Takashi Iwai16ded522005-06-10 19:58:24 +02006188 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006189 /* set connection select to line in (default select for this ADC) */
6190 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai16ded522005-06-10 19:58:24 +02006191 /* mute capture amp left and right */
6192 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6193 /* set connection select to line in (default select for this ADC) */
6194 {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai05acb862005-06-10 19:50:25 +02006195 /* set vol=0 Line-Out mixer amp left and right */
6196 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6197 /* unmute pin widget amp left and right (no gain on this amp) */
6198 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6199 /* set vol=0 HP mixer amp left and right */
6200 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6201 /* unmute pin widget amp left and right (no gain on this amp) */
6202 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6203 /* set vol=0 Mono mixer amp left and right */
6204 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6205 /* unmute pin widget amp left and right (no gain on this amp) */
6206 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6207 /* unmute LINE-2 out pin */
6208 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006209 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6210 * Line In 2 = 0x03
6211 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006212 /* mute analog inputs */
6213 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6214 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6215 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6216 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6217 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006218 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
Takashi Iwai05acb862005-06-10 19:50:25 +02006219 /* mute Front out path */
6220 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6221 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6222 /* mute Headphone out path */
6223 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6224 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6225 /* mute Mono out path */
6226 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6227 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07006228 { }
6229};
6230
Takashi Iwai474167d2006-05-17 17:17:43 +02006231#if 0 /* should be identical with alc260_init_verbs? */
Kailang Yangdf694da2005-12-05 19:42:22 +01006232static struct hda_verb alc260_hp_init_verbs[] = {
6233 /* Headphone and output */
6234 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6235 /* mono output */
6236 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6237 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6238 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6239 /* Mic2 (front panel) pin widget for input and vref at 80% */
6240 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6241 /* Line In pin widget for input */
6242 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6243 /* Line-2 pin widget for output */
6244 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6245 /* CD pin widget for input */
6246 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6247 /* unmute amp left and right */
6248 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6249 /* set connection select to line in (default select for this ADC) */
6250 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6251 /* unmute Line-Out mixer amp left and right (volume = 0) */
6252 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6253 /* mute pin widget amp left and right (no gain on this amp) */
6254 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6255 /* unmute HP mixer amp left and right (volume = 0) */
6256 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6257 /* mute pin widget amp left and right (no gain on this amp) */
6258 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006259 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6260 * Line In 2 = 0x03
6261 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006262 /* mute analog inputs */
6263 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6264 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6265 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6266 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6267 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006268 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6269 /* Unmute Front out path */
6270 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6271 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6272 /* Unmute Headphone out path */
6273 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6274 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6275 /* Unmute Mono out path */
6276 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6277 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6278 { }
6279};
Takashi Iwai474167d2006-05-17 17:17:43 +02006280#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01006281
6282static struct hda_verb alc260_hp_3013_init_verbs[] = {
6283 /* Line out and output */
6284 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6285 /* mono output */
6286 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
6287 /* Mic1 (rear panel) pin widget for input and vref at 80% */
6288 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6289 /* Mic2 (front panel) pin widget for input and vref at 80% */
6290 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
6291 /* Line In pin widget for input */
6292 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6293 /* Headphone pin widget for output */
6294 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
6295 /* CD pin widget for input */
6296 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
6297 /* unmute amp left and right */
6298 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
6299 /* set connection select to line in (default select for this ADC) */
6300 {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
6301 /* unmute Line-Out mixer amp left and right (volume = 0) */
6302 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6303 /* mute pin widget amp left and right (no gain on this amp) */
6304 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
6305 /* unmute HP mixer amp left and right (volume = 0) */
6306 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
6307 /* mute pin widget amp left and right (no gain on this amp) */
6308 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006309 /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
6310 * Line In 2 = 0x03
6311 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02006312 /* mute analog inputs */
6313 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6314 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6315 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
6316 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
6317 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01006318 /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
6319 /* Unmute Front out path */
6320 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6321 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6322 /* Unmute Headphone out path */
6323 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6324 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6325 /* Unmute Mono out path */
6326 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
6327 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
6328 { }
6329};
6330
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006331/* Initialisation sequence for ALC260 as configured in Fujitsu S702x
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006332 * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
6333 * audio = 0x16, internal speaker = 0x10.
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006334 */
6335static struct hda_verb alc260_fujitsu_init_verbs[] = {
6336 /* Disable all GPIOs */
6337 {0x01, AC_VERB_SET_GPIO_MASK, 0},
6338 /* Internal speaker is connected to headphone pin */
6339 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6340 /* Headphone/Line-out jack connects to Line1 pin; make it an output */
6341 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006342 /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
6343 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
6344 /* Ensure all other unused pins are disabled and muted. */
6345 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6346 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006347 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006348 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006349 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006350 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6351 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6352 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006353
Jonathan Woithef7ace402006-02-28 11:46:14 +01006354 /* Disable digital (SPDIF) pins */
6355 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6356 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006357
Kailang Yangea1fb292008-08-26 12:58:38 +02006358 /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
Jonathan Woithef7ace402006-02-28 11:46:14 +01006359 * when acting as an output.
6360 */
6361 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6362
6363 /* Start with output sum widgets muted and their output gains at min */
Takashi Iwai8b33a5a2006-02-09 11:57:01 +01006364 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6365 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6366 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6367 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6368 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6369 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6370 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6371 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6372 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006373
Jonathan Woithef7ace402006-02-28 11:46:14 +01006374 /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
6375 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6376 /* Unmute Line1 pin widget output buffer since it starts as an output.
6377 * If the pin mode is changed by the user the pin mode control will
6378 * take care of enabling the pin's input/output buffers as needed.
6379 * Therefore there's no need to enable the input buffer at this
6380 * stage.
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006381 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006382 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +02006383 /* Unmute input buffer of pin widget used for Line-in (no equiv
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006384 * mixer ctrl)
6385 */
Jonathan Woithef7ace402006-02-28 11:46:14 +01006386 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006387
Jonathan Woithef7ace402006-02-28 11:46:14 +01006388 /* Mute capture amp left and right */
6389 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02006390 /* Set ADC connection select to match default mixer setting - line
Jonathan Woithef7ace402006-02-28 11:46:14 +01006391 * in (on mic1 pin)
6392 */
6393 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006394
Jonathan Woithef7ace402006-02-28 11:46:14 +01006395 /* Do the same for the second ADC: mute capture input amp and
6396 * set ADC connection to line in (on mic1 pin)
6397 */
6398 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6399 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe4c5186e2006-02-09 11:53:48 +01006400
Jonathan Woithef7ace402006-02-28 11:46:14 +01006401 /* Mute all inputs to mixer widget (even unconnected ones) */
6402 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6403 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6404 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6405 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6406 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6407 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6408 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6409 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
Takashi Iwai4a471b72005-12-07 13:56:29 +01006410
6411 { }
Jonathan Woithea9430dd2005-09-16 19:12:48 +02006412};
6413
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006414/* Initialisation sequence for ALC260 as configured in Acer TravelMate and
6415 * similar laptops (adapted from Fujitsu init verbs).
6416 */
6417static struct hda_verb alc260_acer_init_verbs[] = {
6418 /* On TravelMate laptops, GPIO 0 enables the internal speaker and
6419 * the headphone jack. Turn this on and rely on the standard mute
6420 * methods whenever the user wants to turn these outputs off.
6421 */
6422 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6423 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6424 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6425 /* Internal speaker/Headphone jack is connected to Line-out pin */
6426 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6427 /* Internal microphone/Mic jack is connected to Mic1 pin */
6428 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6429 /* Line In jack is connected to Line1 pin */
6430 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Jonathan Woithebd869482006-11-28 11:35:52 +01006431 /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
6432 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006433 /* Ensure all other unused pins are disabled and muted. */
6434 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6435 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006436 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6437 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6438 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6439 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6440 /* Disable digital (SPDIF) pins */
6441 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6442 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6443
Kailang Yangea1fb292008-08-26 12:58:38 +02006444 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006445 * bus when acting as outputs.
6446 */
6447 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6448 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6449
6450 /* Start with output sum widgets muted and their output gains at min */
6451 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6452 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6453 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6454 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6455 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6456 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6457 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6458 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6459 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6460
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006461 /* Unmute Line-out pin widget amp left and right
6462 * (no equiv mixer ctrl)
6463 */
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006464 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithebd869482006-11-28 11:35:52 +01006465 /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
6466 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006467 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6468 * inputs. If the pin mode is changed by the user the pin mode control
6469 * will take care of enabling the pin's input/output buffers as needed.
6470 * Therefore there's no need to enable the input buffer at this
6471 * stage.
6472 */
6473 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6474 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6475
6476 /* Mute capture amp left and right */
6477 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6478 /* Set ADC connection select to match default mixer setting - mic
6479 * (on mic1 pin)
6480 */
6481 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6482
6483 /* Do similar with the second ADC: mute capture input amp and
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006484 * set ADC connection to mic to match ALSA's default state.
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006485 */
6486 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006487 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01006488
6489 /* Mute all inputs to mixer widget (even unconnected ones) */
6490 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6491 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6492 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6493 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6494 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6495 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6496 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6497 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6498
6499 { }
6500};
6501
Michael Schwingencc959482009-02-22 18:58:45 +01006502/* Initialisation sequence for Maxdata Favorit 100XS
6503 * (adapted from Acer init verbs).
6504 */
6505static struct hda_verb alc260_favorit100_init_verbs[] = {
6506 /* GPIO 0 enables the output jack.
6507 * Turn this on and rely on the standard mute
6508 * methods whenever the user wants to turn these outputs off.
6509 */
6510 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6511 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6512 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
6513 /* Line/Mic input jack is connected to Mic1 pin */
6514 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
6515 /* Ensure all other unused pins are disabled and muted. */
6516 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6517 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6518 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6519 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6520 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6521 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6522 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6523 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6524 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
6525 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6526 /* Disable digital (SPDIF) pins */
6527 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6528 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6529
6530 /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
6531 * bus when acting as outputs.
6532 */
6533 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6534 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6535
6536 /* Start with output sum widgets muted and their output gains at min */
6537 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6538 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6539 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6540 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6541 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6542 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6543 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6544 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6545 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6546
6547 /* Unmute Line-out pin widget amp left and right
6548 * (no equiv mixer ctrl)
6549 */
6550 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6551 /* Unmute Mic1 and Line1 pin widget input buffers since they start as
6552 * inputs. If the pin mode is changed by the user the pin mode control
6553 * will take care of enabling the pin's input/output buffers as needed.
6554 * Therefore there's no need to enable the input buffer at this
6555 * stage.
6556 */
6557 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6558
6559 /* Mute capture amp left and right */
6560 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6561 /* Set ADC connection select to match default mixer setting - mic
6562 * (on mic1 pin)
6563 */
6564 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6565
6566 /* Do similar with the second ADC: mute capture input amp and
6567 * set ADC connection to mic to match ALSA's default state.
6568 */
6569 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6570 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6571
6572 /* Mute all inputs to mixer widget (even unconnected ones) */
6573 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6574 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6575 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6576 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6577 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6578 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6579 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6581
6582 { }
6583};
6584
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006585static struct hda_verb alc260_will_verbs[] = {
6586 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6587 {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
6588 {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
6589 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6590 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6591 {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
6592 {}
6593};
6594
6595static struct hda_verb alc260_replacer_672v_verbs[] = {
6596 {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
6597 {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
6598 {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
6599
6600 {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
6601 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
6602 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6603
6604 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6605 {}
6606};
6607
6608/* toggle speaker-output according to the hp-jack state */
6609static void alc260_replacer_672v_automute(struct hda_codec *codec)
6610{
6611 unsigned int present;
6612
6613 /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
Wu Fengguang864f92b2009-11-18 12:38:02 +08006614 present = snd_hda_jack_detect(codec, 0x0f);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006615 if (present) {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006616 snd_hda_codec_write_cache(codec, 0x01, 0,
6617 AC_VERB_SET_GPIO_DATA, 1);
6618 snd_hda_codec_write_cache(codec, 0x0f, 0,
6619 AC_VERB_SET_PIN_WIDGET_CONTROL,
6620 PIN_HP);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006621 } else {
Takashi Iwai82beb8f2007-08-10 17:09:26 +02006622 snd_hda_codec_write_cache(codec, 0x01, 0,
6623 AC_VERB_SET_GPIO_DATA, 0);
6624 snd_hda_codec_write_cache(codec, 0x0f, 0,
6625 AC_VERB_SET_PIN_WIDGET_CONTROL,
6626 PIN_OUT);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02006627 }
6628}
6629
6630static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
6631 unsigned int res)
6632{
6633 if ((res >> 26) == ALC880_HP_EVENT)
6634 alc260_replacer_672v_automute(codec);
6635}
6636
Kailang Yang3f878302008-08-26 13:02:23 +02006637static struct hda_verb alc260_hp_dc7600_verbs[] = {
6638 {0x05, AC_VERB_SET_CONNECT_SEL, 0x01},
6639 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
6640 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6641 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
6642 {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6643 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6644 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
6645 {0x10, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6646 {0x11, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6647 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
6648 {}
6649};
6650
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006651/* Test configuration for debugging, modelled after the ALC880 test
6652 * configuration.
6653 */
6654#ifdef CONFIG_SND_DEBUG
6655static hda_nid_t alc260_test_dac_nids[1] = {
6656 0x02,
6657};
6658static hda_nid_t alc260_test_adc_nids[2] = {
6659 0x04, 0x05,
6660};
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006661/* For testing the ALC260, each input MUX needs its own definition since
Kailang Yangea1fb292008-08-26 12:58:38 +02006662 * the signal assignments are different. This assumes that the first ADC
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006663 * is NID 0x04.
Jonathan Woithe17e7aec2006-02-28 11:35:18 +01006664 */
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006665static struct hda_input_mux alc260_test_capture_sources[2] = {
6666 {
6667 .num_items = 7,
6668 .items = {
6669 { "MIC1 pin", 0x0 },
6670 { "MIC2 pin", 0x1 },
6671 { "LINE1 pin", 0x2 },
6672 { "LINE2 pin", 0x3 },
6673 { "CD pin", 0x4 },
6674 { "LINE-OUT pin", 0x5 },
6675 { "HP-OUT pin", 0x6 },
6676 },
6677 },
6678 {
6679 .num_items = 8,
6680 .items = {
6681 { "MIC1 pin", 0x0 },
6682 { "MIC2 pin", 0x1 },
6683 { "LINE1 pin", 0x2 },
6684 { "LINE2 pin", 0x3 },
6685 { "CD pin", 0x4 },
6686 { "Mixer", 0x5 },
6687 { "LINE-OUT pin", 0x6 },
6688 { "HP-OUT pin", 0x7 },
6689 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006690 },
6691};
6692static struct snd_kcontrol_new alc260_test_mixer[] = {
6693 /* Output driver widgets */
6694 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
6695 HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
6696 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
6697 HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
6698 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
6699 HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
6700
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02006701 /* Modes for retasking pin widgets
6702 * Note: the ALC260 doesn't seem to act on requests to enable mic
6703 * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
6704 * mention this restriction. At this stage it's not clear whether
6705 * this behaviour is intentional or is a hardware bug in chip
6706 * revisions available at least up until early 2006. Therefore for
6707 * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
6708 * choices, but if it turns out that the lack of mic bias for these
6709 * NIDs is intentional we could change their modes from
6710 * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
6711 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006712 ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
6713 ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
6714 ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
6715 ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
6716 ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
6717 ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
6718
6719 /* Loopback mixer controls */
6720 HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
6721 HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
6722 HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
6723 HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
6724 HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
6725 HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
6726 HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
6727 HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
6728 HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
6729 HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006730 HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
6731 HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
6732 HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
6733 HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006734
6735 /* Controls for GPIO pins, assuming they are configured as outputs */
6736 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
6737 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
6738 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
6739 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
6740
Jonathan Woithe92621f12006-02-28 11:47:47 +01006741 /* Switches to allow the digital IO pins to be enabled. The datasheet
6742 * is ambigious as to which NID is which; testing on laptops which
Kailang Yangea1fb292008-08-26 12:58:38 +02006743 * make this output available should provide clarification.
Jonathan Woithe92621f12006-02-28 11:47:47 +01006744 */
6745 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
6746 ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
6747
Jonathan Woithef8225f62008-01-08 12:16:54 +01006748 /* A switch allowing EAPD to be enabled. Some laptops seem to use
6749 * this output to turn on an external amplifier.
6750 */
6751 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
6752 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
6753
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006754 { } /* end */
6755};
6756static struct hda_verb alc260_test_init_verbs[] = {
Jonathan Woithe5c8f8582006-02-28 11:43:27 +01006757 /* Enable all GPIOs as outputs with an initial value of 0 */
6758 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
6759 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
6760 {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
6761
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006762 /* Enable retasking pins as output, initially without power amp */
6763 {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6764 {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6765 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6766 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6767 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6768 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6769
Jonathan Woithe92621f12006-02-28 11:47:47 +01006770 /* Disable digital (SPDIF) pins initially, but users can enable
6771 * them via a mixer switch. In the case of SPDIF-out, this initverb
6772 * payload also sets the generation to 0, output to be in "consumer"
6773 * PCM format, copyright asserted, no pre-emphasis and no validity
6774 * control.
6775 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006776 {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
6777 {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
6778
Kailang Yangea1fb292008-08-26 12:58:38 +02006779 /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006780 * OUT1 sum bus when acting as an output.
6781 */
6782 {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
6783 {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
6784 {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
6785 {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
6786
6787 /* Start with output sum widgets muted and their output gains at min */
6788 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6789 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6790 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6791 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6792 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6793 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6794 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6795 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6796 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6797
Jonathan Woithecdcd9262006-02-28 11:36:42 +01006798 /* Unmute retasking pin widget output buffers since the default
6799 * state appears to be output. As the pin mode is changed by the
6800 * user the pin mode control will take care of enabling the pin's
6801 * input/output buffers as needed.
6802 */
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006803 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6804 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6805 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6806 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6807 {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6808 {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6809 /* Also unmute the mono-out pin widget */
6810 {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6811
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006812 /* Mute capture amp left and right */
6813 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Jonathan Woithef7ace402006-02-28 11:46:14 +01006814 /* Set ADC connection select to match default mixer setting (mic1
6815 * pin)
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006816 */
6817 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6818
6819 /* Do the same for the second ADC: mute capture input amp and
Jonathan Woithef7ace402006-02-28 11:46:14 +01006820 * set ADC connection to mic1 pin
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01006821 */
6822 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6823 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6824
6825 /* Mute all inputs to mixer widget (even unconnected ones) */
6826 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
6827 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
6828 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
6829 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
6830 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
6831 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
6832 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
6833 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
6834
6835 { }
6836};
6837#endif
6838
Takashi Iwai63300792008-01-24 15:31:36 +01006839#define alc260_pcm_analog_playback alc880_pcm_analog_alt_playback
6840#define alc260_pcm_analog_capture alc880_pcm_analog_capture
Linus Torvalds1da177e2005-04-16 15:20:36 -07006841
Takashi Iwaia3bcba32005-12-06 19:05:29 +01006842#define alc260_pcm_digital_playback alc880_pcm_digital_playback
6843#define alc260_pcm_digital_capture alc880_pcm_digital_capture
6844
Kailang Yangdf694da2005-12-05 19:42:22 +01006845/*
6846 * for BIOS auto-configuration
6847 */
6848
6849static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai863b4512008-10-21 17:01:47 +02006850 const char *pfx, int *vol_bits)
Kailang Yangdf694da2005-12-05 19:42:22 +01006851{
6852 hda_nid_t nid_vol;
6853 unsigned long vol_val, sw_val;
Kailang Yangdf694da2005-12-05 19:42:22 +01006854 int err;
6855
6856 if (nid >= 0x0f && nid < 0x11) {
6857 nid_vol = nid - 0x7;
6858 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6859 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6860 } else if (nid == 0x11) {
6861 nid_vol = nid - 0x7;
6862 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
6863 sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
6864 } else if (nid >= 0x12 && nid <= 0x15) {
6865 nid_vol = 0x08;
6866 vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
6867 sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
6868 } else
6869 return 0; /* N/A */
Kailang Yangea1fb292008-08-26 12:58:38 +02006870
Takashi Iwai863b4512008-10-21 17:01:47 +02006871 if (!(*vol_bits & (1 << nid_vol))) {
6872 /* first control for the volume widget */
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006873 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, vol_val);
Takashi Iwai863b4512008-10-21 17:01:47 +02006874 if (err < 0)
6875 return err;
6876 *vol_bits |= (1 << nid_vol);
6877 }
Takashi Iwai0afe5f82009-10-02 09:20:00 +02006878 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, sw_val);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006879 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01006880 return err;
6881 return 1;
6882}
6883
6884/* add playback controls from the parsed DAC table */
6885static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
6886 const struct auto_pin_cfg *cfg)
6887{
6888 hda_nid_t nid;
6889 int err;
Takashi Iwai863b4512008-10-21 17:01:47 +02006890 int vols = 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006891
6892 spec->multiout.num_dacs = 1;
6893 spec->multiout.dac_nids = spec->private_dac_nids;
6894 spec->multiout.dac_nids[0] = 0x02;
6895
6896 nid = cfg->line_out_pins[0];
6897 if (nid) {
Takashi Iwai23112d62009-08-25 16:07:08 +02006898 const char *pfx;
6899 if (!cfg->speaker_pins[0] && !cfg->hp_pins[0])
6900 pfx = "Master";
6901 else if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
6902 pfx = "Speaker";
6903 else
6904 pfx = "Front";
6905 err = alc260_add_playback_controls(spec, nid, pfx, &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006906 if (err < 0)
6907 return err;
6908 }
6909
Takashi Iwai82bc9552006-03-21 11:24:42 +01006910 nid = cfg->speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006911 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006912 err = alc260_add_playback_controls(spec, nid, "Speaker", &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006913 if (err < 0)
6914 return err;
6915 }
6916
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006917 nid = cfg->hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006918 if (nid) {
Takashi Iwai863b4512008-10-21 17:01:47 +02006919 err = alc260_add_playback_controls(spec, nid, "Headphone",
6920 &vols);
Kailang Yangdf694da2005-12-05 19:42:22 +01006921 if (err < 0)
6922 return err;
6923 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006924 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +01006925}
6926
6927/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +02006928static int alc260_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yangdf694da2005-12-05 19:42:22 +01006929 const struct auto_pin_cfg *cfg)
6930{
Takashi Iwai05f5f472009-08-25 13:10:18 +02006931 return alc_auto_create_input_ctls(codec, cfg, 0x07, 0x04, 0x05);
Kailang Yangdf694da2005-12-05 19:42:22 +01006932}
6933
6934static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
6935 hda_nid_t nid, int pin_type,
6936 int sel_idx)
6937{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01006938 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangdf694da2005-12-05 19:42:22 +01006939 /* need the manual connection? */
6940 if (nid >= 0x12) {
6941 int idx = nid - 0x12;
6942 snd_hda_codec_write(codec, idx + 0x0b, 0,
6943 AC_VERB_SET_CONNECT_SEL, sel_idx);
Kailang Yangdf694da2005-12-05 19:42:22 +01006944 }
6945}
6946
6947static void alc260_auto_init_multi_out(struct hda_codec *codec)
6948{
6949 struct alc_spec *spec = codec->spec;
6950 hda_nid_t nid;
6951
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006952 nid = spec->autocfg.line_out_pins[0];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006953 if (nid) {
6954 int pin_type = get_pin_type(spec->autocfg.line_out_type);
6955 alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
6956 }
Kailang Yangea1fb292008-08-26 12:58:38 +02006957
Takashi Iwai82bc9552006-03-21 11:24:42 +01006958 nid = spec->autocfg.speaker_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006959 if (nid)
6960 alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
6961
Takashi Iwaieb06ed82006-09-20 17:10:27 +02006962 nid = spec->autocfg.hp_pins[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01006963 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +02006964 alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006965}
Kailang Yangdf694da2005-12-05 19:42:22 +01006966
6967#define ALC260_PIN_CD_NID 0x16
6968static void alc260_auto_init_analog_input(struct hda_codec *codec)
6969{
6970 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006971 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +01006972 int i;
6973
Takashi Iwai66ceeb62010-08-30 13:05:52 +02006974 for (i = 0; i < cfg->num_inputs; i++) {
6975 hda_nid_t nid = cfg->inputs[i].pin;
Kailang Yangdf694da2005-12-05 19:42:22 +01006976 if (nid >= 0x12) {
Takashi Iwai30ea0982010-09-16 18:47:56 +02006977 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +01006978 if (nid != ALC260_PIN_CD_NID &&
6979 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02006980 snd_hda_codec_write(codec, nid, 0,
6981 AC_VERB_SET_AMP_GAIN_MUTE,
Kailang Yangdf694da2005-12-05 19:42:22 +01006982 AMP_OUT_MUTE);
6983 }
6984 }
6985}
6986
Takashi Iwai7f311a42010-04-09 17:32:23 +02006987#define alc260_auto_init_input_src alc880_auto_init_input_src
6988
Kailang Yangdf694da2005-12-05 19:42:22 +01006989/*
6990 * generic initialization of ADC, input mixers and output mixers
6991 */
6992static struct hda_verb alc260_volume_init_verbs[] = {
6993 /*
6994 * Unmute ADC0-1 and set the default input to mic-in
6995 */
6996 {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
6997 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
6998 {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
6999 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007000
Kailang Yangdf694da2005-12-05 19:42:22 +01007001 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
7002 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007003 * Note: PASD motherboards uses the Line In 2 as the input for
7004 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +01007005 */
7006 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +02007007 /* mute analog inputs */
7008 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7009 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7010 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
7011 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
7012 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +01007013
7014 /*
7015 * Set up output mixers (0x08 - 0x0a)
7016 */
7017 /* set vol=0 to output mixers */
7018 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7019 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7020 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
7021 /* set up input amps for analog loopback */
7022 /* Amp Indices: DAC = 0, mixer = 1 */
7023 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7024 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7025 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7026 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7027 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7028 {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +02007029
Kailang Yangdf694da2005-12-05 19:42:22 +01007030 { }
7031};
7032
7033static int alc260_parse_auto_config(struct hda_codec *codec)
7034{
7035 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007036 int err;
7037 static hda_nid_t alc260_ignore[] = { 0x17, 0 };
7038
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007039 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
7040 alc260_ignore);
7041 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007042 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007043 err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
7044 if (err < 0)
Takashi Iwai4a471b72005-12-07 13:56:29 +01007045 return err;
Takashi Iwai603c4012008-07-30 15:01:44 +02007046 if (!spec->kctls.list)
Kailang Yangdf694da2005-12-05 19:42:22 +01007047 return 0; /* can't find valid BIOS pin config */
Takashi Iwai05f5f472009-08-25 13:10:18 +02007048 err = alc260_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007049 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +01007050 return err;
7051
7052 spec->multiout.max_channels = 2;
7053
Takashi Iwai0852d7a2009-02-11 11:35:15 +01007054 if (spec->autocfg.dig_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +01007055 spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
Takashi Iwai603c4012008-07-30 15:01:44 +02007056 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +01007057 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +01007058
Takashi Iwaid88897e2008-10-31 15:01:37 +01007059 add_verb(spec, alc260_volume_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +01007060
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007061 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -02007062 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +01007063
Kailang Yang6227cdc2010-02-25 08:36:52 +01007064 alc_ssid_check(codec, 0x10, 0x15, 0x0f, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +02007065
Kailang Yangdf694da2005-12-05 19:42:22 +01007066 return 1;
7067}
7068
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007069/* additional initialization for auto-configuration model */
7070static void alc260_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +01007071{
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007072 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007073 alc260_auto_init_multi_out(codec);
7074 alc260_auto_init_analog_input(codec);
Takashi Iwai7f311a42010-04-09 17:32:23 +02007075 alc260_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +02007076 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +01007077 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +02007078 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +01007079}
7080
Takashi Iwaicb53c622007-08-10 17:21:45 +02007081#ifdef CONFIG_SND_HDA_POWER_SAVE
7082static struct hda_amp_list alc260_loopbacks[] = {
7083 { 0x07, HDA_INPUT, 0 },
7084 { 0x07, HDA_INPUT, 1 },
7085 { 0x07, HDA_INPUT, 2 },
7086 { 0x07, HDA_INPUT, 3 },
7087 { 0x07, HDA_INPUT, 4 },
7088 { } /* end */
7089};
7090#endif
7091
Kailang Yangdf694da2005-12-05 19:42:22 +01007092/*
Takashi Iwaifc091762010-08-04 23:53:36 +02007093 * Pin config fixes
7094 */
7095enum {
7096 PINFIX_HP_DC5750,
7097};
7098
Takashi Iwaifc091762010-08-04 23:53:36 +02007099static const struct alc_fixup alc260_fixups[] = {
7100 [PINFIX_HP_DC5750] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007101 .type = ALC_FIXUP_PINS,
7102 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +02007103 { 0x11, 0x90130110 }, /* speaker */
7104 { }
7105 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007106 },
7107};
7108
7109static struct snd_pci_quirk alc260_fixup_tbl[] = {
7110 SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", PINFIX_HP_DC5750),
7111 {}
7112};
7113
7114/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007115 * ALC260 configurations
7116 */
Takashi Iwaiea734962011-01-17 11:29:34 +01007117static const char * const alc260_models[ALC260_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007118 [ALC260_BASIC] = "basic",
7119 [ALC260_HP] = "hp",
7120 [ALC260_HP_3013] = "hp-3013",
Takashi Iwai2922c9a2008-08-27 18:12:42 +02007121 [ALC260_HP_DC7600] = "hp-dc7600",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007122 [ALC260_FUJITSU_S702X] = "fujitsu",
7123 [ALC260_ACER] = "acer",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007124 [ALC260_WILL] = "will",
7125 [ALC260_REPLACER_672V] = "replacer",
Michael Schwingencc959482009-02-22 18:58:45 +01007126 [ALC260_FAVORIT100] = "favorit100",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007127#ifdef CONFIG_SND_DEBUG
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007128 [ALC260_TEST] = "test",
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007129#endif
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007130 [ALC260_AUTO] = "auto",
7131};
7132
7133static struct snd_pci_quirk alc260_cfg_tbl[] = {
Jonathan Woithebd869482006-11-28 11:35:52 +01007134 SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
Daniel T Chen950200e2009-12-13 14:11:02 -05007135 SND_PCI_QUIRK(0x1025, 0x007f, "Acer", ALC260_WILL),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007136 SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
Michael Schwingencc959482009-02-22 18:58:45 +01007137 SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FAVORIT100),
Takashi Iwai9720b712007-03-13 21:46:23 +01007138 SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
Takashi Iwai4ac55982009-11-10 16:08:45 +01007139 SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_AUTO), /* no quirk */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007140 SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
Jaroslav Kysela34ec8a02008-07-10 14:49:19 +02007141 SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP_3013),
Kailang Yang3f878302008-08-26 13:02:23 +02007142 SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_DC7600),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007143 SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
7144 SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
7145 SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
7146 SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
7147 SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
7148 SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
7149 SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
7150 SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
7151 SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007152 SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01007153 SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
Takashi Iwai16ded522005-06-10 19:58:24 +02007154 {}
7155};
7156
Kailang Yangdf694da2005-12-05 19:42:22 +01007157static struct alc_config_preset alc260_presets[] = {
7158 [ALC260_BASIC] = {
7159 .mixers = { alc260_base_output_mixer,
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007160 alc260_input_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007161 .init_verbs = { alc260_init_verbs },
7162 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7163 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007164 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
Takashi Iwai9c4cc0b2010-03-15 09:07:52 +01007165 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007166 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7167 .channel_mode = alc260_modes,
7168 .input_mux = &alc260_capture_source,
7169 },
7170 [ALC260_HP] = {
Takashi Iwaibec15c32008-01-28 18:16:30 +01007171 .mixers = { alc260_hp_output_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007172 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007173 .init_verbs = { alc260_init_verbs,
7174 alc260_hp_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007175 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7176 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007177 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7178 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007179 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7180 .channel_mode = alc260_modes,
7181 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007182 .unsol_event = alc260_hp_unsol_event,
7183 .init_hook = alc260_hp_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007184 },
Kailang Yang3f878302008-08-26 13:02:23 +02007185 [ALC260_HP_DC7600] = {
7186 .mixers = { alc260_hp_dc7600_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007187 alc260_input_mixer },
Kailang Yang3f878302008-08-26 13:02:23 +02007188 .init_verbs = { alc260_init_verbs,
7189 alc260_hp_dc7600_verbs },
7190 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7191 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007192 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7193 .adc_nids = alc260_adc_nids_alt,
Kailang Yang3f878302008-08-26 13:02:23 +02007194 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7195 .channel_mode = alc260_modes,
7196 .input_mux = &alc260_capture_source,
7197 .unsol_event = alc260_hp_3012_unsol_event,
7198 .init_hook = alc260_hp_3012_automute,
7199 },
Kailang Yangdf694da2005-12-05 19:42:22 +01007200 [ALC260_HP_3013] = {
7201 .mixers = { alc260_hp_3013_mixer,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007202 alc260_input_mixer },
Takashi Iwaibec15c32008-01-28 18:16:30 +01007203 .init_verbs = { alc260_hp_3013_init_verbs,
7204 alc260_hp_3013_unsol_verbs },
Kailang Yangdf694da2005-12-05 19:42:22 +01007205 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7206 .dac_nids = alc260_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007207 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt),
7208 .adc_nids = alc260_adc_nids_alt,
Kailang Yangdf694da2005-12-05 19:42:22 +01007209 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7210 .channel_mode = alc260_modes,
7211 .input_mux = &alc260_capture_source,
Takashi Iwaibec15c32008-01-28 18:16:30 +01007212 .unsol_event = alc260_hp_3013_unsol_event,
7213 .init_hook = alc260_hp_3013_automute,
Kailang Yangdf694da2005-12-05 19:42:22 +01007214 },
7215 [ALC260_FUJITSU_S702X] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007216 .mixers = { alc260_fujitsu_mixer },
Kailang Yangdf694da2005-12-05 19:42:22 +01007217 .init_verbs = { alc260_fujitsu_init_verbs },
7218 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7219 .dac_nids = alc260_dac_nids,
Jonathan Woithed57fdac2006-02-28 11:38:35 +01007220 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7221 .adc_nids = alc260_dual_adc_nids,
Kailang Yangdf694da2005-12-05 19:42:22 +01007222 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7223 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007224 .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
7225 .input_mux = alc260_fujitsu_capture_sources,
Kailang Yangdf694da2005-12-05 19:42:22 +01007226 },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007227 [ALC260_ACER] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007228 .mixers = { alc260_acer_mixer },
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007229 .init_verbs = { alc260_acer_init_verbs },
7230 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7231 .dac_nids = alc260_dac_nids,
7232 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7233 .adc_nids = alc260_dual_adc_nids,
7234 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7235 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007236 .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
7237 .input_mux = alc260_acer_capture_sources,
Jonathan Woithe0bfc90e2006-02-28 11:45:11 +01007238 },
Michael Schwingencc959482009-02-22 18:58:45 +01007239 [ALC260_FAVORIT100] = {
7240 .mixers = { alc260_favorit100_mixer },
7241 .init_verbs = { alc260_favorit100_init_verbs },
7242 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7243 .dac_nids = alc260_dac_nids,
7244 .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
7245 .adc_nids = alc260_dual_adc_nids,
7246 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7247 .channel_mode = alc260_modes,
7248 .num_mux_defs = ARRAY_SIZE(alc260_favorit100_capture_sources),
7249 .input_mux = alc260_favorit100_capture_sources,
7250 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007251 [ALC260_WILL] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007252 .mixers = { alc260_will_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007253 .init_verbs = { alc260_init_verbs, alc260_will_verbs },
7254 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7255 .dac_nids = alc260_dac_nids,
7256 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7257 .adc_nids = alc260_adc_nids,
7258 .dig_out_nid = ALC260_DIGOUT_NID,
7259 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7260 .channel_mode = alc260_modes,
7261 .input_mux = &alc260_capture_source,
7262 },
7263 [ALC260_REPLACER_672V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007264 .mixers = { alc260_replacer_672v_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +02007265 .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
7266 .num_dacs = ARRAY_SIZE(alc260_dac_nids),
7267 .dac_nids = alc260_dac_nids,
7268 .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
7269 .adc_nids = alc260_adc_nids,
7270 .dig_out_nid = ALC260_DIGOUT_NID,
7271 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7272 .channel_mode = alc260_modes,
7273 .input_mux = &alc260_capture_source,
7274 .unsol_event = alc260_replacer_672v_unsol_event,
7275 .init_hook = alc260_replacer_672v_automute,
7276 },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007277#ifdef CONFIG_SND_DEBUG
7278 [ALC260_TEST] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007279 .mixers = { alc260_test_mixer },
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007280 .init_verbs = { alc260_test_init_verbs },
7281 .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
7282 .dac_nids = alc260_test_dac_nids,
7283 .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
7284 .adc_nids = alc260_test_adc_nids,
7285 .num_channel_mode = ARRAY_SIZE(alc260_modes),
7286 .channel_mode = alc260_modes,
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +02007287 .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
7288 .input_mux = alc260_test_capture_sources,
Jonathan Woithe7cf51e482006-02-09 12:01:26 +01007289 },
7290#endif
Kailang Yangdf694da2005-12-05 19:42:22 +01007291};
7292
Linus Torvalds1da177e2005-04-16 15:20:36 -07007293static int patch_alc260(struct hda_codec *codec)
7294{
7295 struct alc_spec *spec;
Kailang Yangdf694da2005-12-05 19:42:22 +01007296 int err, board_config;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007297
Takashi Iwaie560d8d2005-09-09 14:21:46 +02007298 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007299 if (spec == NULL)
7300 return -ENOMEM;
7301
7302 codec->spec = spec;
7303
Takashi Iwaif5fcc132006-11-24 17:07:44 +01007304 board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
7305 alc260_models,
7306 alc260_cfg_tbl);
7307 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +02007308 snd_printd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai6c627f32009-05-18 12:33:36 +02007309 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +01007310 board_config = ALC260_AUTO;
Takashi Iwai16ded522005-06-10 19:58:24 +02007311 }
7312
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007313 if (board_config == ALC260_AUTO) {
7314 alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups);
7315 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
7316 }
Takashi Iwaifc091762010-08-04 23:53:36 +02007317
Kailang Yangdf694da2005-12-05 19:42:22 +01007318 if (board_config == ALC260_AUTO) {
7319 /* automatic parse from the BIOS config */
7320 err = alc260_parse_auto_config(codec);
7321 if (err < 0) {
7322 alc_free(codec);
7323 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02007324 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +02007325 printk(KERN_INFO
7326 "hda_codec: Cannot set up configuration "
7327 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +01007328 board_config = ALC260_BASIC;
7329 }
Takashi Iwai16ded522005-06-10 19:58:24 +02007330 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07007331
Kusanagi Kouichi680cd532009-02-05 00:00:58 +09007332 err = snd_hda_attach_beep_device(codec, 0x1);
7333 if (err < 0) {
7334 alc_free(codec);
7335 return err;
7336 }
7337
Kailang Yangdf694da2005-12-05 19:42:22 +01007338 if (board_config != ALC260_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +02007339 setup_preset(codec, &alc260_presets[board_config]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07007340
Linus Torvalds1da177e2005-04-16 15:20:36 -07007341 spec->stream_analog_playback = &alc260_pcm_analog_playback;
7342 spec->stream_analog_capture = &alc260_pcm_analog_capture;
Jonathan Woithe53bacfb2010-08-08 00:17:05 +09307343 spec->stream_analog_alt_capture = &alc260_pcm_analog_capture;
Linus Torvalds1da177e2005-04-16 15:20:36 -07007344
Takashi Iwaia3bcba32005-12-06 19:05:29 +01007345 spec->stream_digital_playback = &alc260_pcm_digital_playback;
7346 spec->stream_digital_capture = &alc260_pcm_digital_capture;
7347
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007348 if (!spec->adc_nids && spec->input_mux) {
7349 /* check whether NID 0x04 is valid */
7350 unsigned int wcap = get_wcaps(codec, 0x04);
Takashi Iwaia22d5432009-07-27 12:54:26 +02007351 wcap = get_wcaps_type(wcap);
Takashi Iwai4ef0ef12008-11-03 17:47:49 +01007352 /* get type */
7353 if (wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
7354 spec->adc_nids = alc260_adc_nids_alt;
7355 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
7356 } else {
7357 spec->adc_nids = alc260_adc_nids;
7358 spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
7359 }
7360 }
Takashi Iwaib59bdf32009-08-11 09:47:30 +02007361 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01007362 set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
Takashi Iwaif9e336f2008-10-31 16:37:07 +01007363
Takashi Iwaib5bfbc62011-01-13 14:22:32 +01007364 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaifc091762010-08-04 23:53:36 +02007365
Takashi Iwai2134ea42008-01-10 16:53:55 +01007366 spec->vmaster_nid = 0x08;
7367
Linus Torvalds1da177e2005-04-16 15:20:36 -07007368 codec->patch_ops = alc_patch_ops;
Kailang Yangdf694da2005-12-05 19:42:22 +01007369 if (board_config == ALC260_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +01007370 spec->init_hook = alc260_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +02007371#ifdef CONFIG_SND_HDA_POWER_SAVE
7372 if (!spec->loopback.amplist)
7373 spec->loopback.amplist = alc260_loopbacks;
7374#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07007375
7376 return 0;
7377}
7378
Takashi Iwaie9edcee2005-06-13 14:16:38 +02007379
Linus Torvalds1da177e2005-04-16 15:20:36 -07007380/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007381 * ALC882/883/885/888/889 support
Linus Torvalds1da177e2005-04-16 15:20:36 -07007382 *
7383 * ALC882 is almost identical with ALC880 but has cleaner and more flexible
7384 * configuration. Each pin widget can choose any input DACs and a mixer.
7385 * Each ADC is connected from a mixer of all inputs. This makes possible
7386 * 6-channel independent captures.
7387 *
7388 * In addition, an independent DAC for the multi-playback (not used in this
7389 * driver yet).
7390 */
Kailang Yangdf694da2005-12-05 19:42:22 +01007391#define ALC882_DIGOUT_NID 0x06
7392#define ALC882_DIGIN_NID 0x0a
Takashi Iwai4953550a2009-06-30 15:28:30 +02007393#define ALC883_DIGOUT_NID ALC882_DIGOUT_NID
7394#define ALC883_DIGIN_NID ALC882_DIGIN_NID
7395#define ALC1200_DIGOUT_NID 0x10
7396
Linus Torvalds1da177e2005-04-16 15:20:36 -07007397
Takashi Iwaid2a6d7d2005-11-17 11:06:29 +01007398static struct hda_channel_mode alc882_ch_modes[1] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07007399 { 8, NULL }
7400};
7401
Takashi Iwai4953550a2009-06-30 15:28:30 +02007402/* DACs */
Linus Torvalds1da177e2005-04-16 15:20:36 -07007403static hda_nid_t alc882_dac_nids[4] = {
7404 /* front, rear, clfe, rear_surr */
7405 0x02, 0x03, 0x04, 0x05
7406};
Takashi Iwai4953550a2009-06-30 15:28:30 +02007407#define alc883_dac_nids alc882_dac_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007408
Takashi Iwai4953550a2009-06-30 15:28:30 +02007409/* ADCs */
Kailang Yangdf694da2005-12-05 19:42:22 +01007410#define alc882_adc_nids alc880_adc_nids
7411#define alc882_adc_nids_alt alc880_adc_nids_alt
Takashi Iwai4953550a2009-06-30 15:28:30 +02007412#define alc883_adc_nids alc882_adc_nids_alt
7413static hda_nid_t alc883_adc_nids_alt[1] = { 0x08 };
7414static hda_nid_t alc883_adc_nids_rev[2] = { 0x09, 0x08 };
7415#define alc889_adc_nids alc880_adc_nids
Linus Torvalds1da177e2005-04-16 15:20:36 -07007416
Takashi Iwaie1406342008-02-11 18:32:32 +01007417static hda_nid_t alc882_capsrc_nids[3] = { 0x24, 0x23, 0x22 };
7418static hda_nid_t alc882_capsrc_nids_alt[2] = { 0x23, 0x22 };
Takashi Iwai4953550a2009-06-30 15:28:30 +02007419#define alc883_capsrc_nids alc882_capsrc_nids_alt
7420static hda_nid_t alc883_capsrc_nids_rev[2] = { 0x22, 0x23 };
7421#define alc889_capsrc_nids alc882_capsrc_nids
Takashi Iwaie1406342008-02-11 18:32:32 +01007422
Linus Torvalds1da177e2005-04-16 15:20:36 -07007423/* input MUX */
7424/* FIXME: should be a matrix-type input source selection */
7425
7426static struct hda_input_mux alc882_capture_source = {
7427 .num_items = 4,
7428 .items = {
7429 { "Mic", 0x0 },
7430 { "Front Mic", 0x1 },
7431 { "Line", 0x2 },
7432 { "CD", 0x4 },
7433 },
7434};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007435
Takashi Iwai4953550a2009-06-30 15:28:30 +02007436#define alc883_capture_source alc882_capture_source
7437
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007438static struct hda_input_mux alc889_capture_source = {
7439 .num_items = 3,
7440 .items = {
7441 { "Front Mic", 0x0 },
7442 { "Mic", 0x3 },
7443 { "Line", 0x2 },
7444 },
7445};
7446
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007447static struct hda_input_mux mb5_capture_source = {
7448 .num_items = 3,
7449 .items = {
7450 { "Mic", 0x1 },
Alex Murrayb8f171e2010-06-14 12:08:43 +09307451 { "Line", 0x7 },
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007452 { "CD", 0x4 },
7453 },
7454};
7455
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007456static struct hda_input_mux macmini3_capture_source = {
7457 .num_items = 2,
7458 .items = {
7459 { "Line", 0x2 },
7460 { "CD", 0x4 },
7461 },
7462};
7463
Takashi Iwai4953550a2009-06-30 15:28:30 +02007464static struct hda_input_mux alc883_3stack_6ch_intel = {
7465 .num_items = 4,
7466 .items = {
7467 { "Mic", 0x1 },
7468 { "Front Mic", 0x0 },
7469 { "Line", 0x2 },
7470 { "CD", 0x4 },
7471 },
7472};
7473
7474static struct hda_input_mux alc883_lenovo_101e_capture_source = {
7475 .num_items = 2,
7476 .items = {
7477 { "Mic", 0x1 },
7478 { "Line", 0x2 },
7479 },
7480};
7481
7482static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
7483 .num_items = 4,
7484 .items = {
7485 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007486 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007487 { "Line", 0x2 },
7488 { "CD", 0x4 },
7489 },
7490};
7491
7492static struct hda_input_mux alc883_fujitsu_pi2515_capture_source = {
7493 .num_items = 2,
7494 .items = {
7495 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +01007496 { "Internal Mic", 0x1 },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007497 },
7498};
7499
7500static struct hda_input_mux alc883_lenovo_sky_capture_source = {
7501 .num_items = 3,
7502 .items = {
7503 { "Mic", 0x0 },
7504 { "Front Mic", 0x1 },
7505 { "Line", 0x4 },
7506 },
7507};
7508
7509static struct hda_input_mux alc883_asus_eee1601_capture_source = {
7510 .num_items = 2,
7511 .items = {
7512 { "Mic", 0x0 },
7513 { "Line", 0x2 },
7514 },
7515};
7516
7517static struct hda_input_mux alc889A_mb31_capture_source = {
7518 .num_items = 2,
7519 .items = {
7520 { "Mic", 0x0 },
7521 /* Front Mic (0x01) unused */
7522 { "Line", 0x2 },
7523 /* Line 2 (0x03) unused */
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02007524 /* CD (0x04) unused? */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007525 },
7526};
7527
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007528static struct hda_input_mux alc889A_imac91_capture_source = {
7529 .num_items = 2,
7530 .items = {
7531 { "Mic", 0x01 },
7532 { "Line", 0x2 }, /* Not sure! */
7533 },
7534};
7535
Takashi Iwai4953550a2009-06-30 15:28:30 +02007536/*
7537 * 2ch mode
7538 */
7539static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
7540 { 2, NULL }
7541};
7542
Kailang Yangdf694da2005-12-05 19:42:22 +01007543/*
Kailang Yang272a5272007-05-14 11:00:38 +02007544 * 2ch mode
7545 */
7546static struct hda_verb alc882_3ST_ch2_init[] = {
7547 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7548 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7549 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7550 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7551 { } /* end */
7552};
7553
7554/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007555 * 4ch mode
7556 */
7557static struct hda_verb alc882_3ST_ch4_init[] = {
7558 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7559 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7560 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7561 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7562 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7563 { } /* end */
7564};
7565
7566/*
Kailang Yang272a5272007-05-14 11:00:38 +02007567 * 6ch mode
7568 */
7569static struct hda_verb alc882_3ST_ch6_init[] = {
7570 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7571 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7572 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7573 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7574 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7575 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7576 { } /* end */
7577};
7578
Takashi Iwai4953550a2009-06-30 15:28:30 +02007579static struct hda_channel_mode alc882_3ST_6ch_modes[3] = {
Kailang Yang272a5272007-05-14 11:00:38 +02007580 { 2, alc882_3ST_ch2_init },
Takashi Iwai4953550a2009-06-30 15:28:30 +02007581 { 4, alc882_3ST_ch4_init },
Kailang Yang272a5272007-05-14 11:00:38 +02007582 { 6, alc882_3ST_ch6_init },
7583};
7584
Takashi Iwai4953550a2009-06-30 15:28:30 +02007585#define alc883_3ST_6ch_modes alc882_3ST_6ch_modes
7586
Kailang Yang272a5272007-05-14 11:00:38 +02007587/*
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04307588 * 2ch mode
7589 */
7590static struct hda_verb alc883_3ST_ch2_clevo_init[] = {
7591 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
7592 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7593 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7594 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7595 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7596 { } /* end */
7597};
7598
7599/*
7600 * 4ch mode
7601 */
7602static struct hda_verb alc883_3ST_ch4_clevo_init[] = {
7603 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7604 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7605 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7606 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7607 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7608 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7609 { } /* end */
7610};
7611
7612/*
7613 * 6ch mode
7614 */
7615static struct hda_verb alc883_3ST_ch6_clevo_init[] = {
7616 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7617 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7618 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7619 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7620 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7621 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7622 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7623 { } /* end */
7624};
7625
7626static struct hda_channel_mode alc883_3ST_6ch_clevo_modes[3] = {
7627 { 2, alc883_3ST_ch2_clevo_init },
7628 { 4, alc883_3ST_ch4_clevo_init },
7629 { 6, alc883_3ST_ch6_clevo_init },
7630};
7631
7632
7633/*
Kailang Yangdf694da2005-12-05 19:42:22 +01007634 * 6ch mode
7635 */
7636static struct hda_verb alc882_sixstack_ch6_init[] = {
7637 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7638 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7639 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7640 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7641 { } /* end */
7642};
7643
7644/*
7645 * 8ch mode
7646 */
7647static struct hda_verb alc882_sixstack_ch8_init[] = {
7648 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7649 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7650 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7651 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7652 { } /* end */
7653};
7654
7655static struct hda_channel_mode alc882_sixstack_modes[2] = {
7656 { 6, alc882_sixstack_ch6_init },
7657 { 8, alc882_sixstack_ch8_init },
7658};
7659
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007660
7661/* Macbook Air 2,1 */
7662
7663static struct hda_channel_mode alc885_mba21_ch_modes[1] = {
7664 { 2, NULL },
7665};
7666
Takashi Iwai87350ad2007-08-16 18:19:38 +02007667/*
Sasha Alexandrdef319f2009-06-16 16:00:15 -04007668 * macbook pro ALC885 can switch LineIn to LineOut without losing Mic
Takashi Iwai87350ad2007-08-16 18:19:38 +02007669 */
7670
7671/*
7672 * 2ch mode
7673 */
7674static struct hda_verb alc885_mbp_ch2_init[] = {
7675 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7676 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
7677 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
7678 { } /* end */
7679};
7680
7681/*
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007682 * 4ch mode
Takashi Iwai87350ad2007-08-16 18:19:38 +02007683 */
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007684static struct hda_verb alc885_mbp_ch4_init[] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007685 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7686 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7687 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7688 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
7689 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
7690 { } /* end */
7691};
7692
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007693static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
Takashi Iwai87350ad2007-08-16 18:19:38 +02007694 { 2, alc885_mbp_ch2_init },
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007695 { 4, alc885_mbp_ch4_init },
Takashi Iwai87350ad2007-08-16 18:19:38 +02007696};
7697
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007698/*
7699 * 2ch
7700 * Speakers/Woofer/HP = Front
7701 * LineIn = Input
7702 */
7703static struct hda_verb alc885_mb5_ch2_init[] = {
7704 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
7705 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
7706 { } /* end */
7707};
7708
7709/*
7710 * 6ch mode
7711 * Speakers/HP = Front
7712 * Woofer = LFE
7713 * LineIn = Surround
7714 */
7715static struct hda_verb alc885_mb5_ch6_init[] = {
7716 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
7717 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
7718 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
7719 { } /* end */
7720};
7721
7722static struct hda_channel_mode alc885_mb5_6ch_modes[2] = {
7723 { 2, alc885_mb5_ch2_init },
7724 { 6, alc885_mb5_ch6_init },
7725};
Takashi Iwai87350ad2007-08-16 18:19:38 +02007726
Takashi Iwaid01aecd2010-02-23 08:07:15 +01007727#define alc885_macmini3_6ch_modes alc885_mb5_6ch_modes
Takashi Iwai4953550a2009-06-30 15:28:30 +02007728
7729/*
7730 * 2ch mode
7731 */
7732static struct hda_verb alc883_4ST_ch2_init[] = {
7733 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7734 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7735 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7736 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7737 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7738 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7739 { } /* end */
7740};
7741
7742/*
7743 * 4ch mode
7744 */
7745static struct hda_verb alc883_4ST_ch4_init[] = {
7746 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7747 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7748 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7749 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7750 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7751 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7752 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7753 { } /* end */
7754};
7755
7756/*
7757 * 6ch mode
7758 */
7759static struct hda_verb alc883_4ST_ch6_init[] = {
7760 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7761 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7762 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7763 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7764 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7765 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7766 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7767 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7768 { } /* end */
7769};
7770
7771/*
7772 * 8ch mode
7773 */
7774static struct hda_verb alc883_4ST_ch8_init[] = {
7775 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7776 { 0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7777 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7778 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7779 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7780 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
7781 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7782 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7783 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7784 { } /* end */
7785};
7786
7787static struct hda_channel_mode alc883_4ST_8ch_modes[4] = {
7788 { 2, alc883_4ST_ch2_init },
7789 { 4, alc883_4ST_ch4_init },
7790 { 6, alc883_4ST_ch6_init },
7791 { 8, alc883_4ST_ch8_init },
7792};
7793
7794
7795/*
7796 * 2ch mode
7797 */
7798static struct hda_verb alc883_3ST_ch2_intel_init[] = {
7799 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7800 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7801 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7802 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7803 { } /* end */
7804};
7805
7806/*
7807 * 4ch mode
7808 */
7809static struct hda_verb alc883_3ST_ch4_intel_init[] = {
7810 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
7811 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7812 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7813 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7814 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7815 { } /* end */
7816};
7817
7818/*
7819 * 6ch mode
7820 */
7821static struct hda_verb alc883_3ST_ch6_intel_init[] = {
7822 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7823 { 0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7824 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x02 },
7825 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7826 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
7827 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
7828 { } /* end */
7829};
7830
7831static struct hda_channel_mode alc883_3ST_6ch_intel_modes[3] = {
7832 { 2, alc883_3ST_ch2_intel_init },
7833 { 4, alc883_3ST_ch4_intel_init },
7834 { 6, alc883_3ST_ch6_intel_init },
7835};
7836
7837/*
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007838 * 2ch mode
7839 */
7840static struct hda_verb alc889_ch2_intel_init[] = {
7841 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7842 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x00 },
7843 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x00 },
7844 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x00 },
7845 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
7846 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7847 { } /* end */
7848};
7849
7850/*
Takashi Iwai4953550a2009-06-30 15:28:30 +02007851 * 6ch mode
7852 */
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007853static struct hda_verb alc889_ch6_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007854 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7855 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7856 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7857 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7858 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007859 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
7860 { } /* end */
7861};
7862
7863/*
7864 * 8ch mode
7865 */
7866static struct hda_verb alc889_ch8_intel_init[] = {
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007867 { 0x14, AC_VERB_SET_CONNECT_SEL, 0x00 },
7868 { 0x19, AC_VERB_SET_CONNECT_SEL, 0x01 },
7869 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x02 },
7870 { 0x17, AC_VERB_SET_CONNECT_SEL, 0x03 },
7871 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x03 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007872 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7873 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007874 { } /* end */
7875};
7876
Wu Fengguangdd7714c2009-07-30 14:36:35 +08007877static struct hda_channel_mode alc889_8ch_intel_modes[3] = {
7878 { 2, alc889_ch2_intel_init },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02007879 { 6, alc889_ch6_intel_init },
7880 { 8, alc889_ch8_intel_init },
7881};
7882
7883/*
7884 * 6ch mode
7885 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02007886static struct hda_verb alc883_sixstack_ch6_init[] = {
7887 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
7888 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7889 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7890 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7891 { } /* end */
7892};
7893
7894/*
7895 * 8ch mode
7896 */
7897static struct hda_verb alc883_sixstack_ch8_init[] = {
7898 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7899 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7900 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7901 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
7902 { } /* end */
7903};
7904
7905static struct hda_channel_mode alc883_sixstack_modes[2] = {
7906 { 6, alc883_sixstack_ch6_init },
7907 { 8, alc883_sixstack_ch8_init },
7908};
7909
7910
Linus Torvalds1da177e2005-04-16 15:20:36 -07007911/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
7912 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
7913 */
Takashi Iwaic8b6bf92005-11-17 14:57:47 +01007914static struct snd_kcontrol_new alc882_base_mixer[] = {
Takashi Iwai05acb862005-06-10 19:50:25 +02007915 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007916 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007917 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007918 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007919 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
7920 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007921 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
7922 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Takashi Iwai05acb862005-06-10 19:50:25 +02007923 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Takashi Iwai985be542005-11-02 18:26:49 +01007924 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007925 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
7926 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
7927 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
7928 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7929 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
7930 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007931 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007932 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
7933 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007934 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007935 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Linus Torvalds1da177e2005-04-16 15:20:36 -07007936 { } /* end */
7937};
7938
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08007939/* Macbook Air 2,1 same control for HP and internal Speaker */
7940
7941static struct snd_kcontrol_new alc885_mba21_mixer[] = {
7942 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7943 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_OUTPUT),
7944 { }
7945};
7946
7947
Takashi Iwai87350ad2007-08-16 18:19:38 +02007948static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
Takashi Iwaia3f730af2009-08-31 08:15:26 +02007949 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7950 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
7951 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7952 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
7953 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
Takashi Iwai2134ea42008-01-10 16:53:55 +01007954 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
7955 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007956 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
7957 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007958 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
7959 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
Takashi Iwai87350ad2007-08-16 18:19:38 +02007960 { } /* end */
7961};
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007962
7963static struct snd_kcontrol_new alc885_mb5_mixer[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007964 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7965 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7966 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7967 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7968 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7969 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
Alex Murraya76221d2010-01-13 23:15:03 +10307970 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7971 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
Alex Murrayb8f171e2010-06-14 12:08:43 +09307972 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7973 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007974 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
7975 HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007976 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
7977 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0x00, HDA_INPUT),
Kacper Szczesniak41d55452009-05-07 12:47:43 +02007978 { } /* end */
7979};
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02007980
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007981static struct snd_kcontrol_new alc885_macmini3_mixer[] = {
7982 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7983 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
7984 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
7985 HDA_BIND_MUTE ("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
7986 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
7987 HDA_BIND_MUTE ("LFE Playback Switch", 0x0e, 0x02, HDA_INPUT),
7988 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0f, 0x00, HDA_OUTPUT),
7989 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0f, 0x02, HDA_INPUT),
7990 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x07, HDA_INPUT),
7991 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x07, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01007992 HDA_CODEC_VOLUME("Line Boost Volume", 0x15, 0x00, HDA_INPUT),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11007993 { } /* end */
7994};
7995
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007996static struct snd_kcontrol_new alc885_imac91_mixer[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07007997 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
7998 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08007999 { } /* end */
8000};
8001
8002
Kailang Yangbdd148a2007-05-08 15:19:08 +02008003static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
8004 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8005 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8006 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8007 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8008 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8009 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8010 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008011 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008012 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +02008013 { } /* end */
8014};
8015
Kailang Yang272a5272007-05-14 11:00:38 +02008016static struct snd_kcontrol_new alc882_targa_mixer[] = {
8017 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8018 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8019 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8020 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8021 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8022 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8023 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8024 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8025 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008026 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008027 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
8028 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008029 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008030 { } /* end */
8031};
8032
8033/* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
8034 * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
8035 */
8036static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
8037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8038 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
8039 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8040 HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
8041 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8042 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8043 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8044 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8045 HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
8046 HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
8047 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
8048 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008049 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02008050 { } /* end */
8051};
8052
Takashi Iwai914759b2007-09-06 14:52:04 +02008053static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
8054 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8055 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8056 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8057 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8058 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8059 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8060 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8061 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008062 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008063 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwai914759b2007-09-06 14:52:04 +02008064 { } /* end */
8065};
8066
Kailang Yangdf694da2005-12-05 19:42:22 +01008067static struct snd_kcontrol_new alc882_chmode_mixer[] = {
8068 {
8069 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
8070 .name = "Channel Mode",
8071 .info = alc_ch_mode_info,
8072 .get = alc_ch_mode_get,
8073 .put = alc_ch_mode_put,
8074 },
8075 { } /* end */
8076};
8077
Takashi Iwai4953550a2009-06-30 15:28:30 +02008078static struct hda_verb alc882_base_init_verbs[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07008079 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008080 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8081 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008082 /* Rear mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008083 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8084 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008085 /* CLFE mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008086 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8087 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008088 /* Side mixer */
Takashi Iwai05acb862005-06-10 19:50:25 +02008089 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8090 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008091
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008092 /* Front Pin: output 0 (0x0c) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008093 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008094 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008095 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008096 /* Rear Pin: output 1 (0x0d) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008097 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008098 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008099 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008100 /* CLFE Pin: output 2 (0x0e) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008101 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008102 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008103 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008104 /* Side Pin: output 3 (0x0f) */
Takashi Iwai05acb862005-06-10 19:50:25 +02008105 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai05acb862005-06-10 19:50:25 +02008106 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008107 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008108 /* Mic (rear) pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008109 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008110 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8111 /* Front Mic pin: input vref at 80% */
Takashi Iwai16ded522005-06-10 19:58:24 +02008112 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008113 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8114 /* Line In pin: input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008115 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaie9edcee2005-06-13 14:16:38 +02008116 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8117 /* Line-2 In: Headphone output (output 0 - 0x0c) */
8118 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8119 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8120 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008121 /* CD pin widget for input */
Takashi Iwai05acb862005-06-10 19:50:25 +02008122 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008123
8124 /* FIXME: use matrix-type input source selection */
8125 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008126 /* Input mixer2 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008127 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008128 /* Input mixer3 */
Takashi Iwai05acb862005-06-10 19:50:25 +02008129 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Takashi Iwai05acb862005-06-10 19:50:25 +02008130 /* ADC2: mute amp left and right */
8131 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008132 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwai05acb862005-06-10 19:50:25 +02008133 /* ADC3: mute amp left and right */
8134 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Takashi Iwai71fe7b82005-05-25 18:11:40 +02008135 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Linus Torvalds1da177e2005-04-16 15:20:36 -07008136
8137 { }
8138};
8139
Takashi Iwai4953550a2009-06-30 15:28:30 +02008140static struct hda_verb alc882_adc1_init_verbs[] = {
8141 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8142 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8143 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8144 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8145 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8146 /* ADC1: mute amp left and right */
8147 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8148 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8149 { }
8150};
8151
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008152static struct hda_verb alc882_eapd_verbs[] = {
8153 /* change to EAPD mode */
8154 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008155 {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008156 { }
Takashi Iwai4b146cb2006-07-28 14:42:36 +02008157};
8158
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008159static struct hda_verb alc889_eapd_verbs[] = {
8160 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
8161 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
8162 { }
8163};
8164
Wu Fengguang6732bd02009-07-30 09:19:14 +02008165static struct hda_verb alc_hp15_unsol_verbs[] = {
8166 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
8167 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8168 {}
8169};
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008170
8171static struct hda_verb alc885_init_verbs[] = {
8172 /* Front mixer: unmute input/output amp left and right (volume = 0) */
Kailang Yang88102f32010-02-04 14:12:58 +01008173 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8174 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008175 /* Rear mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008176 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8177 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008178 /* CLFE mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008179 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8180 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008181 /* Side mixer */
Kailang Yang88102f32010-02-04 14:12:58 +01008182 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8183 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008184
8185 /* Front HP Pin: output 0 (0x0c) */
Wu Fengguang6732bd02009-07-30 09:19:14 +02008186 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008187 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8188 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8189 /* Front Pin: output 0 (0x0c) */
8190 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8191 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8192 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8193 /* Rear Pin: output 1 (0x0d) */
8194 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8195 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8196 {0x19, AC_VERB_SET_CONNECT_SEL, 0x01},
8197 /* CLFE Pin: output 2 (0x0e) */
8198 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8199 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8200 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
8201 /* Side Pin: output 3 (0x0f) */
8202 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8203 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8204 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
8205 /* Mic (rear) pin: input vref at 80% */
8206 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8207 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8208 /* Front Mic pin: input vref at 80% */
8209 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8210 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8211 /* Line In pin: input */
8212 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8213 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8214
8215 /* Mixer elements: 0x18, , 0x1a, 0x1b */
8216 /* Input mixer1 */
Kailang Yang88102f32010-02-04 14:12:58 +01008217 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008218 /* Input mixer2 */
8219 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008220 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008221 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008222 /* ADC2: mute amp left and right */
8223 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8224 /* ADC3: mute amp left and right */
8225 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8226
8227 { }
8228};
8229
8230static struct hda_verb alc885_init_input_verbs[] = {
8231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8232 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
8233 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
8234 { }
8235};
8236
8237
8238/* Unmute Selector 24h and set the default input to front mic */
8239static struct hda_verb alc889_init_input_verbs[] = {
8240 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
8241 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8242 { }
8243};
8244
8245
Takashi Iwai4953550a2009-06-30 15:28:30 +02008246#define alc883_init_verbs alc882_base_init_verbs
8247
Tobin Davis9102cd12006-12-15 10:02:12 +01008248/* Mac Pro test */
8249static struct snd_kcontrol_new alc882_macpro_mixer[] = {
8250 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8251 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8252 HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
8253 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
8254 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008255 /* FIXME: this looks suspicious...
Jaroslav Kyselad355c82a2009-11-03 15:47:25 +01008256 HDA_CODEC_VOLUME("Beep Playback Volume", 0x0b, 0x02, HDA_INPUT),
8257 HDA_CODEC_MUTE("Beep Playback Switch", 0x0b, 0x02, HDA_INPUT),
Takashi Iwai45bdd1c2009-02-06 16:11:25 +01008258 */
Tobin Davis9102cd12006-12-15 10:02:12 +01008259 { } /* end */
8260};
8261
8262static struct hda_verb alc882_macpro_init_verbs[] = {
8263 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8264 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8265 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8266 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8267 /* Front Pin: output 0 (0x0c) */
8268 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8269 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8270 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
8271 /* Front Mic pin: input vref at 80% */
8272 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8273 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8274 /* Speaker: output */
8275 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8276 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8277 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
8278 /* Headphone output (output 0 - 0x0c) */
8279 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8280 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8281 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8282
8283 /* FIXME: use matrix-type input source selection */
8284 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8285 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8286 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8287 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8288 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8289 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8290 /* Input mixer2 */
8291 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8292 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8293 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8294 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8295 /* Input mixer3 */
8296 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8297 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8298 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8299 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8300 /* ADC1: mute amp left and right */
8301 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8302 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8303 /* ADC2: mute amp left and right */
8304 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8305 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8306 /* ADC3: mute amp left and right */
8307 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8308 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8309
8310 { }
8311};
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02008312
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008313/* Macbook 5,1 */
8314static struct hda_verb alc885_mb5_init_verbs[] = {
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008315 /* DACs */
8316 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8317 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8318 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8319 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008320 /* Front mixer */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008321 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8322 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8323 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008324 /* Surround mixer */
8325 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8326 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8327 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8328 /* LFE mixer */
8329 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8330 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8331 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8332 /* HP mixer */
8333 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8334 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8335 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8336 /* Front Pin (0x0c) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008337 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8338 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008339 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8340 /* LFE Pin (0x0e) */
8341 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8342 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8343 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8344 /* HP Pin (0x0f) */
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008345 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8346 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kacper Szczesniak92b9de82009-06-02 00:55:19 +02008347 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
Alex Murraya76221d2010-01-13 23:15:03 +10308348 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008349 /* Front Mic pin: input vref at 80% */
8350 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8351 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8352 /* Line In pin */
8353 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8354 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8355
Alex Murrayb8f171e2010-06-14 12:08:43 +09308356 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0x1)},
8357 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x7)},
8358 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0x4)},
Kacper Szczesniak41d55452009-05-07 12:47:43 +02008359 { }
8360};
8361
Luke Yelaviche458b1f2010-02-12 16:28:29 +11008362/* Macmini 3,1 */
8363static struct hda_verb alc885_macmini3_init_verbs[] = {
8364 /* DACs */
8365 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8366 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8367 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8368 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8369 /* Front mixer */
8370 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8371 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8372 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8373 /* Surround mixer */
8374 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8375 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8376 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8377 /* LFE mixer */
8378 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8380 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8381 /* HP mixer */
8382 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8383 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8384 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8385 /* Front Pin (0x0c) */
8386 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8387 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8388 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8389 /* LFE Pin (0x0e) */
8390 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x01},
8391 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8392 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02},
8393 /* HP Pin (0x0f) */
8394 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8395 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8396 {0x14, AC_VERB_SET_CONNECT_SEL, 0x03},
8397 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8398 /* Line In pin */
8399 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8400 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8401
8402 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8403 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8404 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8405 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8406 { }
8407};
8408
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008409
8410static struct hda_verb alc885_mba21_init_verbs[] = {
8411 /*Internal and HP Speaker Mixer*/
8412 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8413 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8414 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8415 /*Internal Speaker Pin (0x0c)*/
8416 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8417 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8418 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8419 /* HP Pin: output 0 (0x0e) */
8420 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
8421 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8422 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8423 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8424 /* Line in (is hp when jack connected)*/
8425 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8426 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8427
8428 { }
8429 };
8430
8431
Takashi Iwai87350ad2007-08-16 18:19:38 +02008432/* Macbook Pro rev3 */
8433static struct hda_verb alc885_mbp3_init_verbs[] = {
8434 /* Front mixer: unmute input/output amp left and right (volume = 0) */
8435 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8436 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8437 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8438 /* Rear mixer */
8439 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8440 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8441 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008442 /* HP mixer */
8443 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8444 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8445 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008446 /* Front Pin: output 0 (0x0c) */
8447 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8448 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8449 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008450 /* HP Pin: output 0 (0x0e) */
Takashi Iwai87350ad2007-08-16 18:19:38 +02008451 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
Takashi Iwaia3f730af2009-08-31 08:15:26 +02008452 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8453 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
Takashi Iwai87350ad2007-08-16 18:19:38 +02008454 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8455 /* Mic (rear) pin: input vref at 80% */
8456 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8457 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8458 /* Front Mic pin: input vref at 80% */
8459 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8460 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8461 /* Line In pin: use output 1 when in LineOut mode */
8462 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
8463 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8464 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
8465
8466 /* FIXME: use matrix-type input source selection */
8467 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
8468 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
8469 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8470 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8471 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8472 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8473 /* Input mixer2 */
8474 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8475 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8476 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8477 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8478 /* Input mixer3 */
8479 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8480 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8481 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8482 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
8483 /* ADC1: mute amp left and right */
8484 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8485 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
8486 /* ADC2: mute amp left and right */
8487 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8488 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8489 /* ADC3: mute amp left and right */
8490 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8491 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8492
8493 { }
8494};
8495
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008496/* iMac 9,1 */
8497static struct hda_verb alc885_imac91_init_verbs[] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008498 /* Internal Speaker Pin (0x0c) */
8499 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8500 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8501 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8502 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, (PIN_OUT | AC_PINCTL_VREF_50) },
8503 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8504 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8505 /* HP Pin: Rear */
8506 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8507 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8508 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8509 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, (ALC880_HP_EVENT | AC_USRSP_EN)},
8510 /* Line in Rear */
8511 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, AC_PINCTL_VREF_50},
8512 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8513 /* Front Mic pin: input vref at 80% */
8514 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8515 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008516 /* Rear mixer */
8517 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8518 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8519 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008520 /* Line-Out mixer: unmute input/output amp left and right (volume = 0) */
8521 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8522 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8523 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
8524 /* 0x24 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008525 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8526 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8527 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8528 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008529 /* 0x23 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008530 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8531 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8532 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8533 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008534 /* 0x22 [Audio Mixer] wcaps 0x20010b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008535 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8536 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
8537 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
8538 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008539 /* 0x07 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008540 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8541 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008542 /* 0x08 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008543 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8544 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008545 /* 0x09 [Audio Input] wcaps 0x10011b: Stereo Amp-In */
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008546 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
8547 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008548 { }
8549};
8550
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008551/* iMac 24 mixer. */
8552static struct snd_kcontrol_new alc885_imac24_mixer[] = {
8553 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
8554 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
8555 { } /* end */
8556};
8557
8558/* iMac 24 init verbs. */
8559static struct hda_verb alc885_imac24_init_verbs[] = {
8560 /* Internal speakers: output 0 (0x0c) */
8561 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8562 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8563 {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
8564 /* Internal speakers: output 0 (0x0c) */
8565 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8566 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8567 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
8568 /* Headphone: output 0 (0x0c) */
8569 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8570 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
8571 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
8572 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
8573 /* Front Mic: input vref at 80% */
8574 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
8575 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
8576 { }
8577};
8578
8579/* Toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008580static void alc885_imac24_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008581{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008582 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008583
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008584 spec->autocfg.hp_pins[0] = 0x14;
8585 spec->autocfg.speaker_pins[0] = 0x18;
8586 spec->autocfg.speaker_pins[1] = 0x1a;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008587}
8588
Takashi Iwai9d54f082010-02-22 08:34:40 +01008589#define alc885_mb5_setup alc885_imac24_setup
8590#define alc885_macmini3_setup alc885_imac24_setup
8591
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08008592/* Macbook Air 2,1 */
8593static void alc885_mba21_setup(struct hda_codec *codec)
8594{
8595 struct alc_spec *spec = codec->spec;
8596
8597 spec->autocfg.hp_pins[0] = 0x14;
8598 spec->autocfg.speaker_pins[0] = 0x18;
8599}
8600
8601
8602
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008603static void alc885_mbp3_setup(struct hda_codec *codec)
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008604{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008605 struct alc_spec *spec = codec->spec;
Nicola Fagnanic54728d2007-07-19 23:28:52 +02008606
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008607 spec->autocfg.hp_pins[0] = 0x15;
8608 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai87350ad2007-08-16 18:19:38 +02008609}
8610
Takashi Iwai9d54f082010-02-22 08:34:40 +01008611static void alc885_imac91_setup(struct hda_codec *codec)
Alex Murraya76221d2010-01-13 23:15:03 +10308612{
Takashi Iwai9d54f082010-02-22 08:34:40 +01008613 struct alc_spec *spec = codec->spec;
Alex Murraya76221d2010-01-13 23:15:03 +10308614
Takashi Iwai9d54f082010-02-22 08:34:40 +01008615 spec->autocfg.hp_pins[0] = 0x14;
Justin P. Mattockb7cccc52010-05-23 10:55:00 -07008616 spec->autocfg.speaker_pins[0] = 0x18;
Takashi Iwai9d54f082010-02-22 08:34:40 +01008617 spec->autocfg.speaker_pins[1] = 0x1a;
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08008618}
Takashi Iwai87350ad2007-08-16 18:19:38 +02008619
Kailang Yang272a5272007-05-14 11:00:38 +02008620static struct hda_verb alc882_targa_verbs[] = {
8621 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8622 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8623
8624 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8625 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008626
Kailang Yang272a5272007-05-14 11:00:38 +02008627 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8628 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8629 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8630
8631 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yang272a5272007-05-14 11:00:38 +02008632 { } /* end */
8633};
8634
8635/* toggle speaker-output according to the hp-jack state */
8636static void alc882_targa_automute(struct hda_codec *codec)
8637{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008638 struct alc_spec *spec = codec->spec;
8639 alc_automute_amp(codec);
Takashi Iwai82beb8f2007-08-10 17:09:26 +02008640 snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008641 spec->jack_present ? 1 : 3);
8642}
8643
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008644static void alc882_targa_setup(struct hda_codec *codec)
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008645{
8646 struct alc_spec *spec = codec->spec;
8647
8648 spec->autocfg.hp_pins[0] = 0x14;
8649 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang272a5272007-05-14 11:00:38 +02008650}
8651
8652static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
8653{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02008654 if ((res >> 26) == ALC880_HP_EVENT)
Kailang Yang272a5272007-05-14 11:00:38 +02008655 alc882_targa_automute(codec);
Kailang Yang272a5272007-05-14 11:00:38 +02008656}
8657
8658static struct hda_verb alc882_asus_a7j_verbs[] = {
8659 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8660 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8661
8662 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8663 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8664 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008665
Kailang Yang272a5272007-05-14 11:00:38 +02008666 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8667 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8668 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8669
8670 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8671 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8672 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8673 { } /* end */
8674};
8675
Takashi Iwai914759b2007-09-06 14:52:04 +02008676static struct hda_verb alc882_asus_a7m_verbs[] = {
8677 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8678 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8679
8680 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
8681 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
8682 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02008683
Takashi Iwai914759b2007-09-06 14:52:04 +02008684 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8685 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8686 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
8687
8688 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
8689 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
8690 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
8691 { } /* end */
8692};
8693
Tobin Davis9102cd12006-12-15 10:02:12 +01008694static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
8695{
8696 unsigned int gpiostate, gpiomask, gpiodir;
8697
8698 gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
8699 AC_VERB_GET_GPIO_DATA, 0);
8700
8701 if (!muted)
8702 gpiostate |= (1 << pin);
8703 else
8704 gpiostate &= ~(1 << pin);
8705
8706 gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
8707 AC_VERB_GET_GPIO_MASK, 0);
8708 gpiomask |= (1 << pin);
8709
8710 gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
8711 AC_VERB_GET_GPIO_DIRECTION, 0);
8712 gpiodir |= (1 << pin);
8713
8714
8715 snd_hda_codec_write(codec, codec->afg, 0,
8716 AC_VERB_SET_GPIO_MASK, gpiomask);
8717 snd_hda_codec_write(codec, codec->afg, 0,
8718 AC_VERB_SET_GPIO_DIRECTION, gpiodir);
8719
8720 msleep(1);
8721
8722 snd_hda_codec_write(codec, codec->afg, 0,
8723 AC_VERB_SET_GPIO_DATA, gpiostate);
8724}
8725
Takashi Iwai7debbe52007-08-16 15:01:03 +02008726/* set up GPIO at initialization */
8727static void alc885_macpro_init_hook(struct hda_codec *codec)
8728{
8729 alc882_gpio_mute(codec, 0, 0);
8730 alc882_gpio_mute(codec, 1, 0);
8731}
8732
8733/* set up GPIO and update auto-muting at initialization */
8734static void alc885_imac24_init_hook(struct hda_codec *codec)
8735{
8736 alc885_macpro_init_hook(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +02008737 alc_automute_amp(codec);
Takashi Iwai7debbe52007-08-16 15:01:03 +02008738}
8739
Kailang Yangdf694da2005-12-05 19:42:22 +01008740/*
8741 * generic initialization of ADC, input mixers and output mixers
8742 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02008743static struct hda_verb alc883_auto_init_verbs[] = {
Kailang Yangdf694da2005-12-05 19:42:22 +01008744 /*
8745 * Unmute ADC0-2 and set the default input to mic-in
8746 */
Kailang Yangdf694da2005-12-05 19:42:22 +01008747 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
8748 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8749 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
8750 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8751
Kailang Yangdf694da2005-12-05 19:42:22 +01008752 /*
8753 * Set up output mixers (0x0c - 0x0f)
8754 */
8755 /* set vol=0 to output mixers */
8756 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8757 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8758 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8759 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
8760 /* set up input amps for analog loopback */
8761 /* Amp Indices: DAC = 0, mixer = 1 */
8762 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8763 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8764 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8765 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8766 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8767 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8768 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8769 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8770 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
8771 {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
8772
8773 /* FIXME: use matrix-type input source selection */
8774 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
Kailang Yangdf694da2005-12-05 19:42:22 +01008775 /* Input mixer2 */
Kailang Yang88102f32010-02-04 14:12:58 +01008776 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008777 /* Input mixer3 */
Kailang Yang88102f32010-02-04 14:12:58 +01008778 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangdf694da2005-12-05 19:42:22 +01008779 { }
8780};
8781
Torben Schulzeb4c41d2009-05-18 15:02:35 +02008782/* 2ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:front) */
8783static struct hda_verb alc889A_mb31_ch2_init[] = {
8784 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8785 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8786 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8787 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8788 { } /* end */
8789};
8790
8791/* 4ch mode (Speaker:front, Subwoofer:CLFE, Line:CLFE, Headphones:front) */
8792static struct hda_verb alc889A_mb31_ch4_init[] = {
8793 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP as front */
8794 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8795 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8796 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8797 { } /* end */
8798};
8799
8800/* 5ch mode (Speaker:front, Subwoofer:CLFE, Line:input, Headphones:rear) */
8801static struct hda_verb alc889A_mb31_ch5_init[] = {
8802 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as rear */
8803 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Subwoofer on */
8804 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Line as input */
8805 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Line off */
8806 { } /* end */
8807};
8808
8809/* 6ch mode (Speaker:front, Subwoofer:off, Line:CLFE, Headphones:Rear) */
8810static struct hda_verb alc889A_mb31_ch6_init[] = {
8811 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* HP as front */
8812 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Subwoofer off */
8813 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, /* Line as output */
8814 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Line on */
8815 { } /* end */
8816};
8817
8818static struct hda_channel_mode alc889A_mb31_6ch_modes[4] = {
8819 { 2, alc889A_mb31_ch2_init },
8820 { 4, alc889A_mb31_ch4_init },
8821 { 5, alc889A_mb31_ch5_init },
8822 { 6, alc889A_mb31_ch6_init },
8823};
8824
Andrew L. Neporadab373bde2006-11-07 11:37:08 +01008825static struct hda_verb alc883_medion_eapd_verbs[] = {
8826 /* eanable EAPD on medion laptop */
8827 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
8828 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
8829 { }
8830};
8831
Takashi Iwai4953550a2009-06-30 15:28:30 +02008832#define alc883_base_mixer alc882_base_mixer
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008833
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008834static struct snd_kcontrol_new alc883_mitac_mixer[] = {
8835 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8836 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8837 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8838 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8839 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8840 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8841 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8842 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008843 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008844 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8845 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008846 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008847 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01008848 { } /* end */
8849};
8850
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01008851static struct snd_kcontrol_new alc883_clevo_m720_mixer[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01008852 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8853 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8854 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8855 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8856 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008857 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008858 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008859 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008860 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008861 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe368c7a92008-03-04 11:20:33 +01008862 { } /* end */
8863};
8864
Jiang zhefb97dc62008-03-06 11:07:11 +01008865static struct snd_kcontrol_new alc883_2ch_fujitsu_pi2515_mixer[] = {
8866 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8867 HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
8868 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8869 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
8870 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008871 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008872 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008873 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008874 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01008875 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhefb97dc62008-03-06 11:07:11 +01008876 { } /* end */
8877};
8878
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008879static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
8880 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8881 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8882 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8883 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8884 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8885 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8886 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8887 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008888 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008889 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8890 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008891 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008892 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008893 { } /* end */
8894};
8895
8896static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
8897 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8898 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8899 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8900 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8901 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8902 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8903 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8904 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8905 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8906 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8907 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8908 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8909 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8910 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008911 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008912 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8913 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008914 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008915 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +02008916 { } /* end */
8917};
8918
Jiang zhe17bba1b2008-06-04 12:11:07 +02008919static struct snd_kcontrol_new alc883_3ST_6ch_intel_mixer[] = {
8920 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8921 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8922 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8923 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8924 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8925 HDA_OUTPUT),
8926 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8927 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8928 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8929 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8930 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8931 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8932 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8933 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8934 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008935 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008936 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
8937 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008938 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008939 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Jiang zhe17bba1b2008-06-04 12:11:07 +02008940 { } /* end */
8941};
8942
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008943static struct snd_kcontrol_new alc885_8ch_intel_mixer[] = {
8944 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
8945 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
8946 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8947 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8948 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0,
8949 HDA_OUTPUT),
8950 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8951 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8952 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
8953 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
8954 HDA_BIND_MUTE("Speaker Playback Switch", 0x0f, 2, HDA_INPUT),
8955 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
8956 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8957 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8958 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008959 HDA_CODEC_VOLUME("Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
8961 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008962 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02008963 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8964 { } /* end */
8965};
8966
Takashi Iwaid1d985f2006-11-23 19:27:12 +01008967static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
Tobin Davisc07584c2006-10-13 12:32:16 +02008968 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008969 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008970 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008971 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008972 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8973 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
Takashi Iwai0701e062008-06-27 16:30:57 +02008974 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
8975 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008976 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
8977 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
8978 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
8979 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
8980 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
8981 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008982 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008983 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
8984 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01008985 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008986 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Tobin Davisc07584c2006-10-13 12:32:16 +02008987 { } /* end */
8988};
8989
Sasha Alexandrc2592492009-06-16 14:52:54 -04008990static struct snd_kcontrol_new alc883_targa_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02008991 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008992 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008993 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02008994 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02008995 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
8996 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
8997 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
8998 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
8999 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
9000 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
9001 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9002 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9003 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9004 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9005 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009006 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009007 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009008 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009009};
Kailang Yangccc656c2006-10-17 12:32:26 +02009010
Sasha Alexandrc2592492009-06-16 14:52:54 -04009011static struct snd_kcontrol_new alc883_targa_2ch_mixer[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009012 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009013 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009014 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009015 HDA_CODEC_MUTE("Speaker Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009016 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9017 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9018 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009019 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009020 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009021 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009022 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009023 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangccc656c2006-10-17 12:32:26 +02009024 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009025};
Kailang Yangccc656c2006-10-17 12:32:26 +02009026
Takashi Iwaib99dba32009-09-17 18:23:00 +02009027static struct snd_kcontrol_new alc883_targa_8ch_mixer[] = {
9028 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9029 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009030 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009031 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009032 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwaib99dba32009-09-17 18:23:00 +02009033 { } /* end */
9034};
9035
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009036static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
9037 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9038 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +01009039 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
9040 HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009041 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
9042 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009043 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009044 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009045 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +02009046};
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009047
Kailang Yang272a5272007-05-14 11:00:38 +02009048static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
9049 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9050 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
9051 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9052 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9053 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9054 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
9055 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +01009056 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
9057 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +02009058 { } /* end */
Kailang Yangea1fb292008-08-26 12:58:38 +02009059};
Kailang Yang272a5272007-05-14 11:00:38 +02009060
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009061static struct snd_kcontrol_new alc883_medion_wim2160_mixer[] = {
9062 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9063 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9064 HDA_CODEC_MUTE("Speaker Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9065 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
9066 HDA_CODEC_VOLUME("Line Playback Volume", 0x08, 0x0, HDA_INPUT),
9067 HDA_CODEC_MUTE("Line Playback Switch", 0x08, 0x0, HDA_INPUT),
9068 { } /* end */
9069};
9070
9071static struct hda_verb alc883_medion_wim2160_verbs[] = {
9072 /* Unmute front mixer */
9073 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9074 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9075
9076 /* Set speaker pin to front mixer */
9077 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9078
9079 /* Init headphone pin */
9080 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9081 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9082 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9083 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9084
9085 { } /* end */
9086};
9087
9088/* toggle speaker-output according to the hp-jack state */
9089static void alc883_medion_wim2160_setup(struct hda_codec *codec)
9090{
9091 struct alc_spec *spec = codec->spec;
9092
9093 spec->autocfg.hp_pins[0] = 0x1a;
9094 spec->autocfg.speaker_pins[0] = 0x15;
9095}
9096
Tobin Davis2880a862007-08-07 11:50:26 +02009097static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
Kailang Yangd1a991a2007-08-15 16:21:59 +02009098 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9099 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009100 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009101 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9102 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009103 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009104 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangd1a991a2007-08-15 16:21:59 +02009105 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Tobin Davis2880a862007-08-07 11:50:26 +02009106 { } /* end */
Kailang Yangd1a991a2007-08-15 16:21:59 +02009107};
Tobin Davis2880a862007-08-07 11:50:26 +02009108
Tony Vroond2fd4b02009-06-21 00:40:10 +01009109static struct snd_kcontrol_new alc888_acer_aspire_6530_mixer[] = {
9110 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009111 HDA_CODEC_VOLUME("LFE Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
Tony Vroon684a8842009-06-26 09:27:50 +01009112 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9113 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009114 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9115 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
9116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009117 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroond2fd4b02009-06-21 00:40:10 +01009118 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9119 { } /* end */
9120};
9121
Kailang Yange2757d52008-08-26 13:17:46 +02009122static struct snd_kcontrol_new alc888_lenovo_sky_mixer[] = {
9123 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9124 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9125 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
9126 HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
9127 HDA_CODEC_VOLUME_MONO("Center Playback Volume",
9128 0x0d, 1, 0x0, HDA_OUTPUT),
9129 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
9130 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
9131 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
9132 HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
9133 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009134 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
9135 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, 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 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009139 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009140 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
9141 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009142 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009143 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009144 { } /* end */
9145};
9146
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009147static struct snd_kcontrol_new alc889A_mb31_mixer[] = {
9148 /* Output mixers */
9149 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
9150 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 0x02, HDA_INPUT),
9151 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
9152 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 0x02, HDA_INPUT),
9153 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x00,
9154 HDA_OUTPUT),
9155 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x02, HDA_INPUT),
9156 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x00, HDA_OUTPUT),
9157 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x02, HDA_INPUT),
9158 /* Output switches */
9159 HDA_CODEC_MUTE("Enable Speaker", 0x14, 0x00, HDA_OUTPUT),
9160 HDA_CODEC_MUTE("Enable Headphones", 0x15, 0x00, HDA_OUTPUT),
9161 HDA_CODEC_MUTE_MONO("Enable LFE", 0x16, 2, 0x00, HDA_OUTPUT),
9162 /* Boost mixers */
David Henningsson5f99f862011-01-04 15:24:24 +01009163 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0x00, HDA_INPUT),
9164 HDA_CODEC_VOLUME("Line Boost Volume", 0x1a, 0x00, HDA_INPUT),
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009165 /* Input mixers */
9166 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
9167 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
9168 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9169 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9170 { } /* end */
9171};
9172
Guido Günther3e1647c2009-06-05 00:47:26 +02009173static struct snd_kcontrol_new alc883_vaiott_mixer[] = {
9174 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9175 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9176 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
9177 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009178 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
Guido Günther3e1647c2009-06-05 00:47:26 +02009179 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
9180 { } /* end */
9181};
9182
Kailang Yange2757d52008-08-26 13:17:46 +02009183static struct hda_bind_ctls alc883_bind_cap_vol = {
9184 .ops = &snd_hda_bind_vol,
9185 .values = {
9186 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9187 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9188 0
9189 },
9190};
9191
9192static struct hda_bind_ctls alc883_bind_cap_switch = {
9193 .ops = &snd_hda_bind_sw,
9194 .values = {
9195 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
9196 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
9197 0
9198 },
9199};
9200
9201static struct snd_kcontrol_new alc883_asus_eee1601_mixer[] = {
9202 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
9203 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
9204 HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
9205 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
9206 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
9207 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +01009208 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yange2757d52008-08-26 13:17:46 +02009209 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Takashi Iwaif9e336f2008-10-31 16:37:07 +01009210 { } /* end */
9211};
9212
9213static struct snd_kcontrol_new alc883_asus_eee1601_cap_mixer[] = {
Kailang Yange2757d52008-08-26 13:17:46 +02009214 HDA_BIND_VOL("Capture Volume", &alc883_bind_cap_vol),
9215 HDA_BIND_SW("Capture Switch", &alc883_bind_cap_switch),
9216 {
9217 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9218 /* .name = "Capture Source", */
9219 .name = "Input Source",
9220 .count = 1,
Takashi Iwai54cbc9a2008-10-31 15:24:04 +01009221 .info = alc_mux_enum_info,
9222 .get = alc_mux_enum_get,
9223 .put = alc_mux_enum_put,
Kailang Yange2757d52008-08-26 13:17:46 +02009224 },
9225 { } /* end */
9226};
9227
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009228static struct snd_kcontrol_new alc883_chmode_mixer[] = {
9229 {
9230 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
9231 .name = "Channel Mode",
9232 .info = alc_ch_mode_info,
9233 .get = alc_ch_mode_get,
9234 .put = alc_ch_mode_put,
9235 },
9236 { } /* end */
9237};
9238
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009239/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009240static void alc883_mitac_setup(struct hda_codec *codec)
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009241{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009242 struct alc_spec *spec = codec->spec;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009243
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009244 spec->autocfg.hp_pins[0] = 0x15;
9245 spec->autocfg.speaker_pins[0] = 0x14;
9246 spec->autocfg.speaker_pins[1] = 0x17;
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009247}
9248
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009249static struct hda_verb alc883_mitac_verbs[] = {
9250 /* HP */
9251 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9252 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9253 /* Subwoofer */
9254 {0x17, AC_VERB_SET_CONNECT_SEL, 0x02},
9255 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9256
9257 /* enable unsolicited event */
9258 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9259 /* {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN}, */
9260
9261 { } /* end */
9262};
9263
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309264static struct hda_verb alc883_clevo_m540r_verbs[] = {
9265 /* HP */
9266 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9268 /* Int speaker */
9269 /*{0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},*/
9270
9271 /* enable unsolicited event */
9272 /*
9273 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9274 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9275 */
9276
9277 { } /* end */
9278};
9279
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009280static struct hda_verb alc883_clevo_m720_verbs[] = {
Jiang zhe368c7a92008-03-04 11:20:33 +01009281 /* HP */
9282 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9283 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9284 /* Int speaker */
9285 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
9286 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9287
9288 /* enable unsolicited event */
9289 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009290 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Jiang zhe368c7a92008-03-04 11:20:33 +01009291
9292 { } /* end */
9293};
9294
Jiang zhefb97dc62008-03-06 11:07:11 +01009295static struct hda_verb alc883_2ch_fujitsu_pi2515_verbs[] = {
9296 /* HP */
9297 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9298 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9299 /* Subwoofer */
9300 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
9301 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9302
9303 /* enable unsolicited event */
9304 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9305
9306 { } /* end */
9307};
9308
Sasha Alexandrc2592492009-06-16 14:52:54 -04009309static struct hda_verb alc883_targa_verbs[] = {
Kailang Yangccc656c2006-10-17 12:32:26 +02009310 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9311 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9312
9313 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9314 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangea1fb292008-08-26 12:58:38 +02009315
David Heidelberger64a8be72009-06-08 16:15:18 +02009316/* Connect Line-Out side jack (SPDIF) to Side */
9317 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9318 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9319 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
9320/* Connect Mic jack to CLFE */
9321 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9322 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9323 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02},
9324/* Connect Line-in jack to Surround */
9325 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9326 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9327 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
9328/* Connect HP out jack to Front */
9329 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9330 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9331 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangccc656c2006-10-17 12:32:26 +02009332
9333 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangccc656c2006-10-17 12:32:26 +02009334
9335 { } /* end */
9336};
9337
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009338static struct hda_verb alc883_lenovo_101e_verbs[] = {
9339 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9340 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
9341 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
9342 { } /* end */
9343};
9344
Kailang Yang272a5272007-05-14 11:00:38 +02009345static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
9346 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9347 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9348 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9349 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9350 { } /* end */
9351};
9352
9353static struct hda_verb alc888_lenovo_ms7195_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 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9357 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
9358 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9359 { } /* end */
9360};
9361
Kailang Yang189609a2007-08-20 11:31:23 +02009362static struct hda_verb alc883_haier_w66_verbs[] = {
9363 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9364 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9365
9366 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9367
9368 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
9369 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9370 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9371 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9372 { } /* end */
9373};
9374
Kailang Yange2757d52008-08-26 13:17:46 +02009375static struct hda_verb alc888_lenovo_sky_verbs[] = {
9376 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9377 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9378 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9380 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9381 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9382 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
9383 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9384 { } /* end */
9385};
9386
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009387static struct hda_verb alc888_6st_dell_verbs[] = {
9388 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9389 { }
9390};
9391
Guido Günther3e1647c2009-06-05 00:47:26 +02009392static struct hda_verb alc883_vaiott_verbs[] = {
9393 /* HP */
9394 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
9395 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9396
9397 /* enable unsolicited event */
9398 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9399
9400 { } /* end */
9401};
9402
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009403static void alc888_3st_hp_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009404{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009405 struct alc_spec *spec = codec->spec;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009406
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009407 spec->autocfg.hp_pins[0] = 0x1b;
9408 spec->autocfg.speaker_pins[0] = 0x14;
9409 spec->autocfg.speaker_pins[1] = 0x16;
9410 spec->autocfg.speaker_pins[2] = 0x18;
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009411}
9412
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009413static struct hda_verb alc888_3st_hp_verbs[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009414 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
Herton Ronaldo Krzesinskif32a19e2008-03-18 09:27:08 +01009415 {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
9416 {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009417 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Herton Ronaldo Krzesinski8718b702009-03-04 14:22:51 -03009418 { } /* end */
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009419};
9420
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009421/*
9422 * 2ch mode
9423 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009424static struct hda_verb alc888_3st_hp_2ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009425 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9426 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9427 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
9428 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009429 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009430};
9431
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009432/*
9433 * 4ch mode
9434 */
9435static struct hda_verb alc888_3st_hp_4ch_init[] = {
9436 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
9437 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
9438 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9439 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
9440 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9441 { } /* end */
9442};
9443
9444/*
9445 * 6ch mode
9446 */
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009447static struct hda_verb alc888_3st_hp_6ch_init[] = {
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009448 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9449 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009450 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009451 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
9452 { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009453 { 0x16, AC_VERB_SET_CONNECT_SEL, 0x01 },
9454 { } /* end */
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009455};
9456
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009457static struct hda_channel_mode alc888_3st_hp_modes[3] = {
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009458 { 2, alc888_3st_hp_2ch_init },
Herton Ronaldo Krzesinski3ea0d7c2009-03-04 14:22:50 -03009459 { 4, alc888_3st_hp_4ch_init },
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009460 { 6, alc888_3st_hp_6ch_init },
Claudio Matsuoka8341de62007-07-06 12:10:45 +02009461};
9462
Kailang Yang272a5272007-05-14 11:00:38 +02009463/* toggle front-jack and RCA according to the hp-jack state */
9464static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
9465{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009466 unsigned int present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangea1fb292008-08-26 12:58:38 +02009467
Takashi Iwai47fd8302007-08-10 17:11:07 +02009468 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9469 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9470 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9471 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009472}
9473
9474/* toggle RCA according to the front-jack state */
9475static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
9476{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009477 unsigned int present = snd_hda_jack_detect(codec, 0x14);
Kailang Yangea1fb292008-08-26 12:58:38 +02009478
Takashi Iwai47fd8302007-08-10 17:11:07 +02009479 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9480 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
Kailang Yang272a5272007-05-14 11:00:38 +02009481}
Takashi Iwai47fd8302007-08-10 17:11:07 +02009482
Kailang Yang272a5272007-05-14 11:00:38 +02009483static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
9484 unsigned int res)
9485{
9486 if ((res >> 26) == ALC880_HP_EVENT)
9487 alc888_lenovo_ms7195_front_automute(codec);
9488 if ((res >> 26) == ALC880_FRONT_EVENT)
9489 alc888_lenovo_ms7195_rca_automute(codec);
9490}
9491
Kailang Yang272a5272007-05-14 11:00:38 +02009492/* toggle speaker-output according to the hp-jack state */
Takashi Iwaidc4271702010-11-29 07:42:59 +01009493static void alc883_lenovo_nb0763_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +02009494{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009495 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009496
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009497 spec->autocfg.hp_pins[0] = 0x14;
9498 spec->autocfg.speaker_pins[0] = 0x15;
Kailang Yang272a5272007-05-14 11:00:38 +02009499}
9500
Kailang Yangccc656c2006-10-17 12:32:26 +02009501/* toggle speaker-output according to the hp-jack state */
Sasha Alexandrc2592492009-06-16 14:52:54 -04009502#define alc883_targa_init_hook alc882_targa_init_hook
9503#define alc883_targa_unsol_event alc882_targa_unsol_event
Jiang zhe368c7a92008-03-04 11:20:33 +01009504
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009505static void alc883_clevo_m720_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009506{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009507 struct alc_spec *spec = codec->spec;
9508
9509 spec->autocfg.hp_pins[0] = 0x15;
9510 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009511}
9512
9513static void alc883_clevo_m720_init_hook(struct hda_codec *codec)
9514{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009515 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +01009516 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009517}
9518
9519static void alc883_clevo_m720_unsol_event(struct hda_codec *codec,
Jiang zhe368c7a92008-03-04 11:20:33 +01009520 unsigned int res)
9521{
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009522 switch (res >> 26) {
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009523 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +01009524 alc88x_simple_mic_automute(codec);
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009525 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009526 default:
9527 alc_automute_amp_unsol_event(codec, res);
9528 break;
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009529 }
Jiang zhe368c7a92008-03-04 11:20:33 +01009530}
9531
Jiang zhefb97dc62008-03-06 11:07:11 +01009532/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009533static void alc883_2ch_fujitsu_pi2515_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009534{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009535 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009536
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009537 spec->autocfg.hp_pins[0] = 0x14;
9538 spec->autocfg.speaker_pins[0] = 0x15;
Jiang zhefb97dc62008-03-06 11:07:11 +01009539}
9540
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009541static void alc883_haier_w66_setup(struct hda_codec *codec)
Jiang zhefb97dc62008-03-06 11:07:11 +01009542{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009543 struct alc_spec *spec = codec->spec;
Jiang zhefb97dc62008-03-06 11:07:11 +01009544
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009545 spec->autocfg.hp_pins[0] = 0x1b;
9546 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang189609a2007-08-20 11:31:23 +02009547}
9548
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009549static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
9550{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009551 int bits = snd_hda_jack_detect(codec, 0x14) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009552
Takashi Iwai47fd8302007-08-10 17:11:07 +02009553 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9554 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009555}
9556
9557static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
9558{
Wu Fengguang864f92b2009-11-18 12:38:02 +08009559 int bits = snd_hda_jack_detect(codec, 0x1b) ? HDA_AMP_MUTE : 0;
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009560
Takashi Iwai47fd8302007-08-10 17:11:07 +02009561 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
9562 HDA_AMP_MUTE, bits);
9563 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9564 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009565}
9566
9567static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
9568 unsigned int res)
9569{
9570 if ((res >> 26) == ALC880_HP_EVENT)
9571 alc883_lenovo_101e_all_automute(codec);
9572 if ((res >> 26) == ALC880_FRONT_EVENT)
9573 alc883_lenovo_101e_ispeaker_automute(codec);
9574}
9575
Takashi Iwai676a9b52007-08-16 15:23:35 +02009576/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009577static void alc883_acer_aspire_setup(struct hda_codec *codec)
Takashi Iwai676a9b52007-08-16 15:23:35 +02009578{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009579 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009580
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009581 spec->autocfg.hp_pins[0] = 0x14;
9582 spec->autocfg.speaker_pins[0] = 0x15;
9583 spec->autocfg.speaker_pins[1] = 0x16;
Takashi Iwai676a9b52007-08-16 15:23:35 +02009584}
9585
Kailang Yangd1a991a2007-08-15 16:21:59 +02009586static struct hda_verb alc883_acer_eapd_verbs[] = {
9587 /* HP Pin: output 0 (0x0c) */
9588 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9589 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
9590 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
9591 /* Front Pin: output 0 (0x0c) */
Takashi Iwai676a9b52007-08-16 15:23:35 +02009592 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9593 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009594 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009595 {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
9596 /* eanable EAPD on medion laptop */
9597 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
9598 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
Takashi Iwai676a9b52007-08-16 15:23:35 +02009599 /* enable unsolicited event */
9600 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Kailang Yangd1a991a2007-08-15 16:21:59 +02009601 { }
9602};
9603
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009604static void alc888_6st_dell_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009605{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009606 struct alc_spec *spec = codec->spec;
Kailang Yangea1fb292008-08-26 12:58:38 +02009607
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009608 spec->autocfg.hp_pins[0] = 0x1b;
9609 spec->autocfg.speaker_pins[0] = 0x14;
9610 spec->autocfg.speaker_pins[1] = 0x15;
9611 spec->autocfg.speaker_pins[2] = 0x16;
9612 spec->autocfg.speaker_pins[3] = 0x17;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009613}
9614
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009615static void alc888_lenovo_sky_setup(struct hda_codec *codec)
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009616{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009617 struct alc_spec *spec = codec->spec;
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009618
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009619 spec->autocfg.hp_pins[0] = 0x1b;
9620 spec->autocfg.speaker_pins[0] = 0x14;
9621 spec->autocfg.speaker_pins[1] = 0x15;
9622 spec->autocfg.speaker_pins[2] = 0x16;
9623 spec->autocfg.speaker_pins[3] = 0x17;
9624 spec->autocfg.speaker_pins[4] = 0x1a;
Kailang Yange2757d52008-08-26 13:17:46 +02009625}
9626
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009627static void alc883_vaiott_setup(struct hda_codec *codec)
Guido Günther3e1647c2009-06-05 00:47:26 +02009628{
9629 struct alc_spec *spec = codec->spec;
9630
9631 spec->autocfg.hp_pins[0] = 0x15;
9632 spec->autocfg.speaker_pins[0] = 0x14;
9633 spec->autocfg.speaker_pins[1] = 0x17;
Guido Günther3e1647c2009-06-05 00:47:26 +02009634}
9635
Kailang Yange2757d52008-08-26 13:17:46 +02009636static struct hda_verb alc888_asus_m90v_verbs[] = {
9637 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9638 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9639 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
9640 /* enable unsolicited event */
9641 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9642 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
9643 { } /* end */
9644};
9645
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009646static void alc883_mode2_setup(struct hda_codec *codec)
Kailang Yange2757d52008-08-26 13:17:46 +02009647{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009648 struct alc_spec *spec = codec->spec;
Kailang Yange2757d52008-08-26 13:17:46 +02009649
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009650 spec->autocfg.hp_pins[0] = 0x1b;
9651 spec->autocfg.speaker_pins[0] = 0x14;
9652 spec->autocfg.speaker_pins[1] = 0x15;
9653 spec->autocfg.speaker_pins[2] = 0x16;
Takashi Iwai4f5d17062009-08-11 18:17:46 +02009654 spec->ext_mic.pin = 0x18;
9655 spec->int_mic.pin = 0x19;
9656 spec->ext_mic.mux_idx = 0;
9657 spec->int_mic.mux_idx = 1;
9658 spec->auto_mic = 1;
Kailang Yange2757d52008-08-26 13:17:46 +02009659}
9660
9661static struct hda_verb alc888_asus_eee1601_verbs[] = {
9662 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
9663 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
9664 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
9665 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
9666 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
9667 {0x20, AC_VERB_SET_COEF_INDEX, 0x0b},
9668 {0x20, AC_VERB_SET_PROC_COEF, 0x0838},
9669 /* enable unsolicited event */
9670 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9671 { } /* end */
9672};
9673
Kailang Yange2757d52008-08-26 13:17:46 +02009674static void alc883_eee1601_inithook(struct hda_codec *codec)
9675{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +02009676 struct alc_spec *spec = codec->spec;
9677
9678 spec->autocfg.hp_pins[0] = 0x14;
9679 spec->autocfg.speaker_pins[0] = 0x1b;
9680 alc_automute_pin(codec);
Kailang Yange2757d52008-08-26 13:17:46 +02009681}
9682
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009683static struct hda_verb alc889A_mb31_verbs[] = {
9684 /* Init rear pin (used as headphone output) */
9685 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, /* Apple Headphones */
9686 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Connect to front */
9687 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
9688 /* Init line pin (used as output in 4ch and 6ch mode) */
9689 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Connect to CLFE */
9690 /* Init line 2 pin (used as headphone out by default) */
9691 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* Use as input */
9692 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Mute output */
9693 { } /* end */
9694};
9695
9696/* Mute speakers according to the headphone jack state */
9697static void alc889A_mb31_automute(struct hda_codec *codec)
9698{
9699 unsigned int present;
9700
9701 /* Mute only in 2ch or 4ch mode */
9702 if (snd_hda_codec_read(codec, 0x15, 0, AC_VERB_GET_CONNECT_SEL, 0)
9703 == 0x00) {
Wu Fengguang864f92b2009-11-18 12:38:02 +08009704 present = snd_hda_jack_detect(codec, 0x15);
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009705 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
9706 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9707 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
9708 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
9709 }
9710}
9711
9712static void alc889A_mb31_unsol_event(struct hda_codec *codec, unsigned int res)
9713{
9714 if ((res >> 26) == ALC880_HP_EVENT)
9715 alc889A_mb31_automute(codec);
9716}
9717
Takashi Iwai4953550a2009-06-30 15:28:30 +02009718
Takashi Iwaicb53c622007-08-10 17:21:45 +02009719#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwai4953550a2009-06-30 15:28:30 +02009720#define alc882_loopbacks alc880_loopbacks
Takashi Iwaicb53c622007-08-10 17:21:45 +02009721#endif
9722
Sasha Alexandrdef319f2009-06-16 16:00:15 -04009723/* pcm configuration: identical with ALC880 */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009724#define alc882_pcm_analog_playback alc880_pcm_analog_playback
9725#define alc882_pcm_analog_capture alc880_pcm_analog_capture
9726#define alc882_pcm_digital_playback alc880_pcm_digital_playback
9727#define alc882_pcm_digital_capture alc880_pcm_digital_capture
9728
9729static hda_nid_t alc883_slave_dig_outs[] = {
9730 ALC1200_DIGOUT_NID, 0,
9731};
9732
9733static hda_nid_t alc1200_slave_dig_outs[] = {
9734 ALC883_DIGOUT_NID, 0,
9735};
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009736
9737/*
9738 * configuration and preset
9739 */
Takashi Iwaiea734962011-01-17 11:29:34 +01009740static const char * const alc882_models[ALC882_MODEL_LAST] = {
Takashi Iwai4953550a2009-06-30 15:28:30 +02009741 [ALC882_3ST_DIG] = "3stack-dig",
9742 [ALC882_6ST_DIG] = "6stack-dig",
9743 [ALC882_ARIMA] = "arima",
9744 [ALC882_W2JC] = "w2jc",
9745 [ALC882_TARGA] = "targa",
9746 [ALC882_ASUS_A7J] = "asus-a7j",
9747 [ALC882_ASUS_A7M] = "asus-a7m",
9748 [ALC885_MACPRO] = "macpro",
9749 [ALC885_MB5] = "mb5",
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009750 [ALC885_MACMINI3] = "macmini3",
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009751 [ALC885_MBA21] = "mba21",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009752 [ALC885_MBP3] = "mbp3",
9753 [ALC885_IMAC24] = "imac24",
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009754 [ALC885_IMAC91] = "imac91",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009755 [ALC883_3ST_2ch_DIG] = "3stack-2ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009756 [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
9757 [ALC883_3ST_6ch] = "3stack-6ch",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009758 [ALC883_6ST_DIG] = "alc883-6stack-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009759 [ALC883_TARGA_DIG] = "targa-dig",
9760 [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
David Heidelberger64a8be72009-06-08 16:15:18 +02009761 [ALC883_TARGA_8ch_DIG] = "targa-8ch-dig",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009762 [ALC883_ACER] = "acer",
Tobin Davis2880a862007-08-07 11:50:26 +02009763 [ALC883_ACER_ASPIRE] = "acer-aspire",
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009764 [ALC888_ACER_ASPIRE_4930G] = "acer-aspire-4930g",
Takashi Iwaib1a91462009-06-21 10:56:44 +02009765 [ALC888_ACER_ASPIRE_6530G] = "acer-aspire-6530g",
Hector Martin3b315d72009-06-02 10:54:19 +02009766 [ALC888_ACER_ASPIRE_8930G] = "acer-aspire-8930g",
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009767 [ALC888_ACER_ASPIRE_7730G] = "acer-aspire-7730g",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009768 [ALC883_MEDION] = "medion",
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +02009769 [ALC883_MEDION_WIM2160] = "medion-wim2160",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009770 [ALC883_LAPTOP_EAPD] = "laptop-eapd",
Kailang Yangbc9f98a2007-04-12 13:06:07 +02009771 [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
Kailang Yang272a5272007-05-14 11:00:38 +02009772 [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
9773 [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
Kailang Yange2757d52008-08-26 13:17:46 +02009774 [ALC888_LENOVO_SKY] = "lenovo-sky",
Kailang Yang189609a2007-08-20 11:31:23 +02009775 [ALC883_HAIER_W66] = "haier-w66",
Claudio Matsuoka4723c022007-07-13 14:36:19 +02009776 [ALC888_3ST_HP] = "3stack-hp",
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009777 [ALC888_6ST_DELL] = "6stack-dell",
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +01009778 [ALC883_MITAC] = "mitac",
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309779 [ALC883_CLEVO_M540R] = "clevo-m540r",
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009780 [ALC883_CLEVO_M720] = "clevo-m720",
Jiang zhefb97dc62008-03-06 11:07:11 +01009781 [ALC883_FUJITSU_PI2515] = "fujitsu-pi2515",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009782 [ALC888_FUJITSU_XA3530] = "fujitsu-xa3530",
Jiang zhe17bba1b2008-06-04 12:11:07 +02009783 [ALC883_3ST_6ch_INTEL] = "3stack-6ch-intel",
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009784 [ALC889A_INTEL] = "intel-alc889a",
9785 [ALC889_INTEL] = "intel-x58",
Wu Fengguang3ab90932008-11-17 09:51:09 +01009786 [ALC1200_ASUS_P5Q] = "asus-p5q",
Torben Schulzeb4c41d2009-05-18 15:02:35 +02009787 [ALC889A_MB31] = "mb31",
Guido Günther3e1647c2009-06-05 00:47:26 +02009788 [ALC883_SONY_VAIO_TT] = "sony-vaio-tt",
Takashi Iwai4953550a2009-06-30 15:28:30 +02009789 [ALC882_AUTO] = "auto",
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009790};
9791
Takashi Iwai4953550a2009-06-30 15:28:30 +02009792static struct snd_pci_quirk alc882_cfg_tbl[] = {
9793 SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
9794
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009795 SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
Takashi Iwai69e50282008-11-03 10:07:43 +01009796 SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_ACER_ASPIRE),
Takashi Iwai9b6682f2009-03-23 22:50:52 +01009797 SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_ACER_ASPIRE),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009798 SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
9799 SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
Jaroslav Kysela0b18cb12008-07-28 17:07:07 +02009800 SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE),
Vincent Petry5b2d1ec2008-11-18 22:21:57 +08009801 SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
9802 ALC888_ACER_ASPIRE_4930G),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009803 SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
Takashi Iwai83dd7402009-11-24 08:57:53 +01009804 ALC888_ACER_ASPIRE_4930G),
Hector Martin3b315d72009-06-02 10:54:19 +02009805 SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
9806 ALC888_ACER_ASPIRE_8930G),
Takashi Iwaie46b0c82009-06-13 10:16:43 +02009807 SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
9808 ALC888_ACER_ASPIRE_8930G),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009809 SND_PCI_QUIRK(0x1025, 0x0157, "Acer X3200", ALC882_AUTO),
9810 SND_PCI_QUIRK(0x1025, 0x0158, "Acer AX1700-U3700A", ALC882_AUTO),
Lukasz Wojnilowicza8e4f9d2009-01-08 12:00:49 +01009811 SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
Takashi Iwaidde65352009-06-25 08:25:35 +02009812 ALC888_ACER_ASPIRE_6530G),
Juan Jesus Garcia de Soriacc374c42009-02-23 08:11:59 +01009813 SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
Tony Vroond2fd4b02009-06-21 00:40:10 +01009814 ALC888_ACER_ASPIRE_6530G),
Denis Kuplyakovfc86f952009-08-25 18:15:59 +02009815 SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
9816 ALC888_ACER_ASPIRE_7730G),
Takashi Iwai22b530e2009-05-13 11:32:52 +02009817 /* default Acer -- disabled as it causes more problems.
9818 * model=auto should work fine now
9819 */
9820 /* SND_PCI_QUIRK_VENDOR(0x1025, "Acer laptop", ALC883_ACER), */
Takashi Iwai4953550a2009-06-30 15:28:30 +02009821
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +01009822 SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009823
Tobin Davisfebe3372007-06-12 11:27:46 +02009824 SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009825 SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
9826 SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
Herton Ronaldo Krzesinski5d85f8d2008-03-20 12:13:46 +01009827 SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG),
Chris Bagwell06bf3e12009-01-01 10:32:08 +01009828 SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP),
Herton Ronaldo Krzesinski7ec30f02009-03-04 14:22:52 -03009829 SND_PCI_QUIRK(0x103c, 0x2a72, "HP Educ.ar", ALC888_3ST_HP),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009830
9831 SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
9832 SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
9833 SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
Kailang Yanga01c30c2008-10-15 11:14:58 +02009834 SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009835 SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
9836 SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
9837 SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009838 SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
Mackenzie Morgan44a678d2009-02-10 17:13:43 +01009839 SND_PCI_QUIRK(0x1043, 0x8284, "Asus Z37E", ALC883_6ST_DIG),
Wu Fengguang3ab90932008-11-17 09:51:09 +01009840 SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q),
Kailang Yange2757d52008-08-26 13:17:46 +02009841 SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_ASUS_EEE1601),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009842
9843 SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC883_SONY_VAIO_TT),
Travis Place97ec7102008-05-23 18:31:46 +02009844 SND_PCI_QUIRK(0x105b, 0x0ce8, "Foxconn P35AX-S", ALC883_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009845 SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009846 SND_PCI_QUIRK(0x1071, 0x8227, "Mitac 82801H", ALC883_MITAC),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009847 SND_PCI_QUIRK(0x1071, 0x8253, "Mitac 8252d", ALC883_MITAC),
9848 SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
Kailang Yange2757d52008-08-26 13:17:46 +02009849 SND_PCI_QUIRK(0x10f1, 0x2350, "TYAN-S2350", ALC888_6ST_DELL),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009850 SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009851 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte P35 DS3R", ALC882_6ST_DIG),
9852
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009853 SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
9854 SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
9855 SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009856 SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
Takashi Iwai2fef62c2009-12-18 08:48:42 +01009857 SND_PCI_QUIRK(0x1462, 0x2fb3, "MSI", ALC882_AUTO),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009858 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009859 SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
Pascal Terjan82808232008-03-04 11:33:28 +01009860 SND_PCI_QUIRK(0x1462, 0x3783, "NEC S970", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009861 SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
9862 SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
9863 SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
9864 SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
9865 SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
9866 SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009867 SND_PCI_QUIRK(0x1462, 0x42cd, "MSI", ALC883_TARGA_DIG),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009868 SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
9869 SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
9870 SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009871 SND_PCI_QUIRK(0x1462, 0x4570, "MSI Wind Top AE2220", ALC883_TARGA_DIG),
David Heidelberger64a8be72009-06-08 16:15:18 +02009872 SND_PCI_QUIRK(0x1462, 0x6510, "MSI GX620", ALC883_TARGA_8ch_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009873 SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
9874 SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
Tobin Davis799f88a2007-05-29 14:29:08 +02009875 SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
Takashi Iwaiee095432008-11-25 15:03:38 +01009876 SND_PCI_QUIRK(0x1462, 0x7260, "MSI 7260", ALC883_TARGA_DIG),
Herton Ronaldo Krzesinski86d34b72008-03-18 09:27:59 +01009877 SND_PCI_QUIRK(0x1462, 0x7267, "MSI", ALC883_3ST_6ch_DIG),
Leonard Norrgard2a296cb2007-01-08 11:28:22 +01009878 SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
Tobin Davis2dcd5222007-07-10 17:04:57 +02009879 SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
Sasha Alexandrdf01b8a2009-06-16 14:46:17 -04009880 SND_PCI_QUIRK(0x1462, 0x7350, "MSI", ALC883_6ST_DIG),
Anisse Astierb43f6e52010-03-10 19:17:46 +01009881 SND_PCI_QUIRK(0x1462, 0x7437, "MSI NetOn AP1900", ALC883_TARGA_DIG),
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009882 SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
William Westonb1e44222009-07-08 01:10:05 -07009883 SND_PCI_QUIRK(0x1462, 0xaa08, "MSI", ALC883_TARGA_2ch_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009884
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009885 SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
Joerg Schirottked1501ea2010-04-15 08:37:41 +02009886 SND_PCI_QUIRK(0x1558, 0x0571, "Clevo laptop M570U", ALC883_3ST_6ch_DIG),
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +01009887 SND_PCI_QUIRK(0x1558, 0x0721, "Clevo laptop M720R", ALC883_CLEVO_M720),
9888 SND_PCI_QUIRK(0x1558, 0x0722, "Clevo laptop M720SR", ALC883_CLEVO_M720),
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -04309889 SND_PCI_QUIRK(0x1558, 0x5409, "Clevo laptop M540R", ALC883_CLEVO_M540R),
Takashi Iwaidea0a502009-02-09 17:14:52 +01009890 SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC883_LAPTOP_EAPD),
Daniel T Chene60623b2007-05-29 03:41:55 -04009891 SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009892 /* SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA), */
Takashi Iwaif5fcc132006-11-24 17:07:44 +01009893 SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009894 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1100, "FSC AMILO Xi/Pi25xx",
Takashi Iwaif67d8172009-02-04 23:30:19 +01009895 ALC883_FUJITSU_PI2515),
Takashi Iwaibfb53032009-04-14 14:51:04 +02009896 SND_PCI_QUIRK_MASK(0x1734, 0xfff0, 0x1130, "Fujitsu AMILO Xa35xx",
Vincent Petryef8ef5f2008-11-23 11:31:41 +08009897 ALC888_FUJITSU_XA3530),
Kailang Yang272a5272007-05-14 11:00:38 +02009898 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
Kailang Yang272a5272007-05-14 11:00:38 +02009899 SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Takashi Iwaiac3e3742007-12-17 17:14:18 +01009900 SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
9901 SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
Kailang Yange2757d52008-08-26 13:17:46 +02009902 SND_PCI_QUIRK(0x17aa, 0x101d, "Lenovo Sky", ALC888_LENOVO_SKY),
Takashi Iwai959973b2008-11-05 11:30:56 +01009903 SND_PCI_QUIRK(0x17c0, 0x4085, "MEDION MD96630", ALC888_LENOVO_MS7195_DIG),
Andrew Paprocki0b167bf2008-02-03 10:15:44 +01009904 SND_PCI_QUIRK(0x17f2, 0x5000, "Albatron KI690-AM2", ALC883_6ST_DIG),
Kailang Yang189609a2007-08-20 11:31:23 +02009905 SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009906
Jiang zhe17bba1b2008-06-04 12:11:07 +02009907 SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL),
9908 SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL),
Luke Yelavich2de686d2009-01-16 15:08:02 +11009909 SND_PCI_QUIRK(0x8086, 0x2503, "82801H", ALC883_MITAC),
Jaroslav Kysela87a8c372009-07-23 10:58:29 +02009910 SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_INTEL),
9911 SND_PCI_QUIRK(0x8086, 0x0021, "Intel IbexPeak", ALC889A_INTEL),
9912 SND_PCI_QUIRK(0x8086, 0x3b56, "Intel IbexPeak", ALC889A_INTEL),
Daniel T Chen572c0e32010-03-14 23:44:03 -04009913 SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC882_6ST_DIG),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009914
Takashi Iwai9c7f8522006-06-28 15:08:22 +02009915 {}
9916};
9917
Takashi Iwai4953550a2009-06-30 15:28:30 +02009918/* codec SSID table for Intel Mac */
9919static struct snd_pci_quirk alc882_ssid_cfg_tbl[] = {
9920 SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC885_MBP3),
9921 SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC885_MBP3),
9922 SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC885_MBP3),
9923 SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_MACPRO),
9924 SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_IMAC24),
9925 SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_IMAC24),
9926 SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC885_MBP3),
Daniel T Chen26fd74f2010-05-30 09:55:23 -04009927 SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889A_MB31),
Justin P. Mattockab669962010-06-06 16:09:53 -07009928 SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_ASUS_A7M),
Justin P. Mattockf53dae22010-06-06 16:09:51 -07009929 SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC885_MBP3),
Justin P. Mattock6e129702010-06-06 16:09:49 -07009930 SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC885_MBA21),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009931 SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889A_MB31),
9932 SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC885_MBP3),
9933 SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_IMAC24),
Justin P. Mattock4b7e1802009-12-07 15:07:46 -08009934 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC885_IMAC91),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009935 SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC885_MB5),
Luke Yelavich3bfea982010-06-22 11:04:19 +10009936 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009937 /* FIXME: HP jack sense seems not working for MBP 5,1 or 5,2,
9938 * so apparently no perfect solution yet
Takashi Iwai4953550a2009-06-30 15:28:30 +02009939 */
9940 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC885_MB5),
Daniel T Chen46ef6ec2009-11-11 14:32:10 -05009941 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC885_MB5),
Luke Yelaviche458b1f2010-02-12 16:28:29 +11009942 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC885_MACMINI3),
Takashi Iwai4953550a2009-06-30 15:28:30 +02009943 {} /* terminator */
Wu Fengguangf3cd3f52009-04-02 19:44:18 +08009944};
9945
Takashi Iwai4953550a2009-06-30 15:28:30 +02009946static struct alc_config_preset alc882_presets[] = {
9947 [ALC882_3ST_DIG] = {
9948 .mixers = { alc882_base_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009949 .init_verbs = { alc882_base_init_verbs,
9950 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009951 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9952 .dac_nids = alc882_dac_nids,
9953 .dig_out_nid = ALC882_DIGOUT_NID,
9954 .dig_in_nid = ALC882_DIGIN_NID,
9955 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
9956 .channel_mode = alc882_ch_modes,
9957 .need_dac_fix = 1,
9958 .input_mux = &alc882_capture_source,
9959 },
9960 [ALC882_6ST_DIG] = {
9961 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009962 .init_verbs = { alc882_base_init_verbs,
9963 alc882_adc1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009964 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9965 .dac_nids = alc882_dac_nids,
9966 .dig_out_nid = ALC882_DIGOUT_NID,
9967 .dig_in_nid = ALC882_DIGIN_NID,
9968 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9969 .channel_mode = alc882_sixstack_modes,
9970 .input_mux = &alc882_capture_source,
9971 },
9972 [ALC882_ARIMA] = {
9973 .mixers = { alc882_base_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009974 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9975 alc882_eapd_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009976 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9977 .dac_nids = alc882_dac_nids,
9978 .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
9979 .channel_mode = alc882_sixstack_modes,
9980 .input_mux = &alc882_capture_source,
9981 },
9982 [ALC882_W2JC] = {
9983 .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +02009984 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
9985 alc882_eapd_verbs, alc880_gpio1_init_verbs },
Takashi Iwai4953550a2009-06-30 15:28:30 +02009986 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
9987 .dac_nids = alc882_dac_nids,
9988 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
9989 .channel_mode = alc880_threestack_modes,
9990 .need_dac_fix = 1,
9991 .input_mux = &alc882_capture_source,
9992 .dig_out_nid = ALC882_DIGOUT_NID,
9993 },
Reimundo Heluani76e6f5a2010-02-23 01:19:51 -08009994 [ALC885_MBA21] = {
9995 .mixers = { alc885_mba21_mixer },
9996 .init_verbs = { alc885_mba21_init_verbs, alc880_gpio1_init_verbs },
9997 .num_dacs = 2,
9998 .dac_nids = alc882_dac_nids,
9999 .channel_mode = alc885_mba21_ch_modes,
10000 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10001 .input_mux = &alc882_capture_source,
10002 .unsol_event = alc_automute_amp_unsol_event,
10003 .setup = alc885_mba21_setup,
10004 .init_hook = alc_automute_amp,
10005 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010006 [ALC885_MBP3] = {
10007 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
10008 .init_verbs = { alc885_mbp3_init_verbs,
10009 alc880_gpio1_init_verbs },
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010010 .num_dacs = 2,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010011 .dac_nids = alc882_dac_nids,
Takashi Iwaibe0ae922009-08-31 08:27:10 +020010012 .hp_nid = 0x04,
10013 .channel_mode = alc885_mbp_4ch_modes,
10014 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010015 .input_mux = &alc882_capture_source,
10016 .dig_out_nid = ALC882_DIGOUT_NID,
10017 .dig_in_nid = ALC882_DIGIN_NID,
10018 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010019 .setup = alc885_mbp3_setup,
10020 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010021 },
10022 [ALC885_MB5] = {
10023 .mixers = { alc885_mb5_mixer, alc882_chmode_mixer },
10024 .init_verbs = { alc885_mb5_init_verbs,
10025 alc880_gpio1_init_verbs },
10026 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10027 .dac_nids = alc882_dac_nids,
10028 .channel_mode = alc885_mb5_6ch_modes,
10029 .num_channel_mode = ARRAY_SIZE(alc885_mb5_6ch_modes),
10030 .input_mux = &mb5_capture_source,
10031 .dig_out_nid = ALC882_DIGOUT_NID,
10032 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010033 .unsol_event = alc_automute_amp_unsol_event,
10034 .setup = alc885_mb5_setup,
10035 .init_hook = alc_automute_amp,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010036 },
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010037 [ALC885_MACMINI3] = {
10038 .mixers = { alc885_macmini3_mixer, alc882_chmode_mixer },
10039 .init_verbs = { alc885_macmini3_init_verbs,
10040 alc880_gpio1_init_verbs },
10041 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10042 .dac_nids = alc882_dac_nids,
10043 .channel_mode = alc885_macmini3_6ch_modes,
10044 .num_channel_mode = ARRAY_SIZE(alc885_macmini3_6ch_modes),
10045 .input_mux = &macmini3_capture_source,
10046 .dig_out_nid = ALC882_DIGOUT_NID,
10047 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010048 .unsol_event = alc_automute_amp_unsol_event,
10049 .setup = alc885_macmini3_setup,
10050 .init_hook = alc_automute_amp,
Luke Yelaviche458b1f2010-02-12 16:28:29 +110010051 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010052 [ALC885_MACPRO] = {
10053 .mixers = { alc882_macpro_mixer },
10054 .init_verbs = { alc882_macpro_init_verbs },
10055 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10056 .dac_nids = alc882_dac_nids,
10057 .dig_out_nid = ALC882_DIGOUT_NID,
10058 .dig_in_nid = ALC882_DIGIN_NID,
10059 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10060 .channel_mode = alc882_ch_modes,
10061 .input_mux = &alc882_capture_source,
10062 .init_hook = alc885_macpro_init_hook,
10063 },
10064 [ALC885_IMAC24] = {
10065 .mixers = { alc885_imac24_mixer },
10066 .init_verbs = { alc885_imac24_init_verbs },
10067 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10068 .dac_nids = alc882_dac_nids,
10069 .dig_out_nid = ALC882_DIGOUT_NID,
10070 .dig_in_nid = ALC882_DIGIN_NID,
10071 .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
10072 .channel_mode = alc882_ch_modes,
10073 .input_mux = &alc882_capture_source,
10074 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010075 .setup = alc885_imac24_setup,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010076 .init_hook = alc885_imac24_init_hook,
10077 },
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010078 [ALC885_IMAC91] = {
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010079 .mixers = {alc885_imac91_mixer},
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010080 .init_verbs = { alc885_imac91_init_verbs,
10081 alc880_gpio1_init_verbs },
10082 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10083 .dac_nids = alc882_dac_nids,
Justin P. Mattockb7cccc52010-05-23 10:55:00 -070010084 .channel_mode = alc885_mba21_ch_modes,
10085 .num_channel_mode = ARRAY_SIZE(alc885_mba21_ch_modes),
10086 .input_mux = &alc889A_imac91_capture_source,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010087 .dig_out_nid = ALC882_DIGOUT_NID,
10088 .dig_in_nid = ALC882_DIGIN_NID,
Takashi Iwai9d54f082010-02-22 08:34:40 +010010089 .unsol_event = alc_automute_amp_unsol_event,
10090 .setup = alc885_imac91_setup,
10091 .init_hook = alc_automute_amp,
Justin P. Mattock4b7e1802009-12-07 15:07:46 -080010092 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010093 [ALC882_TARGA] = {
10094 .mixers = { alc882_targa_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010095 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
Takashi Iwai31909b82009-07-10 12:33:48 +020010096 alc880_gpio3_init_verbs, alc882_targa_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010097 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10098 .dac_nids = alc882_dac_nids,
10099 .dig_out_nid = ALC882_DIGOUT_NID,
10100 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10101 .adc_nids = alc882_adc_nids,
10102 .capsrc_nids = alc882_capsrc_nids,
10103 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10104 .channel_mode = alc882_3ST_6ch_modes,
10105 .need_dac_fix = 1,
10106 .input_mux = &alc882_capture_source,
10107 .unsol_event = alc882_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010108 .setup = alc882_targa_setup,
10109 .init_hook = alc882_targa_automute,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010110 },
10111 [ALC882_ASUS_A7J] = {
10112 .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010113 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10114 alc882_asus_a7j_verbs},
Takashi Iwai4953550a2009-06-30 15:28:30 +020010115 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10116 .dac_nids = alc882_dac_nids,
10117 .dig_out_nid = ALC882_DIGOUT_NID,
10118 .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
10119 .adc_nids = alc882_adc_nids,
10120 .capsrc_nids = alc882_capsrc_nids,
10121 .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
10122 .channel_mode = alc882_3ST_6ch_modes,
10123 .need_dac_fix = 1,
10124 .input_mux = &alc882_capture_source,
10125 },
10126 [ALC882_ASUS_A7M] = {
10127 .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
Takashi Iwai8ab9e0a2009-07-03 10:58:12 +020010128 .init_verbs = { alc882_base_init_verbs, alc882_adc1_init_verbs,
10129 alc882_eapd_verbs, alc880_gpio1_init_verbs,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010130 alc882_asus_a7m_verbs },
10131 .num_dacs = ARRAY_SIZE(alc882_dac_nids),
10132 .dac_nids = alc882_dac_nids,
10133 .dig_out_nid = ALC882_DIGOUT_NID,
10134 .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
10135 .channel_mode = alc880_threestack_modes,
10136 .need_dac_fix = 1,
10137 .input_mux = &alc882_capture_source,
10138 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010139 [ALC883_3ST_2ch_DIG] = {
10140 .mixers = { alc883_3ST_2ch_mixer },
10141 .init_verbs = { alc883_init_verbs },
10142 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10143 .dac_nids = alc883_dac_nids,
10144 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010145 .dig_in_nid = ALC883_DIGIN_NID,
10146 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10147 .channel_mode = alc883_3ST_2ch_modes,
10148 .input_mux = &alc883_capture_source,
10149 },
10150 [ALC883_3ST_6ch_DIG] = {
10151 .mixers = { alc883_3ST_6ch_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,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010156 .dig_in_nid = ALC883_DIGIN_NID,
10157 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10158 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010159 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010160 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010161 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010162 [ALC883_3ST_6ch] = {
10163 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10164 .init_verbs = { alc883_init_verbs },
10165 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10166 .dac_nids = alc883_dac_nids,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010167 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10168 .channel_mode = alc883_3ST_6ch_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020010169 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010170 .input_mux = &alc883_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010171 },
Jiang zhe17bba1b2008-06-04 12:11:07 +020010172 [ALC883_3ST_6ch_INTEL] = {
10173 .mixers = { alc883_3ST_6ch_intel_mixer, alc883_chmode_mixer },
10174 .init_verbs = { alc883_init_verbs },
10175 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10176 .dac_nids = alc883_dac_nids,
10177 .dig_out_nid = ALC883_DIGOUT_NID,
10178 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangf3cd3f52009-04-02 19:44:18 +080010179 .slave_dig_outs = alc883_slave_dig_outs,
Jiang zhe17bba1b2008-06-04 12:11:07 +020010180 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_intel_modes),
10181 .channel_mode = alc883_3ST_6ch_intel_modes,
10182 .need_dac_fix = 1,
10183 .input_mux = &alc883_3stack_6ch_intel,
10184 },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010185 [ALC889A_INTEL] = {
10186 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020010187 .init_verbs = { alc885_init_verbs, alc885_init_input_verbs,
10188 alc_hp15_unsol_verbs },
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010189 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10190 .dac_nids = alc883_dac_nids,
10191 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10192 .adc_nids = alc889_adc_nids,
10193 .dig_out_nid = ALC883_DIGOUT_NID,
10194 .dig_in_nid = ALC883_DIGIN_NID,
10195 .slave_dig_outs = alc883_slave_dig_outs,
10196 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10197 .channel_mode = alc889_8ch_intel_modes,
10198 .capsrc_nids = alc889_capsrc_nids,
10199 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010200 .setup = alc889_automute_setup,
10201 .init_hook = alc_automute_amp,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010202 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010203 .need_dac_fix = 1,
10204 },
10205 [ALC889_INTEL] = {
10206 .mixers = { alc885_8ch_intel_mixer, alc883_chmode_mixer },
10207 .init_verbs = { alc885_init_verbs, alc889_init_input_verbs,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010208 alc889_eapd_verbs, alc_hp15_unsol_verbs},
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010209 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10210 .dac_nids = alc883_dac_nids,
10211 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10212 .adc_nids = alc889_adc_nids,
10213 .dig_out_nid = ALC883_DIGOUT_NID,
10214 .dig_in_nid = ALC883_DIGIN_NID,
10215 .slave_dig_outs = alc883_slave_dig_outs,
10216 .num_channel_mode = ARRAY_SIZE(alc889_8ch_intel_modes),
10217 .channel_mode = alc889_8ch_intel_modes,
10218 .capsrc_nids = alc889_capsrc_nids,
10219 .input_mux = &alc889_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010220 .setup = alc889_automute_setup,
Wu Fengguang6732bd02009-07-30 09:19:14 +020010221 .init_hook = alc889_intel_init_hook,
10222 .unsol_event = alc_automute_amp_unsol_event,
Jaroslav Kysela87a8c372009-07-23 10:58:29 +020010223 .need_dac_fix = 1,
10224 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010225 [ALC883_6ST_DIG] = {
10226 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10227 .init_verbs = { alc883_init_verbs },
10228 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10229 .dac_nids = alc883_dac_nids,
10230 .dig_out_nid = ALC883_DIGOUT_NID,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010231 .dig_in_nid = ALC883_DIGIN_NID,
10232 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10233 .channel_mode = alc883_sixstack_modes,
10234 .input_mux = &alc883_capture_source,
10235 },
Kailang Yangccc656c2006-10-17 12:32:26 +020010236 [ALC883_TARGA_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010237 .mixers = { alc883_targa_mixer, alc883_chmode_mixer },
David Heidelberger005b1072009-07-09 18:45:46 +020010238 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10239 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010240 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10241 .dac_nids = alc883_dac_nids,
10242 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010243 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10244 .channel_mode = alc883_3ST_6ch_modes,
10245 .need_dac_fix = 1,
10246 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010247 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010248 .setup = alc882_targa_setup,
10249 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010250 },
10251 [ALC883_TARGA_2ch_DIG] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010252 .mixers = { alc883_targa_2ch_mixer},
David Heidelberger005b1072009-07-09 18:45:46 +020010253 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
10254 alc883_targa_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020010255 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10256 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010257 .adc_nids = alc883_adc_nids_alt,
10258 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010259 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangccc656c2006-10-17 12:32:26 +020010260 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yangccc656c2006-10-17 12:32:26 +020010261 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10262 .channel_mode = alc883_3ST_2ch_modes,
10263 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010264 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010265 .setup = alc882_targa_setup,
10266 .init_hook = alc882_targa_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020010267 },
David Heidelberger64a8be72009-06-08 16:15:18 +020010268 [ALC883_TARGA_8ch_DIG] = {
Takashi Iwaib99dba32009-09-17 18:23:00 +020010269 .mixers = { alc883_targa_mixer, alc883_targa_8ch_mixer,
10270 alc883_chmode_mixer },
David Heidelberger64a8be72009-06-08 16:15:18 +020010271 .init_verbs = { alc883_init_verbs, alc880_gpio3_init_verbs,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010272 alc883_targa_verbs },
David Heidelberger64a8be72009-06-08 16:15:18 +020010273 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10274 .dac_nids = alc883_dac_nids,
10275 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10276 .adc_nids = alc883_adc_nids_rev,
10277 .capsrc_nids = alc883_capsrc_nids_rev,
10278 .dig_out_nid = ALC883_DIGOUT_NID,
10279 .dig_in_nid = ALC883_DIGIN_NID,
10280 .num_channel_mode = ARRAY_SIZE(alc883_4ST_8ch_modes),
10281 .channel_mode = alc883_4ST_8ch_modes,
10282 .need_dac_fix = 1,
10283 .input_mux = &alc883_capture_source,
Sasha Alexandrc2592492009-06-16 14:52:54 -040010284 .unsol_event = alc883_targa_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010285 .setup = alc882_targa_setup,
10286 .init_hook = alc882_targa_automute,
David Heidelberger64a8be72009-06-08 16:15:18 +020010287 },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010288 [ALC883_ACER] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010289 .mixers = { alc883_base_mixer },
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010290 /* On TravelMate laptops, GPIO 0 enables the internal speaker
10291 * and the headphone jack. Turn this on and rely on the
10292 * standard mute methods whenever the user wants to turn
10293 * these outputs off.
10294 */
10295 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
10296 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10297 .dac_nids = alc883_dac_nids,
Vladimir Avdoninbab282b92006-08-22 13:31:58 +020010298 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10299 .channel_mode = alc883_3ST_2ch_modes,
10300 .input_mux = &alc883_capture_source,
10301 },
Tobin Davis2880a862007-08-07 11:50:26 +020010302 [ALC883_ACER_ASPIRE] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010303 .mixers = { alc883_acer_aspire_mixer },
Kailang Yangd1a991a2007-08-15 16:21:59 +020010304 .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
Tobin Davis2880a862007-08-07 11:50:26 +020010305 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10306 .dac_nids = alc883_dac_nids,
10307 .dig_out_nid = ALC883_DIGOUT_NID,
Tobin Davis2880a862007-08-07 11:50:26 +020010308 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10309 .channel_mode = alc883_3ST_2ch_modes,
10310 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010311 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010312 .setup = alc883_acer_aspire_setup,
10313 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020010314 },
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010315 [ALC888_ACER_ASPIRE_4930G] = {
Łukasz Wojniłowicz460c92f2011-02-07 13:13:27 +010010316 .mixers = { alc888_acer_aspire_4930g_mixer,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010317 alc883_chmode_mixer },
10318 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10319 alc888_acer_aspire_4930g_verbs },
10320 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10321 .dac_nids = alc883_dac_nids,
10322 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10323 .adc_nids = alc883_adc_nids_rev,
10324 .capsrc_nids = alc883_capsrc_nids_rev,
10325 .dig_out_nid = ALC883_DIGOUT_NID,
10326 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10327 .channel_mode = alc883_3ST_6ch_modes,
10328 .need_dac_fix = 1,
Łukasz Wojniłowicz973b8cb2010-01-24 14:12:37 +010010329 .const_channel_count = 6,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010330 .num_mux_defs =
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010331 ARRAY_SIZE(alc888_2_capture_sources),
10332 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010333 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010334 .setup = alc888_acer_aspire_4930g_setup,
10335 .init_hook = alc_automute_amp,
Vincent Petry5b2d1ec2008-11-18 22:21:57 +080010336 },
Tony Vroond2fd4b02009-06-21 00:40:10 +010010337 [ALC888_ACER_ASPIRE_6530G] = {
10338 .mixers = { alc888_acer_aspire_6530_mixer },
10339 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10340 alc888_acer_aspire_6530g_verbs },
10341 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10342 .dac_nids = alc883_dac_nids,
10343 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10344 .adc_nids = alc883_adc_nids_rev,
10345 .capsrc_nids = alc883_capsrc_nids_rev,
10346 .dig_out_nid = ALC883_DIGOUT_NID,
10347 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10348 .channel_mode = alc883_3ST_2ch_modes,
10349 .num_mux_defs =
10350 ARRAY_SIZE(alc888_2_capture_sources),
10351 .input_mux = alc888_acer_aspire_6530_sources,
10352 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010353 .setup = alc888_acer_aspire_6530g_setup,
10354 .init_hook = alc_automute_amp,
Tony Vroond2fd4b02009-06-21 00:40:10 +010010355 },
Hector Martin3b315d72009-06-02 10:54:19 +020010356 [ALC888_ACER_ASPIRE_8930G] = {
Hector Martin556eea92009-12-20 22:51:23 +010010357 .mixers = { alc889_acer_aspire_8930g_mixer,
Hector Martin3b315d72009-06-02 10:54:19 +020010358 alc883_chmode_mixer },
10359 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
Hector Martin0f86a222009-12-20 22:51:18 +010010360 alc889_acer_aspire_8930g_verbs,
10361 alc889_eapd_verbs},
Hector Martin3b315d72009-06-02 10:54:19 +020010362 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10363 .dac_nids = alc883_dac_nids,
Hector Martin018df412009-06-04 00:13:40 +020010364 .num_adc_nids = ARRAY_SIZE(alc889_adc_nids),
10365 .adc_nids = alc889_adc_nids,
10366 .capsrc_nids = alc889_capsrc_nids,
Hector Martin3b315d72009-06-02 10:54:19 +020010367 .dig_out_nid = ALC883_DIGOUT_NID,
10368 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10369 .channel_mode = alc883_3ST_6ch_modes,
10370 .need_dac_fix = 1,
10371 .const_channel_count = 6,
10372 .num_mux_defs =
Hector Martin018df412009-06-04 00:13:40 +020010373 ARRAY_SIZE(alc889_capture_sources),
10374 .input_mux = alc889_capture_sources,
Hector Martin3b315d72009-06-02 10:54:19 +020010375 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010376 .setup = alc889_acer_aspire_8930g_setup,
10377 .init_hook = alc_automute_amp,
Hector Martinf5de24b2009-12-20 22:51:31 +010010378#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050010379 .power_hook = alc_power_eapd,
Hector Martinf5de24b2009-12-20 22:51:31 +010010380#endif
Hector Martin3b315d72009-06-02 10:54:19 +020010381 },
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010382 [ALC888_ACER_ASPIRE_7730G] = {
10383 .mixers = { alc883_3ST_6ch_mixer,
10384 alc883_chmode_mixer },
10385 .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs,
10386 alc888_acer_aspire_7730G_verbs },
10387 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10388 .dac_nids = alc883_dac_nids,
10389 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10390 .adc_nids = alc883_adc_nids_rev,
10391 .capsrc_nids = alc883_capsrc_nids_rev,
10392 .dig_out_nid = ALC883_DIGOUT_NID,
10393 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10394 .channel_mode = alc883_3ST_6ch_modes,
10395 .need_dac_fix = 1,
10396 .const_channel_count = 6,
10397 .input_mux = &alc883_capture_source,
10398 .unsol_event = alc_automute_amp_unsol_event,
Denis Kuplyakovd9477202010-11-24 06:01:09 +010010399 .setup = alc888_acer_aspire_7730g_setup,
Denis Kuplyakovfc86f952009-08-25 18:15:59 +020010400 .init_hook = alc_automute_amp,
10401 },
Tobin Davisc07584c2006-10-13 12:32:16 +020010402 [ALC883_MEDION] = {
10403 .mixers = { alc883_fivestack_mixer,
10404 alc883_chmode_mixer },
10405 .init_verbs = { alc883_init_verbs,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010406 alc883_medion_eapd_verbs },
Tobin Davisc07584c2006-10-13 12:32:16 +020010407 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10408 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010409 .adc_nids = alc883_adc_nids_alt,
10410 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010411 .capsrc_nids = alc883_capsrc_nids,
Tobin Davisc07584c2006-10-13 12:32:16 +020010412 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10413 .channel_mode = alc883_sixstack_modes,
10414 .input_mux = &alc883_capture_source,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010415 },
Maurus Cuelenaere7ad7b212010-04-06 18:12:52 +020010416 [ALC883_MEDION_WIM2160] = {
10417 .mixers = { alc883_medion_wim2160_mixer },
10418 .init_verbs = { alc883_init_verbs, alc883_medion_wim2160_verbs },
10419 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10420 .dac_nids = alc883_dac_nids,
10421 .dig_out_nid = ALC883_DIGOUT_NID,
10422 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
10423 .adc_nids = alc883_adc_nids,
10424 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10425 .channel_mode = alc883_3ST_2ch_modes,
10426 .input_mux = &alc883_capture_source,
10427 .unsol_event = alc_automute_amp_unsol_event,
10428 .setup = alc883_medion_wim2160_setup,
10429 .init_hook = alc_automute_amp,
10430 },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010431 [ALC883_LAPTOP_EAPD] = {
Takashi Iwai676a9b52007-08-16 15:23:35 +020010432 .mixers = { alc883_base_mixer },
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010433 .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
10434 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10435 .dac_nids = alc883_dac_nids,
Andrew L. Neporadab373bde2006-11-07 11:37:08 +010010436 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10437 .channel_mode = alc883_3ST_2ch_modes,
10438 .input_mux = &alc883_capture_source,
10439 },
ddiaz@cenditel.gob.vea65cc602009-09-05 16:28:06 -043010440 [ALC883_CLEVO_M540R] = {
10441 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10442 .init_verbs = { alc883_init_verbs, alc883_clevo_m540r_verbs },
10443 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10444 .dac_nids = alc883_dac_nids,
10445 .dig_out_nid = ALC883_DIGOUT_NID,
10446 .dig_in_nid = ALC883_DIGIN_NID,
10447 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_clevo_modes),
10448 .channel_mode = alc883_3ST_6ch_clevo_modes,
10449 .need_dac_fix = 1,
10450 .input_mux = &alc883_capture_source,
10451 /* This machine has the hardware HP auto-muting, thus
10452 * we need no software mute via unsol event
10453 */
10454 },
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010455 [ALC883_CLEVO_M720] = {
10456 .mixers = { alc883_clevo_m720_mixer },
10457 .init_verbs = { alc883_init_verbs, alc883_clevo_m720_verbs },
Jiang zhe368c7a92008-03-04 11:20:33 +010010458 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10459 .dac_nids = alc883_dac_nids,
10460 .dig_out_nid = ALC883_DIGOUT_NID,
10461 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10462 .channel_mode = alc883_3ST_2ch_modes,
10463 .input_mux = &alc883_capture_source,
Herton Ronaldo Krzesinski0c4cc442008-03-22 10:26:05 +010010464 .unsol_event = alc883_clevo_m720_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010465 .setup = alc883_clevo_m720_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010466 .init_hook = alc883_clevo_m720_init_hook,
Jiang zhe368c7a92008-03-04 11:20:33 +010010467 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010468 [ALC883_LENOVO_101E_2ch] = {
10469 .mixers = { alc883_lenovo_101e_2ch_mixer},
10470 .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
10471 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10472 .dac_nids = alc883_dac_nids,
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010473 .adc_nids = alc883_adc_nids_alt,
10474 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_alt),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010475 .capsrc_nids = alc883_capsrc_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020010476 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10477 .channel_mode = alc883_3ST_2ch_modes,
10478 .input_mux = &alc883_lenovo_101e_capture_source,
10479 .unsol_event = alc883_lenovo_101e_unsol_event,
10480 .init_hook = alc883_lenovo_101e_all_automute,
10481 },
Kailang Yang272a5272007-05-14 11:00:38 +020010482 [ALC883_LENOVO_NB0763] = {
10483 .mixers = { alc883_lenovo_nb0763_mixer },
10484 .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
10485 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10486 .dac_nids = alc883_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020010487 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10488 .channel_mode = alc883_3ST_2ch_modes,
10489 .need_dac_fix = 1,
10490 .input_mux = &alc883_lenovo_nb0763_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010491 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwaidc4271702010-11-29 07:42:59 +010010492 .setup = alc883_lenovo_nb0763_setup,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010493 .init_hook = alc_automute_amp,
Kailang Yang272a5272007-05-14 11:00:38 +020010494 },
10495 [ALC888_LENOVO_MS7195_DIG] = {
10496 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10497 .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
10498 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10499 .dac_nids = alc883_dac_nids,
10500 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang272a5272007-05-14 11:00:38 +020010501 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10502 .channel_mode = alc883_3ST_6ch_modes,
10503 .need_dac_fix = 1,
10504 .input_mux = &alc883_capture_source,
10505 .unsol_event = alc883_lenovo_ms7195_unsol_event,
10506 .init_hook = alc888_lenovo_ms7195_front_automute,
Kailang Yang189609a2007-08-20 11:31:23 +020010507 },
10508 [ALC883_HAIER_W66] = {
Sasha Alexandrc2592492009-06-16 14:52:54 -040010509 .mixers = { alc883_targa_2ch_mixer},
Kailang Yang189609a2007-08-20 11:31:23 +020010510 .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
10511 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10512 .dac_nids = alc883_dac_nids,
10513 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yang189609a2007-08-20 11:31:23 +020010514 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10515 .channel_mode = alc883_3ST_2ch_modes,
10516 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010517 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010518 .setup = alc883_haier_w66_setup,
10519 .init_hook = alc_automute_amp,
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010520 },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010521 [ALC888_3ST_HP] = {
Herton Ronaldo Krzesinskieea64192008-03-20 12:14:59 +010010522 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010523 .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010524 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10525 .dac_nids = alc883_dac_nids,
Claudio Matsuoka4723c022007-07-13 14:36:19 +020010526 .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
10527 .channel_mode = alc888_3st_hp_modes,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010528 .need_dac_fix = 1,
10529 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010530 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010531 .setup = alc888_3st_hp_setup,
10532 .init_hook = alc_automute_amp,
Claudio Matsuoka8341de62007-07-06 12:10:45 +020010533 },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010534 [ALC888_6ST_DELL] = {
Herton Ronaldo Krzesinskif24dbdc2008-03-20 12:14:28 +010010535 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010536 .init_verbs = { alc883_init_verbs, alc888_6st_dell_verbs },
10537 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10538 .dac_nids = alc883_dac_nids,
10539 .dig_out_nid = ALC883_DIGOUT_NID,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010540 .dig_in_nid = ALC883_DIGIN_NID,
10541 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10542 .channel_mode = alc883_sixstack_modes,
10543 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010544 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010545 .setup = alc888_6st_dell_setup,
10546 .init_hook = alc_automute_amp,
Claudio Matsuoka5795b9e2008-01-13 11:58:27 +010010547 },
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010548 [ALC883_MITAC] = {
10549 .mixers = { alc883_mitac_mixer },
10550 .init_verbs = { alc883_init_verbs, alc883_mitac_verbs },
10551 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10552 .dac_nids = alc883_dac_nids,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010553 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10554 .channel_mode = alc883_3ST_2ch_modes,
10555 .input_mux = &alc883_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010556 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010557 .setup = alc883_mitac_setup,
10558 .init_hook = alc_automute_amp,
Andy Shevchenkoa8848bd2007-12-13 17:32:26 +010010559 },
Jiang zhefb97dc62008-03-06 11:07:11 +010010560 [ALC883_FUJITSU_PI2515] = {
10561 .mixers = { alc883_2ch_fujitsu_pi2515_mixer },
10562 .init_verbs = { alc883_init_verbs,
10563 alc883_2ch_fujitsu_pi2515_verbs},
10564 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10565 .dac_nids = alc883_dac_nids,
10566 .dig_out_nid = ALC883_DIGOUT_NID,
10567 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10568 .channel_mode = alc883_3ST_2ch_modes,
10569 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010570 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010571 .setup = alc883_2ch_fujitsu_pi2515_setup,
10572 .init_hook = alc_automute_amp,
Jiang zhefb97dc62008-03-06 11:07:11 +010010573 },
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010574 [ALC888_FUJITSU_XA3530] = {
10575 .mixers = { alc888_base_mixer, alc883_chmode_mixer },
10576 .init_verbs = { alc883_init_verbs,
10577 alc888_fujitsu_xa3530_verbs },
10578 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10579 .dac_nids = alc883_dac_nids,
10580 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids_rev),
10581 .adc_nids = alc883_adc_nids_rev,
10582 .capsrc_nids = alc883_capsrc_nids_rev,
10583 .dig_out_nid = ALC883_DIGOUT_NID,
10584 .num_channel_mode = ARRAY_SIZE(alc888_4ST_8ch_intel_modes),
10585 .channel_mode = alc888_4ST_8ch_intel_modes,
10586 .num_mux_defs =
10587 ARRAY_SIZE(alc888_2_capture_sources),
10588 .input_mux = alc888_2_capture_sources,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010589 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010590 .setup = alc888_fujitsu_xa3530_setup,
10591 .init_hook = alc_automute_amp,
Vincent Petryef8ef5f2008-11-23 11:31:41 +080010592 },
Kailang Yange2757d52008-08-26 13:17:46 +020010593 [ALC888_LENOVO_SKY] = {
10594 .mixers = { alc888_lenovo_sky_mixer, alc883_chmode_mixer },
10595 .init_verbs = { alc883_init_verbs, alc888_lenovo_sky_verbs},
10596 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10597 .dac_nids = alc883_dac_nids,
10598 .dig_out_nid = ALC883_DIGOUT_NID,
Kailang Yange2757d52008-08-26 13:17:46 +020010599 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10600 .channel_mode = alc883_sixstack_modes,
10601 .need_dac_fix = 1,
10602 .input_mux = &alc883_lenovo_sky_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010603 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010604 .setup = alc888_lenovo_sky_setup,
10605 .init_hook = alc_automute_amp,
Kailang Yange2757d52008-08-26 13:17:46 +020010606 },
10607 [ALC888_ASUS_M90V] = {
10608 .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
10609 .init_verbs = { alc883_init_verbs, alc888_asus_m90v_verbs },
10610 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10611 .dac_nids = alc883_dac_nids,
10612 .dig_out_nid = ALC883_DIGOUT_NID,
10613 .dig_in_nid = ALC883_DIGIN_NID,
10614 .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
10615 .channel_mode = alc883_3ST_6ch_modes,
10616 .need_dac_fix = 1,
10617 .input_mux = &alc883_fujitsu_pi2515_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010618 .unsol_event = alc_sku_unsol_event,
10619 .setup = alc883_mode2_setup,
10620 .init_hook = alc_inithook,
Kailang Yange2757d52008-08-26 13:17:46 +020010621 },
10622 [ALC888_ASUS_EEE1601] = {
10623 .mixers = { alc883_asus_eee1601_mixer },
Takashi Iwaif9e336f2008-10-31 16:37:07 +010010624 .cap_mixer = alc883_asus_eee1601_cap_mixer,
Kailang Yange2757d52008-08-26 13:17:46 +020010625 .init_verbs = { alc883_init_verbs, alc888_asus_eee1601_verbs },
10626 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10627 .dac_nids = alc883_dac_nids,
10628 .dig_out_nid = ALC883_DIGOUT_NID,
10629 .dig_in_nid = ALC883_DIGIN_NID,
10630 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10631 .channel_mode = alc883_3ST_2ch_modes,
10632 .need_dac_fix = 1,
10633 .input_mux = &alc883_asus_eee1601_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020010634 .unsol_event = alc_sku_unsol_event,
Kailang Yange2757d52008-08-26 13:17:46 +020010635 .init_hook = alc883_eee1601_inithook,
10636 },
Wu Fengguang3ab90932008-11-17 09:51:09 +010010637 [ALC1200_ASUS_P5Q] = {
10638 .mixers = { alc883_base_mixer, alc883_chmode_mixer },
10639 .init_verbs = { alc883_init_verbs },
10640 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10641 .dac_nids = alc883_dac_nids,
10642 .dig_out_nid = ALC1200_DIGOUT_NID,
10643 .dig_in_nid = ALC883_DIGIN_NID,
Wu Fengguangb25c9da2009-02-06 15:02:27 +080010644 .slave_dig_outs = alc1200_slave_dig_outs,
Wu Fengguang3ab90932008-11-17 09:51:09 +010010645 .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
10646 .channel_mode = alc883_sixstack_modes,
10647 .input_mux = &alc883_capture_source,
10648 },
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010649 [ALC889A_MB31] = {
10650 .mixers = { alc889A_mb31_mixer, alc883_chmode_mixer},
10651 .init_verbs = { alc883_init_verbs, alc889A_mb31_verbs,
10652 alc880_gpio1_init_verbs },
10653 .adc_nids = alc883_adc_nids,
10654 .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
Takashi Iwai035eb0c2009-12-17 15:00:26 +010010655 .capsrc_nids = alc883_capsrc_nids,
Torben Schulzeb4c41d2009-05-18 15:02:35 +020010656 .dac_nids = alc883_dac_nids,
10657 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10658 .channel_mode = alc889A_mb31_6ch_modes,
10659 .num_channel_mode = ARRAY_SIZE(alc889A_mb31_6ch_modes),
10660 .input_mux = &alc889A_mb31_capture_source,
10661 .dig_out_nid = ALC883_DIGOUT_NID,
10662 .unsol_event = alc889A_mb31_unsol_event,
10663 .init_hook = alc889A_mb31_automute,
10664 },
Guido Günther3e1647c2009-06-05 00:47:26 +020010665 [ALC883_SONY_VAIO_TT] = {
10666 .mixers = { alc883_vaiott_mixer },
10667 .init_verbs = { alc883_init_verbs, alc883_vaiott_verbs },
10668 .num_dacs = ARRAY_SIZE(alc883_dac_nids),
10669 .dac_nids = alc883_dac_nids,
10670 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
10671 .channel_mode = alc883_3ST_2ch_modes,
10672 .input_mux = &alc883_capture_source,
10673 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020010674 .setup = alc883_vaiott_setup,
10675 .init_hook = alc_automute_amp,
Guido Günther3e1647c2009-06-05 00:47:26 +020010676 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010677};
10678
10679
10680/*
Takashi Iwai4953550a2009-06-30 15:28:30 +020010681 * Pin config fixes
10682 */
10683enum {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010684 PINFIX_ABIT_AW9D_MAX,
David Henningsson32eea382011-03-04 13:37:50 +010010685 PINFIX_LENOVO_Y530,
Takashi Iwai954a29c2010-07-30 10:55:44 +020010686 PINFIX_PB_M5210,
David Henningssonc3d226a2010-10-14 15:42:08 +020010687 PINFIX_ACER_ASPIRE_7736,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010688};
10689
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010690static const struct alc_fixup alc882_fixups[] = {
10691 [PINFIX_ABIT_AW9D_MAX] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010692 .type = ALC_FIXUP_PINS,
10693 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010694 { 0x15, 0x01080104 }, /* side */
10695 { 0x16, 0x01011012 }, /* rear */
10696 { 0x17, 0x01016011 }, /* clfe */
10697 { }
10698 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010699 },
David Henningsson32eea382011-03-04 13:37:50 +010010700 [PINFIX_LENOVO_Y530] = {
10701 .type = ALC_FIXUP_PINS,
10702 .v.pins = (const struct alc_pincfg[]) {
10703 { 0x15, 0x99130112 }, /* rear int speakers */
10704 { 0x16, 0x99130111 }, /* subwoofer */
10705 { }
10706 }
10707 },
Takashi Iwai954a29c2010-07-30 10:55:44 +020010708 [PINFIX_PB_M5210] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010709 .type = ALC_FIXUP_VERBS,
10710 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020010711 { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 },
10712 {}
10713 }
Takashi Iwai954a29c2010-07-30 10:55:44 +020010714 },
David Henningssonc3d226a2010-10-14 15:42:08 +020010715 [PINFIX_ACER_ASPIRE_7736] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010010716 .type = ALC_FIXUP_SKU,
10717 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonc3d226a2010-10-14 15:42:08 +020010718 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020010719};
10720
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020010721static struct snd_pci_quirk alc882_fixup_tbl[] = {
Takashi Iwai954a29c2010-07-30 10:55:44 +020010722 SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", PINFIX_PB_M5210),
David Henningsson32eea382011-03-04 13:37:50 +010010723 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", PINFIX_LENOVO_Y530),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010724 SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
David Henningssonc3d226a2010-10-14 15:42:08 +020010725 SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", PINFIX_ACER_ASPIRE_7736),
Takashi Iwai4953550a2009-06-30 15:28:30 +020010726 {}
10727};
10728
10729/*
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010730 * BIOS auto configuration
10731 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020010732static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10733 const struct auto_pin_cfg *cfg)
10734{
10735 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x23, 0x22);
10736}
10737
Takashi Iwai4953550a2009-06-30 15:28:30 +020010738static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010739 hda_nid_t nid, int pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010740 hda_nid_t dac)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010741{
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010742 int idx;
10743
Takashi Iwai489008c2010-04-07 09:06:00 +020010744 /* set as output */
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010745 alc_set_pin_output(codec, nid, pin_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010746
Takashi Iwai489008c2010-04-07 09:06:00 +020010747 if (dac == 0x25)
10748 idx = 4;
10749 else if (dac >= 0x02 && dac <= 0x05)
10750 idx = dac - 2;
10751 else
10752 return;
10753 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010754}
10755
Takashi Iwai4953550a2009-06-30 15:28:30 +020010756static void alc882_auto_init_multi_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010757{
10758 struct alc_spec *spec = codec->spec;
10759 int i;
10760
10761 for (i = 0; i <= HDA_SIDE; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020010762 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020010763 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010764 if (nid)
Takashi Iwai4953550a2009-06-30 15:28:30 +020010765 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai489008c2010-04-07 09:06:00 +020010766 spec->multiout.dac_nids[i]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010767 }
10768}
10769
Takashi Iwai4953550a2009-06-30 15:28:30 +020010770static void alc882_auto_init_hp_out(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010771{
10772 struct alc_spec *spec = codec->spec;
Takashi Iwai489008c2010-04-07 09:06:00 +020010773 hda_nid_t pin, dac;
Takashi Iwai5855fb82010-09-16 18:24:02 +020010774 int i;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010775
Takashi Iwai5855fb82010-09-16 18:24:02 +020010776 for (i = 0; i < ARRAY_SIZE(spec->autocfg.hp_pins); i++) {
10777 pin = spec->autocfg.hp_pins[i];
10778 if (!pin)
10779 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010780 dac = spec->multiout.hp_nid;
10781 if (!dac)
10782 dac = spec->multiout.dac_nids[0]; /* to front */
10783 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10784 }
Takashi Iwai5855fb82010-09-16 18:24:02 +020010785 for (i = 0; i < ARRAY_SIZE(spec->autocfg.speaker_pins); i++) {
10786 pin = spec->autocfg.speaker_pins[i];
10787 if (!pin)
10788 break;
Takashi Iwai489008c2010-04-07 09:06:00 +020010789 dac = spec->multiout.extra_out_nid[0];
10790 if (!dac)
10791 dac = spec->multiout.dac_nids[0]; /* to front */
10792 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10793 }
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010794}
10795
Takashi Iwai4953550a2009-06-30 15:28:30 +020010796static void alc882_auto_init_analog_input(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010797{
10798 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010799 struct auto_pin_cfg *cfg = &spec->autocfg;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010800 int i;
10801
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010802 for (i = 0; i < cfg->num_inputs; i++) {
10803 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai30ea0982010-09-16 18:47:56 +020010804 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai4953550a2009-06-30 15:28:30 +020010805 if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP)
10806 snd_hda_codec_write(codec, nid, 0,
10807 AC_VERB_SET_AMP_GAIN_MUTE,
10808 AMP_OUT_MUTE);
10809 }
10810}
10811
10812static void alc882_auto_init_input_src(struct hda_codec *codec)
10813{
10814 struct alc_spec *spec = codec->spec;
10815 int c;
10816
10817 for (c = 0; c < spec->num_adc_nids; c++) {
10818 hda_nid_t conn_list[HDA_MAX_NUM_INPUTS];
10819 hda_nid_t nid = spec->capsrc_nids[c];
10820 unsigned int mux_idx;
10821 const struct hda_input_mux *imux;
10822 int conns, mute, idx, item;
10823
10824 conns = snd_hda_get_connections(codec, nid, conn_list,
10825 ARRAY_SIZE(conn_list));
10826 if (conns < 0)
10827 continue;
10828 mux_idx = c >= spec->num_mux_defs ? 0 : c;
10829 imux = &spec->input_mux[mux_idx];
Takashi Iwai53111142010-03-08 12:13:07 +010010830 if (!imux->num_items && mux_idx > 0)
10831 imux = &spec->input_mux[0];
Takashi Iwai4953550a2009-06-30 15:28:30 +020010832 for (idx = 0; idx < conns; idx++) {
10833 /* if the current connection is the selected one,
10834 * unmute it as default - otherwise mute it
10835 */
10836 mute = AMP_IN_MUTE(idx);
10837 for (item = 0; item < imux->num_items; item++) {
10838 if (imux->items[item].index == idx) {
10839 if (spec->cur_mux[c] == item)
10840 mute = AMP_IN_UNMUTE(idx);
10841 break;
10842 }
10843 }
10844 /* check if we have a selector or mixer
10845 * we could check for the widget type instead, but
10846 * just check for Amp-In presence (in case of mixer
10847 * without amp-in there is something wrong, this
10848 * function shouldn't be used or capsrc nid is wrong)
10849 */
10850 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010851 snd_hda_codec_write(codec, nid, 0,
10852 AC_VERB_SET_AMP_GAIN_MUTE,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010853 mute);
10854 else if (mute != AMP_IN_MUTE(idx))
10855 snd_hda_codec_write(codec, nid, 0,
10856 AC_VERB_SET_CONNECT_SEL,
10857 idx);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010858 }
10859 }
10860}
10861
Takashi Iwai4953550a2009-06-30 15:28:30 +020010862/* add mic boosts if needed */
10863static int alc_auto_add_mic_boost(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010864{
10865 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010866 struct auto_pin_cfg *cfg = &spec->autocfg;
David Henningsson5322bf22011-01-05 11:03:56 +010010867 int i, err;
Takashi Iwai53e8c322010-12-17 15:23:41 +010010868 int type_idx = 0;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010869 hda_nid_t nid;
David Henningsson5322bf22011-01-05 11:03:56 +010010870 const char *prev_label = NULL;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010871
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010872 for (i = 0; i < cfg->num_inputs; i++) {
Takashi Iwai86e29592010-09-09 14:50:17 +020010873 if (cfg->inputs[i].type > AUTO_PIN_MIC)
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010874 break;
10875 nid = cfg->inputs[i].pin;
10876 if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) {
David Henningsson5322bf22011-01-05 11:03:56 +010010877 const char *label;
10878 char boost_label[32];
10879
10880 label = hda_get_autocfg_input_label(codec, cfg, i);
10881 if (prev_label && !strcmp(label, prev_label))
Takashi Iwai53e8c322010-12-17 15:23:41 +010010882 type_idx++;
10883 else
10884 type_idx = 0;
David Henningsson5322bf22011-01-05 11:03:56 +010010885 prev_label = label;
10886
10887 snprintf(boost_label, sizeof(boost_label),
10888 "%s Boost Volume", label);
10889 err = add_control(spec, ALC_CTL_WIDGET_VOL,
10890 boost_label, type_idx,
Takashi Iwai4953550a2009-06-30 15:28:30 +020010891 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
Takashi Iwai66ceeb62010-08-30 13:05:52 +020010892 if (err < 0)
10893 return err;
10894 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020010895 }
10896 return 0;
10897}
10898
10899/* almost identical with ALC880 parser... */
10900static int alc882_parse_auto_config(struct hda_codec *codec)
10901{
10902 struct alc_spec *spec = codec->spec;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010903 static hda_nid_t alc882_ignore[] = { 0x1d, 0 };
Takashi Iwai757899a2010-07-30 10:48:14 +020010904 int err;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010905
Takashi Iwai05f5f472009-08-25 13:10:18 +020010906 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
10907 alc882_ignore);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010908 if (err < 0)
10909 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010910 if (!spec->autocfg.line_outs)
10911 return 0; /* can't find valid BIOS pin config */
10912
10913 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
10914 if (err < 0)
10915 return err;
Takashi Iwai569ed342011-01-19 10:14:46 +010010916 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010917 if (err < 0)
10918 return err;
Takashi Iwai489008c2010-04-07 09:06:00 +020010919 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10920 "Headphone");
10921 if (err < 0)
10922 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010923 err = alc880_auto_create_extra_out(spec,
10924 spec->autocfg.speaker_pins[0],
10925 "Speaker");
10926 if (err < 0)
10927 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020010928 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10929 if (err < 0)
10930 return err;
10931
10932 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
10933
Takashi Iwai757899a2010-07-30 10:48:14 +020010934 alc_auto_parse_digital(codec);
Takashi Iwai05f5f472009-08-25 13:10:18 +020010935
10936 if (spec->kctls.list)
10937 add_mixer(spec, spec->kctls.list);
10938
10939 add_verb(spec, alc883_auto_init_verbs);
10940 /* if ADC 0x07 is available, initialize it, too */
10941 if (get_wcaps_type(get_wcaps(codec, 0x07)) == AC_WID_AUD_IN)
10942 add_verb(spec, alc882_adc1_init_verbs);
10943
10944 spec->num_mux_defs = 1;
10945 spec->input_mux = &spec->private_imux[0];
10946
Kailang Yang6227cdc2010-02-25 08:36:52 +010010947 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai776e1842007-08-29 15:07:11 +020010948
10949 err = alc_auto_add_mic_boost(codec);
10950 if (err < 0)
10951 return err;
10952
Takashi Iwai776e1842007-08-29 15:07:11 +020010953 return 1; /* config found */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010954}
10955
10956/* additional initialization for auto-configuration model */
Takashi Iwai4953550a2009-06-30 15:28:30 +020010957static void alc882_auto_init(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010958{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010959 struct alc_spec *spec = codec->spec;
Takashi Iwai4953550a2009-06-30 15:28:30 +020010960 alc882_auto_init_multi_out(codec);
10961 alc882_auto_init_hp_out(codec);
10962 alc882_auto_init_analog_input(codec);
10963 alc882_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020010964 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010010965 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020010966 alc_inithook(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010967}
10968
Takashi Iwai4953550a2009-06-30 15:28:30 +020010969static int patch_alc882(struct hda_codec *codec)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010970{
10971 struct alc_spec *spec;
10972 int err, board_config;
10973
10974 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
10975 if (spec == NULL)
10976 return -ENOMEM;
10977
10978 codec->spec = spec;
10979
Takashi Iwai4953550a2009-06-30 15:28:30 +020010980 switch (codec->vendor_id) {
10981 case 0x10ec0882:
10982 case 0x10ec0885:
10983 break;
10984 default:
10985 /* ALC883 and variants */
10986 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
10987 break;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020010988 }
10989
Takashi Iwai4953550a2009-06-30 15:28:30 +020010990 board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
10991 alc882_models,
10992 alc882_cfg_tbl);
10993
10994 if (board_config < 0 || board_config >= ALC882_MODEL_LAST)
10995 board_config = snd_hda_check_board_codec_sid_config(codec,
10996 ALC882_MODEL_LAST, alc882_models, alc882_ssid_cfg_tbl);
10997
10998 if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020010999 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
Takashi Iwai4953550a2009-06-30 15:28:30 +020011000 codec->chip_name);
11001 board_config = ALC882_AUTO;
11002 }
11003
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011004 if (board_config == ALC882_AUTO) {
11005 alc_pick_fixup(codec, NULL, alc882_fixup_tbl, alc882_fixups);
11006 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
11007 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011008
David Henningsson90622912010-10-14 14:50:18 +020011009 alc_auto_parse_customize_define(codec);
11010
Takashi Iwai4953550a2009-06-30 15:28:30 +020011011 if (board_config == ALC882_AUTO) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011012 /* automatic parse from the BIOS config */
Takashi Iwai4953550a2009-06-30 15:28:30 +020011013 err = alc882_parse_auto_config(codec);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011014 if (err < 0) {
11015 alc_free(codec);
11016 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011017 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011018 printk(KERN_INFO
11019 "hda_codec: Cannot set up configuration "
11020 "from BIOS. Using base mode...\n");
Takashi Iwai4953550a2009-06-30 15:28:30 +020011021 board_config = ALC882_3ST_DIG;
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011022 }
11023 }
11024
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011025 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020011026 err = snd_hda_attach_beep_device(codec, 0x1);
11027 if (err < 0) {
11028 alc_free(codec);
11029 return err;
11030 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090011031 }
11032
Takashi Iwai4953550a2009-06-30 15:28:30 +020011033 if (board_config != ALC882_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020011034 setup_preset(codec, &alc882_presets[board_config]);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011035
Takashi Iwai4953550a2009-06-30 15:28:30 +020011036 spec->stream_analog_playback = &alc882_pcm_analog_playback;
11037 spec->stream_analog_capture = &alc882_pcm_analog_capture;
11038 /* FIXME: setup DAC5 */
11039 /*spec->stream_analog_alt_playback = &alc880_pcm_analog_alt_playback;*/
11040 spec->stream_analog_alt_capture = &alc880_pcm_analog_alt_capture;
11041
11042 spec->stream_digital_playback = &alc882_pcm_digital_playback;
11043 spec->stream_digital_capture = &alc882_pcm_digital_capture;
11044
Takashi Iwai4953550a2009-06-30 15:28:30 +020011045 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011046 int i, j;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011047 spec->num_adc_nids = 0;
11048 for (i = 0; i < ARRAY_SIZE(alc882_adc_nids); i++) {
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011049 const struct hda_input_mux *imux = spec->input_mux;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011050 hda_nid_t cap;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011051 hda_nid_t items[16];
Takashi Iwai4953550a2009-06-30 15:28:30 +020011052 hda_nid_t nid = alc882_adc_nids[i];
11053 unsigned int wcap = get_wcaps(codec, nid);
11054 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020011055 wcap = get_wcaps_type(wcap);
Takashi Iwai4953550a2009-06-30 15:28:30 +020011056 if (wcap != AC_WID_AUD_IN)
11057 continue;
11058 spec->private_adc_nids[spec->num_adc_nids] = nid;
11059 err = snd_hda_get_connections(codec, nid, &cap, 1);
11060 if (err < 0)
11061 continue;
Takashi Iwaid11f74c2009-12-08 12:52:47 +010011062 err = snd_hda_get_connections(codec, cap, items,
11063 ARRAY_SIZE(items));
11064 if (err < 0)
11065 continue;
11066 for (j = 0; j < imux->num_items; j++)
11067 if (imux->items[j].index >= err)
11068 break;
11069 if (j < imux->num_items)
11070 continue;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011071 spec->private_capsrc_nids[spec->num_adc_nids] = cap;
11072 spec->num_adc_nids++;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020011073 }
Takashi Iwai4953550a2009-06-30 15:28:30 +020011074 spec->adc_nids = spec->private_adc_nids;
11075 spec->capsrc_nids = spec->private_capsrc_nids;
Kailang Yang2f893282008-05-27 12:14:47 +020011076 }
11077
Takashi Iwaib59bdf32009-08-11 09:47:30 +020011078 set_capture_mixer(codec);
Kailang Yangda00c242010-03-19 11:23:45 +010011079
Takashi Iwaidc1eae22010-07-29 15:30:02 +020011080 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010011081 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011082
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010011083 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020011084
Takashi Iwai2134ea42008-01-10 16:53:55 +010011085 spec->vmaster_nid = 0x0c;
11086
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011087 codec->patch_ops = alc_patch_ops;
Takashi Iwai4953550a2009-06-30 15:28:30 +020011088 if (board_config == ALC882_AUTO)
11089 spec->init_hook = alc882_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020011090
11091 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020011092#ifdef CONFIG_SND_HDA_POWER_SAVE
11093 if (!spec->loopback.amplist)
Takashi Iwai4953550a2009-06-30 15:28:30 +020011094 spec->loopback.amplist = alc882_loopbacks;
Takashi Iwaicb53c622007-08-10 17:21:45 +020011095#endif
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011096
11097 return 0;
11098}
11099
Takashi Iwai4953550a2009-06-30 15:28:30 +020011100
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011101/*
Kailang Yangdf694da2005-12-05 19:42:22 +010011102 * ALC262 support
11103 */
11104
11105#define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
11106#define ALC262_DIGIN_NID ALC880_DIGIN_NID
11107
11108#define alc262_dac_nids alc260_dac_nids
11109#define alc262_adc_nids alc882_adc_nids
11110#define alc262_adc_nids_alt alc882_adc_nids_alt
Takashi Iwai88c71a92008-02-14 17:27:17 +010011111#define alc262_capsrc_nids alc882_capsrc_nids
11112#define alc262_capsrc_nids_alt alc882_capsrc_nids_alt
Kailang Yangdf694da2005-12-05 19:42:22 +010011113
11114#define alc262_modes alc260_modes
Takashi Iwaic5f2ea02005-12-06 18:54:31 +010011115#define alc262_capture_source alc882_capture_source
Kailang Yangdf694da2005-12-05 19:42:22 +010011116
Kailang Yang4e555fe2008-08-26 13:05:55 +020011117static hda_nid_t alc262_dmic_adc_nids[1] = {
11118 /* ADC0 */
11119 0x09
11120};
11121
11122static hda_nid_t alc262_dmic_capsrc_nids[1] = { 0x22 };
11123
Kailang Yangdf694da2005-12-05 19:42:22 +010011124static struct snd_kcontrol_new alc262_base_mixer[] = {
11125 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11126 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11127 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11128 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11129 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11130 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11131 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11132 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011133 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011134 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11135 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011136 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011137 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
11138 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11139 HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
11140 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
Kailang Yangdf694da2005-12-05 19:42:22 +010011141 { } /* end */
Takashi Iwai834be882006-03-01 14:16:17 +010011142};
11143
Takashi Iwaice875f02008-01-28 18:17:43 +010011144/* update HP, line and mono-out pins according to the master switch */
11145static void alc262_hp_master_update(struct hda_codec *codec)
11146{
11147 struct alc_spec *spec = codec->spec;
11148 int val = spec->master_sw;
11149
11150 /* HP & line-out */
11151 snd_hda_codec_write_cache(codec, 0x1b, 0,
11152 AC_VERB_SET_PIN_WIDGET_CONTROL,
11153 val ? PIN_HP : 0);
11154 snd_hda_codec_write_cache(codec, 0x15, 0,
11155 AC_VERB_SET_PIN_WIDGET_CONTROL,
11156 val ? PIN_HP : 0);
11157 /* mono (speaker) depending on the HP jack sense */
11158 val = val && !spec->jack_present;
11159 snd_hda_codec_write_cache(codec, 0x16, 0,
11160 AC_VERB_SET_PIN_WIDGET_CONTROL,
11161 val ? PIN_OUT : 0);
11162}
11163
11164static void alc262_hp_bpc_automute(struct hda_codec *codec)
11165{
11166 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011167
11168 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwaice875f02008-01-28 18:17:43 +010011169 alc262_hp_master_update(codec);
11170}
11171
11172static void alc262_hp_bpc_unsol_event(struct hda_codec *codec, unsigned int res)
11173{
11174 if ((res >> 26) != ALC880_HP_EVENT)
11175 return;
11176 alc262_hp_bpc_automute(codec);
11177}
11178
11179static void alc262_hp_wildwest_automute(struct hda_codec *codec)
11180{
11181 struct alc_spec *spec = codec->spec;
Wu Fengguang864f92b2009-11-18 12:38:02 +080011182
11183 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaice875f02008-01-28 18:17:43 +010011184 alc262_hp_master_update(codec);
11185}
11186
11187static void alc262_hp_wildwest_unsol_event(struct hda_codec *codec,
11188 unsigned int res)
11189{
11190 if ((res >> 26) != ALC880_HP_EVENT)
11191 return;
11192 alc262_hp_wildwest_automute(codec);
11193}
11194
Takashi Iwaib72519b2009-05-08 14:31:55 +020011195#define alc262_hp_master_sw_get alc260_hp_master_sw_get
Takashi Iwaice875f02008-01-28 18:17:43 +010011196
11197static int alc262_hp_master_sw_put(struct snd_kcontrol *kcontrol,
11198 struct snd_ctl_elem_value *ucontrol)
11199{
11200 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11201 struct alc_spec *spec = codec->spec;
11202 int val = !!*ucontrol->value.integer.value;
11203
11204 if (val == spec->master_sw)
11205 return 0;
11206 spec->master_sw = val;
11207 alc262_hp_master_update(codec);
11208 return 1;
11209}
11210
Takashi Iwaib72519b2009-05-08 14:31:55 +020011211#define ALC262_HP_MASTER_SWITCH \
11212 { \
11213 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11214 .name = "Master Playback Switch", \
11215 .info = snd_ctl_boolean_mono_info, \
11216 .get = alc262_hp_master_sw_get, \
11217 .put = alc262_hp_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011218 }, \
11219 { \
11220 .iface = NID_MAPPING, \
11221 .name = "Master Playback Switch", \
11222 .private_value = 0x15 | (0x16 << 8) | (0x1b << 16), \
Takashi Iwaib72519b2009-05-08 14:31:55 +020011223 }
11224
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011225
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011226static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011227 ALC262_HP_MASTER_SWITCH,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011228 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11229 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11230 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011231 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11232 HDA_OUTPUT),
11233 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11234 HDA_OUTPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011235 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11236 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011237 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011238 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11239 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011240 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011241 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11242 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11243 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11244 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011245 HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
11246 HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
11247 { } /* end */
11248};
11249
Kailang Yangcd7509a2007-01-26 18:33:17 +010011250static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
Takashi Iwaib72519b2009-05-08 14:31:55 +020011251 ALC262_HP_MASTER_SWITCH,
Kailang Yangcd7509a2007-01-26 18:33:17 +010011252 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11253 HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
11254 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11255 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Takashi Iwaice875f02008-01-28 18:17:43 +010011256 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 2, 0x0,
11257 HDA_OUTPUT),
11258 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 2, 0x0,
11259 HDA_OUTPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011260 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
11261 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011262 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011263 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11264 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11265 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11266 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011267 { } /* end */
11268};
11269
11270static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
11271 HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11272 HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011273 HDA_CODEC_VOLUME("Rear Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangcd7509a2007-01-26 18:33:17 +010011274 { } /* end */
11275};
11276
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011277/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011278static void alc262_hp_t5735_setup(struct hda_codec *codec)
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011279{
11280 struct alc_spec *spec = codec->spec;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011281
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011282 spec->autocfg.hp_pins[0] = 0x15;
Takashi Iwaidc99be42010-01-20 08:35:06 +010011283 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011284}
11285
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011286static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
Takashi Iwai86cd9292008-01-28 18:09:56 +010011287 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11288 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011289 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11290 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11291 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11292 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011293 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010011294 { } /* end */
11295};
11296
11297static struct hda_verb alc262_hp_t5735_verbs[] = {
11298 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11299 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11300
11301 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
11302 { }
11303};
11304
Kailang Yang8c427222008-01-10 13:03:59 +010011305static struct snd_kcontrol_new alc262_hp_rp5700_mixer[] = {
Takashi Iwaif2f48e12008-01-28 18:14:43 +010011306 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11307 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010011308 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
11309 HDA_CODEC_MUTE("Speaker Playback Switch", 0x16, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010011310 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
11311 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
11312 { } /* end */
11313};
11314
11315static struct hda_verb alc262_hp_rp5700_verbs[] = {
11316 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11317 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11318 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11319 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11320 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11321 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11322 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
11324 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11325 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x00 << 8))},
11326 {}
11327};
11328
11329static struct hda_input_mux alc262_hp_rp5700_capture_source = {
11330 .num_items = 1,
11331 .items = {
11332 { "Line", 0x1 },
11333 },
11334};
11335
Takashi Iwai42171c12009-05-08 14:11:43 +020011336/* bind hp and internal speaker mute (with plug check) as master switch */
11337static void alc262_hippo_master_update(struct hda_codec *codec)
11338{
11339 struct alc_spec *spec = codec->spec;
11340 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
11341 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
11342 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
11343 unsigned int mute;
11344
11345 /* HP */
11346 mute = spec->master_sw ? 0 : HDA_AMP_MUTE;
11347 snd_hda_codec_amp_stereo(codec, hp_nid, HDA_OUTPUT, 0,
11348 HDA_AMP_MUTE, mute);
11349 /* mute internal speaker per jack sense */
11350 if (spec->jack_present)
11351 mute = HDA_AMP_MUTE;
11352 if (line_nid)
11353 snd_hda_codec_amp_stereo(codec, line_nid, HDA_OUTPUT, 0,
11354 HDA_AMP_MUTE, mute);
11355 if (speaker_nid && speaker_nid != line_nid)
11356 snd_hda_codec_amp_stereo(codec, speaker_nid, HDA_OUTPUT, 0,
11357 HDA_AMP_MUTE, mute);
11358}
11359
11360#define alc262_hippo_master_sw_get alc262_hp_master_sw_get
11361
11362static int alc262_hippo_master_sw_put(struct snd_kcontrol *kcontrol,
11363 struct snd_ctl_elem_value *ucontrol)
Takashi Iwai0724ea22007-08-23 00:31:43 +020011364{
11365 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
Takashi Iwai42171c12009-05-08 14:11:43 +020011366 struct alc_spec *spec = codec->spec;
11367 int val = !!*ucontrol->value.integer.value;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011368
Takashi Iwai42171c12009-05-08 14:11:43 +020011369 if (val == spec->master_sw)
11370 return 0;
11371 spec->master_sw = val;
11372 alc262_hippo_master_update(codec);
11373 return 1;
Takashi Iwai0724ea22007-08-23 00:31:43 +020011374}
Takashi Iwai5b319542007-07-26 11:49:22 +020011375
Takashi Iwai42171c12009-05-08 14:11:43 +020011376#define ALC262_HIPPO_MASTER_SWITCH \
11377 { \
11378 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
11379 .name = "Master Playback Switch", \
11380 .info = snd_ctl_boolean_mono_info, \
11381 .get = alc262_hippo_master_sw_get, \
11382 .put = alc262_hippo_master_sw_put, \
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011383 }, \
11384 { \
11385 .iface = NID_MAPPING, \
11386 .name = "Master Playback Switch", \
11387 .subdevice = SUBDEV_HP(0) | (SUBDEV_LINE(0) << 8) | \
11388 (SUBDEV_SPEAKER(0) << 16), \
Takashi Iwai42171c12009-05-08 14:11:43 +020011389 }
11390
11391static struct snd_kcontrol_new alc262_hippo_mixer[] = {
11392 ALC262_HIPPO_MASTER_SWITCH,
11393 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11394 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11395 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11396 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11397 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11398 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11399 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011400 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011401 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11402 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011403 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011404 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11405 { } /* end */
11406};
11407
11408static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
11409 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11410 ALC262_HIPPO_MASTER_SWITCH,
11411 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11412 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
11413 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11414 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11415 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11416 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011417 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011418 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11419 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011420 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011421 { } /* end */
11422};
11423
11424/* mute/unmute internal speaker according to the hp jack and mute state */
11425static void alc262_hippo_automute(struct hda_codec *codec)
11426{
11427 struct alc_spec *spec = codec->spec;
11428 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
Takashi Iwai42171c12009-05-08 14:11:43 +020011429
Wu Fengguang864f92b2009-11-18 12:38:02 +080011430 spec->jack_present = snd_hda_jack_detect(codec, hp_nid);
Takashi Iwai42171c12009-05-08 14:11:43 +020011431 alc262_hippo_master_update(codec);
11432}
11433
11434static void alc262_hippo_unsol_event(struct hda_codec *codec, unsigned int res)
11435{
11436 if ((res >> 26) != ALC880_HP_EVENT)
11437 return;
11438 alc262_hippo_automute(codec);
11439}
11440
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011441static void alc262_hippo_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011442{
11443 struct alc_spec *spec = codec->spec;
11444
11445 spec->autocfg.hp_pins[0] = 0x15;
11446 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011447}
11448
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011449static void alc262_hippo1_setup(struct hda_codec *codec)
Takashi Iwai42171c12009-05-08 14:11:43 +020011450{
11451 struct alc_spec *spec = codec->spec;
11452
11453 spec->autocfg.hp_pins[0] = 0x1b;
11454 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai42171c12009-05-08 14:11:43 +020011455}
11456
11457
Kailang Yang272a5272007-05-14 11:00:38 +020011458static struct snd_kcontrol_new alc262_sony_mixer[] = {
Takashi Iwai0724ea22007-08-23 00:31:43 +020011459 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020011460 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang272a5272007-05-14 11:00:38 +020011461 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11462 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11463 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11464 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11465 { } /* end */
11466};
11467
Kailang Yang83c34212007-07-05 11:43:05 +020011468static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020011469 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11470 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang83c34212007-07-05 11:43:05 +020011471 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11472 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11473 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
11474 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11475 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
11476 { } /* end */
11477};
Kailang Yang272a5272007-05-14 11:00:38 +020011478
Tony Vroonba340e82009-02-02 19:01:30 +000011479static struct snd_kcontrol_new alc262_tyan_mixer[] = {
11480 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11481 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
11482 HDA_CODEC_VOLUME("Aux Playback Volume", 0x0b, 0x06, HDA_INPUT),
11483 HDA_CODEC_MUTE("Aux Playback Switch", 0x0b, 0x06, HDA_INPUT),
11484 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
11485 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
11486 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11487 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011488 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011489 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11490 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011491 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroonba340e82009-02-02 19:01:30 +000011492 { } /* end */
11493};
11494
11495static struct hda_verb alc262_tyan_verbs[] = {
11496 /* Headphone automute */
11497 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11498 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11499 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11500
11501 /* P11 AUX_IN, white 4-pin connector */
11502 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11503 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, 0xe1},
11504 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, 0x93},
11505 {0x14, AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, 0x19},
11506
11507 {}
11508};
11509
11510/* unsolicited event for HP jack sensing */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011511static void alc262_tyan_setup(struct hda_codec *codec)
Tony Vroonba340e82009-02-02 19:01:30 +000011512{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011513 struct alc_spec *spec = codec->spec;
Tony Vroonba340e82009-02-02 19:01:30 +000011514
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011515 spec->autocfg.hp_pins[0] = 0x1b;
11516 spec->autocfg.speaker_pins[0] = 0x15;
Tony Vroonba340e82009-02-02 19:01:30 +000011517}
11518
Tony Vroonba340e82009-02-02 19:01:30 +000011519
Kailang Yangdf694da2005-12-05 19:42:22 +010011520#define alc262_capture_mixer alc882_capture_mixer
11521#define alc262_capture_alt_mixer alc882_capture_alt_mixer
11522
11523/*
11524 * generic initialization of ADC, input mixers and output mixers
11525 */
11526static struct hda_verb alc262_init_verbs[] = {
11527 /*
11528 * Unmute ADC0-2 and set the default input to mic-in
11529 */
11530 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
11531 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11532 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
11533 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11534 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
11535 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11536
Takashi Iwaicb53c622007-08-10 17:21:45 +020011537 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010011538 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011539 * Note: PASD motherboards uses the Line In 2 as the input for
11540 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010011541 */
11542 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020011543 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11544 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11545 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11546 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11547 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010011548
11549 /*
11550 * Set up output mixers (0x0c - 0x0e)
11551 */
11552 /* set vol=0 to output mixers */
11553 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11554 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11555 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11556 /* set up input amps for analog loopback */
11557 /* Amp Indices: DAC = 0, mixer = 1 */
11558 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11559 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11560 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11561 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11562 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11563 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11564
11565 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11566 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11567 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
11568 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11569 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11570 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
11571
11572 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11573 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11574 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11575 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11576 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
Kailang Yangea1fb292008-08-26 12:58:38 +020011577
Kailang Yangdf694da2005-12-05 19:42:22 +010011578 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11579 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
Kailang Yangea1fb292008-08-26 12:58:38 +020011580
Kailang Yangdf694da2005-12-05 19:42:22 +010011581 /* FIXME: use matrix-type input source selection */
11582 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
11583 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
11584 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11585 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11586 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11587 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11588 /* Input mixer2 */
11589 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11590 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11591 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
11592 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
11593 /* Input mixer3 */
11594 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
11595 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
11596 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011597 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
Kailang Yangdf694da2005-12-05 19:42:22 +010011598
11599 { }
11600};
11601
Kailang Yang4e555fe2008-08-26 13:05:55 +020011602static struct hda_verb alc262_eapd_verbs[] = {
11603 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
11604 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
11605 { }
11606};
11607
Kailang Yangccc656c2006-10-17 12:32:26 +020011608static struct hda_verb alc262_hippo1_unsol_verbs[] = {
11609 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11610 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
11611 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
11612
11613 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11614 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11615 {}
11616};
11617
Kailang Yang272a5272007-05-14 11:00:38 +020011618static struct hda_verb alc262_sony_unsol_verbs[] = {
11619 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
11620 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11621 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
11622
11623 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11624 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Akio Idehara7b1e8792008-06-09 22:46:07 +090011625 {}
Kailang Yang272a5272007-05-14 11:00:38 +020011626};
11627
Kailang Yang4e555fe2008-08-26 13:05:55 +020011628static struct snd_kcontrol_new alc262_toshiba_s06_mixer[] = {
11629 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11630 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
11631 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11632 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11633 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang4e555fe2008-08-26 13:05:55 +020011634 { } /* end */
11635};
11636
11637static struct hda_verb alc262_toshiba_s06_verbs[] = {
11638 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
11639 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11640 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11641 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11642 {0x22, AC_VERB_SET_CONNECT_SEL, 0x09},
11643 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11644 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
11645 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11646 {}
11647};
11648
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011649static void alc262_toshiba_s06_setup(struct hda_codec *codec)
Kailang Yang4e555fe2008-08-26 13:05:55 +020011650{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020011651 struct alc_spec *spec = codec->spec;
11652
11653 spec->autocfg.hp_pins[0] = 0x15;
11654 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020011655 spec->ext_mic.pin = 0x18;
11656 spec->ext_mic.mux_idx = 0;
11657 spec->int_mic.pin = 0x12;
11658 spec->int_mic.mux_idx = 9;
11659 spec->auto_mic = 1;
Kailang Yang4e555fe2008-08-26 13:05:55 +020011660}
11661
Takashi Iwai834be882006-03-01 14:16:17 +010011662/*
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011663 * nec model
11664 * 0x15 = headphone
11665 * 0x16 = internal speaker
11666 * 0x18 = external mic
11667 */
11668
11669static struct snd_kcontrol_new alc262_nec_mixer[] = {
11670 HDA_CODEC_VOLUME_MONO("Speaker Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
11671 HDA_CODEC_MUTE_MONO("Speaker Playback Switch", 0x16, 0, 0x0, HDA_OUTPUT),
11672
11673 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11674 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011675 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020011676
11677 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
11678 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
11679 { } /* end */
11680};
11681
11682static struct hda_verb alc262_nec_verbs[] = {
11683 /* Unmute Speaker */
11684 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
11685
11686 /* Headphone */
11687 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11688 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11689
11690 /* External mic to headphone */
11691 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11692 /* External mic to speaker */
11693 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11694 {}
11695};
11696
11697/*
Takashi Iwai834be882006-03-01 14:16:17 +010011698 * fujitsu model
Tony Vroon5d9fab22008-03-14 17:09:18 +010011699 * 0x14 = headphone/spdif-out, 0x15 = internal speaker,
11700 * 0x1b = port replicator headphone out
Takashi Iwai834be882006-03-01 14:16:17 +010011701 */
11702
11703#define ALC_HP_EVENT 0x37
11704
11705static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
11706 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Tony Vroon5d9fab22008-03-14 17:09:18 +010011708 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11709 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai834be882006-03-01 14:16:17 +010011710 {}
11711};
11712
Jiang zhe0e31daf2008-03-20 12:12:39 +010011713static struct hda_verb alc262_lenovo_3000_unsol_verbs[] = {
11714 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
11715 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
11716 {}
11717};
11718
Daniel T Chene2595322009-12-19 18:19:02 -050011719static struct hda_verb alc262_lenovo_3000_init_verbs[] = {
11720 /* Front Mic pin: input vref at 50% */
11721 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
11722 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11723 {}
11724};
11725
Takashi Iwai834be882006-03-01 14:16:17 +010011726static struct hda_input_mux alc262_fujitsu_capture_source = {
Takashi Iwai39d3ed32007-10-12 15:03:48 +020011727 .num_items = 3,
Takashi Iwai834be882006-03-01 14:16:17 +010011728 .items = {
11729 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010011730 { "Internal Mic", 0x1 },
Takashi Iwai834be882006-03-01 14:16:17 +010011731 { "CD", 0x4 },
11732 },
11733};
11734
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011735static struct hda_input_mux alc262_HP_capture_source = {
11736 .num_items = 5,
11737 .items = {
11738 { "Mic", 0x0 },
zhejiangaccbe492007-08-31 12:36:05 +020011739 { "Front Mic", 0x1 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020011740 { "Line", 0x2 },
11741 { "CD", 0x4 },
11742 { "AUX IN", 0x6 },
11743 },
11744};
11745
zhejiangaccbe492007-08-31 12:36:05 +020011746static struct hda_input_mux alc262_HP_D7000_capture_source = {
11747 .num_items = 4,
11748 .items = {
11749 { "Mic", 0x0 },
11750 { "Front Mic", 0x2 },
11751 { "Line", 0x1 },
11752 { "CD", 0x4 },
11753 },
11754};
11755
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011756/* mute/unmute internal speaker according to the hp jacks and mute state */
Takashi Iwai834be882006-03-01 14:16:17 +010011757static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
11758{
11759 struct alc_spec *spec = codec->spec;
11760 unsigned int mute;
11761
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020011762 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011763 spec->jack_present = snd_hda_jack_detect(codec, 0x14) ||
11764 snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai834be882006-03-01 14:16:17 +010011765 spec->sense_updated = 1;
11766 }
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011767 /* unmute internal speaker only if both HPs are unplugged and
11768 * master switch is on
11769 */
11770 if (spec->jack_present)
11771 mute = HDA_AMP_MUTE;
11772 else
Takashi Iwai834be882006-03-01 14:16:17 +010011773 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011774 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
11775 HDA_AMP_MUTE, mute);
Takashi Iwai834be882006-03-01 14:16:17 +010011776}
11777
11778/* unsolicited event for HP jack sensing */
11779static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
11780 unsigned int res)
11781{
11782 if ((res >> 26) != ALC_HP_EVENT)
11783 return;
11784 alc262_fujitsu_automute(codec, 1);
11785}
11786
Takashi Iwaiebc7a402008-05-20 09:23:05 +020011787static void alc262_fujitsu_init_hook(struct hda_codec *codec)
11788{
11789 alc262_fujitsu_automute(codec, 1);
11790}
11791
Takashi Iwai834be882006-03-01 14:16:17 +010011792/* bind volumes of both NID 0x0c and 0x0d */
Takashi Iwaicca3b372007-08-10 17:12:15 +020011793static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
11794 .ops = &snd_hda_bind_vol,
11795 .values = {
11796 HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
11797 HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
11798 0
11799 },
11800};
Takashi Iwai834be882006-03-01 14:16:17 +010011801
Jiang zhe0e31daf2008-03-20 12:12:39 +010011802/* mute/unmute internal speaker according to the hp jack and mute state */
11803static void alc262_lenovo_3000_automute(struct hda_codec *codec, int force)
11804{
11805 struct alc_spec *spec = codec->spec;
11806 unsigned int mute;
11807
11808 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080011809 spec->jack_present = snd_hda_jack_detect(codec, 0x1b);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011810 spec->sense_updated = 1;
11811 }
11812 if (spec->jack_present) {
11813 /* mute internal speaker */
11814 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11815 HDA_AMP_MUTE, HDA_AMP_MUTE);
11816 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11817 HDA_AMP_MUTE, HDA_AMP_MUTE);
11818 } else {
11819 /* unmute internal speaker if necessary */
11820 mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
11821 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
11822 HDA_AMP_MUTE, mute);
11823 snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
11824 HDA_AMP_MUTE, mute);
11825 }
11826}
11827
11828/* unsolicited event for HP jack sensing */
11829static void alc262_lenovo_3000_unsol_event(struct hda_codec *codec,
11830 unsigned int res)
11831{
11832 if ((res >> 26) != ALC_HP_EVENT)
11833 return;
11834 alc262_lenovo_3000_automute(codec, 1);
11835}
11836
Takashi Iwai8de56b72009-07-24 16:51:47 +020011837static int amp_stereo_mute_update(struct hda_codec *codec, hda_nid_t nid,
11838 int dir, int idx, long *valp)
11839{
11840 int i, change = 0;
11841
11842 for (i = 0; i < 2; i++, valp++)
11843 change |= snd_hda_codec_amp_update(codec, nid, i, dir, idx,
11844 HDA_AMP_MUTE,
11845 *valp ? 0 : HDA_AMP_MUTE);
11846 return change;
11847}
11848
Takashi Iwai834be882006-03-01 14:16:17 +010011849/* bind hp and internal speaker mute (with plug check) */
11850static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
11851 struct snd_ctl_elem_value *ucontrol)
11852{
11853 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11854 long *valp = ucontrol->value.integer.value;
11855 int change;
11856
Takashi Iwai8de56b72009-07-24 16:51:47 +020011857 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
11858 change |= amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Takashi Iwai82beb8f2007-08-10 17:09:26 +020011859 if (change)
11860 alc262_fujitsu_automute(codec, 0);
Takashi Iwai834be882006-03-01 14:16:17 +010011861 return change;
11862}
11863
11864static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
Takashi Iwaicca3b372007-08-10 17:12:15 +020011865 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai834be882006-03-01 14:16:17 +010011866 {
11867 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11868 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011869 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwai834be882006-03-01 14:16:17 +010011870 .info = snd_hda_mixer_amp_switch_info,
11871 .get = snd_hda_mixer_amp_switch_get,
11872 .put = alc262_fujitsu_master_sw_put,
11873 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
11874 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010011875 {
11876 .iface = NID_MAPPING,
11877 .name = "Master Playback Switch",
11878 .private_value = 0x1b,
11879 },
Takashi Iwai834be882006-03-01 14:16:17 +010011880 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11881 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011882 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011883 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11884 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011885 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011886 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11887 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Takashi Iwai834be882006-03-01 14:16:17 +010011888 { } /* end */
11889};
11890
Jiang zhe0e31daf2008-03-20 12:12:39 +010011891/* bind hp and internal speaker mute (with plug check) */
11892static int alc262_lenovo_3000_master_sw_put(struct snd_kcontrol *kcontrol,
11893 struct snd_ctl_elem_value *ucontrol)
11894{
11895 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
11896 long *valp = ucontrol->value.integer.value;
11897 int change;
11898
Takashi Iwai8de56b72009-07-24 16:51:47 +020011899 change = amp_stereo_mute_update(codec, 0x1b, HDA_OUTPUT, 0, valp);
Jiang zhe0e31daf2008-03-20 12:12:39 +010011900 if (change)
11901 alc262_lenovo_3000_automute(codec, 0);
11902 return change;
11903}
11904
11905static struct snd_kcontrol_new alc262_lenovo_3000_mixer[] = {
11906 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
11907 {
11908 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
11909 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010011910 .subdevice = HDA_SUBDEV_AMP_FLAG,
Jiang zhe0e31daf2008-03-20 12:12:39 +010011911 .info = snd_hda_mixer_amp_switch_info,
11912 .get = snd_hda_mixer_amp_switch_get,
11913 .put = alc262_lenovo_3000_master_sw_put,
11914 .private_value = HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
11915 },
11916 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
11917 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011918 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011919 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11920 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011921 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010011922 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
11923 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Jiang zhe0e31daf2008-03-20 12:12:39 +010011924 { } /* end */
11925};
11926
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011927static struct snd_kcontrol_new alc262_toshiba_rx1_mixer[] = {
11928 HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
Takashi Iwai42171c12009-05-08 14:11:43 +020011929 ALC262_HIPPO_MASTER_SWITCH,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011930 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
11931 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011932 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011933 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11934 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011935 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Hiroshi Miura9f99a632008-08-28 16:09:06 +020011936 { } /* end */
11937};
11938
Takashi Iwai304dcaa2006-07-25 14:51:16 +020011939/* additional init verbs for Benq laptops */
11940static struct hda_verb alc262_EAPD_verbs[] = {
11941 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11942 {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
11943 {}
11944};
11945
Kailang Yang83c34212007-07-05 11:43:05 +020011946static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
11947 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11948 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
11949
11950 {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
11951 {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
11952 {}
11953};
11954
Tobin Davisf651b502007-10-26 12:40:47 +020011955/* Samsung Q1 Ultra Vista model setup */
11956static struct snd_kcontrol_new alc262_ultra_mixer[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011957 HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
11958 HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011959 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
11960 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010011961 HDA_CODEC_VOLUME("Mic Boost Volume", 0x19, 0, HDA_INPUT),
11962 HDA_CODEC_VOLUME("Headphone Mic Boost Volume", 0x15, 0, HDA_INPUT),
Tobin Davisf651b502007-10-26 12:40:47 +020011963 { } /* end */
11964};
11965
11966static struct hda_verb alc262_ultra_verbs[] = {
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011967 /* output mixer */
11968 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11969 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11970 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
11971 /* speaker */
11972 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
11973 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11974 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11975 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
11976 /* HP */
Tobin Davisf651b502007-10-26 12:40:47 +020011977 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010011978 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
11979 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
11980 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
11981 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
11982 /* internal mic */
11983 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
11984 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
11985 /* ADC, choose mic */
11986 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11987 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
11988 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
11989 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
11990 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
11991 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
11992 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
11993 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
11994 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
11995 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(8)},
Tobin Davisf651b502007-10-26 12:40:47 +020011996 {}
11997};
11998
Tobin Davisf651b502007-10-26 12:40:47 +020011999/* mute/unmute internal speaker according to the hp jack and mute state */
12000static void alc262_ultra_automute(struct hda_codec *codec)
12001{
12002 struct alc_spec *spec = codec->spec;
12003 unsigned int mute;
Tobin Davisf651b502007-10-26 12:40:47 +020012004
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012005 mute = 0;
12006 /* auto-mute only when HP is used as HP */
12007 if (!spec->cur_mux[0]) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080012008 spec->jack_present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012009 if (spec->jack_present)
12010 mute = HDA_AMP_MUTE;
Tobin Davisf651b502007-10-26 12:40:47 +020012011 }
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012012 /* mute/unmute internal speaker */
12013 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
12014 HDA_AMP_MUTE, mute);
12015 /* mute/unmute HP */
12016 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
12017 HDA_AMP_MUTE, mute ? 0 : HDA_AMP_MUTE);
Tobin Davisf651b502007-10-26 12:40:47 +020012018}
12019
12020/* unsolicited event for HP jack sensing */
12021static void alc262_ultra_unsol_event(struct hda_codec *codec,
12022 unsigned int res)
12023{
12024 if ((res >> 26) != ALC880_HP_EVENT)
12025 return;
12026 alc262_ultra_automute(codec);
12027}
12028
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012029static struct hda_input_mux alc262_ultra_capture_source = {
12030 .num_items = 2,
12031 .items = {
12032 { "Mic", 0x1 },
12033 { "Headphone", 0x7 },
12034 },
12035};
12036
12037static int alc262_ultra_mux_enum_put(struct snd_kcontrol *kcontrol,
12038 struct snd_ctl_elem_value *ucontrol)
12039{
12040 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
12041 struct alc_spec *spec = codec->spec;
12042 int ret;
12043
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012044 ret = alc_mux_enum_put(kcontrol, ucontrol);
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012045 if (!ret)
12046 return 0;
12047 /* reprogram the HP pin as mic or HP according to the input source */
12048 snd_hda_codec_write_cache(codec, 0x15, 0,
12049 AC_VERB_SET_PIN_WIDGET_CONTROL,
12050 spec->cur_mux[0] ? PIN_VREF80 : PIN_HP);
12051 alc262_ultra_automute(codec); /* mute/unmute HP */
12052 return ret;
12053}
12054
12055static struct snd_kcontrol_new alc262_ultra_capture_mixer[] = {
12056 HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
12057 HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
12058 {
12059 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
12060 .name = "Capture Source",
Takashi Iwai54cbc9a2008-10-31 15:24:04 +010012061 .info = alc_mux_enum_info,
12062 .get = alc_mux_enum_get,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012063 .put = alc262_ultra_mux_enum_put,
12064 },
Jaroslav Kysela5b0cb1d2009-12-08 16:13:32 +010012065 {
12066 .iface = NID_MAPPING,
12067 .name = "Capture Source",
12068 .private_value = 0x15,
12069 },
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012070 { } /* end */
12071};
12072
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012073/* We use two mixers depending on the output pin; 0x16 is a mono output
12074 * and thus it's bound with a different mixer.
12075 * This function returns which mixer amp should be used.
12076 */
12077static int alc262_check_volbit(hda_nid_t nid)
12078{
12079 if (!nid)
12080 return 0;
12081 else if (nid == 0x16)
12082 return 2;
12083 else
12084 return 1;
12085}
12086
12087static int alc262_add_out_vol_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012088 const char *pfx, int *vbits, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012089{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012090 unsigned long val;
12091 int vbit;
12092
12093 vbit = alc262_check_volbit(nid);
12094 if (!vbit)
12095 return 0;
12096 if (*vbits & vbit) /* a volume control for this mixer already there */
12097 return 0;
12098 *vbits |= vbit;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012099 if (vbit == 2)
12100 val = HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT);
12101 else
12102 val = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012103 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012104}
12105
12106static int alc262_add_out_sw_ctl(struct alc_spec *spec, hda_nid_t nid,
Takashi Iwai033688a2010-09-08 15:47:09 +020012107 const char *pfx, int idx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012108{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012109 unsigned long val;
12110
12111 if (!nid)
12112 return 0;
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012113 if (nid == 0x16)
12114 val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
12115 else
12116 val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
Takashi Iwai033688a2010-09-08 15:47:09 +020012117 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx, val);
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012118}
12119
Kailang Yangdf694da2005-12-05 19:42:22 +010012120/* add playback controls from the parsed DAC table */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012121static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
12122 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010012123{
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012124 const char *pfx;
12125 int vbits;
Takashi Iwai033688a2010-09-08 15:47:09 +020012126 int i, err;
Kailang Yangdf694da2005-12-05 19:42:22 +010012127
12128 spec->multiout.num_dacs = 1; /* only use one dac */
12129 spec->multiout.dac_nids = spec->private_dac_nids;
12130 spec->multiout.dac_nids[0] = 2;
12131
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010012132 pfx = alc_get_line_out_pfx(cfg, true);
12133 if (!pfx)
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012134 pfx = "Front";
Takashi Iwai033688a2010-09-08 15:47:09 +020012135 for (i = 0; i < 2; i++) {
12136 err = alc262_add_out_sw_ctl(spec, cfg->line_out_pins[i], pfx, i);
12137 if (err < 0)
12138 return err;
12139 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12140 err = alc262_add_out_sw_ctl(spec, cfg->speaker_pins[i],
12141 "Speaker", i);
12142 if (err < 0)
12143 return err;
12144 }
12145 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12146 err = alc262_add_out_sw_ctl(spec, cfg->hp_pins[i],
12147 "Headphone", i);
12148 if (err < 0)
12149 return err;
12150 }
12151 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012152
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012153 vbits = alc262_check_volbit(cfg->line_out_pins[0]) |
12154 alc262_check_volbit(cfg->speaker_pins[0]) |
12155 alc262_check_volbit(cfg->hp_pins[0]);
12156 if (vbits == 1 || vbits == 2)
12157 pfx = "Master"; /* only one mixer is used */
Takashi Iwaic3fc1f52009-08-25 16:08:47 +020012158 vbits = 0;
Takashi Iwai033688a2010-09-08 15:47:09 +020012159 for (i = 0; i < 2; i++) {
12160 err = alc262_add_out_vol_ctl(spec, cfg->line_out_pins[i], pfx,
12161 &vbits, i);
12162 if (err < 0)
12163 return err;
12164 if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) {
12165 err = alc262_add_out_vol_ctl(spec, cfg->speaker_pins[i],
12166 "Speaker", &vbits, i);
12167 if (err < 0)
12168 return err;
12169 }
12170 if (cfg->line_out_type != AUTO_PIN_HP_OUT) {
12171 err = alc262_add_out_vol_ctl(spec, cfg->hp_pins[i],
12172 "Headphone", &vbits, i);
12173 if (err < 0)
12174 return err;
12175 }
12176 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012177 return 0;
Kailang Yangdf694da2005-12-05 19:42:22 +010012178}
12179
Takashi Iwai05f5f472009-08-25 13:10:18 +020012180#define alc262_auto_create_input_ctls \
Takashi Iwaieaa9b3a2010-01-17 13:09:33 +010012181 alc882_auto_create_input_ctls
Kailang Yangdf694da2005-12-05 19:42:22 +010012182
12183/*
12184 * generic initialization of ADC, input mixers and output mixers
12185 */
12186static struct hda_verb alc262_volume_init_verbs[] = {
12187 /*
12188 * Unmute ADC0-2 and set the default input to mic-in
12189 */
12190 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12191 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12192 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12193 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12194 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12195 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12196
Takashi Iwaicb53c622007-08-10 17:21:45 +020012197 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangdf694da2005-12-05 19:42:22 +010012198 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012199 * Note: PASD motherboards uses the Line In 2 as the input for
12200 * front panel mic (mic 2)
Kailang Yangdf694da2005-12-05 19:42:22 +010012201 */
12202 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012203 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12204 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12205 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12206 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12207 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Kailang Yangdf694da2005-12-05 19:42:22 +010012208
12209 /*
12210 * Set up output mixers (0x0c - 0x0f)
12211 */
12212 /* set vol=0 to output mixers */
12213 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12214 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12215 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yangea1fb292008-08-26 12:58:38 +020012216
Kailang Yangdf694da2005-12-05 19:42:22 +010012217 /* set up input amps for analog loopback */
12218 /* Amp Indices: DAC = 0, mixer = 1 */
12219 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12220 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12221 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12222 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12223 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12224 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12225
12226 /* FIXME: use matrix-type input source selection */
12227 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12228 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12229 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12230 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12231 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12232 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12233 /* Input mixer2 */
12234 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12235 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12236 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12237 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12238 /* Input mixer3 */
12239 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12240 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12241 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12242 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12243
12244 { }
12245};
12246
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012247static struct hda_verb alc262_HP_BPC_init_verbs[] = {
12248 /*
12249 * Unmute ADC0-2 and set the default input to mic-in
12250 */
12251 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12252 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12253 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12254 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12255 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12256 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12257
Takashi Iwaicb53c622007-08-10 17:21:45 +020012258 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012259 * mixer widget
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012260 * Note: PASD motherboards uses the Line In 2 as the input for
12261 * front panel mic (mic 2)
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012262 */
12263 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012264 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12265 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12266 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12267 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12268 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12269 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12270 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
Kailang Yangea1fb292008-08-26 12:58:38 +020012271
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012272 /*
12273 * Set up output mixers (0x0c - 0x0e)
12274 */
12275 /* set vol=0 to output mixers */
12276 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12277 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12278 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12279
12280 /* set up input amps for analog loopback */
12281 /* Amp Indices: DAC = 0, mixer = 1 */
12282 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12283 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12284 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12285 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12286 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12287 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12288
Takashi Iwaice875f02008-01-28 18:17:43 +010012289 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012290 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12291 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
12292
12293 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12294 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12295
12296 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12297 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12298
12299 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12300 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12301 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
12302 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12303 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
12304
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012305 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012306 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12307 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012308 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012309 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12310 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12311
12312
12313 /* FIXME: use matrix-type input source selection */
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012314 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 0b, 12 */
12315 /* Input mixer1: only unmute Mic */
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012316 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012317 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12318 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12319 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12320 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12321 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12322 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12323 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12324 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012325 /* Input mixer2 */
12326 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012327 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12328 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12329 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12330 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12331 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12332 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12333 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12334 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012335 /* Input mixer3 */
12336 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
Jaroslav Kysela0e4835c2009-05-25 16:44:20 +020012337 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8))},
12338 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
12339 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
12340 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
12341 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x05 << 8))},
12342 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x06 << 8))},
12343 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x07 << 8))},
12344 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x08 << 8))},
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012345
Takashi Iwaice875f02008-01-28 18:17:43 +010012346 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12347
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012348 { }
12349};
12350
Kailang Yangcd7509a2007-01-26 18:33:17 +010012351static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
12352 /*
12353 * Unmute ADC0-2 and set the default input to mic-in
12354 */
12355 {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
12356 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12357 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
12358 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12359 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
12360 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12361
Takashi Iwaicb53c622007-08-10 17:21:45 +020012362 /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
Kailang Yangcd7509a2007-01-26 18:33:17 +010012363 * mixer widget
12364 * Note: PASD motherboards uses the Line In 2 as the input for front
12365 * panel mic (mic 2)
12366 */
12367 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020012368 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
12369 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
12370 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
12371 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
12372 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
12373 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
12374 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
12375 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
Kailang Yangcd7509a2007-01-26 18:33:17 +010012376 /*
12377 * Set up output mixers (0x0c - 0x0e)
12378 */
12379 /* set vol=0 to output mixers */
12380 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12381 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12382 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
12383
12384 /* set up input amps for analog loopback */
12385 /* Amp Indices: DAC = 0, mixer = 1 */
12386 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12387 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12388 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12389 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12390 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
12391 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
12392
12393
12394 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
12395 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
12396 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
12397 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
12398 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12399 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
12400 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
12401
12402 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12403 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12404
12405 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
12406 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
12407
12408 /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
12409 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12410 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12411 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
12412 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12413 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
12414
12415 /* FIXME: use matrix-type input source selection */
12416 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
12417 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
12418 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
12419 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
12420 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
12421 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
12422 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
12423 /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12424 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
12425 /* Input mixer2 */
12426 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12427 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12428 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12429 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12430 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12431 /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12432 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12433 /* Input mixer3 */
12434 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
12435 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
12436 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
12437 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
12438 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
12439 /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
12440 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
12441
Takashi Iwaice875f02008-01-28 18:17:43 +010012442 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
12443
Kailang Yangcd7509a2007-01-26 18:33:17 +010012444 { }
12445};
12446
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012447static struct hda_verb alc262_toshiba_rx1_unsol_verbs[] = {
12448
12449 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Front Speaker */
12450 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
12451 {0x14, AC_VERB_SET_CONNECT_SEL, 0x01},
12452
12453 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* MIC jack */
12454 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
12455 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12456 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0) },
12457
12458 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP jack */
12459 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
12460 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
12461 {}
12462};
12463
Takashi Iwai18675e42010-09-08 15:55:44 +020012464/*
12465 * Pin config fixes
12466 */
12467enum {
12468 PINFIX_FSC_H270,
12469};
12470
12471static const struct alc_fixup alc262_fixups[] = {
12472 [PINFIX_FSC_H270] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012473 .type = ALC_FIXUP_PINS,
12474 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai18675e42010-09-08 15:55:44 +020012475 { 0x14, 0x99130110 }, /* speaker */
12476 { 0x15, 0x0221142f }, /* front HP */
12477 { 0x1b, 0x0121141f }, /* rear HP */
12478 { }
12479 }
12480 },
Takashi Iwai18675e42010-09-08 15:55:44 +020012481};
12482
12483static struct snd_pci_quirk alc262_fixup_tbl[] = {
12484 SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", PINFIX_FSC_H270),
12485 {}
12486};
12487
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012488
Takashi Iwaicb53c622007-08-10 17:21:45 +020012489#ifdef CONFIG_SND_HDA_POWER_SAVE
12490#define alc262_loopbacks alc880_loopbacks
12491#endif
12492
Sasha Alexandrdef319f2009-06-16 16:00:15 -040012493/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012494#define alc262_pcm_analog_playback alc880_pcm_analog_playback
12495#define alc262_pcm_analog_capture alc880_pcm_analog_capture
12496#define alc262_pcm_digital_playback alc880_pcm_digital_playback
12497#define alc262_pcm_digital_capture alc880_pcm_digital_capture
12498
12499/*
12500 * BIOS auto configuration
12501 */
12502static int alc262_parse_auto_config(struct hda_codec *codec)
12503{
12504 struct alc_spec *spec = codec->spec;
12505 int err;
12506 static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
12507
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012508 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
12509 alc262_ignore);
12510 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012511 return err;
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012512 if (!spec->autocfg.line_outs) {
Takashi Iwai0852d7a2009-02-11 11:35:15 +010012513 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012514 spec->multiout.max_channels = 2;
12515 spec->no_analog = 1;
12516 goto dig_only;
12517 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012518 return 0; /* can't find valid BIOS pin config */
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012519 }
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012520 err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
12521 if (err < 0)
12522 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020012523 err = alc262_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012524 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010012525 return err;
12526
12527 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
12528
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012529 dig_only:
Takashi Iwai757899a2010-07-30 10:48:14 +020012530 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012531
Takashi Iwai603c4012008-07-30 15:01:44 +020012532 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010012533 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010012534
Takashi Iwaid88897e2008-10-31 15:01:37 +010012535 add_verb(spec, alc262_volume_init_verbs);
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020012536 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020012537 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010012538
Takashi Iwai776e1842007-08-29 15:07:11 +020012539 err = alc_auto_add_mic_boost(codec);
12540 if (err < 0)
12541 return err;
12542
Kailang Yang6227cdc2010-02-25 08:36:52 +010012543 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020012544
Kailang Yangdf694da2005-12-05 19:42:22 +010012545 return 1;
12546}
12547
12548#define alc262_auto_init_multi_out alc882_auto_init_multi_out
12549#define alc262_auto_init_hp_out alc882_auto_init_hp_out
12550#define alc262_auto_init_analog_input alc882_auto_init_analog_input
Takashi Iwaif511b012008-08-15 16:46:42 +020012551#define alc262_auto_init_input_src alc882_auto_init_input_src
Kailang Yangdf694da2005-12-05 19:42:22 +010012552
12553
12554/* init callback for auto-configuration model -- overriding the default init */
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012555static void alc262_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010012556{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012557 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010012558 alc262_auto_init_multi_out(codec);
12559 alc262_auto_init_hp_out(codec);
12560 alc262_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020012561 alc262_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020012562 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010012563 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020012564 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012565}
12566
12567/*
12568 * configuration and preset
12569 */
Takashi Iwaiea734962011-01-17 11:29:34 +010012570static const char * const alc262_models[ALC262_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012571 [ALC262_BASIC] = "basic",
12572 [ALC262_HIPPO] = "hippo",
12573 [ALC262_HIPPO_1] = "hippo_1",
12574 [ALC262_FUJITSU] = "fujitsu",
12575 [ALC262_HP_BPC] = "hp-bpc",
Kailang Yangcd7509a2007-01-26 18:33:17 +010012576 [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
Takashi Iwai61dc35d2007-11-14 12:26:44 +010012577 [ALC262_HP_TC_T5735] = "hp-tc-t5735",
Kailang Yang8c427222008-01-10 13:03:59 +010012578 [ALC262_HP_RP5700] = "hp-rp5700",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012579 [ALC262_BENQ_ED8] = "benq",
Takashi Iwai0f405022007-07-06 12:24:11 +020012580 [ALC262_BENQ_T31] = "benq-t31",
12581 [ALC262_SONY_ASSAMD] = "sony-assamd",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020012582 [ALC262_TOSHIBA_S06] = "toshiba-s06",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012583 [ALC262_TOSHIBA_RX1] = "toshiba-rx1",
Tobin Davisf651b502007-10-26 12:40:47 +020012584 [ALC262_ULTRA] = "ultra",
Jiang zhe0e31daf2008-03-20 12:12:39 +010012585 [ALC262_LENOVO_3000] = "lenovo-3000",
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012586 [ALC262_NEC] = "nec",
Tony Vroonba340e82009-02-02 19:01:30 +000012587 [ALC262_TYAN] = "tyan",
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012588 [ALC262_AUTO] = "auto",
12589};
12590
12591static struct snd_pci_quirk alc262_cfg_tbl[] = {
12592 SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012593 SND_PCI_QUIRK(0x1033, 0x8895, "NEC Versa S9100", ALC262_NEC),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012594 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1200, "HP xw series",
12595 ALC262_HP_BPC),
12596 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1300, "HP xw series",
12597 ALC262_HP_BPC),
Takashi Iwai5734a072011-01-19 17:07:12 +010012598 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1500, "HP z series",
12599 ALC262_HP_BPC),
Takashi Iwai53eff7e2009-02-27 17:49:44 +010012600 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x1700, "HP xw series",
12601 ALC262_HP_BPC),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012602 SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012603 SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012604 SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012605 SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012606 SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012607 SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012608 SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
Kailang Yangcd7509a2007-01-26 18:33:17 +010012609 SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012610 SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
12611 SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
12612 SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012613 SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
12614 ALC262_HP_TC_T5735),
Kailang Yang8c427222008-01-10 13:03:59 +010012615 SND_PCI_QUIRK(0x103c, 0x2817, "HP RP5700", ALC262_HP_RP5700),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012616 SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012617 SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012618 SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
Takashi Iwaibd6afe32009-03-04 11:30:25 +010012619 SND_PCI_QUIRK(0x104d, 0x9016, "Sony VAIO", ALC262_AUTO), /* dig-only */
Takashi Iwai376b5082009-06-22 11:03:13 +020012620 SND_PCI_QUIRK(0x104d, 0x9025, "Sony VAIO Z21MN", ALC262_TOSHIBA_S06),
Daniel T Chen95491d92009-11-08 19:03:55 -050012621 SND_PCI_QUIRK(0x104d, 0x9035, "Sony VAIO VGN-FW170J", ALC262_AUTO),
Takashi Iwai12929ba2009-11-17 15:58:35 +010012622 SND_PCI_QUIRK(0x104d, 0x9047, "Sony VAIO Type G", ALC262_AUTO),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012623#if 0 /* disable the quirk since model=auto works better in recent versions */
Takashi Iwaif872a912009-02-26 00:57:01 +010012624 SND_PCI_QUIRK_MASK(0x104d, 0xff00, 0x9000, "Sony VAIO",
12625 ALC262_SONY_ASSAMD),
Takashi Iwaic5b51652009-11-17 16:01:58 +010012626#endif
Akio Idehara36ca6e12008-06-09 22:57:40 +090012627 SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1",
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012628 ALC262_TOSHIBA_RX1),
Kailang Yang80ffe862008-10-15 11:23:27 +020012629 SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012630 SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
Tony Vroon3f1eeae2008-02-25 16:44:13 +010012631 SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FUJITSU),
Tony Vroonba340e82009-02-02 19:01:30 +000012632 SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_TYAN),
Takashi Iwaidea0a502009-02-09 17:14:52 +010012633 SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc032, "Samsung Q1",
12634 ALC262_ULTRA),
Luke Yelavich3e420e72008-12-16 12:37:47 +110012635 SND_PCI_QUIRK(0x144d, 0xc510, "Samsung Q45", ALC262_HIPPO),
Jiang zhe0e31daf2008-03-20 12:12:39 +010012636 SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000 y410", ALC262_LENOVO_3000),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012637 SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
Kailang Yang83c34212007-07-05 11:43:05 +020012638 SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010012639 SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
Kailang Yangdf694da2005-12-05 19:42:22 +010012640 {}
12641};
12642
12643static struct alc_config_preset alc262_presets[] = {
12644 [ALC262_BASIC] = {
12645 .mixers = { alc262_base_mixer },
12646 .init_verbs = { alc262_init_verbs },
12647 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12648 .dac_nids = alc262_dac_nids,
12649 .hp_nid = 0x03,
12650 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12651 .channel_mode = alc262_modes,
Takashi Iwaia3bcba32005-12-06 19:05:29 +010012652 .input_mux = &alc262_capture_source,
Kailang Yangdf694da2005-12-05 19:42:22 +010012653 },
Kailang Yangccc656c2006-10-17 12:32:26 +020012654 [ALC262_HIPPO] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020012655 .mixers = { alc262_hippo_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012656 .init_verbs = { alc262_init_verbs, alc_hp15_unsol_verbs},
Kailang Yangccc656c2006-10-17 12:32:26 +020012657 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12658 .dac_nids = alc262_dac_nids,
12659 .hp_nid = 0x03,
12660 .dig_out_nid = ALC262_DIGOUT_NID,
12661 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12662 .channel_mode = alc262_modes,
12663 .input_mux = &alc262_capture_source,
12664 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012665 .setup = alc262_hippo_setup,
12666 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012667 },
12668 [ALC262_HIPPO_1] = {
12669 .mixers = { alc262_hippo1_mixer },
12670 .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
12671 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12672 .dac_nids = alc262_dac_nids,
12673 .hp_nid = 0x02,
12674 .dig_out_nid = ALC262_DIGOUT_NID,
12675 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12676 .channel_mode = alc262_modes,
12677 .input_mux = &alc262_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020012678 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012679 .setup = alc262_hippo1_setup,
12680 .init_hook = alc262_hippo_automute,
Kailang Yangccc656c2006-10-17 12:32:26 +020012681 },
Takashi Iwai834be882006-03-01 14:16:17 +010012682 [ALC262_FUJITSU] = {
12683 .mixers = { alc262_fujitsu_mixer },
Takashi Iwai39d3ed32007-10-12 15:03:48 +020012684 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
12685 alc262_fujitsu_unsol_verbs },
Takashi Iwai834be882006-03-01 14:16:17 +010012686 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12687 .dac_nids = alc262_dac_nids,
12688 .hp_nid = 0x03,
12689 .dig_out_nid = ALC262_DIGOUT_NID,
12690 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12691 .channel_mode = alc262_modes,
12692 .input_mux = &alc262_fujitsu_capture_source,
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012693 .unsol_event = alc262_fujitsu_unsol_event,
Takashi Iwaiebc7a402008-05-20 09:23:05 +020012694 .init_hook = alc262_fujitsu_init_hook,
Takashi Iwai834be882006-03-01 14:16:17 +010012695 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012696 [ALC262_HP_BPC] = {
12697 .mixers = { alc262_HP_BPC_mixer },
12698 .init_verbs = { alc262_HP_BPC_init_verbs },
12699 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12700 .dac_nids = alc262_dac_nids,
12701 .hp_nid = 0x03,
12702 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12703 .channel_mode = alc262_modes,
12704 .input_mux = &alc262_HP_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012705 .unsol_event = alc262_hp_bpc_unsol_event,
12706 .init_hook = alc262_hp_bpc_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012707 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012708 [ALC262_HP_BPC_D7000_WF] = {
12709 .mixers = { alc262_HP_BPC_WildWest_mixer },
12710 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12711 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12712 .dac_nids = alc262_dac_nids,
12713 .hp_nid = 0x03,
12714 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12715 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012716 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012717 .unsol_event = alc262_hp_wildwest_unsol_event,
12718 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012719 },
Kailang Yangcd7509a2007-01-26 18:33:17 +010012720 [ALC262_HP_BPC_D7000_WL] = {
12721 .mixers = { alc262_HP_BPC_WildWest_mixer,
12722 alc262_HP_BPC_WildWest_option_mixer },
12723 .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
12724 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12725 .dac_nids = alc262_dac_nids,
12726 .hp_nid = 0x03,
12727 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12728 .channel_mode = alc262_modes,
zhejiangaccbe492007-08-31 12:36:05 +020012729 .input_mux = &alc262_HP_D7000_capture_source,
Takashi Iwaice875f02008-01-28 18:17:43 +010012730 .unsol_event = alc262_hp_wildwest_unsol_event,
12731 .init_hook = alc262_hp_wildwest_automute,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012732 },
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012733 [ALC262_HP_TC_T5735] = {
12734 .mixers = { alc262_hp_t5735_mixer },
12735 .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
12736 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12737 .dac_nids = alc262_dac_nids,
12738 .hp_nid = 0x03,
12739 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12740 .channel_mode = alc262_modes,
12741 .input_mux = &alc262_capture_source,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012742 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012743 .setup = alc262_hp_t5735_setup,
Takashi Iwaidc99be42010-01-20 08:35:06 +010012744 .init_hook = alc_inithook,
Kailang Yang8c427222008-01-10 13:03:59 +010012745 },
12746 [ALC262_HP_RP5700] = {
12747 .mixers = { alc262_hp_rp5700_mixer },
12748 .init_verbs = { alc262_init_verbs, alc262_hp_rp5700_verbs },
12749 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12750 .dac_nids = alc262_dac_nids,
12751 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12752 .channel_mode = alc262_modes,
12753 .input_mux = &alc262_hp_rp5700_capture_source,
Kailang Yang66d2a9d2007-11-14 12:06:21 +010012754 },
Takashi Iwai304dcaa2006-07-25 14:51:16 +020012755 [ALC262_BENQ_ED8] = {
12756 .mixers = { alc262_base_mixer },
12757 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
12758 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12759 .dac_nids = alc262_dac_nids,
12760 .hp_nid = 0x03,
12761 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12762 .channel_mode = alc262_modes,
12763 .input_mux = &alc262_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012764 },
Kailang Yang272a5272007-05-14 11:00:38 +020012765 [ALC262_SONY_ASSAMD] = {
12766 .mixers = { alc262_sony_mixer },
12767 .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
12768 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12769 .dac_nids = alc262_dac_nids,
12770 .hp_nid = 0x02,
12771 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12772 .channel_mode = alc262_modes,
12773 .input_mux = &alc262_capture_source,
12774 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012775 .setup = alc262_hippo_setup,
12776 .init_hook = alc262_hippo_automute,
Kailang Yang83c34212007-07-05 11:43:05 +020012777 },
12778 [ALC262_BENQ_T31] = {
12779 .mixers = { alc262_benq_t31_mixer },
Wu Fengguang6732bd02009-07-30 09:19:14 +020012780 .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs,
12781 alc_hp15_unsol_verbs },
Kailang Yang83c34212007-07-05 11:43:05 +020012782 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12783 .dac_nids = alc262_dac_nids,
12784 .hp_nid = 0x03,
12785 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12786 .channel_mode = alc262_modes,
12787 .input_mux = &alc262_capture_source,
12788 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012789 .setup = alc262_hippo_setup,
12790 .init_hook = alc262_hippo_automute,
Kailang Yangea1fb292008-08-26 12:58:38 +020012791 },
Tobin Davisf651b502007-10-26 12:40:47 +020012792 [ALC262_ULTRA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010012793 .mixers = { alc262_ultra_mixer },
12794 .cap_mixer = alc262_ultra_capture_mixer,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012795 .init_verbs = { alc262_ultra_verbs },
Tobin Davisf651b502007-10-26 12:40:47 +020012796 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12797 .dac_nids = alc262_dac_nids,
Tobin Davisf651b502007-10-26 12:40:47 +020012798 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12799 .channel_mode = alc262_modes,
12800 .input_mux = &alc262_ultra_capture_source,
Takashi Iwaibb9f76c2008-03-12 12:51:09 +010012801 .adc_nids = alc262_adc_nids, /* ADC0 */
12802 .capsrc_nids = alc262_capsrc_nids,
12803 .num_adc_nids = 1, /* single ADC */
Tobin Davisf651b502007-10-26 12:40:47 +020012804 .unsol_event = alc262_ultra_unsol_event,
12805 .init_hook = alc262_ultra_automute,
12806 },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012807 [ALC262_LENOVO_3000] = {
12808 .mixers = { alc262_lenovo_3000_mixer },
12809 .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
Daniel T Chene2595322009-12-19 18:19:02 -050012810 alc262_lenovo_3000_unsol_verbs,
12811 alc262_lenovo_3000_init_verbs },
Jiang zhe0e31daf2008-03-20 12:12:39 +010012812 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12813 .dac_nids = alc262_dac_nids,
12814 .hp_nid = 0x03,
12815 .dig_out_nid = ALC262_DIGOUT_NID,
12816 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12817 .channel_mode = alc262_modes,
12818 .input_mux = &alc262_fujitsu_capture_source,
12819 .unsol_event = alc262_lenovo_3000_unsol_event,
12820 },
Pascal Terjane8f9ae22008-08-04 14:36:05 +020012821 [ALC262_NEC] = {
12822 .mixers = { alc262_nec_mixer },
12823 .init_verbs = { alc262_nec_verbs },
12824 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12825 .dac_nids = alc262_dac_nids,
12826 .hp_nid = 0x03,
12827 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12828 .channel_mode = alc262_modes,
12829 .input_mux = &alc262_capture_source,
12830 },
Kailang Yang4e555fe2008-08-26 13:05:55 +020012831 [ALC262_TOSHIBA_S06] = {
12832 .mixers = { alc262_toshiba_s06_mixer },
12833 .init_verbs = { alc262_init_verbs, alc262_toshiba_s06_verbs,
12834 alc262_eapd_verbs },
12835 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12836 .capsrc_nids = alc262_dmic_capsrc_nids,
12837 .dac_nids = alc262_dac_nids,
12838 .adc_nids = alc262_dmic_adc_nids, /* ADC0 */
Takashi Iwaiae14ef62009-06-22 08:16:56 +020012839 .num_adc_nids = 1, /* single ADC */
Kailang Yang4e555fe2008-08-26 13:05:55 +020012840 .dig_out_nid = ALC262_DIGOUT_NID,
12841 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12842 .channel_mode = alc262_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012843 .unsol_event = alc_sku_unsol_event,
12844 .setup = alc262_toshiba_s06_setup,
12845 .init_hook = alc_inithook,
Kailang Yang4e555fe2008-08-26 13:05:55 +020012846 },
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012847 [ALC262_TOSHIBA_RX1] = {
12848 .mixers = { alc262_toshiba_rx1_mixer },
12849 .init_verbs = { alc262_init_verbs, alc262_toshiba_rx1_unsol_verbs },
12850 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12851 .dac_nids = alc262_dac_nids,
12852 .hp_nid = 0x03,
12853 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12854 .channel_mode = alc262_modes,
12855 .input_mux = &alc262_capture_source,
12856 .unsol_event = alc262_hippo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012857 .setup = alc262_hippo_setup,
12858 .init_hook = alc262_hippo_automute,
Hiroshi Miura9f99a632008-08-28 16:09:06 +020012859 },
Tony Vroonba340e82009-02-02 19:01:30 +000012860 [ALC262_TYAN] = {
12861 .mixers = { alc262_tyan_mixer },
12862 .init_verbs = { alc262_init_verbs, alc262_tyan_verbs},
12863 .num_dacs = ARRAY_SIZE(alc262_dac_nids),
12864 .dac_nids = alc262_dac_nids,
12865 .hp_nid = 0x02,
12866 .dig_out_nid = ALC262_DIGOUT_NID,
12867 .num_channel_mode = ARRAY_SIZE(alc262_modes),
12868 .channel_mode = alc262_modes,
12869 .input_mux = &alc262_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020012870 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020012871 .setup = alc262_tyan_setup,
12872 .init_hook = alc_automute_amp,
Tony Vroonba340e82009-02-02 19:01:30 +000012873 },
Kailang Yangdf694da2005-12-05 19:42:22 +010012874};
12875
12876static int patch_alc262(struct hda_codec *codec)
12877{
12878 struct alc_spec *spec;
12879 int board_config;
12880 int err;
12881
Robert P. J. Daydc041e02006-12-19 14:44:15 +010012882 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010012883 if (spec == NULL)
12884 return -ENOMEM;
12885
12886 codec->spec = spec;
12887#if 0
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012888 /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
12889 * under-run
12890 */
Kailang Yangdf694da2005-12-05 19:42:22 +010012891 {
12892 int tmp;
12893 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12894 tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
12895 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
12896 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12897 }
12898#endif
Kailang Yangda00c242010-03-19 11:23:45 +010012899 alc_auto_parse_customize_define(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010012900
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020012901 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12902
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012903 board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
12904 alc262_models,
12905 alc262_cfg_tbl);
Kailang Yangcd7509a2007-01-26 18:33:17 +010012906
Takashi Iwaif5fcc132006-11-24 17:07:44 +010012907 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020012908 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
12909 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010012910 board_config = ALC262_AUTO;
12911 }
12912
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012913 if (board_config == ALC262_AUTO) {
12914 alc_pick_fixup(codec, NULL, alc262_fixup_tbl, alc262_fixups);
12915 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
12916 }
Takashi Iwai18675e42010-09-08 15:55:44 +020012917
Kailang Yangdf694da2005-12-05 19:42:22 +010012918 if (board_config == ALC262_AUTO) {
12919 /* automatic parse from the BIOS config */
12920 err = alc262_parse_auto_config(codec);
12921 if (err < 0) {
12922 alc_free(codec);
12923 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012924 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020012925 printk(KERN_INFO
12926 "hda_codec: Cannot set up configuration "
12927 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010012928 board_config = ALC262_BASIC;
12929 }
12930 }
12931
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012932 if (!spec->no_analog && has_cdefine_beep(codec)) {
Takashi Iwai07eba612009-02-19 08:06:35 +010012933 err = snd_hda_attach_beep_device(codec, 0x1);
12934 if (err < 0) {
12935 alc_free(codec);
12936 return err;
12937 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090012938 }
12939
Kailang Yangdf694da2005-12-05 19:42:22 +010012940 if (board_config != ALC262_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020012941 setup_preset(codec, &alc262_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010012942
Kailang Yangdf694da2005-12-05 19:42:22 +010012943 spec->stream_analog_playback = &alc262_pcm_analog_playback;
12944 spec->stream_analog_capture = &alc262_pcm_analog_capture;
Kailang Yangea1fb292008-08-26 12:58:38 +020012945
Kailang Yangdf694da2005-12-05 19:42:22 +010012946 spec->stream_digital_playback = &alc262_pcm_digital_playback;
12947 spec->stream_digital_capture = &alc262_pcm_digital_capture;
12948
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020012949 if (!spec->adc_nids && spec->input_mux) {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012950 int i;
12951 /* check whether the digital-mic has to be supported */
12952 for (i = 0; i < spec->input_mux->num_items; i++) {
12953 if (spec->input_mux->items[i].index >= 9)
12954 break;
12955 }
12956 if (i < spec->input_mux->num_items) {
12957 /* use only ADC0 */
12958 spec->adc_nids = alc262_dmic_adc_nids;
12959 spec->num_adc_nids = 1;
12960 spec->capsrc_nids = alc262_dmic_capsrc_nids;
Kailang Yangdf694da2005-12-05 19:42:22 +010012961 } else {
Takashi Iwai8c927b42009-06-22 10:56:54 +020012962 /* all analog inputs */
12963 /* check whether NID 0x07 is valid */
12964 unsigned int wcap = get_wcaps(codec, 0x07);
12965
12966 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020012967 wcap = get_wcaps_type(wcap);
Takashi Iwai8c927b42009-06-22 10:56:54 +020012968 if (wcap != AC_WID_AUD_IN) {
12969 spec->adc_nids = alc262_adc_nids_alt;
12970 spec->num_adc_nids =
12971 ARRAY_SIZE(alc262_adc_nids_alt);
12972 spec->capsrc_nids = alc262_capsrc_nids_alt;
12973 } else {
12974 spec->adc_nids = alc262_adc_nids;
12975 spec->num_adc_nids =
12976 ARRAY_SIZE(alc262_adc_nids);
12977 spec->capsrc_nids = alc262_capsrc_nids;
12978 }
Kailang Yangdf694da2005-12-05 19:42:22 +010012979 }
12980 }
Takashi Iwaie64f14f2009-01-20 18:32:55 +010012981 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020012982 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020012983 if (!spec->no_analog && has_cdefine_beep(codec))
Takashi Iwai07eba612009-02-19 08:06:35 +010012984 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Kailang Yangdf694da2005-12-05 19:42:22 +010012985
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010012986 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai18675e42010-09-08 15:55:44 +020012987
Takashi Iwai2134ea42008-01-10 16:53:55 +010012988 spec->vmaster_nid = 0x0c;
12989
Kailang Yangdf694da2005-12-05 19:42:22 +010012990 codec->patch_ops = alc_patch_ops;
12991 if (board_config == ALC262_AUTO)
Takashi Iwaiae6b8132006-03-03 16:47:17 +010012992 spec->init_hook = alc262_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020012993
12994 alc_init_jacks(codec);
Takashi Iwaicb53c622007-08-10 17:21:45 +020012995#ifdef CONFIG_SND_HDA_POWER_SAVE
12996 if (!spec->loopback.amplist)
12997 spec->loopback.amplist = alc262_loopbacks;
12998#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020012999
Kailang Yangdf694da2005-12-05 19:42:22 +010013000 return 0;
13001}
13002
Kailang Yangdf694da2005-12-05 19:42:22 +010013003/*
Kailang Yanga361d842007-06-05 12:30:55 +020013004 * ALC268 channel source setting (2 channel)
13005 */
13006#define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
13007#define alc268_modes alc260_modes
Kailang Yangea1fb292008-08-26 12:58:38 +020013008
Kailang Yanga361d842007-06-05 12:30:55 +020013009static hda_nid_t alc268_dac_nids[2] = {
13010 /* front, hp */
13011 0x02, 0x03
13012};
13013
13014static hda_nid_t alc268_adc_nids[2] = {
13015 /* ADC0-1 */
13016 0x08, 0x07
13017};
13018
13019static hda_nid_t alc268_adc_nids_alt[1] = {
13020 /* ADC0 */
13021 0x08
13022};
13023
Takashi Iwaie1406342008-02-11 18:32:32 +010013024static hda_nid_t alc268_capsrc_nids[2] = { 0x23, 0x24 };
13025
Kailang Yanga361d842007-06-05 12:30:55 +020013026static struct snd_kcontrol_new alc268_base_mixer[] = {
13027 /* output mixer control */
13028 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13029 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13030 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13031 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013032 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13033 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13034 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Kailang Yanga361d842007-06-05 12:30:55 +020013035 { }
13036};
13037
Takashi Iwai42171c12009-05-08 14:11:43 +020013038static struct snd_kcontrol_new alc268_toshiba_mixer[] = {
13039 /* output mixer control */
13040 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13041 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13042 ALC262_HIPPO_MASTER_SWITCH,
David Henningsson5f99f862011-01-04 15:24:24 +010013043 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13044 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
13045 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020013046 { }
13047};
13048
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013049/* bind Beep switches of both NID 0x0f and 0x10 */
13050static struct hda_bind_ctls alc268_bind_beep_sw = {
13051 .ops = &snd_hda_bind_sw,
13052 .values = {
13053 HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
13054 HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
13055 0
13056 },
13057};
13058
13059static struct snd_kcontrol_new alc268_beep_mixer[] = {
13060 HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
13061 HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
13062 { }
13063};
13064
Kailang Yangd1a991a2007-08-15 16:21:59 +020013065static struct hda_verb alc268_eapd_verbs[] = {
13066 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
13067 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
13068 { }
13069};
13070
Takashi Iwaid2738092007-08-16 14:59:45 +020013071/* Toshiba specific */
Takashi Iwaid2738092007-08-16 14:59:45 +020013072static struct hda_verb alc268_toshiba_verbs[] = {
13073 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13074 { } /* end */
13075};
13076
13077/* Acer specific */
Takashi Iwai889c4392007-08-23 18:56:52 +020013078/* bind volumes of both NID 0x02 and 0x03 */
Takashi Iwai6bc96852007-08-17 09:02:12 +020013079static struct hda_bind_ctls alc268_acer_bind_master_vol = {
13080 .ops = &snd_hda_bind_vol,
13081 .values = {
13082 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
13083 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
13084 0
13085 },
13086};
13087
Takashi Iwai889c4392007-08-23 18:56:52 +020013088/* mute/unmute internal speaker according to the hp jack and mute state */
13089static void alc268_acer_automute(struct hda_codec *codec, int force)
13090{
13091 struct alc_spec *spec = codec->spec;
13092 unsigned int mute;
13093
13094 if (force || !spec->sense_updated) {
Wu Fengguang864f92b2009-11-18 12:38:02 +080013095 spec->jack_present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai889c4392007-08-23 18:56:52 +020013096 spec->sense_updated = 1;
13097 }
13098 if (spec->jack_present)
13099 mute = HDA_AMP_MUTE; /* mute internal speaker */
13100 else /* unmute internal speaker if necessary */
13101 mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
13102 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
13103 HDA_AMP_MUTE, mute);
13104}
13105
13106
13107/* bind hp and internal speaker mute (with plug check) */
13108static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
13109 struct snd_ctl_elem_value *ucontrol)
13110{
13111 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
13112 long *valp = ucontrol->value.integer.value;
13113 int change;
13114
Takashi Iwai8de56b72009-07-24 16:51:47 +020013115 change = amp_stereo_mute_update(codec, 0x14, HDA_OUTPUT, 0, valp);
Takashi Iwai889c4392007-08-23 18:56:52 +020013116 if (change)
13117 alc268_acer_automute(codec, 0);
13118 return change;
13119}
Takashi Iwaid2738092007-08-16 14:59:45 +020013120
Kailang Yang8ef355d2008-08-26 13:10:22 +020013121static struct snd_kcontrol_new alc268_acer_aspire_one_mixer[] = {
13122 /* output mixer control */
13123 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13124 {
13125 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13126 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013127 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013128 .info = snd_hda_mixer_amp_switch_info,
13129 .get = snd_hda_mixer_amp_switch_get,
13130 .put = alc268_acer_master_sw_put,
13131 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13132 },
13133 HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x18, 0, HDA_INPUT),
13134 { }
13135};
13136
Takashi Iwaid2738092007-08-16 14:59:45 +020013137static struct snd_kcontrol_new alc268_acer_mixer[] = {
13138 /* output mixer control */
13139 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13140 {
13141 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13142 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013143 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaid2738092007-08-16 14:59:45 +020013144 .info = snd_hda_mixer_amp_switch_info,
13145 .get = snd_hda_mixer_amp_switch_get,
13146 .put = alc268_acer_master_sw_put,
13147 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13148 },
David Henningsson5f99f862011-01-04 15:24:24 +010013149 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13150 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
13151 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaid2738092007-08-16 14:59:45 +020013152 { }
13153};
13154
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013155static struct snd_kcontrol_new alc268_acer_dmic_mixer[] = {
13156 /* output mixer control */
13157 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
13158 {
13159 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
13160 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010013161 .subdevice = HDA_SUBDEV_AMP_FLAG,
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013162 .info = snd_hda_mixer_amp_switch_info,
13163 .get = snd_hda_mixer_amp_switch_get,
13164 .put = alc268_acer_master_sw_put,
13165 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
13166 },
David Henningsson5f99f862011-01-04 15:24:24 +010013167 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13168 HDA_CODEC_VOLUME("Line In Boost Volume", 0x1a, 0, HDA_INPUT),
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013169 { }
13170};
13171
Kailang Yang8ef355d2008-08-26 13:10:22 +020013172static struct hda_verb alc268_acer_aspire_one_verbs[] = {
13173 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
13174 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13175 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13176 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
13177 {0x23, AC_VERB_SET_CONNECT_SEL, 0x06},
13178 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, 0xa017},
13179 { }
13180};
13181
Takashi Iwaid2738092007-08-16 14:59:45 +020013182static struct hda_verb alc268_acer_verbs[] = {
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013183 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN}, /* internal dmic? */
13184 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Takashi Iwaid2738092007-08-16 14:59:45 +020013185 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13186 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013187 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
13188 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
Takashi Iwaid2738092007-08-16 14:59:45 +020013189 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13190 { }
13191};
13192
13193/* unsolicited event for HP jack sensing */
Takashi Iwai42171c12009-05-08 14:11:43 +020013194#define alc268_toshiba_unsol_event alc262_hippo_unsol_event
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013195#define alc268_toshiba_setup alc262_hippo_setup
13196#define alc268_toshiba_automute alc262_hippo_automute
Takashi Iwaid2738092007-08-16 14:59:45 +020013197
13198static void alc268_acer_unsol_event(struct hda_codec *codec,
13199 unsigned int res)
13200{
Takashi Iwai889c4392007-08-23 18:56:52 +020013201 if ((res >> 26) != ALC880_HP_EVENT)
Takashi Iwaid2738092007-08-16 14:59:45 +020013202 return;
13203 alc268_acer_automute(codec, 1);
13204}
13205
Takashi Iwai889c4392007-08-23 18:56:52 +020013206static void alc268_acer_init_hook(struct hda_codec *codec)
13207{
13208 alc268_acer_automute(codec, 1);
13209}
13210
Kailang Yang8ef355d2008-08-26 13:10:22 +020013211/* toggle speaker-output according to the hp-jack state */
13212static void alc268_aspire_one_speaker_automute(struct hda_codec *codec)
13213{
13214 unsigned int present;
13215 unsigned char bits;
13216
Wu Fengguang864f92b2009-11-18 12:38:02 +080013217 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013218 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013219 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013220 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013221 snd_hda_codec_amp_stereo(codec, 0x0f, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020013222 HDA_AMP_MUTE, bits);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013223}
13224
Kailang Yang8ef355d2008-08-26 13:10:22 +020013225static void alc268_acer_lc_unsol_event(struct hda_codec *codec,
13226 unsigned int res)
13227{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013228 switch (res >> 26) {
13229 case ALC880_HP_EVENT:
Kailang Yang8ef355d2008-08-26 13:10:22 +020013230 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013231 break;
13232 case ALC880_MIC_EVENT:
13233 alc_mic_automute(codec);
13234 break;
13235 }
13236}
13237
13238static void alc268_acer_lc_setup(struct hda_codec *codec)
13239{
13240 struct alc_spec *spec = codec->spec;
13241 spec->ext_mic.pin = 0x18;
13242 spec->ext_mic.mux_idx = 0;
13243 spec->int_mic.pin = 0x12;
13244 spec->int_mic.mux_idx = 6;
13245 spec->auto_mic = 1;
Kailang Yang8ef355d2008-08-26 13:10:22 +020013246}
13247
13248static void alc268_acer_lc_init_hook(struct hda_codec *codec)
13249{
13250 alc268_aspire_one_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013251 alc_mic_automute(codec);
Kailang Yang8ef355d2008-08-26 13:10:22 +020013252}
13253
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013254static struct snd_kcontrol_new alc268_dell_mixer[] = {
13255 /* output mixer control */
13256 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13257 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13258 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13259 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013260 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13261 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013262 { }
13263};
13264
13265static struct hda_verb alc268_dell_verbs[] = {
13266 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13267 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
13268 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013269 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013270 { }
13271};
13272
13273/* mute/unmute internal speaker according to the hp jack and mute state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013274static void alc268_dell_setup(struct hda_codec *codec)
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013275{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013276 struct alc_spec *spec = codec->spec;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013277
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013278 spec->autocfg.hp_pins[0] = 0x15;
13279 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013280 spec->ext_mic.pin = 0x18;
13281 spec->ext_mic.mux_idx = 0;
13282 spec->int_mic.pin = 0x19;
13283 spec->int_mic.mux_idx = 1;
13284 spec->auto_mic = 1;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013285}
13286
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013287static struct snd_kcontrol_new alc267_quanta_il1_mixer[] = {
13288 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x2, 0x0, HDA_OUTPUT),
13289 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
13290 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
13291 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
13292 HDA_CODEC_VOLUME("Mic Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13293 HDA_BIND_MUTE("Mic Capture Switch", 0x23, 2, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010013294 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
13295 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013296 { }
13297};
13298
13299static struct hda_verb alc267_quanta_il1_verbs[] = {
13300 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
13301 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
13302 { }
13303};
13304
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013305static void alc267_quanta_il1_setup(struct hda_codec *codec)
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013306{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013307 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013308 spec->autocfg.hp_pins[0] = 0x15;
13309 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013310 spec->ext_mic.pin = 0x18;
13311 spec->ext_mic.mux_idx = 0;
13312 spec->int_mic.pin = 0x19;
13313 spec->int_mic.mux_idx = 1;
13314 spec->auto_mic = 1;
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013315}
13316
Kailang Yanga361d842007-06-05 12:30:55 +020013317/*
13318 * generic initialization of ADC, input mixers and output mixers
13319 */
13320static struct hda_verb alc268_base_init_verbs[] = {
13321 /* Unmute DAC0-1 and set vol = 0 */
13322 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013323 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013324
13325 /*
13326 * Set up output mixers (0x0c - 0x0e)
13327 */
13328 /* set vol=0 to output mixers */
13329 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013330 {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
13331
13332 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13333 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13334
13335 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13336 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
13337 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
13338 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13339 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13340 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13341 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13342 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13343
13344 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13345 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13346 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
13347 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013348 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013349
13350 /* set PCBEEP vol = 0, mute connections */
13351 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13352 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13353 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013354
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013355 /* Unmute Selector 23h,24h and set the default input to mic-in */
Kailang Yangea1fb292008-08-26 12:58:38 +020013356
Jiang Zhea9b3aa82007-12-20 13:13:13 +010013357 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
13358 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
13359 {0x24, AC_VERB_SET_CONNECT_SEL, 0x00},
13360 {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013361
Kailang Yanga361d842007-06-05 12:30:55 +020013362 { }
13363};
13364
13365/*
13366 * generic initialization of ADC, input mixers and output mixers
13367 */
13368static struct hda_verb alc268_volume_init_verbs[] = {
13369 /* set output DAC */
Takashi Iwai4cfb91c2009-01-23 12:53:09 +010013370 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
13371 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
Kailang Yanga361d842007-06-05 12:30:55 +020013372
13373 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13374 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
13375 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13376 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13377 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
13378
Kailang Yanga361d842007-06-05 12:30:55 +020013379 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yanga361d842007-06-05 12:30:55 +020013380 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13381 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13382
13383 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013384 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yanga361d842007-06-05 12:30:55 +020013385
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013386 /* set PCBEEP vol = 0, mute connections */
13387 {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
13388 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
13389 {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yanga361d842007-06-05 12:30:55 +020013390
13391 { }
13392};
13393
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013394static struct snd_kcontrol_new alc268_capture_nosrc_mixer[] = {
13395 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13396 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13397 { } /* end */
13398};
13399
Kailang Yanga361d842007-06-05 12:30:55 +020013400static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
13401 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13402 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013403 _DEFINE_CAPSRC(1),
Kailang Yanga361d842007-06-05 12:30:55 +020013404 { } /* end */
13405};
13406
13407static struct snd_kcontrol_new alc268_capture_mixer[] = {
13408 HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13409 HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
13410 HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
13411 HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013412 _DEFINE_CAPSRC(2),
Kailang Yanga361d842007-06-05 12:30:55 +020013413 { } /* end */
13414};
13415
13416static struct hda_input_mux alc268_capture_source = {
13417 .num_items = 4,
13418 .items = {
13419 { "Mic", 0x0 },
13420 { "Front Mic", 0x1 },
13421 { "Line", 0x2 },
13422 { "CD", 0x3 },
13423 },
13424};
13425
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013426static struct hda_input_mux alc268_acer_capture_source = {
13427 .num_items = 3,
13428 .items = {
13429 { "Mic", 0x0 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013430 { "Internal Mic", 0x1 },
13431 { "Line", 0x2 },
13432 },
13433};
13434
13435static struct hda_input_mux alc268_acer_dmic_capture_source = {
13436 .num_items = 3,
13437 .items = {
13438 { "Mic", 0x0 },
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013439 { "Internal Mic", 0x6 },
13440 { "Line", 0x2 },
13441 },
13442};
13443
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013444#ifdef CONFIG_SND_DEBUG
13445static struct snd_kcontrol_new alc268_test_mixer[] = {
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013446 /* Volume widgets */
13447 HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x02, 0x0, HDA_OUTPUT),
13448 HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x03, 0x0, HDA_OUTPUT),
13449 HDA_BIND_MUTE_MONO("Mono sum Playback Switch", 0x0e, 1, 2, HDA_INPUT),
13450 HDA_BIND_MUTE("LINE-OUT sum Playback Switch", 0x0f, 2, HDA_INPUT),
13451 HDA_BIND_MUTE("HP-OUT sum Playback Switch", 0x10, 2, HDA_INPUT),
13452 HDA_BIND_MUTE("LINE-OUT Playback Switch", 0x14, 2, HDA_OUTPUT),
13453 HDA_BIND_MUTE("HP-OUT Playback Switch", 0x15, 2, HDA_OUTPUT),
13454 HDA_BIND_MUTE("Mono Playback Switch", 0x16, 2, HDA_OUTPUT),
13455 HDA_CODEC_VOLUME("MIC1 Capture Volume", 0x18, 0x0, HDA_INPUT),
13456 HDA_BIND_MUTE("MIC1 Capture Switch", 0x18, 2, HDA_OUTPUT),
13457 HDA_CODEC_VOLUME("MIC2 Capture Volume", 0x19, 0x0, HDA_INPUT),
13458 HDA_CODEC_VOLUME("LINE1 Capture Volume", 0x1a, 0x0, HDA_INPUT),
13459 HDA_BIND_MUTE("LINE1 Capture Switch", 0x1a, 2, HDA_OUTPUT),
Takashi Iwaif0747ee2008-01-15 11:41:41 +010013460 /* The below appears problematic on some hardwares */
13461 /*HDA_CODEC_VOLUME("PCBEEP Playback Volume", 0x1d, 0x0, HDA_INPUT),*/
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013462 HDA_CODEC_VOLUME("PCM-IN1 Capture Volume", 0x23, 0x0, HDA_OUTPUT),
13463 HDA_BIND_MUTE("PCM-IN1 Capture Switch", 0x23, 2, HDA_OUTPUT),
13464 HDA_CODEC_VOLUME("PCM-IN2 Capture Volume", 0x24, 0x0, HDA_OUTPUT),
13465 HDA_BIND_MUTE("PCM-IN2 Capture Switch", 0x24, 2, HDA_OUTPUT),
13466
13467 /* Modes for retasking pin widgets */
13468 ALC_PIN_MODE("LINE-OUT pin mode", 0x14, ALC_PIN_DIR_INOUT),
13469 ALC_PIN_MODE("HP-OUT pin mode", 0x15, ALC_PIN_DIR_INOUT),
13470 ALC_PIN_MODE("MIC1 pin mode", 0x18, ALC_PIN_DIR_INOUT),
13471 ALC_PIN_MODE("LINE1 pin mode", 0x1a, ALC_PIN_DIR_INOUT),
13472
13473 /* Controls for GPIO pins, assuming they are configured as outputs */
13474 ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
13475 ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
13476 ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
13477 ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
13478
13479 /* Switches to allow the digital SPDIF output pin to be enabled.
13480 * The ALC268 does not have an SPDIF input.
13481 */
13482 ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x06, 0x01),
13483
13484 /* A switch allowing EAPD to be enabled. Some laptops seem to use
13485 * this output to turn on an external amplifier.
13486 */
13487 ALC_EAPD_CTRL_SWITCH("LINE-OUT EAPD Enable Switch", 0x0f, 0x02),
13488 ALC_EAPD_CTRL_SWITCH("HP-OUT EAPD Enable Switch", 0x10, 0x02),
13489
13490 { } /* end */
13491};
13492#endif
13493
Kailang Yanga361d842007-06-05 12:30:55 +020013494/* create input playback/capture controls for the given pin */
13495static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
13496 const char *ctlname, int idx)
13497{
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013498 hda_nid_t dac;
Kailang Yanga361d842007-06-05 12:30:55 +020013499 int err;
13500
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013501 switch (nid) {
13502 case 0x14:
13503 case 0x16:
13504 dac = 0x02;
13505 break;
13506 case 0x15:
Takashi Iwaib08b1632010-07-30 14:08:25 +020013507 case 0x1a: /* ALC259/269 only */
13508 case 0x1b: /* ALC259/269 only */
Kailang Yang531d8792010-04-09 10:57:33 +020013509 case 0x21: /* ALC269vb has this pin, too */
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013510 dac = 0x03;
13511 break;
13512 default:
Takashi Iwaic7a94342010-07-30 14:10:43 +020013513 snd_printd(KERN_WARNING "hda_codec: "
13514 "ignoring pin 0x%x as unknown\n", nid);
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013515 return 0;
13516 }
13517 if (spec->multiout.dac_nids[0] != dac &&
13518 spec->multiout.dac_nids[1] != dac) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013519 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013520 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
Kailang Yanga361d842007-06-05 12:30:55 +020013521 HDA_OUTPUT));
13522 if (err < 0)
13523 return err;
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013524 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
13525 }
13526
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013527 if (nid != 0x16)
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013528 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Kailang Yanga361d842007-06-05 12:30:55 +020013529 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013530 else /* mono */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013531 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013532 HDA_COMPOSE_AMP_VAL(nid, 2, idx, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013533 if (err < 0)
13534 return err;
13535 return 0;
13536}
13537
13538/* add playback controls from the parsed DAC table */
13539static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
13540 const struct auto_pin_cfg *cfg)
13541{
13542 hda_nid_t nid;
13543 int err;
13544
Kailang Yanga361d842007-06-05 12:30:55 +020013545 spec->multiout.dac_nids = spec->private_dac_nids;
Kailang Yanga361d842007-06-05 12:30:55 +020013546
13547 nid = cfg->line_out_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013548 if (nid) {
13549 const char *name;
13550 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
13551 name = "Speaker";
13552 else
13553 name = "Front";
13554 err = alc268_new_analog_output(spec, nid, name, 0);
13555 if (err < 0)
13556 return err;
13557 }
Kailang Yanga361d842007-06-05 12:30:55 +020013558
13559 nid = cfg->speaker_pins[0];
13560 if (nid == 0x1d) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013561 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, "Speaker",
Kailang Yanga361d842007-06-05 12:30:55 +020013562 HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
13563 if (err < 0)
13564 return err;
David Henningsson7bfb9c02010-08-02 13:13:25 +020013565 } else if (nid) {
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013566 err = alc268_new_analog_output(spec, nid, "Speaker", 0);
13567 if (err < 0)
13568 return err;
Kailang Yanga361d842007-06-05 12:30:55 +020013569 }
13570 nid = cfg->hp_pins[0];
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013571 if (nid) {
13572 err = alc268_new_analog_output(spec, nid, "Headphone", 0);
13573 if (err < 0)
13574 return err;
13575 }
Kailang Yanga361d842007-06-05 12:30:55 +020013576
13577 nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
13578 if (nid == 0x16) {
Takashi Iwai0afe5f82009-10-02 09:20:00 +020013579 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, "Mono",
Takashi Iwai3f3b7c12009-07-17 14:36:59 +020013580 HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT));
Kailang Yanga361d842007-06-05 12:30:55 +020013581 if (err < 0)
13582 return err;
13583 }
Kailang Yangea1fb292008-08-26 12:58:38 +020013584 return 0;
Kailang Yanga361d842007-06-05 12:30:55 +020013585}
13586
13587/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020013588static int alc268_auto_create_input_ctls(struct hda_codec *codec,
Kailang Yanga361d842007-06-05 12:30:55 +020013589 const struct auto_pin_cfg *cfg)
13590{
Takashi Iwai05f5f472009-08-25 13:10:18 +020013591 return alc_auto_create_input_ctls(codec, cfg, 0, 0x23, 0x24);
Kailang Yanga361d842007-06-05 12:30:55 +020013592}
13593
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013594static void alc268_auto_set_output_and_unmute(struct hda_codec *codec,
13595 hda_nid_t nid, int pin_type)
13596{
13597 int idx;
13598
13599 alc_set_pin_output(codec, nid, pin_type);
13600 if (nid == 0x14 || nid == 0x16)
13601 idx = 0;
13602 else
13603 idx = 1;
13604 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
13605}
13606
13607static void alc268_auto_init_multi_out(struct hda_codec *codec)
13608{
13609 struct alc_spec *spec = codec->spec;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013610 int i;
13611
13612 for (i = 0; i < spec->autocfg.line_outs; i++) {
13613 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013614 int pin_type = get_pin_type(spec->autocfg.line_out_type);
13615 alc268_auto_set_output_and_unmute(codec, nid, pin_type);
13616 }
13617}
13618
13619static void alc268_auto_init_hp_out(struct hda_codec *codec)
13620{
13621 struct alc_spec *spec = codec->spec;
13622 hda_nid_t pin;
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013623 int i;
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013624
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013625 for (i = 0; i < spec->autocfg.hp_outs; i++) {
13626 pin = spec->autocfg.hp_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013627 alc268_auto_set_output_and_unmute(codec, pin, PIN_HP);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013628 }
13629 for (i = 0; i < spec->autocfg.speaker_outs; i++) {
13630 pin = spec->autocfg.speaker_pins[i];
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013631 alc268_auto_set_output_and_unmute(codec, pin, PIN_OUT);
Takashi Iwaie1ca7b42010-09-20 14:58:57 +020013632 }
13633 if (spec->autocfg.mono_out_pin)
13634 snd_hda_codec_write(codec, spec->autocfg.mono_out_pin, 0,
13635 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013636}
13637
Kailang Yanga361d842007-06-05 12:30:55 +020013638static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
13639{
13640 struct alc_spec *spec = codec->spec;
13641 hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
13642 hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
13643 hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
13644 unsigned int dac_vol1, dac_vol2;
13645
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013646 if (line_nid == 0x1d || speaker_nid == 0x1d) {
Kailang Yanga361d842007-06-05 12:30:55 +020013647 snd_hda_codec_write(codec, speaker_nid, 0,
13648 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013649 /* mute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013650 snd_hda_codec_write(codec, 0x0f, 0,
13651 AC_VERB_SET_AMP_GAIN_MUTE,
13652 AMP_IN_UNMUTE(1));
13653 snd_hda_codec_write(codec, 0x10, 0,
13654 AC_VERB_SET_AMP_GAIN_MUTE,
13655 AMP_IN_UNMUTE(1));
13656 } else {
Takashi Iwaie9af4f32009-08-29 23:23:08 +020013657 /* unmute mixer inputs from 0x1d */
Kailang Yanga361d842007-06-05 12:30:55 +020013658 snd_hda_codec_write(codec, 0x0f, 0,
13659 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13660 snd_hda_codec_write(codec, 0x10, 0,
13661 AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
13662 }
13663
13664 dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
Kailang Yangea1fb292008-08-26 12:58:38 +020013665 if (line_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013666 dac_vol2 = AMP_OUT_ZERO;
13667 else if (line_nid == 0x15)
13668 dac_vol1 = AMP_OUT_ZERO;
Kailang Yangea1fb292008-08-26 12:58:38 +020013669 if (hp_nid == 0x14)
Kailang Yanga361d842007-06-05 12:30:55 +020013670 dac_vol2 = AMP_OUT_ZERO;
13671 else if (hp_nid == 0x15)
13672 dac_vol1 = AMP_OUT_ZERO;
13673 if (line_nid != 0x16 || hp_nid != 0x16 ||
13674 spec->autocfg.line_out_pins[1] != 0x16 ||
13675 spec->autocfg.line_out_pins[2] != 0x16)
13676 dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
13677
13678 snd_hda_codec_write(codec, 0x02, 0,
13679 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
13680 snd_hda_codec_write(codec, 0x03, 0,
13681 AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
13682}
13683
Sasha Alexandrdef319f2009-06-16 16:00:15 -040013684/* pcm configuration: identical with ALC880 */
Kailang Yanga361d842007-06-05 12:30:55 +020013685#define alc268_pcm_analog_playback alc880_pcm_analog_playback
13686#define alc268_pcm_analog_capture alc880_pcm_analog_capture
Takashi Iwai63300792008-01-24 15:31:36 +010013687#define alc268_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
Kailang Yanga361d842007-06-05 12:30:55 +020013688#define alc268_pcm_digital_playback alc880_pcm_digital_playback
13689
13690/*
13691 * BIOS auto configuration
13692 */
13693static int alc268_parse_auto_config(struct hda_codec *codec)
13694{
13695 struct alc_spec *spec = codec->spec;
13696 int err;
13697 static hda_nid_t alc268_ignore[] = { 0 };
13698
13699 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
13700 alc268_ignore);
13701 if (err < 0)
13702 return err;
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013703 if (!spec->autocfg.line_outs) {
13704 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
13705 spec->multiout.max_channels = 2;
13706 spec->no_analog = 1;
13707 goto dig_only;
13708 }
Kailang Yanga361d842007-06-05 12:30:55 +020013709 return 0; /* can't find valid BIOS pin config */
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013710 }
Kailang Yanga361d842007-06-05 12:30:55 +020013711 err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
13712 if (err < 0)
13713 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020013714 err = alc268_auto_create_input_ctls(codec, &spec->autocfg);
Kailang Yanga361d842007-06-05 12:30:55 +020013715 if (err < 0)
13716 return err;
13717
13718 spec->multiout.max_channels = 2;
13719
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010013720 dig_only:
Kailang Yanga361d842007-06-05 12:30:55 +020013721 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020013722 alc_auto_parse_digital(codec);
Takashi Iwai603c4012008-07-30 15:01:44 +020013723 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013724 add_mixer(spec, spec->kctls.list);
Kailang Yanga361d842007-06-05 12:30:55 +020013725
Takashi Iwai892981f2009-03-02 08:04:35 +010013726 if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d)
Takashi Iwaid88897e2008-10-31 15:01:37 +010013727 add_mixer(spec, alc268_beep_mixer);
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013728
Takashi Iwaid88897e2008-10-31 15:01:37 +010013729 add_verb(spec, alc268_volume_init_verbs);
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030013730 spec->num_mux_defs = 2;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020013731 spec->input_mux = &spec->private_imux[0];
Kailang Yanga361d842007-06-05 12:30:55 +020013732
Takashi Iwai776e1842007-08-29 15:07:11 +020013733 err = alc_auto_add_mic_boost(codec);
13734 if (err < 0)
13735 return err;
13736
Kailang Yang6227cdc2010-02-25 08:36:52 +010013737 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai1d955eb2009-06-29 11:33:53 +020013738
Kailang Yanga361d842007-06-05 12:30:55 +020013739 return 1;
13740}
13741
Kailang Yanga361d842007-06-05 12:30:55 +020013742#define alc268_auto_init_analog_input alc882_auto_init_analog_input
13743
13744/* init callback for auto-configuration model -- overriding the default init */
13745static void alc268_auto_init(struct hda_codec *codec)
13746{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013747 struct alc_spec *spec = codec->spec;
Kailang Yanga361d842007-06-05 12:30:55 +020013748 alc268_auto_init_multi_out(codec);
13749 alc268_auto_init_hp_out(codec);
13750 alc268_auto_init_mono_speaker_out(codec);
13751 alc268_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020013752 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010013753 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020013754 alc_inithook(codec);
Kailang Yanga361d842007-06-05 12:30:55 +020013755}
13756
13757/*
13758 * configuration and preset
13759 */
Takashi Iwaiea734962011-01-17 11:29:34 +010013760static const char * const alc268_models[ALC268_MODEL_LAST] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013761 [ALC267_QUANTA_IL1] = "quanta-il1",
Kailang Yanga361d842007-06-05 12:30:55 +020013762 [ALC268_3ST] = "3stack",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020013763 [ALC268_TOSHIBA] = "toshiba",
Takashi Iwaid2738092007-08-16 14:59:45 +020013764 [ALC268_ACER] = "acer",
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013765 [ALC268_ACER_DMIC] = "acer-dmic",
Kailang Yang8ef355d2008-08-26 13:10:22 +020013766 [ALC268_ACER_ASPIRE_ONE] = "acer-aspire",
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013767 [ALC268_DELL] = "dell",
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013768 [ALC268_ZEPTO] = "zepto",
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013769#ifdef CONFIG_SND_DEBUG
13770 [ALC268_TEST] = "test",
13771#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013772 [ALC268_AUTO] = "auto",
13773};
13774
13775static struct snd_pci_quirk alc268_cfg_tbl[] = {
Takashi Iwaia0b8f7d2008-04-22 19:39:49 +020013776 SND_PCI_QUIRK(0x1025, 0x011e, "Acer Aspire 5720z", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013777 SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
Andy Shevchenkodafc8352008-01-25 11:53:50 +010013778 SND_PCI_QUIRK(0x1025, 0x012e, "Acer Aspire 5310", ALC268_ACER),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010013779 SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
Andy Shevchenko29a52c22008-01-24 17:29:00 +010013780 SND_PCI_QUIRK(0x1025, 0x0136, "Acer Aspire 5315", ALC268_ACER),
Kailang Yang8ef355d2008-08-26 13:10:22 +020013781 SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One",
13782 ALC268_ACER_ASPIRE_ONE),
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013783 SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL),
Daniel T Chena1bf8082009-11-01 18:32:29 -050013784 SND_PCI_QUIRK_MASK(0x1028, 0xfff0, 0x02b0,
13785 "Dell Inspiron Mini9/Vostro A90", ALC268_DELL),
Takashi Iwai33d78672009-09-08 11:03:41 +020013786 /* almost compatible with toshiba but with optional digital outs;
13787 * auto-probing seems working fine
13788 */
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013789 SND_PCI_QUIRK_MASK(0x103c, 0xff00, 0x3000, "HP TX25xx series",
Takashi Iwai33d78672009-09-08 11:03:41 +020013790 ALC268_AUTO),
Kailang Yanga361d842007-06-05 12:30:55 +020013791 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
Takashi Iwai8871e5b2009-06-02 01:02:50 +020013792 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
Tony Vroon378bd6a2008-06-04 12:08:30 +020013793 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
Takashi Iwaib875bf32007-09-06 15:00:27 +020013794 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013795 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
Kailang Yanga361d842007-06-05 12:30:55 +020013796 {}
13797};
13798
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013799/* Toshiba laptops have no unique PCI SSID but only codec SSID */
13800static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
13801 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
13802 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
13803 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
13804 ALC268_TOSHIBA),
13805 {}
13806};
13807
Kailang Yanga361d842007-06-05 12:30:55 +020013808static struct alc_config_preset alc268_presets[] = {
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013809 [ALC267_QUANTA_IL1] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013810 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer,
13811 alc268_capture_nosrc_mixer },
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013812 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13813 alc267_quanta_il1_verbs },
13814 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13815 .dac_nids = alc268_dac_nids,
13816 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13817 .adc_nids = alc268_adc_nids_alt,
13818 .hp_nid = 0x03,
13819 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13820 .channel_mode = alc268_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013821 .unsol_event = alc_sku_unsol_event,
13822 .setup = alc267_quanta_il1_setup,
13823 .init_hook = alc_inithook,
Herton Ronaldo Krzesinskieb5a6622008-04-14 13:46:28 +020013824 },
Kailang Yanga361d842007-06-05 12:30:55 +020013825 [ALC268_3ST] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013826 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13827 alc268_beep_mixer },
Kailang Yanga361d842007-06-05 12:30:55 +020013828 .init_verbs = { alc268_base_init_verbs },
13829 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13830 .dac_nids = alc268_dac_nids,
13831 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13832 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013833 .capsrc_nids = alc268_capsrc_nids,
Kailang Yanga361d842007-06-05 12:30:55 +020013834 .hp_nid = 0x03,
13835 .dig_out_nid = ALC268_DIGOUT_NID,
13836 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13837 .channel_mode = alc268_modes,
13838 .input_mux = &alc268_capture_source,
13839 },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013840 [ALC268_TOSHIBA] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020013841 .mixers = { alc268_toshiba_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013842 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013843 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13844 alc268_toshiba_verbs },
Kailang Yangd1a991a2007-08-15 16:21:59 +020013845 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13846 .dac_nids = alc268_dac_nids,
13847 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13848 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013849 .capsrc_nids = alc268_capsrc_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013850 .hp_nid = 0x03,
13851 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13852 .channel_mode = alc268_modes,
13853 .input_mux = &alc268_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013854 .unsol_event = alc268_toshiba_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013855 .setup = alc268_toshiba_setup,
13856 .init_hook = alc268_toshiba_automute,
Takashi Iwaid2738092007-08-16 14:59:45 +020013857 },
13858 [ALC268_ACER] = {
Takashi Iwai432fd132009-09-30 08:13:44 +020013859 .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013860 alc268_beep_mixer },
Takashi Iwaid2738092007-08-16 14:59:45 +020013861 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13862 alc268_acer_verbs },
13863 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13864 .dac_nids = alc268_dac_nids,
13865 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13866 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013867 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwaid2738092007-08-16 14:59:45 +020013868 .hp_nid = 0x02,
13869 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13870 .channel_mode = alc268_modes,
Takashi Iwai0ccb5412008-03-06 16:58:35 +010013871 .input_mux = &alc268_acer_capture_source,
Takashi Iwaid2738092007-08-16 14:59:45 +020013872 .unsol_event = alc268_acer_unsol_event,
Takashi Iwai889c4392007-08-23 18:56:52 +020013873 .init_hook = alc268_acer_init_hook,
Kailang Yangd1a991a2007-08-15 16:21:59 +020013874 },
Takashi Iwaic238b4f2008-11-05 14:57:20 +010013875 [ALC268_ACER_DMIC] = {
13876 .mixers = { alc268_acer_dmic_mixer, alc268_capture_alt_mixer,
13877 alc268_beep_mixer },
13878 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13879 alc268_acer_verbs },
13880 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13881 .dac_nids = alc268_dac_nids,
13882 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13883 .adc_nids = alc268_adc_nids_alt,
13884 .capsrc_nids = alc268_capsrc_nids,
13885 .hp_nid = 0x02,
13886 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13887 .channel_mode = alc268_modes,
13888 .input_mux = &alc268_acer_dmic_capture_source,
13889 .unsol_event = alc268_acer_unsol_event,
13890 .init_hook = alc268_acer_init_hook,
13891 },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013892 [ALC268_ACER_ASPIRE_ONE] = {
13893 .mixers = { alc268_acer_aspire_one_mixer,
Takashi Iwai22971e32009-02-10 11:56:44 +010013894 alc268_beep_mixer,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013895 alc268_capture_nosrc_mixer },
Kailang Yang8ef355d2008-08-26 13:10:22 +020013896 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13897 alc268_acer_aspire_one_verbs },
13898 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13899 .dac_nids = alc268_dac_nids,
13900 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13901 .adc_nids = alc268_adc_nids_alt,
13902 .capsrc_nids = alc268_capsrc_nids,
13903 .hp_nid = 0x03,
13904 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13905 .channel_mode = alc268_modes,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013906 .unsol_event = alc268_acer_lc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013907 .setup = alc268_acer_lc_setup,
Kailang Yang8ef355d2008-08-26 13:10:22 +020013908 .init_hook = alc268_acer_lc_init_hook,
13909 },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013910 [ALC268_DELL] = {
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013911 .mixers = { alc268_dell_mixer, alc268_beep_mixer,
13912 alc268_capture_nosrc_mixer },
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013913 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13914 alc268_dell_verbs },
13915 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13916 .dac_nids = alc268_dac_nids,
Takashi Iwaifdbc66262009-08-19 00:18:10 +020013917 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13918 .adc_nids = alc268_adc_nids_alt,
13919 .capsrc_nids = alc268_capsrc_nids,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013920 .hp_nid = 0x02,
13921 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13922 .channel_mode = alc268_modes,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020013923 .unsol_event = alc_sku_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013924 .setup = alc268_dell_setup,
13925 .init_hook = alc_inithook,
Takashi Iwai3866f0b2008-01-15 12:37:42 +010013926 },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013927 [ALC268_ZEPTO] = {
Takashi Iwaiaef9d312008-02-19 13:16:41 +010013928 .mixers = { alc268_base_mixer, alc268_capture_alt_mixer,
13929 alc268_beep_mixer },
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013930 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13931 alc268_toshiba_verbs },
13932 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13933 .dac_nids = alc268_dac_nids,
13934 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13935 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013936 .capsrc_nids = alc268_capsrc_nids,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013937 .hp_nid = 0x03,
13938 .dig_out_nid = ALC268_DIGOUT_NID,
13939 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13940 .channel_mode = alc268_modes,
13941 .input_mux = &alc268_capture_source,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020013942 .setup = alc268_toshiba_setup,
13943 .init_hook = alc268_toshiba_automute,
Mirco Tischlerf12462c2008-02-04 12:33:59 +010013944 },
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013945#ifdef CONFIG_SND_DEBUG
13946 [ALC268_TEST] = {
13947 .mixers = { alc268_test_mixer, alc268_capture_mixer },
13948 .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
13949 alc268_volume_init_verbs },
13950 .num_dacs = ARRAY_SIZE(alc268_dac_nids),
13951 .dac_nids = alc268_dac_nids,
13952 .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
13953 .adc_nids = alc268_adc_nids_alt,
Takashi Iwaie1406342008-02-11 18:32:32 +010013954 .capsrc_nids = alc268_capsrc_nids,
Jonathan Woithe86c53bd2008-01-08 12:33:19 +010013955 .hp_nid = 0x03,
13956 .dig_out_nid = ALC268_DIGOUT_NID,
13957 .num_channel_mode = ARRAY_SIZE(alc268_modes),
13958 .channel_mode = alc268_modes,
13959 .input_mux = &alc268_capture_source,
13960 },
13961#endif
Kailang Yanga361d842007-06-05 12:30:55 +020013962};
13963
13964static int patch_alc268(struct hda_codec *codec)
13965{
13966 struct alc_spec *spec;
13967 int board_config;
Takashi Iwai22971e32009-02-10 11:56:44 +010013968 int i, has_beep, err;
Kailang Yanga361d842007-06-05 12:30:55 +020013969
Julia Lawallef86f582009-12-19 08:18:03 +010013970 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yanga361d842007-06-05 12:30:55 +020013971 if (spec == NULL)
13972 return -ENOMEM;
13973
13974 codec->spec = spec;
13975
13976 board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
13977 alc268_models,
13978 alc268_cfg_tbl);
13979
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013980 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
13981 board_config = snd_hda_check_board_codec_sid_config(codec,
Takashi Iwai50ae0aa2010-03-08 12:09:59 +010013982 ALC268_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
Takashi Iwai3abf2f32009-08-19 20:05:02 +020013983
Kailang Yanga361d842007-06-05 12:30:55 +020013984 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020013985 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
13986 codec->chip_name);
Kailang Yanga361d842007-06-05 12:30:55 +020013987 board_config = ALC268_AUTO;
13988 }
13989
13990 if (board_config == ALC268_AUTO) {
13991 /* automatic parse from the BIOS config */
13992 err = alc268_parse_auto_config(codec);
13993 if (err < 0) {
13994 alc_free(codec);
13995 return err;
13996 } else if (!err) {
13997 printk(KERN_INFO
13998 "hda_codec: Cannot set up configuration "
13999 "from BIOS. Using base mode...\n");
14000 board_config = ALC268_3ST;
14001 }
14002 }
14003
14004 if (board_config != ALC268_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020014005 setup_preset(codec, &alc268_presets[board_config]);
Kailang Yanga361d842007-06-05 12:30:55 +020014006
Kailang Yanga361d842007-06-05 12:30:55 +020014007 spec->stream_analog_playback = &alc268_pcm_analog_playback;
14008 spec->stream_analog_capture = &alc268_pcm_analog_capture;
Takashi Iwai63300792008-01-24 15:31:36 +010014009 spec->stream_analog_alt_capture = &alc268_pcm_analog_alt_capture;
Kailang Yanga361d842007-06-05 12:30:55 +020014010
Kailang Yanga361d842007-06-05 12:30:55 +020014011 spec->stream_digital_playback = &alc268_pcm_digital_playback;
14012
Takashi Iwai22971e32009-02-10 11:56:44 +010014013 has_beep = 0;
14014 for (i = 0; i < spec->num_mixers; i++) {
14015 if (spec->mixers[i] == alc268_beep_mixer) {
14016 has_beep = 1;
14017 break;
14018 }
14019 }
14020
14021 if (has_beep) {
14022 err = snd_hda_attach_beep_device(codec, 0x1);
14023 if (err < 0) {
14024 alc_free(codec);
14025 return err;
14026 }
14027 if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
14028 /* override the amp caps for beep generator */
14029 snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014030 (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
14031 (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
14032 (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
14033 (0 << AC_AMPCAP_MUTE_SHIFT));
Takashi Iwai22971e32009-02-10 11:56:44 +010014034 }
Takashi Iwaiaef9d312008-02-19 13:16:41 +010014035
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014036 if (!spec->no_analog && !spec->adc_nids && spec->input_mux) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014037 /* check whether NID 0x07 is valid */
14038 unsigned int wcap = get_wcaps(codec, 0x07);
Takashi Iwai85860c02008-02-19 15:00:15 +010014039 int i;
Kailang Yanga361d842007-06-05 12:30:55 +020014040
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014041 spec->capsrc_nids = alc268_capsrc_nids;
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014042 /* get type */
Takashi Iwaia22d5432009-07-27 12:54:26 +020014043 wcap = get_wcaps_type(wcap);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014044 if (spec->auto_mic ||
14045 wcap != AC_WID_AUD_IN || spec->input_mux->num_items == 1) {
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014046 spec->adc_nids = alc268_adc_nids_alt;
14047 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt);
Takashi Iwaidefb5ab2009-10-07 15:12:27 +020014048 if (spec->auto_mic)
14049 fixup_automic_adc(codec);
Takashi Iwaifdbc66262009-08-19 00:18:10 +020014050 if (spec->auto_mic || spec->input_mux->num_items == 1)
14051 add_mixer(spec, alc268_capture_nosrc_mixer);
14052 else
14053 add_mixer(spec, alc268_capture_alt_mixer);
Takashi Iwai3866f0b2008-01-15 12:37:42 +010014054 } else {
14055 spec->adc_nids = alc268_adc_nids;
14056 spec->num_adc_nids = ARRAY_SIZE(alc268_adc_nids);
Takashi Iwaid88897e2008-10-31 15:01:37 +010014057 add_mixer(spec, alc268_capture_mixer);
Kailang Yanga361d842007-06-05 12:30:55 +020014058 }
Takashi Iwai85860c02008-02-19 15:00:15 +010014059 /* set default input source */
14060 for (i = 0; i < spec->num_adc_nids; i++)
14061 snd_hda_codec_write_cache(codec, alc268_capsrc_nids[i],
14062 0, AC_VERB_SET_CONNECT_SEL,
Herton Ronaldo Krzesinski59085892009-08-11 22:33:09 -030014063 i < spec->num_mux_defs ?
14064 spec->input_mux[i].items[0].index :
Takashi Iwai85860c02008-02-19 15:00:15 +010014065 spec->input_mux->items[0].index);
Kailang Yanga361d842007-06-05 12:30:55 +020014066 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010014067
14068 spec->vmaster_nid = 0x02;
14069
Kailang Yanga361d842007-06-05 12:30:55 +020014070 codec->patch_ops = alc_patch_ops;
14071 if (board_config == ALC268_AUTO)
14072 spec->init_hook = alc268_auto_init;
Kailang Yangea1fb292008-08-26 12:58:38 +020014073
Kailang Yangbf1b0222010-10-21 08:49:56 +020014074 alc_init_jacks(codec);
14075
Kailang Yanga361d842007-06-05 12:30:55 +020014076 return 0;
14077}
14078
14079/*
Kailang Yangf6a92242007-12-13 16:52:54 +010014080 * ALC269 channel source setting (2 channel)
14081 */
14082#define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
14083
14084#define alc269_dac_nids alc260_dac_nids
14085
14086static hda_nid_t alc269_adc_nids[1] = {
14087 /* ADC1 */
Kailang Yangf53281e2008-07-18 12:36:43 +020014088 0x08,
14089};
14090
Takashi Iwaie01bf502008-08-21 16:25:07 +020014091static hda_nid_t alc269_capsrc_nids[1] = {
14092 0x23,
14093};
14094
Kailang Yang84898e82010-02-04 14:16:14 +010014095static hda_nid_t alc269vb_adc_nids[1] = {
14096 /* ADC1 */
14097 0x09,
14098};
14099
14100static hda_nid_t alc269vb_capsrc_nids[1] = {
14101 0x22,
14102};
14103
Takashi Iwai66946352010-03-29 17:21:45 +020014104static hda_nid_t alc269_adc_candidates[] = {
14105 0x08, 0x09, 0x07,
14106};
Takashi Iwaie01bf502008-08-21 16:25:07 +020014107
Kailang Yangf6a92242007-12-13 16:52:54 +010014108#define alc269_modes alc260_modes
14109#define alc269_capture_source alc880_lg_lw_capture_source
14110
14111static struct snd_kcontrol_new alc269_base_mixer[] = {
14112 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14113 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14114 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
14115 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
14116 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14117 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014118 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014119 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14120 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014121 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangf6a92242007-12-13 16:52:54 +010014122 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
14123 HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
14124 { } /* end */
14125};
14126
Kailang Yang60db6b52008-08-26 13:13:00 +020014127static struct snd_kcontrol_new alc269_quanta_fl1_mixer[] = {
14128 /* output mixer control */
14129 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14130 {
14131 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14132 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014133 .subdevice = HDA_SUBDEV_AMP_FLAG,
Kailang Yang60db6b52008-08-26 13:13:00 +020014134 .info = snd_hda_mixer_amp_switch_info,
14135 .get = snd_hda_mixer_amp_switch_get,
14136 .put = alc268_acer_master_sw_put,
14137 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14138 },
14139 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14140 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014141 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014142 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14143 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014144 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang60db6b52008-08-26 13:13:00 +020014145 { }
14146};
14147
Tony Vroon64154832008-11-06 15:08:49 +000014148static struct snd_kcontrol_new alc269_lifebook_mixer[] = {
14149 /* output mixer control */
14150 HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
14151 {
14152 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
14153 .name = "Master Playback Switch",
Jaroslav Kysela5e26dfd2009-12-10 13:57:01 +010014154 .subdevice = HDA_SUBDEV_AMP_FLAG,
Tony Vroon64154832008-11-06 15:08:49 +000014155 .info = snd_hda_mixer_amp_switch_info,
14156 .get = snd_hda_mixer_amp_switch_get,
14157 .put = alc268_acer_master_sw_put,
14158 .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
14159 },
14160 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
14161 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014162 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014163 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
14164 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014165 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014166 HDA_CODEC_VOLUME("Dock Mic Playback Volume", 0x0b, 0x03, HDA_INPUT),
14167 HDA_CODEC_MUTE("Dock Mic Playback Switch", 0x0b, 0x03, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014168 HDA_CODEC_VOLUME("Dock Mic Boost Volume", 0x1b, 0, HDA_INPUT),
Tony Vroon64154832008-11-06 15:08:49 +000014169 { }
14170};
14171
Kailang Yang84898e82010-02-04 14:16:14 +010014172static struct snd_kcontrol_new alc269_laptop_mixer[] = {
Takashi Iwaiaa202452009-07-03 15:00:54 +020014173 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014174 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwaiaa202452009-07-03 15:00:54 +020014175 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
Darren Salt508f7112009-07-08 15:29:49 +010014176 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yangf53281e2008-07-18 12:36:43 +020014177 { } /* end */
14178};
14179
Kailang Yang84898e82010-02-04 14:16:14 +010014180static struct snd_kcontrol_new alc269vb_laptop_mixer[] = {
14181 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
14182 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14183 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
14184 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
14185 { } /* end */
14186};
14187
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014188static struct snd_kcontrol_new alc269_asus_mixer[] = {
14189 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
14190 HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x0, HDA_INPUT),
14191 { } /* end */
14192};
14193
Kailang Yangf6a92242007-12-13 16:52:54 +010014194/* capture mixer elements */
Kailang Yang84898e82010-02-04 14:16:14 +010014195static struct snd_kcontrol_new alc269_laptop_analog_capture_mixer[] = {
14196 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14197 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014198 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14199 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014200 { } /* end */
14201};
14202
14203static struct snd_kcontrol_new alc269_laptop_digital_capture_mixer[] = {
Kailang Yangf53281e2008-07-18 12:36:43 +020014204 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
14205 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014206 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Takashi Iwai26f5df22008-11-03 17:39:46 +010014207 { } /* end */
14208};
14209
Kailang Yang84898e82010-02-04 14:16:14 +010014210static struct snd_kcontrol_new alc269vb_laptop_analog_capture_mixer[] = {
14211 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14212 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014213 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
14214 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014215 { } /* end */
14216};
14217
14218static struct snd_kcontrol_new alc269vb_laptop_digital_capture_mixer[] = {
14219 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
14220 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010014221 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yang84898e82010-02-04 14:16:14 +010014222 { } /* end */
14223};
14224
Takashi Iwai26f5df22008-11-03 17:39:46 +010014225/* FSC amilo */
Kailang Yang84898e82010-02-04 14:16:14 +010014226#define alc269_fujitsu_mixer alc269_laptop_mixer
Kailang Yangf53281e2008-07-18 12:36:43 +020014227
Kailang Yang60db6b52008-08-26 13:13:00 +020014228static struct hda_verb alc269_quanta_fl1_verbs[] = {
14229 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14230 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14231 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14232 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14233 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14234 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14235 { }
14236};
14237
Tony Vroon64154832008-11-06 15:08:49 +000014238static struct hda_verb alc269_lifebook_verbs[] = {
14239 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14240 {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
14241 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14242 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14243 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14244 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14245 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14246 {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
14247 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14248 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14249 { }
14250};
14251
Kailang Yang60db6b52008-08-26 13:13:00 +020014252/* toggle speaker-output according to the hp-jack state */
14253static void alc269_quanta_fl1_speaker_automute(struct hda_codec *codec)
14254{
14255 unsigned int present;
14256 unsigned char bits;
14257
Wu Fengguang864f92b2009-11-18 12:38:02 +080014258 present = snd_hda_jack_detect(codec, 0x15);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014259 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014260 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014261 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014262 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014263 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014264
14265 snd_hda_codec_write(codec, 0x20, 0,
14266 AC_VERB_SET_COEF_INDEX, 0x0c);
14267 snd_hda_codec_write(codec, 0x20, 0,
14268 AC_VERB_SET_PROC_COEF, 0x680);
14269
14270 snd_hda_codec_write(codec, 0x20, 0,
14271 AC_VERB_SET_COEF_INDEX, 0x0c);
14272 snd_hda_codec_write(codec, 0x20, 0,
14273 AC_VERB_SET_PROC_COEF, 0x480);
14274}
14275
Tony Vroon64154832008-11-06 15:08:49 +000014276/* toggle speaker-output according to the hp-jacks state */
14277static void alc269_lifebook_speaker_automute(struct hda_codec *codec)
14278{
14279 unsigned int present;
14280 unsigned char bits;
14281
14282 /* Check laptop headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014283 present = snd_hda_jack_detect(codec, 0x15);
Tony Vroon64154832008-11-06 15:08:49 +000014284
14285 /* Check port replicator headphone socket */
Wu Fengguang864f92b2009-11-18 12:38:02 +080014286 present |= snd_hda_jack_detect(codec, 0x1a);
Tony Vroon64154832008-11-06 15:08:49 +000014287
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014288 bits = present ? HDA_AMP_MUTE : 0;
Tony Vroon64154832008-11-06 15:08:49 +000014289 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014290 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014291 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014292 HDA_AMP_MUTE, bits);
Tony Vroon64154832008-11-06 15:08:49 +000014293
14294 snd_hda_codec_write(codec, 0x20, 0,
14295 AC_VERB_SET_COEF_INDEX, 0x0c);
14296 snd_hda_codec_write(codec, 0x20, 0,
14297 AC_VERB_SET_PROC_COEF, 0x680);
14298
14299 snd_hda_codec_write(codec, 0x20, 0,
14300 AC_VERB_SET_COEF_INDEX, 0x0c);
14301 snd_hda_codec_write(codec, 0x20, 0,
14302 AC_VERB_SET_PROC_COEF, 0x480);
14303}
14304
Tony Vroon64154832008-11-06 15:08:49 +000014305static void alc269_lifebook_mic_autoswitch(struct hda_codec *codec)
14306{
14307 unsigned int present_laptop;
14308 unsigned int present_dock;
14309
Wu Fengguang864f92b2009-11-18 12:38:02 +080014310 present_laptop = snd_hda_jack_detect(codec, 0x18);
14311 present_dock = snd_hda_jack_detect(codec, 0x1b);
Tony Vroon64154832008-11-06 15:08:49 +000014312
14313 /* Laptop mic port overrides dock mic port, design decision */
14314 if (present_dock)
14315 snd_hda_codec_write(codec, 0x23, 0,
14316 AC_VERB_SET_CONNECT_SEL, 0x3);
14317 if (present_laptop)
14318 snd_hda_codec_write(codec, 0x23, 0,
14319 AC_VERB_SET_CONNECT_SEL, 0x0);
14320 if (!present_dock && !present_laptop)
14321 snd_hda_codec_write(codec, 0x23, 0,
14322 AC_VERB_SET_CONNECT_SEL, 0x1);
14323}
14324
Kailang Yang60db6b52008-08-26 13:13:00 +020014325static void alc269_quanta_fl1_unsol_event(struct hda_codec *codec,
14326 unsigned int res)
14327{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014328 switch (res >> 26) {
14329 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014330 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014331 break;
14332 case ALC880_MIC_EVENT:
14333 alc_mic_automute(codec);
14334 break;
14335 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014336}
14337
Tony Vroon64154832008-11-06 15:08:49 +000014338static void alc269_lifebook_unsol_event(struct hda_codec *codec,
14339 unsigned int res)
14340{
14341 if ((res >> 26) == ALC880_HP_EVENT)
14342 alc269_lifebook_speaker_automute(codec);
14343 if ((res >> 26) == ALC880_MIC_EVENT)
14344 alc269_lifebook_mic_autoswitch(codec);
14345}
14346
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014347static void alc269_quanta_fl1_setup(struct hda_codec *codec)
14348{
14349 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014350 spec->autocfg.hp_pins[0] = 0x15;
14351 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014352 spec->ext_mic.pin = 0x18;
14353 spec->ext_mic.mux_idx = 0;
14354 spec->int_mic.pin = 0x19;
14355 spec->int_mic.mux_idx = 1;
14356 spec->auto_mic = 1;
14357}
14358
Kailang Yang60db6b52008-08-26 13:13:00 +020014359static void alc269_quanta_fl1_init_hook(struct hda_codec *codec)
14360{
14361 alc269_quanta_fl1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014362 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014363}
14364
Tony Vroon64154832008-11-06 15:08:49 +000014365static void alc269_lifebook_init_hook(struct hda_codec *codec)
14366{
14367 alc269_lifebook_speaker_automute(codec);
14368 alc269_lifebook_mic_autoswitch(codec);
14369}
14370
Kailang Yang84898e82010-02-04 14:16:14 +010014371static struct hda_verb alc269_laptop_dmic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014372 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14373 {0x23, AC_VERB_SET_CONNECT_SEL, 0x05},
14374 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14375 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14376 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14377 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14378 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14379 {}
14380};
14381
Kailang Yang84898e82010-02-04 14:16:14 +010014382static struct hda_verb alc269_laptop_amic_init_verbs[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014383 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
14384 {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
14385 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14386 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x701b | (0x00 << 8))},
14387 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14388 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14389 {}
14390};
14391
Kailang Yang84898e82010-02-04 14:16:14 +010014392static struct hda_verb alc269vb_laptop_dmic_init_verbs[] = {
14393 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14394 {0x22, AC_VERB_SET_CONNECT_SEL, 0x06},
14395 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14396 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14397 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14398 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14399 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14400 {}
14401};
14402
14403static struct hda_verb alc269vb_laptop_amic_init_verbs[] = {
14404 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01},
14405 {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
14406 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, 0xb026 },
14407 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7019 | (0x00 << 8))},
14408 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14409 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14410 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14411 {}
14412};
14413
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014414static struct hda_verb alc271_acer_dmic_verbs[] = {
14415 {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
14416 {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
14417 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14418 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14419 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14420 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14421 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00},
14422 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
14423 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
14424 {0x22, AC_VERB_SET_CONNECT_SEL, 6},
14425 { }
14426};
14427
Kailang Yang60db6b52008-08-26 13:13:00 +020014428/* toggle speaker-output according to the hp-jack state */
14429static void alc269_speaker_automute(struct hda_codec *codec)
14430{
Kailang Yangebb83ee2009-12-17 12:23:00 +010014431 struct alc_spec *spec = codec->spec;
14432 unsigned int nid = spec->autocfg.hp_pins[0];
Kailang Yang60db6b52008-08-26 13:13:00 +020014433 unsigned int present;
14434 unsigned char bits;
14435
Kailang Yangebb83ee2009-12-17 12:23:00 +010014436 present = snd_hda_jack_detect(codec, nid);
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014437 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yang60db6b52008-08-26 13:13:00 +020014438 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014439 HDA_AMP_MUTE, bits);
Kailang Yang60db6b52008-08-26 13:13:00 +020014440 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020014441 HDA_AMP_MUTE, bits);
Takashi Iwaicd372fb2011-03-03 14:40:14 +010014442 snd_hda_input_jack_report(codec, nid);
Kailang Yang60db6b52008-08-26 13:13:00 +020014443}
14444
Kailang Yang60db6b52008-08-26 13:13:00 +020014445/* unsolicited event for HP jack sensing */
Kailang Yang84898e82010-02-04 14:16:14 +010014446static void alc269_laptop_unsol_event(struct hda_codec *codec,
Kailang Yang60db6b52008-08-26 13:13:00 +020014447 unsigned int res)
14448{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014449 switch (res >> 26) {
14450 case ALC880_HP_EVENT:
Kailang Yang60db6b52008-08-26 13:13:00 +020014451 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014452 break;
14453 case ALC880_MIC_EVENT:
14454 alc_mic_automute(codec);
14455 break;
14456 }
Kailang Yang60db6b52008-08-26 13:13:00 +020014457}
14458
Kailang Yang226b1ec2010-04-09 11:01:20 +020014459static void alc269_laptop_amic_setup(struct hda_codec *codec)
14460{
14461 struct alc_spec *spec = codec->spec;
14462 spec->autocfg.hp_pins[0] = 0x15;
14463 spec->autocfg.speaker_pins[0] = 0x14;
14464 spec->ext_mic.pin = 0x18;
14465 spec->ext_mic.mux_idx = 0;
14466 spec->int_mic.pin = 0x19;
14467 spec->int_mic.mux_idx = 1;
14468 spec->auto_mic = 1;
14469}
14470
Kailang Yang84898e82010-02-04 14:16:14 +010014471static void alc269_laptop_dmic_setup(struct hda_codec *codec)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014472{
14473 struct alc_spec *spec = codec->spec;
Takashi Iwai20645d72010-03-02 11:14:01 +010014474 spec->autocfg.hp_pins[0] = 0x15;
14475 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014476 spec->ext_mic.pin = 0x18;
14477 spec->ext_mic.mux_idx = 0;
14478 spec->int_mic.pin = 0x12;
14479 spec->int_mic.mux_idx = 5;
14480 spec->auto_mic = 1;
14481}
14482
Kailang Yang226b1ec2010-04-09 11:01:20 +020014483static void alc269vb_laptop_amic_setup(struct hda_codec *codec)
Kailang Yang84898e82010-02-04 14:16:14 +010014484{
14485 struct alc_spec *spec = codec->spec;
Kailang Yang226b1ec2010-04-09 11:01:20 +020014486 spec->autocfg.hp_pins[0] = 0x21;
Takashi Iwai20645d72010-03-02 11:14:01 +010014487 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014488 spec->ext_mic.pin = 0x18;
14489 spec->ext_mic.mux_idx = 0;
14490 spec->int_mic.pin = 0x19;
14491 spec->int_mic.mux_idx = 1;
14492 spec->auto_mic = 1;
14493}
14494
Kailang Yang226b1ec2010-04-09 11:01:20 +020014495static void alc269vb_laptop_dmic_setup(struct hda_codec *codec)
14496{
14497 struct alc_spec *spec = codec->spec;
14498 spec->autocfg.hp_pins[0] = 0x21;
14499 spec->autocfg.speaker_pins[0] = 0x14;
14500 spec->ext_mic.pin = 0x18;
14501 spec->ext_mic.mux_idx = 0;
14502 spec->int_mic.pin = 0x12;
14503 spec->int_mic.mux_idx = 6;
14504 spec->auto_mic = 1;
14505}
14506
Kailang Yang84898e82010-02-04 14:16:14 +010014507static void alc269_laptop_inithook(struct hda_codec *codec)
Kailang Yang60db6b52008-08-26 13:13:00 +020014508{
14509 alc269_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020014510 alc_mic_automute(codec);
Kailang Yang60db6b52008-08-26 13:13:00 +020014511}
14512
Kailang Yangf6a92242007-12-13 16:52:54 +010014513/*
14514 * generic initialization of ADC, input mixers and output mixers
14515 */
14516static struct hda_verb alc269_init_verbs[] = {
14517 /*
14518 * Unmute ADC0 and set the default input to mic-in
14519 */
Kailang Yang84898e82010-02-04 14:16:14 +010014520 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangf6a92242007-12-13 16:52:54 +010014521
14522 /*
Kailang Yang84898e82010-02-04 14:16:14 +010014523 * Set up output mixers (0x02 - 0x03)
Kailang Yangf6a92242007-12-13 16:52:54 +010014524 */
14525 /* set vol=0 to output mixers */
14526 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14527 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14528
14529 /* set up input amps for analog loopback */
14530 /* Amp Indices: DAC = 0, mixer = 1 */
14531 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14532 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14533 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14534 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14535 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14536 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14537
14538 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14539 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14540 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14541 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14542 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14543 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14544 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14545
14546 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14547 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf6a92242007-12-13 16:52:54 +010014548
Kailang Yang84898e82010-02-04 14:16:14 +010014549 /* FIXME: use Mux-type input source selection */
Kailang Yangf6a92242007-12-13 16:52:54 +010014550 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14551 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yang84898e82010-02-04 14:16:14 +010014552 {0x23, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangf6a92242007-12-13 16:52:54 +010014553
14554 /* set EAPD */
14555 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yang84898e82010-02-04 14:16:14 +010014556 { }
14557};
14558
14559static struct hda_verb alc269vb_init_verbs[] = {
14560 /*
14561 * Unmute ADC0 and set the default input to mic-in
14562 */
14563 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14564
14565 /*
14566 * Set up output mixers (0x02 - 0x03)
14567 */
14568 /* set vol=0 to output mixers */
14569 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14570 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
14571
14572 /* set up input amps for analog loopback */
14573 /* Amp Indices: DAC = 0, mixer = 1 */
14574 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14575 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14576 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14577 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14578 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
14579 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
14580
14581 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14582 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
14583 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
14584 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14585 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
14586 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14587 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
14588
14589 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14590 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
14591
14592 /* FIXME: use Mux-type input source selection */
14593 /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
14594 /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
14595 {0x22, AC_VERB_SET_CONNECT_SEL, 0x00},
14596
14597 /* set EAPD */
14598 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
Kailang Yangf6a92242007-12-13 16:52:54 +010014599 { }
14600};
14601
Takashi Iwai9d0b71b2009-08-24 14:10:30 +020014602#define alc269_auto_create_multi_out_ctls \
14603 alc268_auto_create_multi_out_ctls
Takashi Iwai05f5f472009-08-25 13:10:18 +020014604#define alc269_auto_create_input_ctls \
14605 alc268_auto_create_input_ctls
Kailang Yangf6a92242007-12-13 16:52:54 +010014606
14607#ifdef CONFIG_SND_HDA_POWER_SAVE
14608#define alc269_loopbacks alc880_loopbacks
14609#endif
14610
Sasha Alexandrdef319f2009-06-16 16:00:15 -040014611/* pcm configuration: identical with ALC880 */
Kailang Yangf6a92242007-12-13 16:52:54 +010014612#define alc269_pcm_analog_playback alc880_pcm_analog_playback
14613#define alc269_pcm_analog_capture alc880_pcm_analog_capture
14614#define alc269_pcm_digital_playback alc880_pcm_digital_playback
14615#define alc269_pcm_digital_capture alc880_pcm_digital_capture
14616
Takashi Iwaif03d3112009-03-05 14:18:16 +010014617static struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
14618 .substreams = 1,
14619 .channels_min = 2,
14620 .channels_max = 8,
14621 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14622 /* NID is set in alc_build_pcms */
14623 .ops = {
14624 .open = alc880_playback_pcm_open,
14625 .prepare = alc880_playback_pcm_prepare,
14626 .cleanup = alc880_playback_pcm_cleanup
14627 },
14628};
14629
14630static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
14631 .substreams = 1,
14632 .channels_min = 2,
14633 .channels_max = 2,
14634 .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
14635 /* NID is set in alc_build_pcms */
14636};
14637
Takashi Iwaiad358792010-03-30 18:00:59 +020014638#ifdef CONFIG_SND_HDA_POWER_SAVE
14639static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14640{
14641 switch (codec->subsystem_id) {
14642 case 0x103c1586:
14643 return 1;
14644 }
14645 return 0;
14646}
14647
14648static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14649{
14650 /* update mute-LED according to the speaker mute state */
14651 if (nid == 0x01 || nid == 0x14) {
14652 int pinval;
14653 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14654 HDA_AMP_MUTE)
14655 pinval = 0x24;
14656 else
14657 pinval = 0x20;
14658 /* mic2 vref pin is used for mute LED control */
Takashi Iwaia68d5a542010-03-30 18:03:44 +020014659 snd_hda_codec_update_cache(codec, 0x19, 0,
14660 AC_VERB_SET_PIN_WIDGET_CONTROL,
14661 pinval);
Takashi Iwaiad358792010-03-30 18:00:59 +020014662 }
14663 return alc_check_power_status(codec, nid);
14664}
14665#endif /* CONFIG_SND_HDA_POWER_SAVE */
14666
Takashi Iwai840b64c2010-07-13 22:49:01 +020014667static int alc275_setup_dual_adc(struct hda_codec *codec)
14668{
14669 struct alc_spec *spec = codec->spec;
14670
14671 if (codec->vendor_id != 0x10ec0275 || !spec->auto_mic)
14672 return 0;
14673 if ((spec->ext_mic.pin >= 0x18 && spec->int_mic.pin <= 0x13) ||
14674 (spec->ext_mic.pin <= 0x12 && spec->int_mic.pin >= 0x18)) {
14675 if (spec->ext_mic.pin <= 0x12) {
14676 spec->private_adc_nids[0] = 0x08;
14677 spec->private_adc_nids[1] = 0x11;
14678 spec->private_capsrc_nids[0] = 0x23;
14679 spec->private_capsrc_nids[1] = 0x22;
14680 } else {
14681 spec->private_adc_nids[0] = 0x11;
14682 spec->private_adc_nids[1] = 0x08;
14683 spec->private_capsrc_nids[0] = 0x22;
14684 spec->private_capsrc_nids[1] = 0x23;
14685 }
14686 spec->adc_nids = spec->private_adc_nids;
14687 spec->capsrc_nids = spec->private_capsrc_nids;
14688 spec->num_adc_nids = 2;
14689 spec->dual_adc_switch = 1;
14690 snd_printdd("realtek: enabling dual ADC switchg (%02x:%02x)\n",
14691 spec->adc_nids[0], spec->adc_nids[1]);
14692 return 1;
14693 }
14694 return 0;
14695}
14696
Takashi Iwaid433a672010-09-20 15:11:54 +020014697/* different alc269-variants */
14698enum {
14699 ALC269_TYPE_NORMAL,
Kailang Yang48c88e82010-11-23 08:56:16 +010014700 ALC269_TYPE_ALC258,
Takashi Iwaid433a672010-09-20 15:11:54 +020014701 ALC269_TYPE_ALC259,
Kailang Yang48c88e82010-11-23 08:56:16 +010014702 ALC269_TYPE_ALC269VB,
14703 ALC269_TYPE_ALC270,
Takashi Iwaid433a672010-09-20 15:11:54 +020014704 ALC269_TYPE_ALC271X,
14705};
14706
Kailang Yangf6a92242007-12-13 16:52:54 +010014707/*
14708 * BIOS auto configuration
14709 */
14710static int alc269_parse_auto_config(struct hda_codec *codec)
14711{
14712 struct alc_spec *spec = codec->spec;
Takashi Iwaicfb9fb52009-02-06 17:34:03 +010014713 int err;
Kailang Yangf6a92242007-12-13 16:52:54 +010014714 static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
14715
14716 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
14717 alc269_ignore);
14718 if (err < 0)
14719 return err;
14720
14721 err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
14722 if (err < 0)
14723 return err;
Takashi Iwaif3550d12010-09-20 15:09:03 +020014724 if (spec->codec_variant == ALC269_TYPE_NORMAL)
14725 err = alc269_auto_create_input_ctls(codec, &spec->autocfg);
14726 else
14727 err = alc_auto_create_input_ctls(codec, &spec->autocfg, 0,
14728 0x22, 0);
Kailang Yangf6a92242007-12-13 16:52:54 +010014729 if (err < 0)
14730 return err;
14731
14732 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
14733
Takashi Iwai757899a2010-07-30 10:48:14 +020014734 alc_auto_parse_digital(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014735
Takashi Iwai603c4012008-07-30 15:01:44 +020014736 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010014737 add_mixer(spec, spec->kctls.list);
Kailang Yangf6a92242007-12-13 16:52:54 +010014738
Takashi Iwaid433a672010-09-20 15:11:54 +020014739 if (spec->codec_variant != ALC269_TYPE_NORMAL) {
Kailang Yang84898e82010-02-04 14:16:14 +010014740 add_verb(spec, alc269vb_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014741 alc_ssid_check(codec, 0, 0x1b, 0x14, 0x21);
Kailang Yang84898e82010-02-04 14:16:14 +010014742 } else {
14743 add_verb(spec, alc269_init_verbs);
Kailang Yang6227cdc2010-02-25 08:36:52 +010014744 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Kailang Yang84898e82010-02-04 14:16:14 +010014745 }
14746
Kailang Yangf6a92242007-12-13 16:52:54 +010014747 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020014748 spec->input_mux = &spec->private_imux[0];
Takashi Iwai840b64c2010-07-13 22:49:01 +020014749
14750 if (!alc275_setup_dual_adc(codec))
14751 fillup_priv_adc_nids(codec, alc269_adc_candidates,
14752 sizeof(alc269_adc_candidates));
Takashi Iwai66946352010-03-29 17:21:45 +020014753
Takashi Iwaie01bf502008-08-21 16:25:07 +020014754 /* set default input source */
Takashi Iwai840b64c2010-07-13 22:49:01 +020014755 if (!spec->dual_adc_switch)
Takashi Iwai748cce42010-08-04 07:37:39 +020014756 select_or_unmute_capsrc(codec, spec->capsrc_nids[0],
14757 spec->input_mux->items[0].index);
Kailang Yangf6a92242007-12-13 16:52:54 +010014758
14759 err = alc_auto_add_mic_boost(codec);
14760 if (err < 0)
14761 return err;
14762
Takashi Iwai7e0e44d2009-02-19 08:15:49 +010014763 if (!spec->cap_mixer && !spec->no_analog)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020014764 set_capture_mixer(codec);
Kailang Yangf53281e2008-07-18 12:36:43 +020014765
Kailang Yangf6a92242007-12-13 16:52:54 +010014766 return 1;
14767}
14768
Takashi Iwaie9af4f32009-08-29 23:23:08 +020014769#define alc269_auto_init_multi_out alc268_auto_init_multi_out
14770#define alc269_auto_init_hp_out alc268_auto_init_hp_out
Kailang Yangf6a92242007-12-13 16:52:54 +010014771#define alc269_auto_init_analog_input alc882_auto_init_analog_input
14772
14773
14774/* init callback for auto-configuration model -- overriding the default init */
14775static void alc269_auto_init(struct hda_codec *codec)
14776{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014777 struct alc_spec *spec = codec->spec;
Kailang Yangf6a92242007-12-13 16:52:54 +010014778 alc269_auto_init_multi_out(codec);
14779 alc269_auto_init_hp_out(codec);
14780 alc269_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020014781 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010014782 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020014783 alc_inithook(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010014784}
14785
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014786#ifdef SND_HDA_NEEDS_RESUME
14787static void alc269_toggle_power_output(struct hda_codec *codec, int power_up)
14788{
14789 int val = alc_read_coef_idx(codec, 0x04);
14790 if (power_up)
14791 val |= 1 << 11;
14792 else
14793 val &= ~(1 << 11);
14794 alc_write_coef_idx(codec, 0x04, val);
14795}
14796
Kailang Yang977ddd62010-09-15 10:02:29 +020014797#ifdef CONFIG_SND_HDA_POWER_SAVE
14798static int alc269_suspend(struct hda_codec *codec, pm_message_t state)
14799{
14800 struct alc_spec *spec = codec->spec;
Kailang Yang977ddd62010-09-15 10:02:29 +020014801
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014802 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017)
14803 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014804 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014805 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014806 msleep(150);
14807 }
14808
14809 alc_shutup(codec);
14810 if (spec && spec->power_hook)
14811 spec->power_hook(codec);
14812 return 0;
14813}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014814#endif /* CONFIG_SND_HDA_POWER_SAVE */
14815
Kailang Yang977ddd62010-09-15 10:02:29 +020014816static int alc269_resume(struct hda_codec *codec)
14817{
Kailang Yang977ddd62010-09-15 10:02:29 +020014818 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014819 alc269_toggle_power_output(codec, 0);
Kailang Yang977ddd62010-09-15 10:02:29 +020014820 msleep(150);
14821 }
14822
14823 codec->patch_ops.init(codec);
14824
14825 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014826 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014827 msleep(200);
14828 }
14829
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014830 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018)
14831 alc269_toggle_power_output(codec, 1);
Kailang Yang977ddd62010-09-15 10:02:29 +020014832
14833 snd_hda_codec_resume_amp(codec);
14834 snd_hda_codec_resume_cache(codec);
Takashi Iwai9e5341b2010-09-21 09:57:06 +020014835 hda_call_check_power_status(codec, 0x01);
Kailang Yang977ddd62010-09-15 10:02:29 +020014836 return 0;
14837}
Takashi Iwai0ec33d12010-09-20 15:20:52 +020014838#endif /* SND_HDA_NEEDS_RESUME */
Kailang Yang977ddd62010-09-15 10:02:29 +020014839
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014840static void alc269_fixup_hweq(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014841 const struct alc_fixup *fix, int action)
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014842{
14843 int coef;
14844
Takashi Iwai58701122011-01-13 15:41:45 +010014845 if (action != ALC_FIXUP_ACT_INIT)
Takashi Iwai9fb1ef22011-01-13 14:40:43 +010014846 return;
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014847 coef = alc_read_coef_idx(codec, 0x1e);
14848 alc_write_coef_idx(codec, 0x1e, coef | 0x80);
14849}
14850
Takashi Iwaiff818c22010-04-12 08:59:25 +020014851enum {
14852 ALC269_FIXUP_SONY_VAIO,
Takashi Iwai74dc8902011-01-13 14:14:41 +010014853 ALC275_FIXUP_SONY_VAIO_GPIO2,
David Henningsson145a9022010-09-16 10:07:53 +020014854 ALC269_FIXUP_DELL_M101Z,
David Henningsson022c92b2010-12-17 20:43:04 +010014855 ALC269_FIXUP_SKU_IGNORE,
David Henningssonac612402010-12-15 09:18:18 +010014856 ALC269_FIXUP_ASUS_G73JW,
Kailang Yang357f9152011-01-12 08:12:52 +010014857 ALC269_FIXUP_LENOVO_EAPD,
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014858 ALC275_FIXUP_SONY_HWEQ,
Takashi Iwaiff818c22010-04-12 08:59:25 +020014859};
14860
Takashi Iwaiff818c22010-04-12 08:59:25 +020014861static const struct alc_fixup alc269_fixups[] = {
14862 [ALC269_FIXUP_SONY_VAIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014863 .type = ALC_FIXUP_VERBS,
14864 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020014865 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD},
14866 {}
14867 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014868 },
Takashi Iwai74dc8902011-01-13 14:14:41 +010014869 [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014870 .type = ALC_FIXUP_VERBS,
14871 .v.verbs = (const struct hda_verb[]) {
Kailang Yang27855912010-12-21 09:09:53 +010014872 {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
14873 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
14874 {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
14875 { }
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014876 },
14877 .chained = true,
14878 .chain_id = ALC269_FIXUP_SONY_VAIO
Kailang Yang27855912010-12-21 09:09:53 +010014879 },
David Henningsson145a9022010-09-16 10:07:53 +020014880 [ALC269_FIXUP_DELL_M101Z] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014881 .type = ALC_FIXUP_VERBS,
14882 .v.verbs = (const struct hda_verb[]) {
David Henningsson145a9022010-09-16 10:07:53 +020014883 /* Enables internal speaker */
14884 {0x20, AC_VERB_SET_COEF_INDEX, 13},
14885 {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
14886 {}
14887 }
14888 },
David Henningsson022c92b2010-12-17 20:43:04 +010014889 [ALC269_FIXUP_SKU_IGNORE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014890 .type = ALC_FIXUP_SKU,
14891 .v.sku = ALC_FIXUP_SKU_IGNORE,
David Henningssonfe67b242010-12-15 08:01:46 +010014892 },
David Henningssonac612402010-12-15 09:18:18 +010014893 [ALC269_FIXUP_ASUS_G73JW] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014894 .type = ALC_FIXUP_PINS,
14895 .v.pins = (const struct alc_pincfg[]) {
David Henningssonac612402010-12-15 09:18:18 +010014896 { 0x17, 0x99130111 }, /* subwoofer */
14897 { }
14898 }
14899 },
Kailang Yang357f9152011-01-12 08:12:52 +010014900 [ALC269_FIXUP_LENOVO_EAPD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014901 .type = ALC_FIXUP_VERBS,
14902 .v.verbs = (const struct hda_verb[]) {
Kailang Yang357f9152011-01-12 08:12:52 +010014903 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
14904 {}
14905 }
14906 },
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014907 [ALC275_FIXUP_SONY_HWEQ] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010014908 .type = ALC_FIXUP_FUNC,
14909 .v.func = alc269_fixup_hweq,
14910 .chained = true,
14911 .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014912 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020014913};
14914
14915static struct snd_pci_quirk alc269_fixup_tbl[] = {
Takashi Iwai74dc8902011-01-13 14:14:41 +010014916 SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
Kailang Yang1a99d4a2011-01-12 09:01:23 +010014917 SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
14918 SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
Takashi Iwai7039c742010-12-23 16:35:34 +010014919 SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
David Henningsson145a9022010-09-16 10:07:53 +020014920 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
David Henningsson022c92b2010-12-17 20:43:04 +010014921 SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
David Henningssonded9f522011-01-26 11:46:12 +010014922 SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
14923 SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
14924 SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
14925 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
David Henningssonac612402010-12-15 09:18:18 +010014926 SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
Kailang Yang357f9152011-01-12 08:12:52 +010014927 SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014928 {}
14929};
14930
14931
Kailang Yangf6a92242007-12-13 16:52:54 +010014932/*
14933 * configuration and preset
14934 */
Takashi Iwaiea734962011-01-17 11:29:34 +010014935static const char * const alc269_models[ALC269_MODEL_LAST] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014936 [ALC269_BASIC] = "basic",
Takashi Iwai2922c9a2008-08-27 18:12:42 +020014937 [ALC269_QUANTA_FL1] = "quanta",
Kailang Yang84898e82010-02-04 14:16:14 +010014938 [ALC269_AMIC] = "laptop-amic",
14939 [ALC269_DMIC] = "laptop-dmic",
Tony Vroon64154832008-11-06 15:08:49 +000014940 [ALC269_FUJITSU] = "fujitsu",
Takashi Iwai3d3792c2009-09-11 07:50:47 +020014941 [ALC269_LIFEBOOK] = "lifebook",
14942 [ALC269_AUTO] = "auto",
Kailang Yangf6a92242007-12-13 16:52:54 +010014943};
14944
14945static struct snd_pci_quirk alc269_cfg_tbl[] = {
Kailang Yang60db6b52008-08-26 13:13:00 +020014946 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_QUANTA_FL1),
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020014947 SND_PCI_QUIRK(0x1025, 0x047c, "ACER ZGA", ALC271_ACER),
Kailang Yangf53281e2008-07-18 12:36:43 +020014948 SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
Kailang Yang84898e82010-02-04 14:16:14 +010014949 ALC269_AMIC),
14950 SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269VB_AMIC),
14951 SND_PCI_QUIRK(0x1043, 0x1113, "ASUS N63Jn", ALC269VB_AMIC),
14952 SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269VB_AMIC),
14953 SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_AMIC),
14954 SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269VB_AMIC),
14955 SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269VB_AMIC),
14956 SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269VB_AMIC),
14957 SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269VB_AMIC),
14958 SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_AMIC),
Chih-Wei Huangc790ad32011-02-25 11:14:31 +080014959 SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269VB_AMIC),
Kailang Yang84898e82010-02-04 14:16:14 +010014960 SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_AMIC),
14961 SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_AMIC),
14962 SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_AMIC),
14963 SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_AMIC),
14964 SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_AMIC),
14965 SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_AMIC),
14966 SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_AMIC),
14967 SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_AMIC),
14968 SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_AMIC),
14969 SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_AMIC),
14970 SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_AMIC),
14971 SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_AMIC),
14972 SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_AMIC),
14973 SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_AMIC),
14974 SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_AMIC),
14975 SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_AMIC),
14976 SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_AMIC),
14977 SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_AMIC),
14978 SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_AMIC),
14979 SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_AMIC),
14980 SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_AMIC),
14981 SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_DMIC),
14982 SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_AMIC),
14983 SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_AMIC),
14984 SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_AMIC),
14985 SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_AMIC),
Kailang Yangf53281e2008-07-18 12:36:43 +020014986 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS Eeepc P901",
Kailang Yang84898e82010-02-04 14:16:14 +010014987 ALC269_DMIC),
Kailang Yang60db6b52008-08-26 13:13:00 +020014988 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS Eeepc S101",
Kailang Yang84898e82010-02-04 14:16:14 +010014989 ALC269_DMIC),
14990 SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005HA", ALC269_DMIC),
14991 SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005HA", ALC269_DMIC),
Takashi Iwaiff818c22010-04-12 08:59:25 +020014992 SND_PCI_QUIRK(0x104d, 0x9071, "Sony VAIO", ALC269_AUTO),
Tony Vroon64154832008-11-06 15:08:49 +000014993 SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook ICH9M-based", ALC269_LIFEBOOK),
Kailang Yang61c2d2b2010-02-25 08:49:06 +010014994 SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_DMIC),
14995 SND_PCI_QUIRK(0x1734, 0x115d, "FSC Amilo", ALC269_FUJITSU),
14996 SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_AMIC),
14997 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_AMIC),
14998 SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_DMIC),
14999 SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_DMIC),
Kailang Yangf6a92242007-12-13 16:52:54 +010015000 {}
15001};
15002
15003static struct alc_config_preset alc269_presets[] = {
15004 [ALC269_BASIC] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015005 .mixers = { alc269_base_mixer },
Kailang Yangf6a92242007-12-13 16:52:54 +010015006 .init_verbs = { alc269_init_verbs },
15007 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15008 .dac_nids = alc269_dac_nids,
15009 .hp_nid = 0x03,
15010 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15011 .channel_mode = alc269_modes,
15012 .input_mux = &alc269_capture_source,
15013 },
Kailang Yang60db6b52008-08-26 13:13:00 +020015014 [ALC269_QUANTA_FL1] = {
15015 .mixers = { alc269_quanta_fl1_mixer },
15016 .init_verbs = { alc269_init_verbs, alc269_quanta_fl1_verbs },
15017 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15018 .dac_nids = alc269_dac_nids,
15019 .hp_nid = 0x03,
15020 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15021 .channel_mode = alc269_modes,
15022 .input_mux = &alc269_capture_source,
15023 .unsol_event = alc269_quanta_fl1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020015024 .setup = alc269_quanta_fl1_setup,
Kailang Yang60db6b52008-08-26 13:13:00 +020015025 .init_hook = alc269_quanta_fl1_init_hook,
15026 },
Kailang Yang84898e82010-02-04 14:16:14 +010015027 [ALC269_AMIC] = {
15028 .mixers = { alc269_laptop_mixer },
15029 .cap_mixer = alc269_laptop_analog_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015030 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015031 alc269_laptop_amic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015032 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15033 .dac_nids = alc269_dac_nids,
15034 .hp_nid = 0x03,
15035 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15036 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015037 .unsol_event = alc269_laptop_unsol_event,
15038 .setup = alc269_laptop_amic_setup,
15039 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015040 },
Kailang Yang84898e82010-02-04 14:16:14 +010015041 [ALC269_DMIC] = {
15042 .mixers = { alc269_laptop_mixer },
15043 .cap_mixer = alc269_laptop_digital_capture_mixer,
Kailang Yangf53281e2008-07-18 12:36:43 +020015044 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015045 alc269_laptop_dmic_init_verbs },
Kailang Yangf53281e2008-07-18 12:36:43 +020015046 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15047 .dac_nids = alc269_dac_nids,
15048 .hp_nid = 0x03,
15049 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15050 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015051 .unsol_event = alc269_laptop_unsol_event,
15052 .setup = alc269_laptop_dmic_setup,
15053 .init_hook = alc269_laptop_inithook,
15054 },
15055 [ALC269VB_AMIC] = {
15056 .mixers = { alc269vb_laptop_mixer },
15057 .cap_mixer = alc269vb_laptop_analog_capture_mixer,
15058 .init_verbs = { alc269vb_init_verbs,
15059 alc269vb_laptop_amic_init_verbs },
15060 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15061 .dac_nids = alc269_dac_nids,
15062 .hp_nid = 0x03,
15063 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15064 .channel_mode = alc269_modes,
15065 .unsol_event = alc269_laptop_unsol_event,
Kailang Yang226b1ec2010-04-09 11:01:20 +020015066 .setup = alc269vb_laptop_amic_setup,
Kailang Yang84898e82010-02-04 14:16:14 +010015067 .init_hook = alc269_laptop_inithook,
15068 },
15069 [ALC269VB_DMIC] = {
15070 .mixers = { alc269vb_laptop_mixer },
15071 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15072 .init_verbs = { alc269vb_init_verbs,
15073 alc269vb_laptop_dmic_init_verbs },
15074 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15075 .dac_nids = alc269_dac_nids,
15076 .hp_nid = 0x03,
15077 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15078 .channel_mode = alc269_modes,
15079 .unsol_event = alc269_laptop_unsol_event,
15080 .setup = alc269vb_laptop_dmic_setup,
15081 .init_hook = alc269_laptop_inithook,
Kailang Yangf53281e2008-07-18 12:36:43 +020015082 },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015083 [ALC269_FUJITSU] = {
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010015084 .mixers = { alc269_fujitsu_mixer },
Kailang Yang84898e82010-02-04 14:16:14 +010015085 .cap_mixer = alc269_laptop_digital_capture_mixer,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015086 .init_verbs = { alc269_init_verbs,
Kailang Yang84898e82010-02-04 14:16:14 +010015087 alc269_laptop_dmic_init_verbs },
Takashi Iwai26f5df22008-11-03 17:39:46 +010015088 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15089 .dac_nids = alc269_dac_nids,
15090 .hp_nid = 0x03,
15091 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15092 .channel_mode = alc269_modes,
Kailang Yang84898e82010-02-04 14:16:14 +010015093 .unsol_event = alc269_laptop_unsol_event,
15094 .setup = alc269_laptop_dmic_setup,
15095 .init_hook = alc269_laptop_inithook,
Takashi Iwai26f5df22008-11-03 17:39:46 +010015096 },
Tony Vroon64154832008-11-06 15:08:49 +000015097 [ALC269_LIFEBOOK] = {
15098 .mixers = { alc269_lifebook_mixer },
15099 .init_verbs = { alc269_init_verbs, alc269_lifebook_verbs },
15100 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15101 .dac_nids = alc269_dac_nids,
15102 .hp_nid = 0x03,
15103 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15104 .channel_mode = alc269_modes,
15105 .input_mux = &alc269_capture_source,
15106 .unsol_event = alc269_lifebook_unsol_event,
15107 .init_hook = alc269_lifebook_init_hook,
15108 },
Kailang Yangfe3eb0a2010-08-06 10:02:57 +020015109 [ALC271_ACER] = {
15110 .mixers = { alc269_asus_mixer },
15111 .cap_mixer = alc269vb_laptop_digital_capture_mixer,
15112 .init_verbs = { alc269_init_verbs, alc271_acer_dmic_verbs },
15113 .num_dacs = ARRAY_SIZE(alc269_dac_nids),
15114 .dac_nids = alc269_dac_nids,
15115 .adc_nids = alc262_dmic_adc_nids,
15116 .num_adc_nids = ARRAY_SIZE(alc262_dmic_adc_nids),
15117 .capsrc_nids = alc262_dmic_capsrc_nids,
15118 .num_channel_mode = ARRAY_SIZE(alc269_modes),
15119 .channel_mode = alc269_modes,
15120 .input_mux = &alc269_capture_source,
15121 .dig_out_nid = ALC880_DIGOUT_NID,
15122 .unsol_event = alc_sku_unsol_event,
15123 .setup = alc269vb_laptop_dmic_setup,
15124 .init_hook = alc_inithook,
15125 },
Kailang Yangf6a92242007-12-13 16:52:54 +010015126};
15127
Kailang Yang977ddd62010-09-15 10:02:29 +020015128static int alc269_fill_coef(struct hda_codec *codec)
15129{
15130 int val;
15131
15132 if ((alc_read_coef_idx(codec, 0) & 0x00ff) < 0x015) {
15133 alc_write_coef_idx(codec, 0xf, 0x960b);
15134 alc_write_coef_idx(codec, 0xe, 0x8817);
15135 }
15136
15137 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x016) {
15138 alc_write_coef_idx(codec, 0xf, 0x960b);
15139 alc_write_coef_idx(codec, 0xe, 0x8814);
15140 }
15141
15142 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x017) {
15143 val = alc_read_coef_idx(codec, 0x04);
15144 /* Power up output pin */
15145 alc_write_coef_idx(codec, 0x04, val | (1<<11));
15146 }
15147
15148 if ((alc_read_coef_idx(codec, 0) & 0x00ff) == 0x018) {
15149 val = alc_read_coef_idx(codec, 0xd);
15150 if ((val & 0x0c00) >> 10 != 0x1) {
15151 /* Capless ramp up clock control */
15152 alc_write_coef_idx(codec, 0xd, val | 1<<10);
15153 }
15154 val = alc_read_coef_idx(codec, 0x17);
15155 if ((val & 0x01c0) >> 6 != 0x4) {
15156 /* Class D power on reset */
15157 alc_write_coef_idx(codec, 0x17, val | 1<<7);
15158 }
15159 }
15160 return 0;
15161}
15162
Kailang Yangf6a92242007-12-13 16:52:54 +010015163static int patch_alc269(struct hda_codec *codec)
15164{
15165 struct alc_spec *spec;
Kailang Yang48c88e82010-11-23 08:56:16 +010015166 int board_config, coef;
Kailang Yangf6a92242007-12-13 16:52:54 +010015167 int err;
15168
15169 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
15170 if (spec == NULL)
15171 return -ENOMEM;
15172
15173 codec->spec = spec;
15174
Kailang Yangda00c242010-03-19 11:23:45 +010015175 alc_auto_parse_customize_define(codec);
15176
Kailang Yangc793bec2010-12-21 09:14:13 +010015177 if (codec->vendor_id == 0x10ec0269) {
15178 coef = alc_read_coef_idx(codec, 0);
15179 if ((coef & 0x00f0) == 0x0010) {
15180 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
15181 spec->cdefine.platform_type == 1) {
15182 alc_codec_rename(codec, "ALC271X");
15183 spec->codec_variant = ALC269_TYPE_ALC271X;
15184 } else if ((coef & 0xf000) == 0x1000) {
15185 spec->codec_variant = ALC269_TYPE_ALC270;
15186 } else if ((coef & 0xf000) == 0x2000) {
15187 alc_codec_rename(codec, "ALC259");
15188 spec->codec_variant = ALC269_TYPE_ALC259;
15189 } else if ((coef & 0xf000) == 0x3000) {
15190 alc_codec_rename(codec, "ALC258");
15191 spec->codec_variant = ALC269_TYPE_ALC258;
15192 } else {
15193 alc_codec_rename(codec, "ALC269VB");
15194 spec->codec_variant = ALC269_TYPE_ALC269VB;
15195 }
15196 } else
15197 alc_fix_pll_init(codec, 0x20, 0x04, 15);
15198 alc269_fill_coef(codec);
15199 }
Kailang Yang977ddd62010-09-15 10:02:29 +020015200
Kailang Yangf6a92242007-12-13 16:52:54 +010015201 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
15202 alc269_models,
15203 alc269_cfg_tbl);
15204
15205 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020015206 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
15207 codec->chip_name);
Kailang Yangf6a92242007-12-13 16:52:54 +010015208 board_config = ALC269_AUTO;
15209 }
15210
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015211 if (board_config == ALC269_AUTO) {
15212 alc_pick_fixup(codec, NULL, alc269_fixup_tbl, alc269_fixups);
15213 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
15214 }
Takashi Iwaiff818c22010-04-12 08:59:25 +020015215
Kailang Yangf6a92242007-12-13 16:52:54 +010015216 if (board_config == ALC269_AUTO) {
15217 /* automatic parse from the BIOS config */
15218 err = alc269_parse_auto_config(codec);
15219 if (err < 0) {
15220 alc_free(codec);
15221 return err;
15222 } else if (!err) {
15223 printk(KERN_INFO
15224 "hda_codec: Cannot set up configuration "
15225 "from BIOS. Using base mode...\n");
15226 board_config = ALC269_BASIC;
15227 }
15228 }
15229
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015230 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020015231 err = snd_hda_attach_beep_device(codec, 0x1);
15232 if (err < 0) {
15233 alc_free(codec);
15234 return err;
15235 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090015236 }
15237
Kailang Yangf6a92242007-12-13 16:52:54 +010015238 if (board_config != ALC269_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020015239 setup_preset(codec, &alc269_presets[board_config]);
Kailang Yangf6a92242007-12-13 16:52:54 +010015240
Kailang Yang84898e82010-02-04 14:16:14 +010015241 if (board_config == ALC269_QUANTA_FL1) {
Takashi Iwaif03d3112009-03-05 14:18:16 +010015242 /* Due to a hardware problem on Lenovo Ideadpad, we need to
15243 * fix the sample rate of analog I/O to 44.1kHz
15244 */
15245 spec->stream_analog_playback = &alc269_44k_pcm_analog_playback;
15246 spec->stream_analog_capture = &alc269_44k_pcm_analog_capture;
Takashi Iwai840b64c2010-07-13 22:49:01 +020015247 } else if (spec->dual_adc_switch) {
15248 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15249 /* switch ADC dynamically */
15250 spec->stream_analog_capture = &dualmic_pcm_analog_capture;
Takashi Iwaif03d3112009-03-05 14:18:16 +010015251 } else {
15252 spec->stream_analog_playback = &alc269_pcm_analog_playback;
15253 spec->stream_analog_capture = &alc269_pcm_analog_capture;
15254 }
Kailang Yangf6a92242007-12-13 16:52:54 +010015255 spec->stream_digital_playback = &alc269_pcm_digital_playback;
15256 spec->stream_digital_capture = &alc269_pcm_digital_capture;
15257
Takashi Iwai66946352010-03-29 17:21:45 +020015258 if (!spec->adc_nids) { /* wasn't filled automatically? use default */
Kailang Yang1657cbd2010-11-23 08:53:32 +010015259 if (spec->codec_variant == ALC269_TYPE_NORMAL) {
Takashi Iwai66946352010-03-29 17:21:45 +020015260 spec->adc_nids = alc269_adc_nids;
15261 spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
15262 spec->capsrc_nids = alc269_capsrc_nids;
15263 } else {
15264 spec->adc_nids = alc269vb_adc_nids;
15265 spec->num_adc_nids = ARRAY_SIZE(alc269vb_adc_nids);
15266 spec->capsrc_nids = alc269vb_capsrc_nids;
15267 }
Kailang Yang84898e82010-02-04 14:16:14 +010015268 }
15269
Takashi Iwaif9e336f2008-10-31 16:37:07 +010015270 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020015271 set_capture_mixer(codec);
Takashi Iwaidc1eae22010-07-29 15:30:02 +020015272 if (has_cdefine_beep(codec))
Kailang Yangda00c242010-03-19 11:23:45 +010015273 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
Kailang Yangf6a92242007-12-13 16:52:54 +010015274
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010015275 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwaiff818c22010-04-12 08:59:25 +020015276
Takashi Iwai100d5eb2009-08-10 11:55:51 +020015277 spec->vmaster_nid = 0x02;
15278
Kailang Yangf6a92242007-12-13 16:52:54 +010015279 codec->patch_ops = alc_patch_ops;
Kailang Yang977ddd62010-09-15 10:02:29 +020015280#ifdef CONFIG_SND_HDA_POWER_SAVE
15281 codec->patch_ops.suspend = alc269_suspend;
15282#endif
15283#ifdef SND_HDA_NEEDS_RESUME
15284 codec->patch_ops.resume = alc269_resume;
15285#endif
Kailang Yangf6a92242007-12-13 16:52:54 +010015286 if (board_config == ALC269_AUTO)
15287 spec->init_hook = alc269_auto_init;
Kailang Yangbf1b0222010-10-21 08:49:56 +020015288
15289 alc_init_jacks(codec);
Kailang Yangf6a92242007-12-13 16:52:54 +010015290#ifdef CONFIG_SND_HDA_POWER_SAVE
15291 if (!spec->loopback.amplist)
15292 spec->loopback.amplist = alc269_loopbacks;
Takashi Iwaiad358792010-03-30 18:00:59 +020015293 if (alc269_mic2_for_mute_led(codec))
15294 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
Kailang Yangf6a92242007-12-13 16:52:54 +010015295#endif
15296
15297 return 0;
15298}
15299
15300/*
Kailang Yangdf694da2005-12-05 19:42:22 +010015301 * ALC861 channel source setting (2/6 channel selection for 3-stack)
15302 */
15303
15304/*
15305 * set the path ways for 2 channel output
15306 * need to set the codec line out and mic 1 pin widgets to inputs
15307 */
15308static struct hda_verb alc861_threestack_ch2_init[] = {
15309 /* set pin widget 1Ah (line in) for input */
15310 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015311 /* set pin widget 18h (mic1/2) for input, for mic also enable
15312 * the vref
15313 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015314 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15315
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015316 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15317#if 0
15318 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15319 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15320#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015321 { } /* end */
15322};
15323/*
15324 * 6ch mode
15325 * need to set the codec line out and mic 1 pin widgets to outputs
15326 */
15327static struct hda_verb alc861_threestack_ch6_init[] = {
15328 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15329 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15330 /* set pin widget 18h (mic1) for output (CLFE)*/
15331 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15332
15333 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015334 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015335
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015336 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15337#if 0
15338 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15339 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15340#endif
Kailang Yangdf694da2005-12-05 19:42:22 +010015341 { } /* end */
15342};
15343
15344static struct hda_channel_mode alc861_threestack_modes[2] = {
15345 { 2, alc861_threestack_ch2_init },
15346 { 6, alc861_threestack_ch6_init },
15347};
Takashi Iwai22309c32006-08-09 16:57:28 +020015348/* Set mic1 as input and unmute the mixer */
15349static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
15350 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15351 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15352 { } /* end */
15353};
15354/* Set mic1 as output and mute mixer */
15355static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
15356 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15357 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15358 { } /* end */
15359};
15360
15361static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
15362 { 2, alc861_uniwill_m31_ch2_init },
15363 { 4, alc861_uniwill_m31_ch4_init },
15364};
Kailang Yangdf694da2005-12-05 19:42:22 +010015365
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015366/* Set mic1 and line-in as input and unmute the mixer */
15367static struct hda_verb alc861_asus_ch2_init[] = {
15368 /* set pin widget 1Ah (line in) for input */
15369 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015370 /* set pin widget 18h (mic1/2) for input, for mic also enable
15371 * the vref
15372 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015373 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15374
15375 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
15376#if 0
15377 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
15378 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
15379#endif
15380 { } /* end */
15381};
15382/* Set mic1 nad line-in as output and mute mixer */
15383static struct hda_verb alc861_asus_ch6_init[] = {
15384 /* set pin widget 1Ah (line in) for output (Back Surround)*/
15385 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15386 /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15387 /* set pin widget 18h (mic1) for output (CLFE)*/
15388 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15389 /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
15390 { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
15391 { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
15392
15393 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
15394#if 0
15395 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
15396 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
15397#endif
15398 { } /* end */
15399};
15400
15401static struct hda_channel_mode alc861_asus_modes[2] = {
15402 { 2, alc861_asus_ch2_init },
15403 { 6, alc861_asus_ch6_init },
15404};
15405
Kailang Yangdf694da2005-12-05 19:42:22 +010015406/* patch-ALC861 */
15407
15408static struct snd_kcontrol_new alc861_base_mixer[] = {
15409 /* output mixer control */
15410 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15411 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15412 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15413 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15414 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15415
15416 /*Input mixer control */
15417 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15418 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15419 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15420 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15421 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15422 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15423 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15424 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15425 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15426 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015427
Kailang Yangdf694da2005-12-05 19:42:22 +010015428 { } /* end */
15429};
15430
15431static struct snd_kcontrol_new alc861_3ST_mixer[] = {
15432 /* output mixer control */
15433 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15434 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15435 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15436 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15437 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15438
15439 /* Input mixer control */
15440 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15441 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15442 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15443 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15444 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15445 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15446 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15447 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15448 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15449 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015450
Kailang Yangdf694da2005-12-05 19:42:22 +010015451 {
15452 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15453 .name = "Channel Mode",
15454 .info = alc_ch_mode_info,
15455 .get = alc_ch_mode_get,
15456 .put = alc_ch_mode_put,
15457 .private_value = ARRAY_SIZE(alc861_threestack_modes),
15458 },
15459 { } /* end */
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015460};
15461
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015462static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015463 /* output mixer control */
15464 HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15465 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15466 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020015467
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015468 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015469};
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015470
Takashi Iwai22309c32006-08-09 16:57:28 +020015471static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
15472 /* output mixer control */
15473 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15474 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15475 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15476 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15477 /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
15478
15479 /* Input mixer control */
15480 /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15481 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
15482 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15483 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15484 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15485 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15486 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15487 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15488 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
15489 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015490
Takashi Iwai22309c32006-08-09 16:57:28 +020015491 {
15492 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15493 .name = "Channel Mode",
15494 .info = alc_ch_mode_info,
15495 .get = alc_ch_mode_get,
15496 .put = alc_ch_mode_put,
15497 .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
15498 },
15499 { } /* end */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015500};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015501
15502static struct snd_kcontrol_new alc861_asus_mixer[] = {
15503 /* output mixer control */
15504 HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
15505 HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
15506 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
15507 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
15508 HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
15509
15510 /* Input mixer control */
15511 HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
15512 HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
15513 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15514 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
15515 HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
15516 HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
15517 HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
15518 HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
15519 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015520 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
15521
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015522 {
15523 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
15524 .name = "Channel Mode",
15525 .info = alc_ch_mode_info,
15526 .get = alc_ch_mode_get,
15527 .put = alc_ch_mode_put,
15528 .private_value = ARRAY_SIZE(alc861_asus_modes),
15529 },
15530 { }
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015531};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015532
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015533/* additional mixer */
Takashi Iwaid1d985f2006-11-23 19:27:12 +010015534static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015535 HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
15536 HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015537 { }
15538};
15539
Kailang Yangdf694da2005-12-05 19:42:22 +010015540/*
15541 * generic initialization of ADC, input mixers and output mixers
15542 */
15543static struct hda_verb alc861_base_init_verbs[] = {
15544 /*
15545 * Unmute ADC0 and set the default input to mic-in
15546 */
15547 /* port-A for surround (rear panel) */
15548 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15549 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
15550 /* port-B for mic-in (rear panel) with vref */
15551 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15552 /* port-C for line-in (rear panel) */
15553 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15554 /* port-D for Front */
15555 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15556 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15557 /* port-E for HP out (front panel) */
15558 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15559 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015560 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015561 /* port-F for mic-in (front panel) with vref */
15562 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15563 /* port-G for CLFE (rear panel) */
15564 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15565 { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
15566 /* port-H for side (rear panel) */
15567 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15568 { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
15569 /* CD-in */
15570 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15571 /* route front mic to ADC1*/
15572 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15573 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015574
Kailang Yangdf694da2005-12-05 19:42:22 +010015575 /* Unmute DAC0~3 & spdif out*/
15576 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15577 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15578 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15579 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15580 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015581
Kailang Yangdf694da2005-12-05 19:42:22 +010015582 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15583 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15584 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15585 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15586 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015587
Kailang Yangdf694da2005-12-05 19:42:22 +010015588 /* Unmute Stereo Mixer 15 */
15589 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15590 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15591 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015592 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015593
15594 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15595 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15596 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15597 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15598 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15599 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15600 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15601 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015602 /* hp used DAC 3 (Front) */
15603 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015604 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15605
15606 { }
15607};
15608
15609static struct hda_verb alc861_threestack_init_verbs[] = {
15610 /*
15611 * Unmute ADC0 and set the default input to mic-in
15612 */
15613 /* port-A for surround (rear panel) */
15614 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15615 /* port-B for mic-in (rear panel) with vref */
15616 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15617 /* port-C for line-in (rear panel) */
15618 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15619 /* port-D for Front */
15620 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15621 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15622 /* port-E for HP out (front panel) */
15623 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
15624 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015625 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Kailang Yangdf694da2005-12-05 19:42:22 +010015626 /* port-F for mic-in (front panel) with vref */
15627 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15628 /* port-G for CLFE (rear panel) */
15629 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15630 /* port-H for side (rear panel) */
15631 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15632 /* CD-in */
15633 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15634 /* route front mic to ADC1*/
15635 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15636 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15637 /* Unmute DAC0~3 & spdif out*/
15638 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15639 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15640 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15641 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15642 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015643
Kailang Yangdf694da2005-12-05 19:42:22 +010015644 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15645 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15646 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15647 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15648 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015649
Kailang Yangdf694da2005-12-05 19:42:22 +010015650 /* Unmute Stereo Mixer 15 */
15651 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15652 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15653 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015654 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Kailang Yangdf694da2005-12-05 19:42:22 +010015655
15656 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15657 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15658 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15659 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15660 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15661 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15662 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15663 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015664 /* hp used DAC 3 (Front) */
15665 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015666 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15667 { }
15668};
Takashi Iwai22309c32006-08-09 16:57:28 +020015669
15670static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
15671 /*
15672 * Unmute ADC0 and set the default input to mic-in
15673 */
15674 /* port-A for surround (rear panel) */
15675 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15676 /* port-B for mic-in (rear panel) with vref */
15677 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15678 /* port-C for line-in (rear panel) */
15679 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15680 /* port-D for Front */
15681 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15682 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15683 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015684 /* this has to be set to VREF80 */
15685 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015686 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015687 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Takashi Iwai22309c32006-08-09 16:57:28 +020015688 /* port-F for mic-in (front panel) with vref */
15689 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15690 /* port-G for CLFE (rear panel) */
15691 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15692 /* port-H for side (rear panel) */
15693 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
15694 /* CD-in */
15695 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15696 /* route front mic to ADC1*/
15697 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15698 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15699 /* Unmute DAC0~3 & spdif out*/
15700 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15701 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15702 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15703 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15704 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015705
Takashi Iwai22309c32006-08-09 16:57:28 +020015706 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15707 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15708 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15709 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15710 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015711
Takashi Iwai22309c32006-08-09 16:57:28 +020015712 /* Unmute Stereo Mixer 15 */
15713 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15714 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15715 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015716 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Takashi Iwai22309c32006-08-09 16:57:28 +020015717
15718 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15719 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15720 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15721 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15722 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15723 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15724 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15725 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015726 /* hp used DAC 3 (Front) */
15727 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Takashi Iwai22309c32006-08-09 16:57:28 +020015728 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15729 { }
15730};
15731
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015732static struct hda_verb alc861_asus_init_verbs[] = {
15733 /*
15734 * Unmute ADC0 and set the default input to mic-in
15735 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015736 /* port-A for surround (rear panel)
15737 * according to codec#0 this is the HP jack
15738 */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015739 { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
15740 /* route front PCM to HP */
15741 { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
15742 /* port-B for mic-in (rear panel) with vref */
15743 { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15744 /* port-C for line-in (rear panel) */
15745 { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15746 /* port-D for Front */
15747 { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15748 { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
15749 /* port-E for HP out (front panel) */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015750 /* this has to be set to VREF80 */
15751 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015752 /* route front PCM to HP */
Takashi Iwai9dece1d2006-11-16 17:12:49 +010015753 { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015754 /* port-F for mic-in (front panel) with vref */
15755 { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
15756 /* port-G for CLFE (rear panel) */
15757 { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15758 /* port-H for side (rear panel) */
15759 { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
15760 /* CD-in */
15761 { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
15762 /* route front mic to ADC1*/
15763 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
15764 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15765 /* Unmute DAC0~3 & spdif out*/
15766 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15767 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15768 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15769 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15770 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
15771 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15772 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15773 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15774 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15775 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015776
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015777 /* Unmute Stereo Mixer 15 */
15778 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15779 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15780 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015781 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015782
15783 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15784 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15785 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15786 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15787 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15788 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15789 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15790 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015791 /* hp used DAC 3 (Front) */
15792 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015793 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15794 { }
15795};
15796
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010015797/* additional init verbs for ASUS laptops */
15798static struct hda_verb alc861_asus_laptop_init_verbs[] = {
15799 { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
15800 { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
15801 { }
15802};
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020015803
Kailang Yangdf694da2005-12-05 19:42:22 +010015804/*
15805 * generic initialization of ADC, input mixers and output mixers
15806 */
15807static struct hda_verb alc861_auto_init_verbs[] = {
15808 /*
15809 * Unmute ADC0 and set the default input to mic-in
15810 */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015811 /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
Kailang Yangdf694da2005-12-05 19:42:22 +010015812 {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015813
Kailang Yangdf694da2005-12-05 19:42:22 +010015814 /* Unmute DAC0~3 & spdif out*/
15815 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15816 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15817 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15818 {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
15819 {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangea1fb292008-08-26 12:58:38 +020015820
Kailang Yangdf694da2005-12-05 19:42:22 +010015821 /* Unmute Mixer 14 (mic) 1c (Line in)*/
15822 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15823 {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15824 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15825 {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020015826
Kailang Yangdf694da2005-12-05 19:42:22 +010015827 /* Unmute Stereo Mixer 15 */
15828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
15829 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
15830 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
15831 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
15832
Takashi Iwai1c209302009-07-22 15:17:45 +020015833 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15834 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15835 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15836 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15837 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15838 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
15839 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15840 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015841
15842 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15843 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015844 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15845 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015846 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
15847 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Takashi Iwai1c209302009-07-22 15:17:45 +020015848 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
15849 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
Kailang Yangdf694da2005-12-05 19:42:22 +010015850
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015851 {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015852
15853 { }
15854};
15855
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015856static struct hda_verb alc861_toshiba_init_verbs[] = {
15857 {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015858
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015859 { }
15860};
15861
15862/* toggle speaker-output according to the hp-jack state */
15863static void alc861_toshiba_automute(struct hda_codec *codec)
15864{
Wu Fengguang864f92b2009-11-18 12:38:02 +080015865 unsigned int present = snd_hda_jack_detect(codec, 0x0f);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015866
Takashi Iwai47fd8302007-08-10 17:11:07 +020015867 snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
15868 HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
15869 snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
15870 HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015871}
15872
15873static void alc861_toshiba_unsol_event(struct hda_codec *codec,
15874 unsigned int res)
15875{
Tobin Davisa53d1ae2006-10-17 12:00:28 +020015876 if ((res >> 26) == ALC880_HP_EVENT)
15877 alc861_toshiba_automute(codec);
15878}
15879
Sasha Alexandrdef319f2009-06-16 16:00:15 -040015880/* pcm configuration: identical with ALC880 */
Kailang Yangdf694da2005-12-05 19:42:22 +010015881#define alc861_pcm_analog_playback alc880_pcm_analog_playback
15882#define alc861_pcm_analog_capture alc880_pcm_analog_capture
15883#define alc861_pcm_digital_playback alc880_pcm_digital_playback
15884#define alc861_pcm_digital_capture alc880_pcm_digital_capture
15885
15886
15887#define ALC861_DIGOUT_NID 0x07
15888
15889static struct hda_channel_mode alc861_8ch_modes[1] = {
15890 { 8, NULL }
15891};
15892
15893static hda_nid_t alc861_dac_nids[4] = {
15894 /* front, surround, clfe, side */
15895 0x03, 0x06, 0x05, 0x04
15896};
15897
Takashi Iwai9c7f8522006-06-28 15:08:22 +020015898static hda_nid_t alc660_dac_nids[3] = {
15899 /* front, clfe, surround */
15900 0x03, 0x05, 0x06
15901};
15902
Kailang Yangdf694da2005-12-05 19:42:22 +010015903static hda_nid_t alc861_adc_nids[1] = {
15904 /* ADC0-2 */
15905 0x08,
15906};
15907
15908static struct hda_input_mux alc861_capture_source = {
15909 .num_items = 5,
15910 .items = {
15911 { "Mic", 0x0 },
15912 { "Front Mic", 0x3 },
15913 { "Line", 0x1 },
15914 { "CD", 0x4 },
15915 { "Mixer", 0x5 },
15916 },
15917};
15918
Takashi Iwai1c209302009-07-22 15:17:45 +020015919static hda_nid_t alc861_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
15920{
15921 struct alc_spec *spec = codec->spec;
15922 hda_nid_t mix, srcs[5];
15923 int i, j, num;
15924
15925 if (snd_hda_get_connections(codec, pin, &mix, 1) != 1)
15926 return 0;
15927 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
15928 if (num < 0)
15929 return 0;
15930 for (i = 0; i < num; i++) {
15931 unsigned int type;
Takashi Iwaia22d5432009-07-27 12:54:26 +020015932 type = get_wcaps_type(get_wcaps(codec, srcs[i]));
Takashi Iwai1c209302009-07-22 15:17:45 +020015933 if (type != AC_WID_AUD_OUT)
15934 continue;
15935 for (j = 0; j < spec->multiout.num_dacs; j++)
15936 if (spec->multiout.dac_nids[j] == srcs[i])
15937 break;
15938 if (j >= spec->multiout.num_dacs)
15939 return srcs[i];
15940 }
15941 return 0;
15942}
15943
Kailang Yangdf694da2005-12-05 19:42:22 +010015944/* fill in the dac_nids table from the parsed pin configuration */
Takashi Iwai1c209302009-07-22 15:17:45 +020015945static int alc861_auto_fill_dac_nids(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015946 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010015947{
Takashi Iwai1c209302009-07-22 15:17:45 +020015948 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010015949 int i;
Takashi Iwai1c209302009-07-22 15:17:45 +020015950 hda_nid_t nid, dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015951
15952 spec->multiout.dac_nids = spec->private_dac_nids;
15953 for (i = 0; i < cfg->line_outs; i++) {
15954 nid = cfg->line_out_pins[i];
Takashi Iwai1c209302009-07-22 15:17:45 +020015955 dac = alc861_look_for_dac(codec, nid);
15956 if (!dac)
15957 continue;
15958 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
Kailang Yangdf694da2005-12-05 19:42:22 +010015959 }
Kailang Yangdf694da2005-12-05 19:42:22 +010015960 return 0;
15961}
15962
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015963static int __alc861_create_out_sw(struct hda_codec *codec, const char *pfx,
15964 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangdf694da2005-12-05 19:42:22 +010015965{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015966 return __add_pb_sw_ctrl(codec->spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai1c209302009-07-22 15:17:45 +020015967 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
15968}
15969
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015970#define alc861_create_out_sw(codec, pfx, nid, chs) \
15971 __alc861_create_out_sw(codec, pfx, nid, 0, chs)
15972
Takashi Iwai1c209302009-07-22 15:17:45 +020015973/* add playback controls from the parsed DAC table */
15974static int alc861_auto_create_multi_out_ctls(struct hda_codec *codec,
15975 const struct auto_pin_cfg *cfg)
15976{
15977 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010015978 static const char * const chname[4] = {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015979 "Front", "Surround", NULL /*CLFE*/, "Side"
15980 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015981 const char *pfx = alc_get_line_out_pfx(cfg, true);
Kailang Yangdf694da2005-12-05 19:42:22 +010015982 hda_nid_t nid;
Takashi Iwai1c209302009-07-22 15:17:45 +020015983 int i, err;
15984
Kailang Yangdf694da2005-12-05 19:42:22 +010015985 for (i = 0; i < cfg->line_outs; i++) {
15986 nid = spec->multiout.dac_nids[i];
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015987 if (!nid)
Kailang Yangdf694da2005-12-05 19:42:22 +010015988 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015989 if (!pfx && i == 2) {
Kailang Yangdf694da2005-12-05 19:42:22 +010015990 /* Center/LFE */
Takashi Iwai1c209302009-07-22 15:17:45 +020015991 err = alc861_create_out_sw(codec, "Center", nid, 1);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015992 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015993 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020015994 err = alc861_create_out_sw(codec, "LFE", nid, 2);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020015995 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010015996 return err;
15997 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010015998 const char *name = pfx;
15999 if (!name)
16000 name = chname[i];
16001 err = __alc861_create_out_sw(codec, name, nid, i, 3);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016002 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016003 return err;
16004 }
16005 }
16006 return 0;
16007}
16008
Takashi Iwai1c209302009-07-22 15:17:45 +020016009static int alc861_auto_create_hp_ctls(struct hda_codec *codec, hda_nid_t pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016010{
Takashi Iwai1c209302009-07-22 15:17:45 +020016011 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016012 int err;
16013 hda_nid_t nid;
16014
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016015 if (!pin)
Kailang Yangdf694da2005-12-05 19:42:22 +010016016 return 0;
16017
16018 if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
Takashi Iwai1c209302009-07-22 15:17:45 +020016019 nid = alc861_look_for_dac(codec, pin);
16020 if (nid) {
16021 err = alc861_create_out_sw(codec, "Headphone", nid, 3);
16022 if (err < 0)
16023 return err;
16024 spec->multiout.hp_nid = nid;
16025 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016026 }
16027 return 0;
16028}
16029
16030/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020016031static int alc861_auto_create_input_ctls(struct hda_codec *codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016032 const struct auto_pin_cfg *cfg)
Kailang Yangdf694da2005-12-05 19:42:22 +010016033{
Takashi Iwai05f5f472009-08-25 13:10:18 +020016034 return alc_auto_create_input_ctls(codec, cfg, 0x15, 0x08, 0);
Kailang Yangdf694da2005-12-05 19:42:22 +010016035}
16036
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016037static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
16038 hda_nid_t nid,
Takashi Iwai1c209302009-07-22 15:17:45 +020016039 int pin_type, hda_nid_t dac)
Kailang Yangdf694da2005-12-05 19:42:22 +010016040{
Takashi Iwai1c209302009-07-22 15:17:45 +020016041 hda_nid_t mix, srcs[5];
16042 int i, num;
16043
Jacek Luczak564c5be2008-05-03 18:41:23 +020016044 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
16045 pin_type);
Takashi Iwai1c209302009-07-22 15:17:45 +020016046 snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE,
Jacek Luczak564c5be2008-05-03 18:41:23 +020016047 AMP_OUT_UNMUTE);
Takashi Iwai1c209302009-07-22 15:17:45 +020016048 if (snd_hda_get_connections(codec, nid, &mix, 1) != 1)
16049 return;
16050 num = snd_hda_get_connections(codec, mix, srcs, ARRAY_SIZE(srcs));
16051 if (num < 0)
16052 return;
16053 for (i = 0; i < num; i++) {
16054 unsigned int mute;
16055 if (srcs[i] == dac || srcs[i] == 0x15)
16056 mute = AMP_IN_UNMUTE(i);
16057 else
16058 mute = AMP_IN_MUTE(i);
16059 snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE,
16060 mute);
16061 }
Kailang Yangdf694da2005-12-05 19:42:22 +010016062}
16063
16064static void alc861_auto_init_multi_out(struct hda_codec *codec)
16065{
16066 struct alc_spec *spec = codec->spec;
16067 int i;
16068
16069 for (i = 0; i < spec->autocfg.line_outs; i++) {
16070 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016071 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016072 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020016073 alc861_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016074 spec->multiout.dac_nids[i]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016075 }
16076}
16077
16078static void alc861_auto_init_hp_out(struct hda_codec *codec)
16079{
16080 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016081
Takashi Iwai15870f02009-10-05 08:25:13 +020016082 if (spec->autocfg.hp_outs)
16083 alc861_auto_set_output_and_unmute(codec,
16084 spec->autocfg.hp_pins[0],
16085 PIN_HP,
Takashi Iwai1c209302009-07-22 15:17:45 +020016086 spec->multiout.hp_nid);
Takashi Iwai15870f02009-10-05 08:25:13 +020016087 if (spec->autocfg.speaker_outs)
16088 alc861_auto_set_output_and_unmute(codec,
16089 spec->autocfg.speaker_pins[0],
16090 PIN_OUT,
Takashi Iwai1c209302009-07-22 15:17:45 +020016091 spec->multiout.dac_nids[0]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016092}
16093
16094static void alc861_auto_init_analog_input(struct hda_codec *codec)
16095{
16096 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016097 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangdf694da2005-12-05 19:42:22 +010016098 int i;
16099
Takashi Iwai66ceeb62010-08-30 13:05:52 +020016100 for (i = 0; i < cfg->num_inputs; i++) {
16101 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai23f0c042009-02-26 13:03:58 +010016102 if (nid >= 0x0c && nid <= 0x11)
Takashi Iwai30ea0982010-09-16 18:47:56 +020016103 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Kailang Yangdf694da2005-12-05 19:42:22 +010016104 }
16105}
16106
16107/* parse the BIOS configuration and set up the alc_spec */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016108/* return 1 if successful, 0 if the proper config is not found,
16109 * or a negative error code
16110 */
Kailang Yangdf694da2005-12-05 19:42:22 +010016111static int alc861_parse_auto_config(struct hda_codec *codec)
16112{
16113 struct alc_spec *spec = codec->spec;
16114 int err;
16115 static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
16116
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016117 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
16118 alc861_ignore);
16119 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016120 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016121 if (!spec->autocfg.line_outs)
Kailang Yangdf694da2005-12-05 19:42:22 +010016122 return 0; /* can't find valid BIOS pin config */
16123
Takashi Iwai1c209302009-07-22 15:17:45 +020016124 err = alc861_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016125 if (err < 0)
16126 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016127 err = alc861_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016128 if (err < 0)
16129 return err;
Takashi Iwai1c209302009-07-22 15:17:45 +020016130 err = alc861_auto_create_hp_ctls(codec, spec->autocfg.hp_pins[0]);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016131 if (err < 0)
16132 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020016133 err = alc861_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016134 if (err < 0)
Kailang Yangdf694da2005-12-05 19:42:22 +010016135 return err;
16136
16137 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
16138
Takashi Iwai757899a2010-07-30 10:48:14 +020016139 alc_auto_parse_digital(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016140
Takashi Iwai603c4012008-07-30 15:01:44 +020016141 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010016142 add_mixer(spec, spec->kctls.list);
Kailang Yangdf694da2005-12-05 19:42:22 +010016143
Takashi Iwaid88897e2008-10-31 15:01:37 +010016144 add_verb(spec, alc861_auto_init_verbs);
Kailang Yangdf694da2005-12-05 19:42:22 +010016145
Jonathan Woithea1e8d2d2006-03-28 12:47:09 +020016146 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020016147 spec->input_mux = &spec->private_imux[0];
Kailang Yangdf694da2005-12-05 19:42:22 +010016148
16149 spec->adc_nids = alc861_adc_nids;
16150 spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
Takashi Iwaib59bdf32009-08-11 09:47:30 +020016151 set_capture_mixer(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016152
Kailang Yang6227cdc2010-02-25 08:36:52 +010016153 alc_ssid_check(codec, 0x0e, 0x0f, 0x0b, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020016154
Kailang Yangdf694da2005-12-05 19:42:22 +010016155 return 1;
16156}
16157
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016158/* additional initialization for auto-configuration model */
16159static void alc861_auto_init(struct hda_codec *codec)
Kailang Yangdf694da2005-12-05 19:42:22 +010016160{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016161 struct alc_spec *spec = codec->spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016162 alc861_auto_init_multi_out(codec);
16163 alc861_auto_init_hp_out(codec);
16164 alc861_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020016165 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010016166 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020016167 alc_inithook(codec);
Kailang Yangdf694da2005-12-05 19:42:22 +010016168}
16169
Takashi Iwaicb53c622007-08-10 17:21:45 +020016170#ifdef CONFIG_SND_HDA_POWER_SAVE
16171static struct hda_amp_list alc861_loopbacks[] = {
16172 { 0x15, HDA_INPUT, 0 },
16173 { 0x15, HDA_INPUT, 1 },
16174 { 0x15, HDA_INPUT, 2 },
16175 { 0x15, HDA_INPUT, 3 },
16176 { } /* end */
16177};
16178#endif
16179
Kailang Yangdf694da2005-12-05 19:42:22 +010016180
16181/*
16182 * configuration and preset
16183 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016184static const char * const alc861_models[ALC861_MODEL_LAST] = {
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016185 [ALC861_3ST] = "3stack",
16186 [ALC660_3ST] = "3stack-660",
16187 [ALC861_3ST_DIG] = "3stack-dig",
16188 [ALC861_6ST_DIG] = "6stack-dig",
16189 [ALC861_UNIWILL_M31] = "uniwill-m31",
16190 [ALC861_TOSHIBA] = "toshiba",
16191 [ALC861_ASUS] = "asus",
16192 [ALC861_ASUS_LAPTOP] = "asus-laptop",
16193 [ALC861_AUTO] = "auto",
16194};
16195
16196static struct snd_pci_quirk alc861_cfg_tbl[] = {
Takashi Iwai687a47b2007-01-10 11:25:58 +010016197 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016198 SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16199 SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
16200 SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016201 SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
Kailang Yang83c34212007-07-05 11:43:05 +020016202 SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
Tobin Davisad5e7732007-01-08 10:57:32 +010016203 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
Takashi Iwai341d4eb2007-07-09 17:53:18 +020016204 /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
16205 * Any other models that need this preset?
16206 */
16207 /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
Claudio Matsuokaef64adb2007-07-14 00:26:16 +020016208 SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
16209 SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016210 SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
16211 SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
16212 SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
16213 /* FIXME: the below seems conflict */
16214 /* SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31), */
16215 SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
16216 SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
Kailang Yangdf694da2005-12-05 19:42:22 +010016217 {}
16218};
16219
16220static struct alc_config_preset alc861_presets[] = {
16221 [ALC861_3ST] = {
16222 .mixers = { alc861_3ST_mixer },
16223 .init_verbs = { alc861_threestack_init_verbs },
16224 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16225 .dac_nids = alc861_dac_nids,
16226 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16227 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016228 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016229 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16230 .adc_nids = alc861_adc_nids,
16231 .input_mux = &alc861_capture_source,
16232 },
16233 [ALC861_3ST_DIG] = {
16234 .mixers = { alc861_base_mixer },
16235 .init_verbs = { alc861_threestack_init_verbs },
16236 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16237 .dac_nids = alc861_dac_nids,
16238 .dig_out_nid = ALC861_DIGOUT_NID,
16239 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16240 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016241 .need_dac_fix = 1,
Kailang Yangdf694da2005-12-05 19:42:22 +010016242 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16243 .adc_nids = alc861_adc_nids,
16244 .input_mux = &alc861_capture_source,
16245 },
16246 [ALC861_6ST_DIG] = {
16247 .mixers = { alc861_base_mixer },
16248 .init_verbs = { alc861_base_init_verbs },
16249 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16250 .dac_nids = alc861_dac_nids,
16251 .dig_out_nid = ALC861_DIGOUT_NID,
16252 .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
16253 .channel_mode = alc861_8ch_modes,
16254 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16255 .adc_nids = alc861_adc_nids,
16256 .input_mux = &alc861_capture_source,
16257 },
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016258 [ALC660_3ST] = {
16259 .mixers = { alc861_3ST_mixer },
16260 .init_verbs = { alc861_threestack_init_verbs },
16261 .num_dacs = ARRAY_SIZE(alc660_dac_nids),
16262 .dac_nids = alc660_dac_nids,
16263 .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
16264 .channel_mode = alc861_threestack_modes,
Takashi Iwai4e195a72006-07-28 14:47:34 +020016265 .need_dac_fix = 1,
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016266 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16267 .adc_nids = alc861_adc_nids,
16268 .input_mux = &alc861_capture_source,
16269 },
Takashi Iwai22309c32006-08-09 16:57:28 +020016270 [ALC861_UNIWILL_M31] = {
16271 .mixers = { alc861_uniwill_m31_mixer },
16272 .init_verbs = { alc861_uniwill_m31_init_verbs },
16273 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16274 .dac_nids = alc861_dac_nids,
16275 .dig_out_nid = ALC861_DIGOUT_NID,
16276 .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
16277 .channel_mode = alc861_uniwill_m31_modes,
16278 .need_dac_fix = 1,
16279 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16280 .adc_nids = alc861_adc_nids,
16281 .input_mux = &alc861_capture_source,
16282 },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016283 [ALC861_TOSHIBA] = {
16284 .mixers = { alc861_toshiba_mixer },
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016285 .init_verbs = { alc861_base_init_verbs,
16286 alc861_toshiba_init_verbs },
Tobin Davisa53d1ae2006-10-17 12:00:28 +020016287 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16288 .dac_nids = alc861_dac_nids,
16289 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16290 .channel_mode = alc883_3ST_2ch_modes,
16291 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16292 .adc_nids = alc861_adc_nids,
16293 .input_mux = &alc861_capture_source,
16294 .unsol_event = alc861_toshiba_unsol_event,
16295 .init_hook = alc861_toshiba_automute,
16296 },
Mariusz Domanski7cdbff92006-10-23 13:42:56 +020016297 [ALC861_ASUS] = {
16298 .mixers = { alc861_asus_mixer },
16299 .init_verbs = { alc861_asus_init_verbs },
16300 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16301 .dac_nids = alc861_dac_nids,
16302 .dig_out_nid = ALC861_DIGOUT_NID,
16303 .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
16304 .channel_mode = alc861_asus_modes,
16305 .need_dac_fix = 1,
16306 .hp_nid = 0x06,
16307 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16308 .adc_nids = alc861_adc_nids,
16309 .input_mux = &alc861_capture_source,
16310 },
Takashi Iwai56bb0ca2006-11-22 11:52:52 +010016311 [ALC861_ASUS_LAPTOP] = {
16312 .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
16313 .init_verbs = { alc861_asus_init_verbs,
16314 alc861_asus_laptop_init_verbs },
16315 .num_dacs = ARRAY_SIZE(alc861_dac_nids),
16316 .dac_nids = alc861_dac_nids,
16317 .dig_out_nid = ALC861_DIGOUT_NID,
16318 .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
16319 .channel_mode = alc883_3ST_2ch_modes,
16320 .need_dac_fix = 1,
16321 .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
16322 .adc_nids = alc861_adc_nids,
16323 .input_mux = &alc861_capture_source,
16324 },
16325};
Kailang Yangdf694da2005-12-05 19:42:22 +010016326
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016327/* Pin config fixes */
16328enum {
16329 PINFIX_FSC_AMILO_PI1505,
16330};
16331
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016332static const struct alc_fixup alc861_fixups[] = {
16333 [PINFIX_FSC_AMILO_PI1505] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016334 .type = ALC_FIXUP_PINS,
16335 .v.pins = (const struct alc_pincfg[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020016336 { 0x0b, 0x0221101f }, /* HP */
16337 { 0x0f, 0x90170310 }, /* speaker */
16338 { }
16339 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016340 },
16341};
16342
16343static struct snd_pci_quirk alc861_fixup_tbl[] = {
16344 SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", PINFIX_FSC_AMILO_PI1505),
16345 {}
16346};
Kailang Yangdf694da2005-12-05 19:42:22 +010016347
16348static int patch_alc861(struct hda_codec *codec)
16349{
16350 struct alc_spec *spec;
16351 int board_config;
16352 int err;
16353
Robert P. J. Daydc041e02006-12-19 14:44:15 +010016354 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
Kailang Yangdf694da2005-12-05 19:42:22 +010016355 if (spec == NULL)
16356 return -ENOMEM;
16357
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016358 codec->spec = spec;
Kailang Yangdf694da2005-12-05 19:42:22 +010016359
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016360 board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
16361 alc861_models,
16362 alc861_cfg_tbl);
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016363
Takashi Iwaif5fcc132006-11-24 17:07:44 +010016364 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020016365 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
16366 codec->chip_name);
Kailang Yangdf694da2005-12-05 19:42:22 +010016367 board_config = ALC861_AUTO;
16368 }
16369
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016370 if (board_config == ALC861_AUTO) {
16371 alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
16372 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
16373 }
Takashi Iwaicfc9b062009-12-01 12:19:37 +010016374
Kailang Yangdf694da2005-12-05 19:42:22 +010016375 if (board_config == ALC861_AUTO) {
16376 /* automatic parse from the BIOS config */
16377 err = alc861_parse_auto_config(codec);
16378 if (err < 0) {
16379 alc_free(codec);
16380 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020016381 } else if (!err) {
Takashi Iwai9c7f8522006-06-28 15:08:22 +020016382 printk(KERN_INFO
16383 "hda_codec: Cannot set up configuration "
16384 "from BIOS. Using base mode...\n");
Kailang Yangdf694da2005-12-05 19:42:22 +010016385 board_config = ALC861_3ST_DIG;
16386 }
16387 }
16388
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090016389 err = snd_hda_attach_beep_device(codec, 0x23);
16390 if (err < 0) {
16391 alc_free(codec);
16392 return err;
16393 }
16394
Kailang Yangdf694da2005-12-05 19:42:22 +010016395 if (board_config != ALC861_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020016396 setup_preset(codec, &alc861_presets[board_config]);
Kailang Yangdf694da2005-12-05 19:42:22 +010016397
Kailang Yangdf694da2005-12-05 19:42:22 +010016398 spec->stream_analog_playback = &alc861_pcm_analog_playback;
16399 spec->stream_analog_capture = &alc861_pcm_analog_capture;
16400
Kailang Yangdf694da2005-12-05 19:42:22 +010016401 spec->stream_digital_playback = &alc861_pcm_digital_playback;
16402 spec->stream_digital_capture = &alc861_pcm_digital_capture;
16403
Takashi Iwaic7a8eb12010-01-14 12:39:02 +010016404 if (!spec->cap_mixer)
16405 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010016406 set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
16407
Takashi Iwai2134ea42008-01-10 16:53:55 +010016408 spec->vmaster_nid = 0x03;
16409
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010016410 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020016411
Kailang Yangdf694da2005-12-05 19:42:22 +010016412 codec->patch_ops = alc_patch_ops;
Daniel T Chenc97259d2009-12-27 18:52:08 -050016413 if (board_config == ALC861_AUTO) {
Takashi Iwaiae6b8132006-03-03 16:47:17 +010016414 spec->init_hook = alc861_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020016415#ifdef CONFIG_SND_HDA_POWER_SAVE
Daniel T Chenc97259d2009-12-27 18:52:08 -050016416 spec->power_hook = alc_power_eapd;
16417#endif
16418 }
16419#ifdef CONFIG_SND_HDA_POWER_SAVE
Takashi Iwaicb53c622007-08-10 17:21:45 +020016420 if (!spec->loopback.amplist)
16421 spec->loopback.amplist = alc861_loopbacks;
16422#endif
Kailang Yangea1fb292008-08-26 12:58:38 +020016423
Kailang Yangdf694da2005-12-05 19:42:22 +010016424 return 0;
16425}
16426
16427/*
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016428 * ALC861-VD support
16429 *
16430 * Based on ALC882
16431 *
16432 * In addition, an independent DAC
16433 */
16434#define ALC861VD_DIGOUT_NID 0x06
16435
16436static hda_nid_t alc861vd_dac_nids[4] = {
16437 /* front, surr, clfe, side surr */
16438 0x02, 0x03, 0x04, 0x05
16439};
16440
16441/* dac_nids for ALC660vd are in a different order - according to
16442 * Realtek's driver.
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016443 * This should probably result in a different mixer for 6stack models
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016444 * of ALC660vd codecs, but for now there is only 3stack mixer
16445 * - and it is the same as in 861vd.
16446 * adc_nids in ALC660vd are (is) the same as in 861vd
16447 */
16448static hda_nid_t alc660vd_dac_nids[3] = {
16449 /* front, rear, clfe, rear_surr */
16450 0x02, 0x04, 0x03
16451};
16452
16453static hda_nid_t alc861vd_adc_nids[1] = {
16454 /* ADC0 */
16455 0x09,
16456};
16457
Takashi Iwaie1406342008-02-11 18:32:32 +010016458static hda_nid_t alc861vd_capsrc_nids[1] = { 0x22 };
16459
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016460/* input MUX */
16461/* FIXME: should be a matrix-type input source selection */
16462static struct hda_input_mux alc861vd_capture_source = {
16463 .num_items = 4,
16464 .items = {
16465 { "Mic", 0x0 },
16466 { "Front Mic", 0x1 },
16467 { "Line", 0x2 },
16468 { "CD", 0x4 },
16469 },
16470};
16471
Kailang Yang272a5272007-05-14 11:00:38 +020016472static struct hda_input_mux alc861vd_dallas_capture_source = {
Tobin Davisb419f342008-03-07 11:57:51 +010016473 .num_items = 2,
Kailang Yang272a5272007-05-14 11:00:38 +020016474 .items = {
David Henningsson8607f7c2010-12-20 14:43:54 +010016475 { "Mic", 0x0 },
David Henningsson28c4edb2010-12-20 14:24:29 +010016476 { "Internal Mic", 0x1 },
Kailang Yang272a5272007-05-14 11:00:38 +020016477 },
16478};
16479
Kailang Yangd1a991a2007-08-15 16:21:59 +020016480static struct hda_input_mux alc861vd_hp_capture_source = {
16481 .num_items = 2,
16482 .items = {
16483 { "Front Mic", 0x0 },
16484 { "ATAPI Mic", 0x1 },
16485 },
16486};
16487
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016488/*
16489 * 2ch mode
16490 */
16491static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
16492 { 2, NULL }
16493};
16494
16495/*
16496 * 6ch mode
16497 */
16498static struct hda_verb alc861vd_6stack_ch6_init[] = {
16499 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
16500 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16501 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16502 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16503 { } /* end */
16504};
16505
16506/*
16507 * 8ch mode
16508 */
16509static struct hda_verb alc861vd_6stack_ch8_init[] = {
16510 { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16511 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16512 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16513 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
16514 { } /* end */
16515};
16516
16517static struct hda_channel_mode alc861vd_6stack_modes[2] = {
16518 { 6, alc861vd_6stack_ch6_init },
16519 { 8, alc861vd_6stack_ch8_init },
16520};
16521
16522static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
16523 {
16524 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
16525 .name = "Channel Mode",
16526 .info = alc_ch_mode_info,
16527 .get = alc_ch_mode_get,
16528 .put = alc_ch_mode_put,
16529 },
16530 { } /* end */
16531};
16532
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016533/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
16534 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
16535 */
16536static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
16537 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16538 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16539
16540 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16541 HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
16542
16543 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
16544 HDA_OUTPUT),
16545 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
16546 HDA_OUTPUT),
16547 HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
16548 HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
16549
16550 HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
16551 HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
16552
16553 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16554
David Henningsson5f99f862011-01-04 15:24:24 +010016555 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016556 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16557 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16558
David Henningsson5f99f862011-01-04 15:24:24 +010016559 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016560 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16561 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16562
16563 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16564 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16565
16566 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16567 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16568
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016569 { } /* end */
16570};
16571
16572static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
16573 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16574 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16575
16576 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16577
David Henningsson5f99f862011-01-04 15:24:24 +010016578 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016579 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16580 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16581
David Henningsson5f99f862011-01-04 15:24:24 +010016582 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016583 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16584 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16585
16586 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
16587 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
16588
16589 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16590 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16591
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016592 { } /* end */
16593};
16594
Kailang Yangbdd148a2007-05-08 15:19:08 +020016595static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
16596 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16597 /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
16598 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
16599
16600 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
16601
David Henningsson5f99f862011-01-04 15:24:24 +010016602 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16605
David Henningsson5f99f862011-01-04 15:24:24 +010016606 HDA_CODEC_VOLUME("Front Mic Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangbdd148a2007-05-08 15:19:08 +020016607 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16608 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
16609
16610 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
16611 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
16612
16613 { } /* end */
16614};
16615
Tobin Davisb419f342008-03-07 11:57:51 +010016616/* Pin assignment: Speaker=0x14, HP = 0x15,
David Henningsson8607f7c2010-12-20 14:43:54 +010016617 * Mic=0x18, Internal Mic = 0x19, CD = 0x1c, PC Beep = 0x1d
Kailang Yang272a5272007-05-14 11:00:38 +020016618 */
16619static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
Tobin Davisb419f342008-03-07 11:57:51 +010016620 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16621 HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016622 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16623 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016624 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson8607f7c2010-12-20 14:43:54 +010016625 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16626 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010016627 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson28c4edb2010-12-20 14:24:29 +010016628 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16629 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang272a5272007-05-14 11:00:38 +020016630 { } /* end */
16631};
16632
Kailang Yangd1a991a2007-08-15 16:21:59 +020016633/* Pin assignment: Speaker=0x14, Line-out = 0x15,
16634 * Front Mic=0x18, ATAPI Mic = 0x19,
16635 */
16636static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
16637 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
16638 HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
16639 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
16640 HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
16641 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
16642 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
16643 HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
16644 HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangea1fb292008-08-26 12:58:38 +020016645
Kailang Yangd1a991a2007-08-15 16:21:59 +020016646 { } /* end */
16647};
16648
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016649/*
16650 * generic initialization of ADC, input mixers and output mixers
16651 */
16652static struct hda_verb alc861vd_volume_init_verbs[] = {
16653 /*
16654 * Unmute ADC0 and set the default input to mic-in
16655 */
16656 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
16657 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16658
16659 /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
16660 * the analog-loopback mixer widget
16661 */
16662 /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
Takashi Iwaicb53c622007-08-10 17:21:45 +020016663 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16664 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16665 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16666 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16667 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016668
16669 /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
Kailang Yangbdd148a2007-05-08 15:19:08 +020016670 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16671 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16672 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016673 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016674
16675 /*
16676 * Set up output mixers (0x02 - 0x05)
16677 */
16678 /* set vol=0 to output mixers */
16679 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16680 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16681 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16682 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16683
16684 /* set up input amps for analog loopback */
16685 /* Amp Indices: DAC = 0, mixer = 1 */
16686 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16687 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16688 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16689 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16690 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16691 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16692 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16693 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16694
16695 { }
16696};
16697
16698/*
16699 * 3-stack pin configuration:
16700 * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
16701 */
16702static struct hda_verb alc861vd_3stack_init_verbs[] = {
16703 /*
16704 * Set pin mode and muting
16705 */
16706 /* set front pin widgets 0x14 for output */
16707 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16708 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16709 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16710
16711 /* Mic (rear) pin: input vref at 80% */
16712 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16713 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16714 /* Front Mic pin: input vref at 80% */
16715 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16716 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16717 /* Line In pin: input */
16718 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16719 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16720 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16721 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16722 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16723 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16724 /* CD pin widget for input */
16725 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16726
16727 { }
16728};
16729
16730/*
16731 * 6-stack pin configuration:
16732 */
16733static struct hda_verb alc861vd_6stack_init_verbs[] = {
16734 /*
16735 * Set pin mode and muting
16736 */
16737 /* set front pin widgets 0x14 for output */
16738 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16739 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16740 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
16741
16742 /* Rear Pin: output 1 (0x0d) */
16743 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16744 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16745 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
16746 /* CLFE Pin: output 2 (0x0e) */
16747 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16748 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16749 {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
16750 /* Side Pin: output 3 (0x0f) */
16751 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16752 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16753 {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
16754
16755 /* Mic (rear) pin: input vref at 80% */
16756 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16757 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16758 /* Front Mic pin: input vref at 80% */
16759 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
16760 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16761 /* Line In pin: input */
16762 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16763 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16764 /* Line-2 In: Headphone output (output 0 - 0x0c) */
16765 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
16766 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16767 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
16768 /* CD pin widget for input */
16769 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16770
16771 { }
16772};
16773
Kailang Yangbdd148a2007-05-08 15:19:08 +020016774static struct hda_verb alc861vd_eapd_verbs[] = {
16775 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16776 { }
16777};
16778
Kailang Yangf9423e72008-05-27 12:32:25 +020016779static struct hda_verb alc660vd_eapd_verbs[] = {
16780 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
16781 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
16782 { }
16783};
16784
Kailang Yangbdd148a2007-05-08 15:19:08 +020016785static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
16786 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16787 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16788 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
16789 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
Kailang Yangea1fb292008-08-26 12:58:38 +020016790 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
Kailang Yangbdd148a2007-05-08 15:19:08 +020016791 {}
16792};
16793
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016794static void alc861vd_lenovo_setup(struct hda_codec *codec)
Kailang Yangbdd148a2007-05-08 15:19:08 +020016795{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016796 struct alc_spec *spec = codec->spec;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016797 spec->autocfg.hp_pins[0] = 0x1b;
16798 spec->autocfg.speaker_pins[0] = 0x14;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016799}
16800
16801static void alc861vd_lenovo_init_hook(struct hda_codec *codec)
16802{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016803 alc_automute_amp(codec);
Anisse Astiereeb43382010-12-16 12:19:47 +010016804 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016805}
16806
16807static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
16808 unsigned int res)
16809{
16810 switch (res >> 26) {
Kailang Yangbdd148a2007-05-08 15:19:08 +020016811 case ALC880_MIC_EVENT:
Anisse Astiereeb43382010-12-16 12:19:47 +010016812 alc88x_simple_mic_automute(codec);
Kailang Yangbdd148a2007-05-08 15:19:08 +020016813 break;
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016814 default:
16815 alc_automute_amp_unsol_event(codec, res);
16816 break;
Kailang Yangbdd148a2007-05-08 15:19:08 +020016817 }
16818}
16819
Kailang Yang272a5272007-05-14 11:00:38 +020016820static struct hda_verb alc861vd_dallas_verbs[] = {
16821 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16822 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16823 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16824 {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
16825
16826 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16827 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
16828 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16829 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16830 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16831 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
16832 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
16833 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016834
Kailang Yang272a5272007-05-14 11:00:38 +020016835 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16836 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16837 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16838 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16839 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16840 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16841 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
16842 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
16843
16844 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16845 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16846 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
16847 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
16848 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16849 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16850 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16851 {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
16852
16853 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
16854 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
16855 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
16856 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
16857
16858 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
Kailang Yangea1fb292008-08-26 12:58:38 +020016859 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yang272a5272007-05-14 11:00:38 +020016860 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
16861
16862 { } /* end */
16863};
16864
16865/* toggle speaker-output according to the hp-jack state */
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016866static void alc861vd_dallas_setup(struct hda_codec *codec)
Kailang Yang272a5272007-05-14 11:00:38 +020016867{
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016868 struct alc_spec *spec = codec->spec;
Kailang Yang272a5272007-05-14 11:00:38 +020016869
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016870 spec->autocfg.hp_pins[0] = 0x15;
16871 spec->autocfg.speaker_pins[0] = 0x14;
Kailang Yang272a5272007-05-14 11:00:38 +020016872}
16873
Takashi Iwaicb53c622007-08-10 17:21:45 +020016874#ifdef CONFIG_SND_HDA_POWER_SAVE
16875#define alc861vd_loopbacks alc880_loopbacks
16876#endif
16877
Sasha Alexandrdef319f2009-06-16 16:00:15 -040016878/* pcm configuration: identical with ALC880 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016879#define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
16880#define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
16881#define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
16882#define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
16883
16884/*
16885 * configuration and preset
16886 */
Takashi Iwaiea734962011-01-17 11:29:34 +010016887static const char * const alc861vd_models[ALC861VD_MODEL_LAST] = {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016888 [ALC660VD_3ST] = "3stack-660",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016889 [ALC660VD_3ST_DIG] = "3stack-660-digout",
Takashi Iwai13c94742008-11-05 08:06:08 +010016890 [ALC660VD_ASUS_V1S] = "asus-v1s",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016891 [ALC861VD_3ST] = "3stack",
16892 [ALC861VD_3ST_DIG] = "3stack-digout",
16893 [ALC861VD_6ST_DIG] = "6stack-digout",
Kailang Yangbdd148a2007-05-08 15:19:08 +020016894 [ALC861VD_LENOVO] = "lenovo",
Kailang Yang272a5272007-05-14 11:00:38 +020016895 [ALC861VD_DALLAS] = "dallas",
Takashi Iwai983f8ae2007-08-15 16:44:04 +020016896 [ALC861VD_HP] = "hp",
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016897 [ALC861VD_AUTO] = "auto",
16898};
16899
16900static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016901 SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
16902 SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
Takashi Iwai07e038b2007-02-15 18:23:41 +010016903 SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020016904 /*SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),*/ /* auto */
Takashi Iwai13c94742008-11-05 08:06:08 +010016905 SND_PCI_QUIRK(0x1043, 0x1633, "Asus V1Sn", ALC660VD_ASUS_V1S),
Mike Crash6963f842007-06-25 12:12:51 +020016906 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016907 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
Takashi Iwaiac3e3742007-12-17 17:14:18 +010016908 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai38baf5a2007-08-16 17:52:43 +020016909 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
Takashi Iwaice577e82009-08-03 08:23:52 +020016910 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
Takashi Iwai542d7c62007-08-16 18:57:30 +020016911 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
Tobin Davisb419f342008-03-07 11:57:51 +010016912 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
Takashi Iwai39c5d412007-08-15 16:24:17 +020016913 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010016914 SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", ALC861VD_LENOVO),
Tobin Davis625dc0b2007-07-30 21:42:10 +020016915 SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016916 {}
16917};
16918
16919static struct alc_config_preset alc861vd_presets[] = {
16920 [ALC660VD_3ST] = {
16921 .mixers = { alc861vd_3st_mixer },
16922 .init_verbs = { alc861vd_volume_init_verbs,
16923 alc861vd_3stack_init_verbs },
16924 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16925 .dac_nids = alc660vd_dac_nids,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016926 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16927 .channel_mode = alc861vd_3stack_2ch_modes,
16928 .input_mux = &alc861vd_capture_source,
16929 },
Mike Crash6963f842007-06-25 12:12:51 +020016930 [ALC660VD_3ST_DIG] = {
16931 .mixers = { alc861vd_3st_mixer },
16932 .init_verbs = { alc861vd_volume_init_verbs,
16933 alc861vd_3stack_init_verbs },
16934 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16935 .dac_nids = alc660vd_dac_nids,
16936 .dig_out_nid = ALC861VD_DIGOUT_NID,
Mike Crash6963f842007-06-25 12:12:51 +020016937 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16938 .channel_mode = alc861vd_3stack_2ch_modes,
16939 .input_mux = &alc861vd_capture_source,
16940 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010016941 [ALC861VD_3ST] = {
16942 .mixers = { alc861vd_3st_mixer },
16943 .init_verbs = { alc861vd_volume_init_verbs,
16944 alc861vd_3stack_init_verbs },
16945 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16946 .dac_nids = alc861vd_dac_nids,
16947 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16948 .channel_mode = alc861vd_3stack_2ch_modes,
16949 .input_mux = &alc861vd_capture_source,
16950 },
16951 [ALC861VD_3ST_DIG] = {
16952 .mixers = { alc861vd_3st_mixer },
16953 .init_verbs = { alc861vd_volume_init_verbs,
16954 alc861vd_3stack_init_verbs },
16955 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16956 .dac_nids = alc861vd_dac_nids,
16957 .dig_out_nid = ALC861VD_DIGOUT_NID,
16958 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16959 .channel_mode = alc861vd_3stack_2ch_modes,
16960 .input_mux = &alc861vd_capture_source,
16961 },
16962 [ALC861VD_6ST_DIG] = {
16963 .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
16964 .init_verbs = { alc861vd_volume_init_verbs,
16965 alc861vd_6stack_init_verbs },
16966 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16967 .dac_nids = alc861vd_dac_nids,
16968 .dig_out_nid = ALC861VD_DIGOUT_NID,
16969 .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
16970 .channel_mode = alc861vd_6stack_modes,
16971 .input_mux = &alc861vd_capture_source,
16972 },
Kailang Yangbdd148a2007-05-08 15:19:08 +020016973 [ALC861VD_LENOVO] = {
16974 .mixers = { alc861vd_lenovo_mixer },
16975 .init_verbs = { alc861vd_volume_init_verbs,
16976 alc861vd_3stack_init_verbs,
16977 alc861vd_eapd_verbs,
16978 alc861vd_lenovo_unsol_verbs },
16979 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
16980 .dac_nids = alc660vd_dac_nids,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016981 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16982 .channel_mode = alc861vd_3stack_2ch_modes,
16983 .input_mux = &alc861vd_capture_source,
16984 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016985 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016986 .init_hook = alc861vd_lenovo_init_hook,
Kailang Yangbdd148a2007-05-08 15:19:08 +020016987 },
Kailang Yang272a5272007-05-14 11:00:38 +020016988 [ALC861VD_DALLAS] = {
16989 .mixers = { alc861vd_dallas_mixer },
16990 .init_verbs = { alc861vd_dallas_verbs },
16991 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
16992 .dac_nids = alc861vd_dac_nids,
Kailang Yang272a5272007-05-14 11:00:38 +020016993 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
16994 .channel_mode = alc861vd_3stack_2ch_modes,
16995 .input_mux = &alc861vd_dallas_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020016996 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020016997 .setup = alc861vd_dallas_setup,
16998 .init_hook = alc_automute_amp,
Kailang Yangd1a991a2007-08-15 16:21:59 +020016999 },
17000 [ALC861VD_HP] = {
17001 .mixers = { alc861vd_hp_mixer },
17002 .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
17003 .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
17004 .dac_nids = alc861vd_dac_nids,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017005 .dig_out_nid = ALC861VD_DIGOUT_NID,
Kailang Yangd1a991a2007-08-15 16:21:59 +020017006 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17007 .channel_mode = alc861vd_3stack_2ch_modes,
17008 .input_mux = &alc861vd_hp_capture_source,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017009 .unsol_event = alc_automute_amp_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017010 .setup = alc861vd_dallas_setup,
17011 .init_hook = alc_automute_amp,
Kailang Yangea1fb292008-08-26 12:58:38 +020017012 },
Takashi Iwai13c94742008-11-05 08:06:08 +010017013 [ALC660VD_ASUS_V1S] = {
17014 .mixers = { alc861vd_lenovo_mixer },
17015 .init_verbs = { alc861vd_volume_init_verbs,
17016 alc861vd_3stack_init_verbs,
17017 alc861vd_eapd_verbs,
17018 alc861vd_lenovo_unsol_verbs },
17019 .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
17020 .dac_nids = alc660vd_dac_nids,
17021 .dig_out_nid = ALC861VD_DIGOUT_NID,
17022 .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
17023 .channel_mode = alc861vd_3stack_2ch_modes,
17024 .input_mux = &alc861vd_capture_source,
17025 .unsol_event = alc861vd_lenovo_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017026 .setup = alc861vd_lenovo_setup,
Takashi Iwaia9fd4f32009-05-08 15:57:59 +020017027 .init_hook = alc861vd_lenovo_init_hook,
Takashi Iwai13c94742008-11-05 08:06:08 +010017028 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017029};
17030
17031/*
17032 * BIOS auto configuration
17033 */
Takashi Iwai05f5f472009-08-25 13:10:18 +020017034static int alc861vd_auto_create_input_ctls(struct hda_codec *codec,
17035 const struct auto_pin_cfg *cfg)
17036{
Herton Ronaldo Krzesinski71675942010-11-25 00:08:01 -020017037 return alc_auto_create_input_ctls(codec, cfg, 0x0b, 0x22, 0);
Takashi Iwai05f5f472009-08-25 13:10:18 +020017038}
17039
17040
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017041static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
17042 hda_nid_t nid, int pin_type, int dac_idx)
17043{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017044 alc_set_pin_output(codec, nid, pin_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017045}
17046
17047static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
17048{
17049 struct alc_spec *spec = codec->spec;
17050 int i;
17051
17052 for (i = 0; i <= HDA_SIDE; i++) {
17053 hda_nid_t nid = spec->autocfg.line_out_pins[i];
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017054 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017055 if (nid)
17056 alc861vd_auto_set_output_and_unmute(codec, nid,
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020017057 pin_type, i);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017058 }
17059}
17060
17061
17062static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
17063{
17064 struct alc_spec *spec = codec->spec;
17065 hda_nid_t pin;
17066
17067 pin = spec->autocfg.hp_pins[0];
Sasha Alexandrdef319f2009-06-16 16:00:15 -040017068 if (pin) /* connect to front and use dac 0 */
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017069 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017070 pin = spec->autocfg.speaker_pins[0];
17071 if (pin)
17072 alc861vd_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017073}
17074
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017075#define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
17076
17077static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
17078{
17079 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017080 struct auto_pin_cfg *cfg = &spec->autocfg;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017081 int i;
17082
Takashi Iwai66ceeb62010-08-30 13:05:52 +020017083 for (i = 0; i < cfg->num_inputs; i++) {
17084 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017085 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020017086 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwaie82c0252009-03-23 15:17:38 +010017087 if (nid != ALC861VD_PIN_CD_NID &&
17088 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017089 snd_hda_codec_write(codec, nid, 0,
17090 AC_VERB_SET_AMP_GAIN_MUTE,
17091 AMP_OUT_MUTE);
17092 }
17093 }
17094}
17095
Takashi Iwaif511b012008-08-15 16:46:42 +020017096#define alc861vd_auto_init_input_src alc882_auto_init_input_src
17097
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017098#define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
17099#define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
17100
17101/* add playback controls from the parsed DAC table */
Takashi Iwai569ed342011-01-19 10:14:46 +010017102/* Based on ALC880 version. But ALC861VD has separate,
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017103 * different NIDs for mute/unmute switch and volume control */
17104static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
17105 const struct auto_pin_cfg *cfg)
17106{
Takashi Iwaiea734962011-01-17 11:29:34 +010017107 static const char * const chname[4] = {
17108 "Front", "Surround", "CLFE", "Side"
17109 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017110 const char *pfx = alc_get_line_out_pfx(cfg, true);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017111 hda_nid_t nid_v, nid_s;
17112 int i, err;
17113
17114 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017115 if (!spec->multiout.dac_nids[i])
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017116 continue;
17117 nid_v = alc861vd_idx_to_mixer_vol(
17118 alc880_dac_to_idx(
17119 spec->multiout.dac_nids[i]));
17120 nid_s = alc861vd_idx_to_mixer_switch(
17121 alc880_dac_to_idx(
17122 spec->multiout.dac_nids[i]));
17123
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017124 if (!pfx && i == 2) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017125 /* Center/LFE */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017126 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17127 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017128 HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
17129 HDA_OUTPUT));
17130 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017131 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017132 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17133 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017134 HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
17135 HDA_OUTPUT));
17136 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017137 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017138 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17139 "Center",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017140 HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
17141 HDA_INPUT));
17142 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017143 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017144 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17145 "LFE",
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017146 HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
17147 HDA_INPUT));
17148 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017149 return err;
17150 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017151 const char *name = pfx;
17152 if (!name)
17153 name = chname[i];
17154 err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL,
17155 name, i,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017156 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
17157 HDA_OUTPUT));
17158 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017159 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010017160 err = __add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE,
17161 name, i,
Kailang Yangbdd148a2007-05-08 15:19:08 +020017162 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017163 HDA_INPUT));
17164 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017165 return err;
17166 }
17167 }
17168 return 0;
17169}
17170
17171/* add playback controls for speaker and HP outputs */
17172/* Based on ALC880 version. But ALC861VD has separate,
17173 * different NIDs for mute/unmute switch and volume control */
17174static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
17175 hda_nid_t pin, const char *pfx)
17176{
17177 hda_nid_t nid_v, nid_s;
17178 int err;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017179
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017180 if (!pin)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017181 return 0;
17182
17183 if (alc880_is_fixed_pin(pin)) {
17184 nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
17185 /* specify the DAC as the extra output */
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017186 if (!spec->multiout.hp_nid)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017187 spec->multiout.hp_nid = nid_v;
17188 else
17189 spec->multiout.extra_out_nid[0] = nid_v;
17190 /* control HP volume/switch on the output mixer amp */
17191 nid_v = alc861vd_idx_to_mixer_vol(
17192 alc880_fixed_pin_idx(pin));
17193 nid_s = alc861vd_idx_to_mixer_switch(
17194 alc880_fixed_pin_idx(pin));
17195
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017196 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017197 HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
17198 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017199 return err;
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017200 err = add_pb_sw_ctrl(spec, ALC_CTL_BIND_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017201 HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
17202 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017203 return err;
17204 } else if (alc880_is_multi_pin(pin)) {
17205 /* set manual connection */
17206 /* we have only a switch on HP-out PIN */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020017207 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017208 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
17209 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017210 return err;
17211 }
17212 return 0;
17213}
17214
17215/* parse the BIOS configuration and set up the alc_spec
17216 * return 1 if successful, 0 if the proper config is not found,
17217 * or a negative error code
17218 * Based on ALC880 version - had to change it to override
17219 * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
17220static int alc861vd_parse_auto_config(struct hda_codec *codec)
17221{
17222 struct alc_spec *spec = codec->spec;
17223 int err;
17224 static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
17225
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017226 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
17227 alc861vd_ignore);
17228 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017229 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017230 if (!spec->autocfg.line_outs)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017231 return 0; /* can't find valid BIOS pin config */
17232
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017233 err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
17234 if (err < 0)
17235 return err;
17236 err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
17237 if (err < 0)
17238 return err;
17239 err = alc861vd_auto_create_extra_out(spec,
17240 spec->autocfg.speaker_pins[0],
17241 "Speaker");
17242 if (err < 0)
17243 return err;
17244 err = alc861vd_auto_create_extra_out(spec,
17245 spec->autocfg.hp_pins[0],
17246 "Headphone");
17247 if (err < 0)
17248 return err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020017249 err = alc861vd_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017250 if (err < 0)
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017251 return err;
17252
17253 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
17254
Takashi Iwai757899a2010-07-30 10:48:14 +020017255 alc_auto_parse_digital(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017256
Takashi Iwai603c4012008-07-30 15:01:44 +020017257 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010017258 add_mixer(spec, spec->kctls.list);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017259
Takashi Iwaid88897e2008-10-31 15:01:37 +010017260 add_verb(spec, alc861vd_volume_init_verbs);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017261
17262 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020017263 spec->input_mux = &spec->private_imux[0];
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017264
Takashi Iwai776e1842007-08-29 15:07:11 +020017265 err = alc_auto_add_mic_boost(codec);
17266 if (err < 0)
17267 return err;
17268
Kailang Yang6227cdc2010-02-25 08:36:52 +010017269 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020017270
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017271 return 1;
17272}
17273
17274/* additional initialization for auto-configuration model */
17275static void alc861vd_auto_init(struct hda_codec *codec)
17276{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017277 struct alc_spec *spec = codec->spec;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017278 alc861vd_auto_init_multi_out(codec);
17279 alc861vd_auto_init_hp_out(codec);
17280 alc861vd_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020017281 alc861vd_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020017282 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010017283 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020017284 alc_inithook(codec);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017285}
17286
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017287enum {
17288 ALC660VD_FIX_ASUS_GPIO1
17289};
17290
17291/* reset GPIO1 */
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017292static const struct alc_fixup alc861vd_fixups[] = {
17293 [ALC660VD_FIX_ASUS_GPIO1] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017294 .type = ALC_FIXUP_VERBS,
17295 .v.verbs = (const struct hda_verb[]) {
Takashi Iwai73413b12010-08-30 09:39:57 +020017296 {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
17297 {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
17298 {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
17299 { }
17300 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017301 },
17302};
17303
17304static struct snd_pci_quirk alc861vd_fixup_tbl[] = {
17305 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
17306 {}
17307};
17308
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017309static int patch_alc861vd(struct hda_codec *codec)
17310{
17311 struct alc_spec *spec;
17312 int err, board_config;
17313
17314 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
17315 if (spec == NULL)
17316 return -ENOMEM;
17317
17318 codec->spec = spec;
17319
17320 board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
17321 alc861vd_models,
17322 alc861vd_cfg_tbl);
17323
17324 if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020017325 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
17326 codec->chip_name);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017327 board_config = ALC861VD_AUTO;
17328 }
17329
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017330 if (board_config == ALC861VD_AUTO) {
17331 alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
17332 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
17333 }
Takashi Iwaif8f25ba2009-10-06 08:31:29 +020017334
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017335 if (board_config == ALC861VD_AUTO) {
17336 /* automatic parse from the BIOS config */
17337 err = alc861vd_parse_auto_config(codec);
17338 if (err < 0) {
17339 alc_free(codec);
17340 return err;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020017341 } else if (!err) {
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017342 printk(KERN_INFO
17343 "hda_codec: Cannot set up configuration "
17344 "from BIOS. Using base mode...\n");
17345 board_config = ALC861VD_3ST;
17346 }
17347 }
17348
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090017349 err = snd_hda_attach_beep_device(codec, 0x23);
17350 if (err < 0) {
17351 alc_free(codec);
17352 return err;
17353 }
17354
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017355 if (board_config != ALC861VD_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020017356 setup_preset(codec, &alc861vd_presets[board_config]);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017357
Kailang Yang2f893282008-05-27 12:14:47 +020017358 if (codec->vendor_id == 0x10ec0660) {
Kailang Yangf9423e72008-05-27 12:32:25 +020017359 /* always turn on EAPD */
Takashi Iwaid88897e2008-10-31 15:01:37 +010017360 add_verb(spec, alc660vd_eapd_verbs);
Kailang Yang2f893282008-05-27 12:14:47 +020017361 }
17362
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017363 spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
17364 spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
17365
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017366 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
17367 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
17368
Takashi Iwaidd704692009-08-11 08:45:11 +020017369 if (!spec->adc_nids) {
17370 spec->adc_nids = alc861vd_adc_nids;
17371 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
17372 }
17373 if (!spec->capsrc_nids)
17374 spec->capsrc_nids = alc861vd_capsrc_nids;
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017375
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017376 set_capture_mixer(codec);
Takashi Iwai45bdd1c2009-02-06 16:11:25 +010017377 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017378
Takashi Iwai2134ea42008-01-10 16:53:55 +010017379 spec->vmaster_nid = 0x02;
17380
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010017381 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
Takashi Iwai7fa90e82010-04-12 08:49:00 +020017382
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017383 codec->patch_ops = alc_patch_ops;
17384
17385 if (board_config == ALC861VD_AUTO)
17386 spec->init_hook = alc861vd_auto_init;
Takashi Iwaicb53c622007-08-10 17:21:45 +020017387#ifdef CONFIG_SND_HDA_POWER_SAVE
17388 if (!spec->loopback.amplist)
17389 spec->loopback.amplist = alc861vd_loopbacks;
17390#endif
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010017391
17392 return 0;
17393}
17394
17395/*
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017396 * ALC662 support
17397 *
17398 * ALC662 is almost identical with ALC880 but has cleaner and more flexible
17399 * configuration. Each pin widget can choose any input DACs and a mixer.
17400 * Each ADC is connected from a mixer of all inputs. This makes possible
17401 * 6-channel independent captures.
17402 *
17403 * In addition, an independent DAC for the multi-playback (not used in this
17404 * driver yet).
17405 */
17406#define ALC662_DIGOUT_NID 0x06
17407#define ALC662_DIGIN_NID 0x0a
17408
17409static hda_nid_t alc662_dac_nids[4] = {
17410 /* front, rear, clfe, rear_surr */
17411 0x02, 0x03, 0x04
17412};
17413
Kailang Yang622e84c2009-04-21 07:39:04 +020017414static hda_nid_t alc272_dac_nids[2] = {
17415 0x02, 0x03
17416};
17417
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017418static hda_nid_t alc662_adc_nids[2] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017419 /* ADC1-2 */
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017420 0x09, 0x08
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017421};
Takashi Iwaie1406342008-02-11 18:32:32 +010017422
Kailang Yang622e84c2009-04-21 07:39:04 +020017423static hda_nid_t alc272_adc_nids[1] = {
17424 /* ADC1-2 */
17425 0x08,
17426};
17427
Takashi Iwaib59bdf32009-08-11 09:47:30 +020017428static hda_nid_t alc662_capsrc_nids[2] = { 0x22, 0x23 };
Kailang Yang622e84c2009-04-21 07:39:04 +020017429static hda_nid_t alc272_capsrc_nids[1] = { 0x23 };
17430
Takashi Iwaie1406342008-02-11 18:32:32 +010017431
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017432/* input MUX */
17433/* FIXME: should be a matrix-type input source selection */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017434static struct hda_input_mux alc662_capture_source = {
17435 .num_items = 4,
17436 .items = {
17437 { "Mic", 0x0 },
17438 { "Front Mic", 0x1 },
17439 { "Line", 0x2 },
17440 { "CD", 0x4 },
17441 },
17442};
17443
17444static struct hda_input_mux alc662_lenovo_101e_capture_source = {
17445 .num_items = 2,
17446 .items = {
17447 { "Mic", 0x1 },
17448 { "Line", 0x2 },
17449 },
17450};
Kailang Yang291702f2007-10-16 14:28:03 +020017451
Kailang Yang6dda9f42008-05-27 12:05:31 +020017452static struct hda_input_mux alc663_capture_source = {
17453 .num_items = 3,
17454 .items = {
17455 { "Mic", 0x0 },
17456 { "Front Mic", 0x1 },
17457 { "Line", 0x2 },
17458 },
17459};
17460
Takashi Iwai4f5d17062009-08-11 18:17:46 +020017461#if 0 /* set to 1 for testing other input sources below */
Chris Pockelé9541ba12009-05-12 08:08:53 +020017462static struct hda_input_mux alc272_nc10_capture_source = {
17463 .num_items = 16,
17464 .items = {
17465 { "Autoselect Mic", 0x0 },
17466 { "Internal Mic", 0x1 },
17467 { "In-0x02", 0x2 },
17468 { "In-0x03", 0x3 },
17469 { "In-0x04", 0x4 },
17470 { "In-0x05", 0x5 },
17471 { "In-0x06", 0x6 },
17472 { "In-0x07", 0x7 },
17473 { "In-0x08", 0x8 },
17474 { "In-0x09", 0x9 },
17475 { "In-0x0a", 0x0a },
17476 { "In-0x0b", 0x0b },
17477 { "In-0x0c", 0x0c },
17478 { "In-0x0d", 0x0d },
17479 { "In-0x0e", 0x0e },
17480 { "In-0x0f", 0x0f },
17481 },
17482};
17483#endif
17484
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017485/*
17486 * 2ch mode
17487 */
17488static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
17489 { 2, NULL }
17490};
17491
17492/*
17493 * 2ch mode
17494 */
17495static struct hda_verb alc662_3ST_ch2_init[] = {
17496 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
17497 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17498 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
17499 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
17500 { } /* end */
17501};
17502
17503/*
17504 * 6ch mode
17505 */
17506static struct hda_verb alc662_3ST_ch6_init[] = {
17507 { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17508 { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17509 { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
17510 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17511 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
17512 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
17513 { } /* end */
17514};
17515
17516static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
17517 { 2, alc662_3ST_ch2_init },
17518 { 6, alc662_3ST_ch6_init },
17519};
17520
17521/*
17522 * 2ch mode
17523 */
17524static struct hda_verb alc662_sixstack_ch6_init[] = {
17525 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17526 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
17527 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17528 { } /* end */
17529};
17530
17531/*
17532 * 6ch mode
17533 */
17534static struct hda_verb alc662_sixstack_ch8_init[] = {
17535 { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17536 { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17537 { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
17538 { } /* end */
17539};
17540
17541static struct hda_channel_mode alc662_5stack_modes[2] = {
17542 { 2, alc662_sixstack_ch6_init },
17543 { 6, alc662_sixstack_ch8_init },
17544};
17545
17546/* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
17547 * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
17548 */
17549
17550static struct snd_kcontrol_new alc662_base_mixer[] = {
17551 /* output mixer control */
17552 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017553 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017554 HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017555 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017556 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17557 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017558 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17559 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017560 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17561
17562 /*Input mixer control */
17563 HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
17564 HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
17565 HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
17566 HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
17567 HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
17568 HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
17569 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
17570 HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017571 { } /* end */
17572};
17573
17574static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
17575 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017576 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017577 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17578 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17579 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17580 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17581 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17582 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17583 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17584 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17585 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017586 { } /* end */
17587};
17588
17589static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
17590 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017591 HDA_CODEC_MUTE("Front Playback Switch", 0x0c, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017592 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017593 HDA_CODEC_MUTE("Surround Playback Switch", 0x0d, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017594 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17595 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Herton Ronaldo Krzesinski7055ad82008-03-14 12:52:20 +010017596 HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x0e, 1, 0x0, HDA_INPUT),
17597 HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 0x0, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017598 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17599 HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
17600 HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
17601 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17602 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17603 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17604 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17605 HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17606 HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017607 { } /* end */
17608};
17609
17610static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
17611 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17612 HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
Takashi Iwai86cd9292008-01-28 18:09:56 +010017613 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17614 HDA_BIND_MUTE("Speaker Playback Switch", 0x03, 2, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017615 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17616 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17617 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17618 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17619 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017620 { } /* end */
17621};
17622
Kailang Yang291702f2007-10-16 14:28:03 +020017623static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017624 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17625 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yang291702f2007-10-16 14:28:03 +020017626
David Henningsson5f99f862011-01-04 15:24:24 +010017627 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017628 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17629 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017630
David Henningsson5f99f862011-01-04 15:24:24 +010017631 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017632 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17633 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang291702f2007-10-16 14:28:03 +020017634 { } /* end */
17635};
17636
Kailang Yang8c427222008-01-10 13:03:59 +010017637static struct snd_kcontrol_new alc662_eeepc_ep20_mixer[] = {
Takashi Iwai42171c12009-05-08 14:11:43 +020017638 ALC262_HIPPO_MASTER_SWITCH,
17639 HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017640 HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017641 HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
17642 HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
Kailang Yang8c427222008-01-10 13:03:59 +010017643 HDA_BIND_MUTE("MuteCtrl Playback Switch", 0x0c, 2, HDA_INPUT),
17644 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17645 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17646 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17647 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17648 { } /* end */
17649};
17650
Kailang Yangf1d4e282008-08-26 14:03:29 +020017651static struct hda_bind_ctls alc663_asus_bind_master_vol = {
17652 .ops = &snd_hda_bind_vol,
17653 .values = {
17654 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17655 HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
17656 0
17657 },
17658};
17659
17660static struct hda_bind_ctls alc663_asus_one_bind_switch = {
17661 .ops = &snd_hda_bind_sw,
17662 .values = {
17663 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17664 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17665 0
17666 },
17667};
17668
Kailang Yang6dda9f42008-05-27 12:05:31 +020017669static struct snd_kcontrol_new alc663_m51va_mixer[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017670 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17671 HDA_BIND_SW("Master Playback Switch", &alc663_asus_one_bind_switch),
17672 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17673 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17674 { } /* end */
17675};
17676
17677static struct hda_bind_ctls alc663_asus_tree_bind_switch = {
17678 .ops = &snd_hda_bind_sw,
17679 .values = {
17680 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17681 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17682 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17683 0
17684 },
17685};
17686
17687static struct snd_kcontrol_new alc663_two_hp_m1_mixer[] = {
17688 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17689 HDA_BIND_SW("Master Playback Switch", &alc663_asus_tree_bind_switch),
17690 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17691 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17692 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17693 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17694
17695 { } /* end */
17696};
17697
17698static struct hda_bind_ctls alc663_asus_four_bind_switch = {
17699 .ops = &snd_hda_bind_sw,
17700 .values = {
17701 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17702 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17703 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17704 0
17705 },
17706};
17707
17708static struct snd_kcontrol_new alc663_two_hp_m2_mixer[] = {
17709 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17710 HDA_BIND_SW("Master Playback Switch", &alc663_asus_four_bind_switch),
17711 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17712 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17713 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17714 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17715 { } /* end */
17716};
17717
17718static struct snd_kcontrol_new alc662_1bjd_mixer[] = {
Kailang Yang6dda9f42008-05-27 12:05:31 +020017719 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17720 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017721 HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17722 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17723 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17724 HDA_CODEC_VOLUME("F-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17725 HDA_CODEC_MUTE("F-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17726 { } /* end */
17727};
17728
17729static struct hda_bind_ctls alc663_asus_two_bind_master_vol = {
17730 .ops = &snd_hda_bind_vol,
17731 .values = {
17732 HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
17733 HDA_COMPOSE_AMP_VAL(0x04, 3, 0, HDA_OUTPUT),
17734 0
17735 },
17736};
17737
17738static struct hda_bind_ctls alc663_asus_two_bind_switch = {
17739 .ops = &snd_hda_bind_sw,
17740 .values = {
17741 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17742 HDA_COMPOSE_AMP_VAL(0x16, 3, 0, HDA_OUTPUT),
17743 0
17744 },
17745};
17746
17747static struct snd_kcontrol_new alc663_asus_21jd_clfe_mixer[] = {
17748 HDA_BIND_VOL("Master Playback Volume",
17749 &alc663_asus_two_bind_master_vol),
17750 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17751 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017752 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17753 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17754 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020017755 { } /* end */
17756};
17757
17758static struct snd_kcontrol_new alc663_asus_15jd_clfe_mixer[] = {
17759 HDA_BIND_VOL("Master Playback Volume", &alc663_asus_bind_master_vol),
17760 HDA_BIND_SW("Master Playback Switch", &alc663_asus_two_bind_switch),
17761 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17762 HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17763 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17764 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017765 { } /* end */
17766};
17767
17768static struct snd_kcontrol_new alc663_g71v_mixer[] = {
17769 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17770 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17771 HDA_CODEC_VOLUME("Front Playback Volume", 0x03, 0x0, HDA_OUTPUT),
17772 HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17773 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17774
17775 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17776 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017777 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17778 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017779 { } /* end */
17780};
17781
17782static struct snd_kcontrol_new alc663_g50v_mixer[] = {
17783 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
17784 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
17785 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17786
17787 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17788 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010017789 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17790 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yang6dda9f42008-05-27 12:05:31 +020017791 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
17792 HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
17793 { } /* end */
17794};
17795
Kailang Yangebb83ee2009-12-17 12:23:00 +010017796static struct hda_bind_ctls alc663_asus_mode7_8_all_bind_switch = {
17797 .ops = &snd_hda_bind_sw,
17798 .values = {
17799 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17800 HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
17801 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17802 HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
17803 HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
17804 0
17805 },
17806};
17807
17808static struct hda_bind_ctls alc663_asus_mode7_8_sp_bind_switch = {
17809 .ops = &snd_hda_bind_sw,
17810 .values = {
17811 HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
17812 HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_OUTPUT),
17813 0
17814 },
17815};
17816
17817static struct snd_kcontrol_new alc663_mode7_mixer[] = {
17818 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17819 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17820 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17821 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
17822 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17823 HDA_CODEC_VOLUME("IntMic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17824 HDA_CODEC_MUTE("IntMic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17825 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
17826 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
17827 { } /* end */
17828};
17829
17830static struct snd_kcontrol_new alc663_mode8_mixer[] = {
17831 HDA_BIND_SW("Master Playback Switch", &alc663_asus_mode7_8_all_bind_switch),
17832 HDA_BIND_VOL("Speaker Playback Volume", &alc663_asus_bind_master_vol),
17833 HDA_BIND_SW("Speaker Playback Switch", &alc663_asus_mode7_8_sp_bind_switch),
17834 HDA_CODEC_MUTE("Headphone1 Playback Switch", 0x15, 0x0, HDA_OUTPUT),
17835 HDA_CODEC_MUTE("Headphone2 Playback Switch", 0x21, 0x0, HDA_OUTPUT),
17836 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
17837 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
17838 { } /* end */
17839};
17840
17841
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017842static struct snd_kcontrol_new alc662_chmode_mixer[] = {
17843 {
17844 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
17845 .name = "Channel Mode",
17846 .info = alc_ch_mode_info,
17847 .get = alc_ch_mode_get,
17848 .put = alc_ch_mode_put,
17849 },
17850 { } /* end */
17851};
17852
17853static struct hda_verb alc662_init_verbs[] = {
17854 /* ADC: mute amp left and right */
17855 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17856 {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017857
Kailang Yangb60dd392007-09-20 12:50:29 +020017858 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17859 {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17860 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17861 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17862 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17863 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017864
17865 /* Front Pin: output 0 (0x0c) */
17866 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17867 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17868
17869 /* Rear Pin: output 1 (0x0d) */
17870 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17871 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17872
17873 /* CLFE Pin: output 2 (0x0e) */
17874 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17875 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17876
17877 /* Mic (rear) pin: input vref at 80% */
17878 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17879 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17880 /* Front Mic pin: input vref at 80% */
17881 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
17882 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17883 /* Line In pin: input */
17884 {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17885 {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17886 /* Line-2 In: Headphone output (output 0 - 0x0c) */
17887 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17888 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17889 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
17890 /* CD pin widget for input */
17891 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17892
17893 /* FIXME: use matrix-type input source selection */
17894 /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
17895 /* Input mixer */
17896 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang291702f2007-10-16 14:28:03 +020017897 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017898
17899 /* always trun on EAPD */
17900 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
17901 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
17902
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017903 { }
17904};
17905
Kailang Yangcec27c82010-02-04 14:18:18 +010017906static struct hda_verb alc663_init_verbs[] = {
17907 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17908 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17909 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17910 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17911 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17912 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17913 { }
17914};
17915
17916static struct hda_verb alc272_init_verbs[] = {
17917 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17918 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
17919 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17920 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17921 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17922 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17923 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
17924 {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17925 { }
17926};
17927
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017928static struct hda_verb alc662_sue_init_verbs[] = {
17929 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
17930 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
Kailang Yang291702f2007-10-16 14:28:03 +020017931 {}
17932};
17933
17934static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
17935 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17936 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17937 {}
Kailang Yangbc9f98a2007-04-12 13:06:07 +020017938};
17939
Kailang Yang8c427222008-01-10 13:03:59 +010017940/* Set Unsolicited Event*/
17941static struct hda_verb alc662_eeepc_ep20_sue_init_verbs[] = {
17942 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
17943 {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17944 {}
17945};
17946
Kailang Yang6dda9f42008-05-27 12:05:31 +020017947static struct hda_verb alc663_m51va_init_verbs[] = {
Kailang Yangf1d4e282008-08-26 14:03:29 +020017948 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17949 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017950 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17951 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangf1d4e282008-08-26 14:03:29 +020017952 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17953 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17954 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
Kailang Yang6dda9f42008-05-27 12:05:31 +020017955 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17956 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17957 {}
17958};
17959
Kailang Yangf1d4e282008-08-26 14:03:29 +020017960static struct hda_verb alc663_21jd_amic_init_verbs[] = {
17961 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17962 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17963 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17964 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17965 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17966 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17967 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17968 {}
17969};
17970
17971static struct hda_verb alc662_1bjd_amic_init_verbs[] = {
17972 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
17973 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17974 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17975 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
17976 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17977 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17978 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17979 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17980 {}
17981};
17982
17983static struct hda_verb alc663_15jd_amic_init_verbs[] = {
17984 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
17985 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
17986 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
17987 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
17988 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
17989 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
17990 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
17991 {}
17992};
17993
17994static struct hda_verb alc663_two_hp_amic_m1_init_verbs[] = {
17995 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
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, 0x0}, /* Headphone */
17999 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18000 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18001 {0x15, AC_VERB_SET_CONNECT_SEL, 0x0}, /* Headphone */
18002 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18003 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18004 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18005 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18006 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18007 {}
18008};
18009
18010static struct hda_verb alc663_two_hp_amic_m2_init_verbs[] = {
18011 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18012 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18013 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18014 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18015 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18016 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18017 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18018 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18019 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
18020 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18021 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18022 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18023 {}
18024};
18025
Kailang Yang6dda9f42008-05-27 12:05:31 +020018026static struct hda_verb alc663_g71v_init_verbs[] = {
18027 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18028 /* {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
18029 /* {0x15, AC_VERB_SET_CONNECT_SEL, 0x01}, */ /* Headphone */
18030
18031 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18032 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18033 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18034
18035 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
18036 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_MIC_EVENT},
18037 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
18038 {}
18039};
18040
18041static struct hda_verb alc663_g50v_init_verbs[] = {
18042 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18043 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18044 {0x21, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Headphone */
18045
18046 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18047 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18048 {}
18049};
18050
Kailang Yangf1d4e282008-08-26 14:03:29 +020018051static struct hda_verb alc662_ecs_init_verbs[] = {
18052 {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0x701f},
18053 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18054 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18055 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18056 {}
18057};
18058
Kailang Yang622e84c2009-04-21 07:39:04 +020018059static struct hda_verb alc272_dell_zm1_init_verbs[] = {
18060 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18061 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18062 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18063 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18064 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18065 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18066 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18067 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18068 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18069 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18070 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18071 {}
18072};
18073
18074static struct hda_verb alc272_dell_init_verbs[] = {
18075 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18076 {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18077 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18078 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18079 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18080 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18081 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18082 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18083 {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18084 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18085 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18086 {}
18087};
18088
Kailang Yangebb83ee2009-12-17 12:23:00 +010018089static struct hda_verb alc663_mode7_init_verbs[] = {
18090 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18091 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18092 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18093 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18094 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18095 {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18096 {0x1b, AC_VERB_SET_CONNECT_SEL, 0x01},
18097 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18098 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18099 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18100 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18101 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18102 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18103 {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18104 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18105 {}
18106};
18107
18108static struct hda_verb alc663_mode8_init_verbs[] = {
18109 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18110 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18111 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18112 {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
18113 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18114 {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
18115 {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18116 {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
18117 {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
18118 {0x21, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
18119 {0x21, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Headphone */
18120 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
18121 {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(9)},
18122 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18123 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
18124 {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
18125 {}
18126};
18127
Kailang Yangf1d4e282008-08-26 14:03:29 +020018128static struct snd_kcontrol_new alc662_auto_capture_mixer[] = {
18129 HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
18130 HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
18131 { } /* end */
18132};
18133
Kailang Yang622e84c2009-04-21 07:39:04 +020018134static struct snd_kcontrol_new alc272_auto_capture_mixer[] = {
18135 HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
18136 HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
18137 { } /* end */
18138};
18139
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018140static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
18141{
18142 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018143 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018144
Wu Fengguang864f92b2009-11-18 12:38:02 +080018145 present = snd_hda_jack_detect(codec, 0x14);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018146 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018147
Takashi Iwai47fd8302007-08-10 17:11:07 +020018148 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18149 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018150}
18151
18152static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
18153{
18154 unsigned int present;
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018155 unsigned char bits;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018156
Wu Fengguang864f92b2009-11-18 12:38:02 +080018157 present = snd_hda_jack_detect(codec, 0x1b);
Takashi Iwai47fd8302007-08-10 17:11:07 +020018158 bits = present ? HDA_AMP_MUTE : 0;
Wu Fengguang864f92b2009-11-18 12:38:02 +080018159
Takashi Iwai47fd8302007-08-10 17:11:07 +020018160 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18161 HDA_AMP_MUTE, bits);
18162 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18163 HDA_AMP_MUTE, bits);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018164}
18165
18166static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
18167 unsigned int res)
18168{
18169 if ((res >> 26) == ALC880_HP_EVENT)
18170 alc662_lenovo_101e_all_automute(codec);
18171 if ((res >> 26) == ALC880_FRONT_EVENT)
18172 alc662_lenovo_101e_ispeaker_automute(codec);
18173}
18174
Kailang Yang291702f2007-10-16 14:28:03 +020018175/* unsolicited event for HP jack sensing */
18176static void alc662_eeepc_unsol_event(struct hda_codec *codec,
18177 unsigned int res)
18178{
Kailang Yang291702f2007-10-16 14:28:03 +020018179 if ((res >> 26) == ALC880_MIC_EVENT)
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018180 alc_mic_automute(codec);
Takashi Iwai42171c12009-05-08 14:11:43 +020018181 else
18182 alc262_hippo_unsol_event(codec, res);
Kailang Yang291702f2007-10-16 14:28:03 +020018183}
18184
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018185static void alc662_eeepc_setup(struct hda_codec *codec)
Kailang Yang291702f2007-10-16 14:28:03 +020018186{
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018187 struct alc_spec *spec = codec->spec;
18188
18189 alc262_hippo1_setup(codec);
18190 spec->ext_mic.pin = 0x18;
18191 spec->ext_mic.mux_idx = 0;
18192 spec->int_mic.pin = 0x19;
18193 spec->int_mic.mux_idx = 1;
18194 spec->auto_mic = 1;
Kailang Yang291702f2007-10-16 14:28:03 +020018195}
18196
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018197static void alc662_eeepc_inithook(struct hda_codec *codec)
18198{
18199 alc262_hippo_automute(codec);
18200 alc_mic_automute(codec);
18201}
18202
18203static void alc662_eeepc_ep20_setup(struct hda_codec *codec)
Kailang Yang8c427222008-01-10 13:03:59 +010018204{
Takashi Iwai42171c12009-05-08 14:11:43 +020018205 struct alc_spec *spec = codec->spec;
18206
18207 spec->autocfg.hp_pins[0] = 0x14;
18208 spec->autocfg.speaker_pins[0] = 0x1b;
Kailang Yang8c427222008-01-10 13:03:59 +010018209}
18210
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018211#define alc662_eeepc_ep20_inithook alc262_hippo_master_update
18212
Kailang Yang6dda9f42008-05-27 12:05:31 +020018213static void alc663_m51va_speaker_automute(struct hda_codec *codec)
18214{
18215 unsigned int present;
18216 unsigned char bits;
18217
Wu Fengguang864f92b2009-11-18 12:38:02 +080018218 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018219 bits = present ? HDA_AMP_MUTE : 0;
Kailang Yangf1d4e282008-08-26 14:03:29 +020018220 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018221 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018222 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018223 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018224}
18225
18226static void alc663_21jd_two_speaker_automute(struct hda_codec *codec)
18227{
18228 unsigned int present;
18229 unsigned char bits;
18230
Wu Fengguang864f92b2009-11-18 12:38:02 +080018231 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018232 bits = present ? HDA_AMP_MUTE : 0;
18233 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018234 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018235 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018236 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018237 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018238 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018239 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018240 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018241}
18242
18243static void alc663_15jd_two_speaker_automute(struct hda_codec *codec)
18244{
18245 unsigned int present;
18246 unsigned char bits;
18247
Wu Fengguang864f92b2009-11-18 12:38:02 +080018248 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018249 bits = present ? HDA_AMP_MUTE : 0;
18250 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018251 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018252 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018253 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018254 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018255 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018256 snd_hda_codec_amp_stereo(codec, 0x0e, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018257 HDA_AMP_MUTE, bits);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018258}
18259
18260static void alc662_f5z_speaker_automute(struct hda_codec *codec)
18261{
18262 unsigned int present;
18263 unsigned char bits;
18264
Wu Fengguang864f92b2009-11-18 12:38:02 +080018265 present = snd_hda_jack_detect(codec, 0x1b);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018266 bits = present ? 0 : PIN_OUT;
18267 snd_hda_codec_write(codec, 0x14, 0,
18268 AC_VERB_SET_PIN_WIDGET_CONTROL, bits);
18269}
18270
18271static void alc663_two_hp_m1_speaker_automute(struct hda_codec *codec)
18272{
18273 unsigned int present1, present2;
18274
Wu Fengguang864f92b2009-11-18 12:38:02 +080018275 present1 = snd_hda_jack_detect(codec, 0x21);
18276 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018277
18278 if (present1 || present2) {
18279 snd_hda_codec_write_cache(codec, 0x14, 0,
18280 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18281 } else {
18282 snd_hda_codec_write_cache(codec, 0x14, 0,
18283 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18284 }
18285}
18286
18287static void alc663_two_hp_m2_speaker_automute(struct hda_codec *codec)
18288{
18289 unsigned int present1, present2;
18290
Wu Fengguang864f92b2009-11-18 12:38:02 +080018291 present1 = snd_hda_jack_detect(codec, 0x1b);
18292 present2 = snd_hda_jack_detect(codec, 0x15);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018293
18294 if (present1 || present2) {
18295 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018296 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018297 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018298 HDA_AMP_MUTE, HDA_AMP_MUTE);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018299 } else {
18300 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 0,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018301 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018302 snd_hda_codec_amp_stereo(codec, 0x0c, HDA_INPUT, 1,
Takashi Iwai5dbd5ec2010-03-29 09:16:24 +020018303 HDA_AMP_MUTE, 0);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018304 }
Kailang Yang6dda9f42008-05-27 12:05:31 +020018305}
18306
Kailang Yangebb83ee2009-12-17 12:23:00 +010018307static void alc663_two_hp_m7_speaker_automute(struct hda_codec *codec)
18308{
18309 unsigned int present1, present2;
18310
18311 present1 = snd_hda_codec_read(codec, 0x1b, 0,
18312 AC_VERB_GET_PIN_SENSE, 0)
18313 & AC_PINSENSE_PRESENCE;
18314 present2 = snd_hda_codec_read(codec, 0x21, 0,
18315 AC_VERB_GET_PIN_SENSE, 0)
18316 & AC_PINSENSE_PRESENCE;
18317
18318 if (present1 || present2) {
18319 snd_hda_codec_write_cache(codec, 0x14, 0,
18320 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18321 snd_hda_codec_write_cache(codec, 0x17, 0,
18322 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18323 } else {
18324 snd_hda_codec_write_cache(codec, 0x14, 0,
18325 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18326 snd_hda_codec_write_cache(codec, 0x17, 0,
18327 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18328 }
18329}
18330
18331static void alc663_two_hp_m8_speaker_automute(struct hda_codec *codec)
18332{
18333 unsigned int present1, present2;
18334
18335 present1 = snd_hda_codec_read(codec, 0x21, 0,
18336 AC_VERB_GET_PIN_SENSE, 0)
18337 & AC_PINSENSE_PRESENCE;
18338 present2 = snd_hda_codec_read(codec, 0x15, 0,
18339 AC_VERB_GET_PIN_SENSE, 0)
18340 & AC_PINSENSE_PRESENCE;
18341
18342 if (present1 || present2) {
18343 snd_hda_codec_write_cache(codec, 0x14, 0,
18344 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18345 snd_hda_codec_write_cache(codec, 0x17, 0,
18346 AC_VERB_SET_PIN_WIDGET_CONTROL, 0);
18347 } else {
18348 snd_hda_codec_write_cache(codec, 0x14, 0,
18349 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18350 snd_hda_codec_write_cache(codec, 0x17, 0,
18351 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
18352 }
18353}
18354
Kailang Yang6dda9f42008-05-27 12:05:31 +020018355static void alc663_m51va_unsol_event(struct hda_codec *codec,
18356 unsigned int res)
18357{
18358 switch (res >> 26) {
18359 case ALC880_HP_EVENT:
18360 alc663_m51va_speaker_automute(codec);
18361 break;
18362 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018363 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018364 break;
18365 }
18366}
18367
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018368static void alc663_m51va_setup(struct hda_codec *codec)
18369{
18370 struct alc_spec *spec = codec->spec;
18371 spec->ext_mic.pin = 0x18;
18372 spec->ext_mic.mux_idx = 0;
18373 spec->int_mic.pin = 0x12;
Kailang Yangebb83ee2009-12-17 12:23:00 +010018374 spec->int_mic.mux_idx = 9;
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018375 spec->auto_mic = 1;
18376}
18377
Kailang Yang6dda9f42008-05-27 12:05:31 +020018378static void alc663_m51va_inithook(struct hda_codec *codec)
18379{
18380 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018381 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018382}
18383
Kailang Yangf1d4e282008-08-26 14:03:29 +020018384/* ***************** Mode1 ******************************/
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018385#define alc663_mode1_unsol_event alc663_m51va_unsol_event
Kailang Yangebb83ee2009-12-17 12:23:00 +010018386
18387static void alc663_mode1_setup(struct hda_codec *codec)
18388{
18389 struct alc_spec *spec = codec->spec;
18390 spec->ext_mic.pin = 0x18;
18391 spec->ext_mic.mux_idx = 0;
18392 spec->int_mic.pin = 0x19;
18393 spec->int_mic.mux_idx = 1;
18394 spec->auto_mic = 1;
18395}
18396
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018397#define alc663_mode1_inithook alc663_m51va_inithook
Kailang Yangf1d4e282008-08-26 14:03:29 +020018398
Kailang Yangf1d4e282008-08-26 14:03:29 +020018399/* ***************** Mode2 ******************************/
18400static void alc662_mode2_unsol_event(struct hda_codec *codec,
18401 unsigned int res)
18402{
18403 switch (res >> 26) {
18404 case ALC880_HP_EVENT:
18405 alc662_f5z_speaker_automute(codec);
18406 break;
18407 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018408 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018409 break;
18410 }
18411}
18412
Kailang Yangebb83ee2009-12-17 12:23:00 +010018413#define alc662_mode2_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018414
Kailang Yangf1d4e282008-08-26 14:03:29 +020018415static void alc662_mode2_inithook(struct hda_codec *codec)
18416{
18417 alc662_f5z_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018418 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018419}
18420/* ***************** Mode3 ******************************/
18421static void alc663_mode3_unsol_event(struct hda_codec *codec,
18422 unsigned int res)
18423{
18424 switch (res >> 26) {
18425 case ALC880_HP_EVENT:
18426 alc663_two_hp_m1_speaker_automute(codec);
18427 break;
18428 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018429 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018430 break;
18431 }
18432}
18433
Kailang Yangebb83ee2009-12-17 12:23:00 +010018434#define alc663_mode3_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018435
Kailang Yangf1d4e282008-08-26 14:03:29 +020018436static void alc663_mode3_inithook(struct hda_codec *codec)
18437{
18438 alc663_two_hp_m1_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018439 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018440}
18441/* ***************** Mode4 ******************************/
18442static void alc663_mode4_unsol_event(struct hda_codec *codec,
18443 unsigned int res)
18444{
18445 switch (res >> 26) {
18446 case ALC880_HP_EVENT:
18447 alc663_21jd_two_speaker_automute(codec);
18448 break;
18449 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018450 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018451 break;
18452 }
18453}
18454
Kailang Yangebb83ee2009-12-17 12:23:00 +010018455#define alc663_mode4_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018456
Kailang Yangf1d4e282008-08-26 14:03:29 +020018457static void alc663_mode4_inithook(struct hda_codec *codec)
18458{
18459 alc663_21jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018460 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018461}
18462/* ***************** Mode5 ******************************/
18463static void alc663_mode5_unsol_event(struct hda_codec *codec,
18464 unsigned int res)
18465{
18466 switch (res >> 26) {
18467 case ALC880_HP_EVENT:
18468 alc663_15jd_two_speaker_automute(codec);
18469 break;
18470 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018471 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018472 break;
18473 }
18474}
18475
Kailang Yangebb83ee2009-12-17 12:23:00 +010018476#define alc663_mode5_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018477
Kailang Yangf1d4e282008-08-26 14:03:29 +020018478static void alc663_mode5_inithook(struct hda_codec *codec)
18479{
18480 alc663_15jd_two_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018481 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018482}
18483/* ***************** Mode6 ******************************/
18484static void alc663_mode6_unsol_event(struct hda_codec *codec,
18485 unsigned int res)
18486{
18487 switch (res >> 26) {
18488 case ALC880_HP_EVENT:
18489 alc663_two_hp_m2_speaker_automute(codec);
18490 break;
18491 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018492 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018493 break;
18494 }
18495}
18496
Kailang Yangebb83ee2009-12-17 12:23:00 +010018497#define alc663_mode6_setup alc663_mode1_setup
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018498
Kailang Yangf1d4e282008-08-26 14:03:29 +020018499static void alc663_mode6_inithook(struct hda_codec *codec)
18500{
18501 alc663_two_hp_m2_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018502 alc_mic_automute(codec);
Kailang Yangf1d4e282008-08-26 14:03:29 +020018503}
18504
Kailang Yangebb83ee2009-12-17 12:23:00 +010018505/* ***************** Mode7 ******************************/
18506static void alc663_mode7_unsol_event(struct hda_codec *codec,
18507 unsigned int res)
18508{
18509 switch (res >> 26) {
18510 case ALC880_HP_EVENT:
18511 alc663_two_hp_m7_speaker_automute(codec);
18512 break;
18513 case ALC880_MIC_EVENT:
18514 alc_mic_automute(codec);
18515 break;
18516 }
18517}
18518
18519#define alc663_mode7_setup alc663_mode1_setup
18520
18521static void alc663_mode7_inithook(struct hda_codec *codec)
18522{
18523 alc663_two_hp_m7_speaker_automute(codec);
18524 alc_mic_automute(codec);
18525}
18526
18527/* ***************** Mode8 ******************************/
18528static void alc663_mode8_unsol_event(struct hda_codec *codec,
18529 unsigned int res)
18530{
18531 switch (res >> 26) {
18532 case ALC880_HP_EVENT:
18533 alc663_two_hp_m8_speaker_automute(codec);
18534 break;
18535 case ALC880_MIC_EVENT:
18536 alc_mic_automute(codec);
18537 break;
18538 }
18539}
18540
18541#define alc663_mode8_setup alc663_m51va_setup
18542
18543static void alc663_mode8_inithook(struct hda_codec *codec)
18544{
18545 alc663_two_hp_m8_speaker_automute(codec);
18546 alc_mic_automute(codec);
18547}
18548
Kailang Yang6dda9f42008-05-27 12:05:31 +020018549static void alc663_g71v_hp_automute(struct hda_codec *codec)
18550{
18551 unsigned int present;
18552 unsigned char bits;
18553
Wu Fengguang864f92b2009-11-18 12:38:02 +080018554 present = snd_hda_jack_detect(codec, 0x21);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018555 bits = present ? HDA_AMP_MUTE : 0;
18556 snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
18557 HDA_AMP_MUTE, bits);
18558 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18559 HDA_AMP_MUTE, bits);
18560}
18561
18562static void alc663_g71v_front_automute(struct hda_codec *codec)
18563{
18564 unsigned int present;
18565 unsigned char bits;
18566
Wu Fengguang864f92b2009-11-18 12:38:02 +080018567 present = snd_hda_jack_detect(codec, 0x15);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018568 bits = present ? HDA_AMP_MUTE : 0;
18569 snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
18570 HDA_AMP_MUTE, bits);
18571}
18572
18573static void alc663_g71v_unsol_event(struct hda_codec *codec,
18574 unsigned int res)
18575{
18576 switch (res >> 26) {
18577 case ALC880_HP_EVENT:
18578 alc663_g71v_hp_automute(codec);
18579 break;
18580 case ALC880_FRONT_EVENT:
18581 alc663_g71v_front_automute(codec);
18582 break;
18583 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018584 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018585 break;
18586 }
18587}
18588
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018589#define alc663_g71v_setup alc663_m51va_setup
18590
Kailang Yang6dda9f42008-05-27 12:05:31 +020018591static void alc663_g71v_inithook(struct hda_codec *codec)
18592{
18593 alc663_g71v_front_automute(codec);
18594 alc663_g71v_hp_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018595 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018596}
18597
18598static void alc663_g50v_unsol_event(struct hda_codec *codec,
18599 unsigned int res)
18600{
18601 switch (res >> 26) {
18602 case ALC880_HP_EVENT:
18603 alc663_m51va_speaker_automute(codec);
18604 break;
18605 case ALC880_MIC_EVENT:
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018606 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018607 break;
18608 }
18609}
18610
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018611#define alc663_g50v_setup alc663_m51va_setup
18612
Kailang Yang6dda9f42008-05-27 12:05:31 +020018613static void alc663_g50v_inithook(struct hda_codec *codec)
18614{
18615 alc663_m51va_speaker_automute(codec);
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018616 alc_mic_automute(codec);
Kailang Yang6dda9f42008-05-27 12:05:31 +020018617}
18618
Kailang Yangf1d4e282008-08-26 14:03:29 +020018619static struct snd_kcontrol_new alc662_ecs_mixer[] = {
18620 HDA_CODEC_VOLUME("Master Playback Volume", 0x02, 0x0, HDA_OUTPUT),
Takashi Iwai42171c12009-05-08 14:11:43 +020018621 ALC262_HIPPO_MASTER_SWITCH,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018622
David Henningsson5f99f862011-01-04 15:24:24 +010018623 HDA_CODEC_VOLUME("Mic/LineIn Boost Volume", 0x18, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018624 HDA_CODEC_VOLUME("Mic/LineIn Playback Volume", 0x0b, 0x0, HDA_INPUT),
18625 HDA_CODEC_MUTE("Mic/LineIn Playback Switch", 0x0b, 0x0, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018626
David Henningsson5f99f862011-01-04 15:24:24 +010018627 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
David Henningsson10528022010-12-20 14:50:59 +010018628 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18629 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
Kailang Yangf1d4e282008-08-26 14:03:29 +020018630 { } /* end */
18631};
18632
Chris Pockelé9541ba12009-05-12 08:08:53 +020018633static struct snd_kcontrol_new alc272_nc10_mixer[] = {
18634 /* Master Playback automatically created from Speaker and Headphone */
18635 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x02, 0x0, HDA_OUTPUT),
18636 HDA_CODEC_MUTE("Speaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
18637 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
18638 HDA_CODEC_MUTE("Headphone Playback Switch", 0x21, 0x0, HDA_OUTPUT),
18639
David Henningsson8607f7c2010-12-20 14:43:54 +010018640 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
18641 HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018642 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018643
David Henningsson28c4edb2010-12-20 14:24:29 +010018644 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
18645 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010018646 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x19, 0, HDA_INPUT),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018647 { } /* end */
18648};
18649
Takashi Iwaicb53c622007-08-10 17:21:45 +020018650#ifdef CONFIG_SND_HDA_POWER_SAVE
18651#define alc662_loopbacks alc880_loopbacks
18652#endif
18653
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018654
Sasha Alexandrdef319f2009-06-16 16:00:15 -040018655/* pcm configuration: identical with ALC880 */
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018656#define alc662_pcm_analog_playback alc880_pcm_analog_playback
18657#define alc662_pcm_analog_capture alc880_pcm_analog_capture
18658#define alc662_pcm_digital_playback alc880_pcm_digital_playback
18659#define alc662_pcm_digital_capture alc880_pcm_digital_capture
18660
18661/*
18662 * configuration and preset
18663 */
Takashi Iwaiea734962011-01-17 11:29:34 +010018664static const char * const alc662_models[ALC662_MODEL_LAST] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018665 [ALC662_3ST_2ch_DIG] = "3stack-dig",
18666 [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
18667 [ALC662_3ST_6ch] = "3stack-6ch",
18668 [ALC662_5ST_DIG] = "6stack-dig",
18669 [ALC662_LENOVO_101E] = "lenovo-101e",
Takashi Iwaib995d762007-10-17 10:41:06 +020018670 [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
Kailang Yang8c427222008-01-10 13:03:59 +010018671 [ALC662_ASUS_EEEPC_EP20] = "eeepc-ep20",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018672 [ALC662_ECS] = "ecs",
Kailang Yang6dda9f42008-05-27 12:05:31 +020018673 [ALC663_ASUS_M51VA] = "m51va",
18674 [ALC663_ASUS_G71V] = "g71v",
18675 [ALC663_ASUS_H13] = "h13",
18676 [ALC663_ASUS_G50V] = "g50v",
Kailang Yangf1d4e282008-08-26 14:03:29 +020018677 [ALC663_ASUS_MODE1] = "asus-mode1",
18678 [ALC662_ASUS_MODE2] = "asus-mode2",
18679 [ALC663_ASUS_MODE3] = "asus-mode3",
18680 [ALC663_ASUS_MODE4] = "asus-mode4",
18681 [ALC663_ASUS_MODE5] = "asus-mode5",
18682 [ALC663_ASUS_MODE6] = "asus-mode6",
Kailang Yangebb83ee2009-12-17 12:23:00 +010018683 [ALC663_ASUS_MODE7] = "asus-mode7",
18684 [ALC663_ASUS_MODE8] = "asus-mode8",
Takashi Iwai01f2bd42009-05-11 08:12:43 +020018685 [ALC272_DELL] = "dell",
18686 [ALC272_DELL_ZM1] = "dell-zm1",
Chris Pockelé9541ba12009-05-12 08:08:53 +020018687 [ALC272_SAMSUNG_NC10] = "samsung-nc10",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018688 [ALC662_AUTO] = "auto",
18689};
18690
18691static struct snd_pci_quirk alc662_cfg_tbl[] = {
Takashi Iwaidea0a502009-02-09 17:14:52 +010018692 SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_ECS),
Kailang Yang622e84c2009-04-21 07:39:04 +020018693 SND_PCI_QUIRK(0x1028, 0x02d6, "DELL", ALC272_DELL),
18694 SND_PCI_QUIRK(0x1028, 0x02f4, "DELL ZM1", ALC272_DELL_ZM1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018695 SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC663_ASUS_MODE1),
18696 SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC663_ASUS_MODE3),
Kailang Yangcec27c82010-02-04 14:18:18 +010018697 SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018698 SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC663_ASUS_MODE3),
18699 SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC663_ASUS_MODE1),
18700 SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_ASUS_MODE2),
18701 SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC663_ASUS_MODE1),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018702 SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC663_ASUS_MODE1),
18703 SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018704 SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018705 SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC663_ASUS_MODE7),
18706 SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC663_ASUS_MODE7),
18707 SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC663_ASUS_MODE8),
18708 SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC663_ASUS_MODE3),
18709 SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018710 SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018711 SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_ASUS_MODE2),
18712 SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018713 SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_ASUS_MODE2),
18714 SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC663_ASUS_MODE6),
18715 SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC663_ASUS_MODE6),
18716 SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yangebb83ee2009-12-17 12:23:00 +010018717 SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018718 SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC663_ASUS_MODE3),
18719 SND_PCI_QUIRK(0x1043, 0x17c3, "ASUS UX20", ALC663_ASUS_M51VA),
18720 SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_ASUS_MODE2),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018721 SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_ASUS_MODE2),
18722 SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC663_ASUS_MODE5),
18723 SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC663_ASUS_MODE6),
18724 SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018725 SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018726 SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_ASUS_MODE2),
18727 SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_ASUS_MODE2),
Kailang Yang6dda9f42008-05-27 12:05:31 +020018728 SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M51VA", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018729 /*SND_PCI_QUIRK(0x1043, 0x1878, "ASUS M50Vr", ALC663_ASUS_MODE1),*/
18730 SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC663_ASUS_MODE3),
18731 SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018732 SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC663_ASUS_MODE1),
Kailang Yangcec27c82010-02-04 14:18:18 +010018733 SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC663_ASUS_MODE1),
Kailang Yang622e84c2009-04-21 07:39:04 +020018734 SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC663_ASUS_MODE1),
18735 SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018736 SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC663_ASUS_MODE1),
18737 SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_ASUS_MODE2),
18738 SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018739 SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018740 SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC663_ASUS_MODE1),
18741 SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC663_ASUS_MODE3),
Kailang Yang622e84c2009-04-21 07:39:04 +020018742 SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC663_ASUS_MODE1),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018743 SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC663_ASUS_MODE1),
Kailang Yang80ffe862008-10-15 11:23:27 +020018744 SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS G50V", ALC663_ASUS_G50V),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018745 /*SND_PCI_QUIRK(0x1043, 0x19a3, "ASUS NB", ALC663_ASUS_MODE1),*/
18746 SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC663_ASUS_MODE1),
18747 SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_ASUS_MODE2),
Kailang Yang622e84c2009-04-21 07:39:04 +020018748 SND_PCI_QUIRK(0x1043, 0x19d3, "ASUS NB", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018749 SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC663_ASUS_MODE1),
18750 SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC663_ASUS_MODE4),
Herton Ronaldo Krzesinski3da23ca2008-03-14 12:52:59 +010018751 SND_PCI_QUIRK(0x1043, 0x8290, "ASUS P5GC-MX", ALC662_3ST_6ch_DIG),
Kailang Yang291702f2007-10-16 14:28:03 +020018752 SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
Kailang Yang8c427222008-01-10 13:03:59 +010018753 SND_PCI_QUIRK(0x1043, 0x82d1, "ASUS Eeepc EP20", ALC662_ASUS_EEEPC_EP20),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018754 SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_ECS),
Herton Ronaldo Krzesinski95fe5f22008-09-26 23:48:45 -030018755 SND_PCI_QUIRK(0x105b, 0x0d47, "Foxconn 45CMX/45GMX/45CMX-K",
18756 ALC662_3ST_6ch_DIG),
Takashi Iwai4dee8ba2010-01-13 17:20:08 +010018757 SND_PCI_QUIRK(0x1179, 0xff6e, "Toshiba NB20x", ALC662_AUTO),
Chris Pockelé9541ba12009-05-12 08:08:53 +020018758 SND_PCI_QUIRK(0x144d, 0xca00, "Samsung NC10", ALC272_SAMSUNG_NC10),
Herton Ronaldo Krzesinskicb559742008-09-26 23:47:45 -030018759 SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte 945GCM-S2L",
18760 ALC662_3ST_6ch_DIG),
Kailang Yang6227cdc2010-02-25 08:36:52 +010018761 SND_PCI_QUIRK(0x152d, 0x2304, "Quanta WH1", ALC663_ASUS_H13),
Vedran Miletic19c009a2008-09-29 20:29:25 +020018762 SND_PCI_QUIRK(0x1565, 0x820f, "Biostar TA780G M2+", ALC662_3ST_6ch_DIG),
Takashi Iwai5bd37292009-04-21 18:36:30 +020018763 SND_PCI_QUIRK(0x1631, 0xc10c, "PB RS65", ALC663_ASUS_M51VA),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018764 SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
Takashi Iwai238713d2008-10-05 10:57:39 +020018765 SND_PCI_QUIRK(0x1849, 0x3662, "ASROCK K10N78FullHD-hSLI R3.0",
Vedran Miletic19c009a2008-09-29 20:29:25 +020018766 ALC662_3ST_6ch_DIG),
Takashi Iwaidea0a502009-02-09 17:14:52 +010018767 SND_PCI_QUIRK_MASK(0x1854, 0xf000, 0x2000, "ASUS H13-200x",
18768 ALC663_ASUS_H13),
Anisse Astier965b76d2011-02-10 13:14:44 +010018769 SND_PCI_QUIRK(0x1991, 0x5628, "Ordissimo EVE", ALC662_LENOVO_101E),
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018770 {}
18771};
18772
18773static struct alc_config_preset alc662_presets[] = {
18774 [ALC662_3ST_2ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018775 .mixers = { alc662_3ST_2ch_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018776 .init_verbs = { alc662_init_verbs },
18777 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18778 .dac_nids = alc662_dac_nids,
18779 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018780 .dig_in_nid = ALC662_DIGIN_NID,
18781 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18782 .channel_mode = alc662_3ST_2ch_modes,
18783 .input_mux = &alc662_capture_source,
18784 },
18785 [ALC662_3ST_6ch_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018786 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018787 .init_verbs = { alc662_init_verbs },
18788 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18789 .dac_nids = alc662_dac_nids,
18790 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018791 .dig_in_nid = ALC662_DIGIN_NID,
18792 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18793 .channel_mode = alc662_3ST_6ch_modes,
18794 .need_dac_fix = 1,
18795 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018796 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018797 [ALC662_3ST_6ch] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018798 .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018799 .init_verbs = { alc662_init_verbs },
18800 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18801 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018802 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18803 .channel_mode = alc662_3ST_6ch_modes,
18804 .need_dac_fix = 1,
18805 .input_mux = &alc662_capture_source,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020018806 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018807 [ALC662_5ST_DIG] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018808 .mixers = { alc662_base_mixer, alc662_chmode_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018809 .init_verbs = { alc662_init_verbs },
18810 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18811 .dac_nids = alc662_dac_nids,
18812 .dig_out_nid = ALC662_DIGOUT_NID,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018813 .dig_in_nid = ALC662_DIGIN_NID,
18814 .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
18815 .channel_mode = alc662_5stack_modes,
18816 .input_mux = &alc662_capture_source,
18817 },
18818 [ALC662_LENOVO_101E] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018819 .mixers = { alc662_lenovo_101e_mixer },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018820 .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
18821 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18822 .dac_nids = alc662_dac_nids,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020018823 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18824 .channel_mode = alc662_3ST_2ch_modes,
18825 .input_mux = &alc662_lenovo_101e_capture_source,
18826 .unsol_event = alc662_lenovo_101e_unsol_event,
18827 .init_hook = alc662_lenovo_101e_all_automute,
18828 },
Kailang Yang291702f2007-10-16 14:28:03 +020018829 [ALC662_ASUS_EEEPC_P701] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018830 .mixers = { alc662_eeepc_p701_mixer },
Kailang Yang291702f2007-10-16 14:28:03 +020018831 .init_verbs = { alc662_init_verbs,
18832 alc662_eeepc_sue_init_verbs },
18833 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18834 .dac_nids = alc662_dac_nids,
Kailang Yang291702f2007-10-16 14:28:03 +020018835 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18836 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang291702f2007-10-16 14:28:03 +020018837 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018838 .setup = alc662_eeepc_setup,
Kailang Yang291702f2007-10-16 14:28:03 +020018839 .init_hook = alc662_eeepc_inithook,
18840 },
Kailang Yang8c427222008-01-10 13:03:59 +010018841 [ALC662_ASUS_EEEPC_EP20] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018842 .mixers = { alc662_eeepc_ep20_mixer,
Kailang Yang8c427222008-01-10 13:03:59 +010018843 alc662_chmode_mixer },
18844 .init_verbs = { alc662_init_verbs,
18845 alc662_eeepc_ep20_sue_init_verbs },
18846 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18847 .dac_nids = alc662_dac_nids,
Kailang Yang8c427222008-01-10 13:03:59 +010018848 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18849 .channel_mode = alc662_3ST_6ch_modes,
18850 .input_mux = &alc662_lenovo_101e_capture_source,
Takashi Iwai42171c12009-05-08 14:11:43 +020018851 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018852 .setup = alc662_eeepc_ep20_setup,
Kailang Yang8c427222008-01-10 13:03:59 +010018853 .init_hook = alc662_eeepc_ep20_inithook,
18854 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018855 [ALC662_ECS] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018856 .mixers = { alc662_ecs_mixer },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018857 .init_verbs = { alc662_init_verbs,
18858 alc662_ecs_init_verbs },
18859 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18860 .dac_nids = alc662_dac_nids,
18861 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18862 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018863 .unsol_event = alc662_eeepc_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018864 .setup = alc662_eeepc_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018865 .init_hook = alc662_eeepc_inithook,
18866 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018867 [ALC663_ASUS_M51VA] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018868 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018869 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18870 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18871 .dac_nids = alc662_dac_nids,
18872 .dig_out_nid = ALC662_DIGOUT_NID,
18873 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18874 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018875 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018876 .setup = alc663_m51va_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018877 .init_hook = alc663_m51va_inithook,
18878 },
18879 [ALC663_ASUS_G71V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018880 .mixers = { alc663_g71v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018881 .init_verbs = { alc662_init_verbs, alc663_g71v_init_verbs },
18882 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18883 .dac_nids = alc662_dac_nids,
18884 .dig_out_nid = ALC662_DIGOUT_NID,
18885 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18886 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018887 .unsol_event = alc663_g71v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018888 .setup = alc663_g71v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018889 .init_hook = alc663_g71v_inithook,
18890 },
18891 [ALC663_ASUS_H13] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018892 .mixers = { alc663_m51va_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018893 .init_verbs = { alc662_init_verbs, alc663_m51va_init_verbs },
18894 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18895 .dac_nids = alc662_dac_nids,
18896 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18897 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018898 .unsol_event = alc663_m51va_unsol_event,
18899 .init_hook = alc663_m51va_inithook,
18900 },
18901 [ALC663_ASUS_G50V] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018902 .mixers = { alc663_g50v_mixer },
Kailang Yang6dda9f42008-05-27 12:05:31 +020018903 .init_verbs = { alc662_init_verbs, alc663_g50v_init_verbs },
18904 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18905 .dac_nids = alc662_dac_nids,
18906 .dig_out_nid = ALC662_DIGOUT_NID,
18907 .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
18908 .channel_mode = alc662_3ST_6ch_modes,
18909 .input_mux = &alc663_capture_source,
18910 .unsol_event = alc663_g50v_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018911 .setup = alc663_g50v_setup,
Kailang Yang6dda9f42008-05-27 12:05:31 +020018912 .init_hook = alc663_g50v_inithook,
18913 },
Kailang Yangf1d4e282008-08-26 14:03:29 +020018914 [ALC663_ASUS_MODE1] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018915 .mixers = { alc663_m51va_mixer },
18916 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018917 .init_verbs = { alc662_init_verbs,
18918 alc663_21jd_amic_init_verbs },
18919 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18920 .hp_nid = 0x03,
18921 .dac_nids = alc662_dac_nids,
18922 .dig_out_nid = ALC662_DIGOUT_NID,
18923 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18924 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018925 .unsol_event = alc663_mode1_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018926 .setup = alc663_mode1_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018927 .init_hook = alc663_mode1_inithook,
18928 },
18929 [ALC662_ASUS_MODE2] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018930 .mixers = { alc662_1bjd_mixer },
18931 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018932 .init_verbs = { alc662_init_verbs,
18933 alc662_1bjd_amic_init_verbs },
18934 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18935 .dac_nids = alc662_dac_nids,
18936 .dig_out_nid = ALC662_DIGOUT_NID,
18937 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18938 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018939 .unsol_event = alc662_mode2_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018940 .setup = alc662_mode2_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018941 .init_hook = alc662_mode2_inithook,
18942 },
18943 [ALC663_ASUS_MODE3] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018944 .mixers = { alc663_two_hp_m1_mixer },
18945 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018946 .init_verbs = { alc662_init_verbs,
18947 alc663_two_hp_amic_m1_init_verbs },
18948 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18949 .hp_nid = 0x03,
18950 .dac_nids = alc662_dac_nids,
18951 .dig_out_nid = ALC662_DIGOUT_NID,
18952 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18953 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018954 .unsol_event = alc663_mode3_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018955 .setup = alc663_mode3_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018956 .init_hook = alc663_mode3_inithook,
18957 },
18958 [ALC663_ASUS_MODE4] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018959 .mixers = { alc663_asus_21jd_clfe_mixer },
18960 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018961 .init_verbs = { alc662_init_verbs,
18962 alc663_21jd_amic_init_verbs},
18963 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18964 .hp_nid = 0x03,
18965 .dac_nids = alc662_dac_nids,
18966 .dig_out_nid = ALC662_DIGOUT_NID,
18967 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18968 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018969 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018970 .setup = alc663_mode4_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018971 .init_hook = alc663_mode4_inithook,
18972 },
18973 [ALC663_ASUS_MODE5] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018974 .mixers = { alc663_asus_15jd_clfe_mixer },
18975 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018976 .init_verbs = { alc662_init_verbs,
18977 alc663_15jd_amic_init_verbs },
18978 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18979 .hp_nid = 0x03,
18980 .dac_nids = alc662_dac_nids,
18981 .dig_out_nid = ALC662_DIGOUT_NID,
18982 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18983 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018984 .unsol_event = alc663_mode5_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020018985 .setup = alc663_mode5_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018986 .init_hook = alc663_mode5_inithook,
18987 },
18988 [ALC663_ASUS_MODE6] = {
Takashi Iwaif9e336f2008-10-31 16:37:07 +010018989 .mixers = { alc663_two_hp_m2_mixer },
18990 .cap_mixer = alc662_auto_capture_mixer,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018991 .init_verbs = { alc662_init_verbs,
18992 alc663_two_hp_amic_m2_init_verbs },
18993 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
18994 .hp_nid = 0x03,
18995 .dac_nids = alc662_dac_nids,
18996 .dig_out_nid = ALC662_DIGOUT_NID,
18997 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
18998 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yangf1d4e282008-08-26 14:03:29 +020018999 .unsol_event = alc663_mode6_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019000 .setup = alc663_mode6_setup,
Kailang Yangf1d4e282008-08-26 14:03:29 +020019001 .init_hook = alc663_mode6_inithook,
19002 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010019003 [ALC663_ASUS_MODE7] = {
19004 .mixers = { alc663_mode7_mixer },
19005 .cap_mixer = alc662_auto_capture_mixer,
19006 .init_verbs = { alc662_init_verbs,
19007 alc663_mode7_init_verbs },
19008 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19009 .hp_nid = 0x03,
19010 .dac_nids = alc662_dac_nids,
19011 .dig_out_nid = ALC662_DIGOUT_NID,
19012 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19013 .channel_mode = alc662_3ST_2ch_modes,
19014 .unsol_event = alc663_mode7_unsol_event,
19015 .setup = alc663_mode7_setup,
19016 .init_hook = alc663_mode7_inithook,
19017 },
19018 [ALC663_ASUS_MODE8] = {
19019 .mixers = { alc663_mode8_mixer },
19020 .cap_mixer = alc662_auto_capture_mixer,
19021 .init_verbs = { alc662_init_verbs,
19022 alc663_mode8_init_verbs },
19023 .num_dacs = ARRAY_SIZE(alc662_dac_nids),
19024 .hp_nid = 0x03,
19025 .dac_nids = alc662_dac_nids,
19026 .dig_out_nid = ALC662_DIGOUT_NID,
19027 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19028 .channel_mode = alc662_3ST_2ch_modes,
19029 .unsol_event = alc663_mode8_unsol_event,
19030 .setup = alc663_mode8_setup,
19031 .init_hook = alc663_mode8_inithook,
19032 },
Kailang Yang622e84c2009-04-21 07:39:04 +020019033 [ALC272_DELL] = {
19034 .mixers = { alc663_m51va_mixer },
19035 .cap_mixer = alc272_auto_capture_mixer,
19036 .init_verbs = { alc662_init_verbs, alc272_dell_init_verbs },
19037 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19038 .dac_nids = alc662_dac_nids,
19039 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19040 .adc_nids = alc272_adc_nids,
19041 .num_adc_nids = ARRAY_SIZE(alc272_adc_nids),
19042 .capsrc_nids = alc272_capsrc_nids,
19043 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019044 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019045 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019046 .init_hook = alc663_m51va_inithook,
19047 },
19048 [ALC272_DELL_ZM1] = {
19049 .mixers = { alc663_m51va_mixer },
19050 .cap_mixer = alc662_auto_capture_mixer,
19051 .init_verbs = { alc662_init_verbs, alc272_dell_zm1_init_verbs },
19052 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19053 .dac_nids = alc662_dac_nids,
19054 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19055 .adc_nids = alc662_adc_nids,
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019056 .num_adc_nids = 1,
Kailang Yang622e84c2009-04-21 07:39:04 +020019057 .capsrc_nids = alc662_capsrc_nids,
19058 .channel_mode = alc662_3ST_2ch_modes,
Kailang Yang622e84c2009-04-21 07:39:04 +020019059 .unsol_event = alc663_m51va_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019060 .setup = alc663_m51va_setup,
Kailang Yang622e84c2009-04-21 07:39:04 +020019061 .init_hook = alc663_m51va_inithook,
19062 },
Chris Pockelé9541ba12009-05-12 08:08:53 +020019063 [ALC272_SAMSUNG_NC10] = {
19064 .mixers = { alc272_nc10_mixer },
19065 .init_verbs = { alc662_init_verbs,
19066 alc663_21jd_amic_init_verbs },
19067 .num_dacs = ARRAY_SIZE(alc272_dac_nids),
19068 .dac_nids = alc272_dac_nids,
19069 .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
19070 .channel_mode = alc662_3ST_2ch_modes,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019071 /*.input_mux = &alc272_nc10_capture_source,*/
Chris Pockelé9541ba12009-05-12 08:08:53 +020019072 .unsol_event = alc663_mode4_unsol_event,
Takashi Iwai4f5d17062009-08-11 18:17:46 +020019073 .setup = alc663_mode4_setup,
Chris Pockelé9541ba12009-05-12 08:08:53 +020019074 .init_hook = alc663_mode4_inithook,
19075 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019076};
19077
19078
19079/*
19080 * BIOS auto configuration
19081 */
19082
Takashi Iwai7085ec12009-10-02 09:03:58 +020019083/* convert from MIX nid to DAC */
19084static inline hda_nid_t alc662_mix_to_dac(hda_nid_t nid)
19085{
19086 if (nid == 0x0f)
19087 return 0x02;
19088 else if (nid >= 0x0c && nid <= 0x0e)
19089 return nid - 0x0c + 0x02;
David Henningssoncc1c4522010-11-24 14:17:47 +010019090 else if (nid == 0x26) /* ALC887-VD has this DAC too */
19091 return 0x25;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019092 else
19093 return 0;
19094}
19095
19096/* get MIX nid connected to the given pin targeted to DAC */
19097static hda_nid_t alc662_dac_to_mix(struct hda_codec *codec, hda_nid_t pin,
19098 hda_nid_t dac)
19099{
David Henningssoncc1c4522010-11-24 14:17:47 +010019100 hda_nid_t mix[5];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019101 int i, num;
19102
19103 num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix));
19104 for (i = 0; i < num; i++) {
19105 if (alc662_mix_to_dac(mix[i]) == dac)
19106 return mix[i];
19107 }
19108 return 0;
19109}
19110
19111/* look for an empty DAC slot */
19112static hda_nid_t alc662_look_for_dac(struct hda_codec *codec, hda_nid_t pin)
19113{
19114 struct alc_spec *spec = codec->spec;
19115 hda_nid_t srcs[5];
19116 int i, j, num;
19117
19118 num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs));
19119 if (num < 0)
19120 return 0;
19121 for (i = 0; i < num; i++) {
19122 hda_nid_t nid = alc662_mix_to_dac(srcs[i]);
19123 if (!nid)
19124 continue;
19125 for (j = 0; j < spec->multiout.num_dacs; j++)
19126 if (spec->multiout.dac_nids[j] == nid)
19127 break;
19128 if (j >= spec->multiout.num_dacs)
19129 return nid;
19130 }
19131 return 0;
19132}
19133
19134/* fill in the dac_nids table from the parsed pin configuration */
19135static int alc662_auto_fill_dac_nids(struct hda_codec *codec,
19136 const struct auto_pin_cfg *cfg)
19137{
19138 struct alc_spec *spec = codec->spec;
19139 int i;
19140 hda_nid_t dac;
19141
19142 spec->multiout.dac_nids = spec->private_dac_nids;
19143 for (i = 0; i < cfg->line_outs; i++) {
19144 dac = alc662_look_for_dac(codec, cfg->line_out_pins[i]);
19145 if (!dac)
19146 continue;
19147 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19148 }
19149 return 0;
19150}
19151
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019152static inline int __alc662_add_vol_ctl(struct alc_spec *spec, const char *pfx,
19153 hda_nid_t nid, int idx, unsigned int chs)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019154{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019155 return __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019156 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
19157}
19158
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019159static inline int __alc662_add_sw_ctl(struct alc_spec *spec, const char *pfx,
19160 hda_nid_t nid, int idx, unsigned int chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019161{
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019162 return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, idx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019163 HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT));
19164}
19165
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019166#define alc662_add_vol_ctl(spec, pfx, nid, chs) \
19167 __alc662_add_vol_ctl(spec, pfx, nid, 0, chs)
19168#define alc662_add_sw_ctl(spec, pfx, nid, chs) \
19169 __alc662_add_sw_ctl(spec, pfx, nid, 0, chs)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019170#define alc662_add_stereo_vol(spec, pfx, nid) \
19171 alc662_add_vol_ctl(spec, pfx, nid, 3)
19172#define alc662_add_stereo_sw(spec, pfx, nid) \
19173 alc662_add_sw_ctl(spec, pfx, nid, 3)
19174
19175/* add playback controls from the parsed DAC table */
19176static int alc662_auto_create_multi_out_ctls(struct hda_codec *codec,
19177 const struct auto_pin_cfg *cfg)
19178{
19179 struct alc_spec *spec = codec->spec;
Takashi Iwaiea734962011-01-17 11:29:34 +010019180 static const char * const chname[4] = {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019181 "Front", "Surround", NULL /*CLFE*/, "Side"
19182 };
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019183 const char *pfx = alc_get_line_out_pfx(cfg, true);
Takashi Iwai7085ec12009-10-02 09:03:58 +020019184 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019185 int i, err;
19186
19187 for (i = 0; i < cfg->line_outs; i++) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019188 nid = spec->multiout.dac_nids[i];
19189 if (!nid)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019190 continue;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019191 mix = alc662_dac_to_mix(codec, cfg->line_out_pins[i], nid);
19192 if (!mix)
19193 continue;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019194 if (!pfx && i == 2) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019195 /* Center/LFE */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019196 err = alc662_add_vol_ctl(spec, "Center", nid, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019197 if (err < 0)
19198 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019199 err = alc662_add_vol_ctl(spec, "LFE", nid, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019200 if (err < 0)
19201 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019202 err = alc662_add_sw_ctl(spec, "Center", mix, 1);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019203 if (err < 0)
19204 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019205 err = alc662_add_sw_ctl(spec, "LFE", mix, 2);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019206 if (err < 0)
19207 return err;
19208 } else {
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019209 const char *name = pfx;
19210 if (!name)
19211 name = chname[i];
19212 err = __alc662_add_vol_ctl(spec, name, nid, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019213 if (err < 0)
19214 return err;
Takashi Iwaibcb2f0f2011-01-10 15:45:23 +010019215 err = __alc662_add_sw_ctl(spec, name, mix, i, 3);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019216 if (err < 0)
19217 return err;
19218 }
19219 }
19220 return 0;
19221}
19222
19223/* add playback controls for speaker and HP outputs */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019224/* return DAC nid if any new DAC is assigned */
19225static int alc662_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin,
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019226 const char *pfx)
19227{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019228 struct alc_spec *spec = codec->spec;
19229 hda_nid_t nid, mix;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019230 int err;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019231
19232 if (!pin)
19233 return 0;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019234 nid = alc662_look_for_dac(codec, pin);
19235 if (!nid) {
Takashi Iwai7085ec12009-10-02 09:03:58 +020019236 /* the corresponding DAC is already occupied */
19237 if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP))
19238 return 0; /* no way */
19239 /* create a switch only */
Takashi Iwai0afe5f82009-10-02 09:20:00 +020019240 return add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019241 HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
19242 }
19243
19244 mix = alc662_dac_to_mix(codec, pin, nid);
19245 if (!mix)
19246 return 0;
19247 err = alc662_add_vol_ctl(spec, pfx, nid, 3);
19248 if (err < 0)
Takashi Iwai24fb9172008-09-02 14:48:20 +020019249 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019250 err = alc662_add_sw_ctl(spec, pfx, mix, 3);
19251 if (err < 0)
19252 return err;
19253 return nid;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019254}
19255
19256/* create playback/capture controls for input pins */
Takashi Iwai05f5f472009-08-25 13:10:18 +020019257#define alc662_auto_create_input_ctls \
Takashi Iwai4b7348a2009-10-14 18:25:23 +020019258 alc882_auto_create_input_ctls
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019259
19260static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
19261 hda_nid_t nid, int pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019262 hda_nid_t dac)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019263{
Takashi Iwai7085ec12009-10-02 09:03:58 +020019264 int i, num;
Takashi Iwaice503f32010-07-30 10:37:29 +020019265 hda_nid_t srcs[HDA_MAX_CONNECTIONS];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019266
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019267 alc_set_pin_output(codec, nid, pin_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019268 /* need the manual connection? */
Takashi Iwai7085ec12009-10-02 09:03:58 +020019269 num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs));
19270 if (num <= 1)
19271 return;
19272 for (i = 0; i < num; i++) {
19273 if (alc662_mix_to_dac(srcs[i]) != dac)
19274 continue;
19275 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i);
19276 return;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019277 }
19278}
19279
19280static void alc662_auto_init_multi_out(struct hda_codec *codec)
19281{
19282 struct alc_spec *spec = codec->spec;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019283 int pin_type = get_pin_type(spec->autocfg.line_out_type);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019284 int i;
19285
19286 for (i = 0; i <= HDA_SIDE; i++) {
19287 hda_nid_t nid = spec->autocfg.line_out_pins[i];
19288 if (nid)
Takashi Iwaibaba8ee2007-04-23 17:17:48 +020019289 alc662_auto_set_output_and_unmute(codec, nid, pin_type,
Takashi Iwai7085ec12009-10-02 09:03:58 +020019290 spec->multiout.dac_nids[i]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019291 }
19292}
19293
19294static void alc662_auto_init_hp_out(struct hda_codec *codec)
19295{
19296 struct alc_spec *spec = codec->spec;
19297 hda_nid_t pin;
19298
19299 pin = spec->autocfg.hp_pins[0];
Takashi Iwai7085ec12009-10-02 09:03:58 +020019300 if (pin)
19301 alc662_auto_set_output_and_unmute(codec, pin, PIN_HP,
19302 spec->multiout.hp_nid);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019303 pin = spec->autocfg.speaker_pins[0];
19304 if (pin)
Takashi Iwai7085ec12009-10-02 09:03:58 +020019305 alc662_auto_set_output_and_unmute(codec, pin, PIN_OUT,
19306 spec->multiout.extra_out_nid[0]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019307}
19308
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019309#define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
19310
19311static void alc662_auto_init_analog_input(struct hda_codec *codec)
19312{
19313 struct alc_spec *spec = codec->spec;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019314 struct auto_pin_cfg *cfg = &spec->autocfg;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019315 int i;
19316
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019317 for (i = 0; i < cfg->num_inputs; i++) {
19318 hda_nid_t nid = cfg->inputs[i].pin;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019319 if (alc_is_input_pin(codec, nid)) {
Takashi Iwai30ea0982010-09-16 18:47:56 +020019320 alc_set_input_pin(codec, nid, cfg->inputs[i].type);
Takashi Iwai52ca15b2009-03-23 12:51:55 +010019321 if (nid != ALC662_PIN_CD_NID &&
Takashi Iwaie82c0252009-03-23 15:17:38 +010019322 (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP))
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019323 snd_hda_codec_write(codec, nid, 0,
19324 AC_VERB_SET_AMP_GAIN_MUTE,
19325 AMP_OUT_MUTE);
19326 }
19327 }
19328}
19329
Takashi Iwaif511b012008-08-15 16:46:42 +020019330#define alc662_auto_init_input_src alc882_auto_init_input_src
19331
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019332static int alc662_parse_auto_config(struct hda_codec *codec)
19333{
19334 struct alc_spec *spec = codec->spec;
19335 int err;
19336 static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
19337
19338 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19339 alc662_ignore);
19340 if (err < 0)
19341 return err;
19342 if (!spec->autocfg.line_outs)
19343 return 0; /* can't find valid BIOS pin config */
19344
Takashi Iwai7085ec12009-10-02 09:03:58 +020019345 err = alc662_auto_fill_dac_nids(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019346 if (err < 0)
19347 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019348 err = alc662_auto_create_multi_out_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019349 if (err < 0)
19350 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019351 err = alc662_auto_create_extra_out(codec,
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019352 spec->autocfg.speaker_pins[0],
19353 "Speaker");
19354 if (err < 0)
19355 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019356 if (err)
19357 spec->multiout.extra_out_nid[0] = err;
19358 err = alc662_auto_create_extra_out(codec, spec->autocfg.hp_pins[0],
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019359 "Headphone");
19360 if (err < 0)
19361 return err;
Takashi Iwai7085ec12009-10-02 09:03:58 +020019362 if (err)
19363 spec->multiout.hp_nid = err;
Takashi Iwai05f5f472009-08-25 13:10:18 +020019364 err = alc662_auto_create_input_ctls(codec, &spec->autocfg);
Takashi Iwaif12ab1e2007-04-12 15:51:47 +020019365 if (err < 0)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019366 return err;
19367
19368 spec->multiout.max_channels = spec->multiout.num_dacs * 2;
19369
Takashi Iwai757899a2010-07-30 10:48:14 +020019370 alc_auto_parse_digital(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019371
Takashi Iwai603c4012008-07-30 15:01:44 +020019372 if (spec->kctls.list)
Takashi Iwaid88897e2008-10-31 15:01:37 +010019373 add_mixer(spec, spec->kctls.list);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019374
19375 spec->num_mux_defs = 1;
Herton Ronaldo Krzesinski61b9b9b2009-01-28 09:16:33 -020019376 spec->input_mux = &spec->private_imux[0];
Kailang Yangea1fb292008-08-26 12:58:38 +020019377
Kailang Yangcec27c82010-02-04 14:18:18 +010019378 add_verb(spec, alc662_init_verbs);
19379 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019380 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
Kailang Yangcec27c82010-02-04 14:18:18 +010019381 add_verb(spec, alc663_init_verbs);
19382
19383 if (codec->vendor_id == 0x10ec0272)
19384 add_verb(spec, alc272_init_verbs);
Takashi Iwaiee979a142008-09-02 15:42:20 +020019385
19386 err = alc_auto_add_mic_boost(codec);
19387 if (err < 0)
19388 return err;
19389
Kailang Yang6227cdc2010-02-25 08:36:52 +010019390 if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
19391 codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670)
19392 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0x21);
19393 else
19394 alc_ssid_check(codec, 0x15, 0x1b, 0x14, 0);
Takashi Iwai4a79ba32009-04-22 16:31:35 +020019395
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019396 return 1;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019397}
19398
19399/* additional initialization for auto-configuration model */
19400static void alc662_auto_init(struct hda_codec *codec)
19401{
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019402 struct alc_spec *spec = codec->spec;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019403 alc662_auto_init_multi_out(codec);
19404 alc662_auto_init_hp_out(codec);
19405 alc662_auto_init_analog_input(codec);
Takashi Iwaif511b012008-08-15 16:46:42 +020019406 alc662_auto_init_input_src(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019407 alc_auto_init_digital(codec);
Takashi Iwaif6c7e542008-02-12 18:32:23 +010019408 if (spec->unsol_event)
Kailang Yang7fb0d782008-10-15 11:12:35 +020019409 alc_inithook(codec);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019410}
19411
Todd Broch6be79482010-12-07 16:51:05 -080019412static void alc272_fixup_mario(struct hda_codec *codec,
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019413 const struct alc_fixup *fix, int action)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019414{
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019415 if (action != ALC_FIXUP_ACT_PROBE)
Takashi Iwai6fc398c2011-01-13 14:36:37 +010019416 return;
Todd Broch6be79482010-12-07 16:51:05 -080019417 if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
19418 (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
19419 (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
19420 (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
19421 (0 << AC_AMPCAP_MUTE_SHIFT)))
19422 printk(KERN_WARNING
19423 "hda_codec: failed to override amp caps for NID 0x2\n");
19424}
19425
David Henningsson6cb3b702010-09-09 08:51:44 +020019426enum {
Daniel T Chen2df03512010-10-10 22:39:28 -040019427 ALC662_FIXUP_ASPIRE,
David Henningsson6cb3b702010-09-09 08:51:44 +020019428 ALC662_FIXUP_IDEAPAD,
Todd Broch6be79482010-12-07 16:51:05 -080019429 ALC272_FIXUP_MARIO,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019430 ALC662_FIXUP_CZC_P10T,
David Henningsson6cb3b702010-09-09 08:51:44 +020019431};
19432
19433static const struct alc_fixup alc662_fixups[] = {
Daniel T Chen2df03512010-10-10 22:39:28 -040019434 [ALC662_FIXUP_ASPIRE] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019435 .type = ALC_FIXUP_PINS,
19436 .v.pins = (const struct alc_pincfg[]) {
Daniel T Chen2df03512010-10-10 22:39:28 -040019437 { 0x15, 0x99130112 }, /* subwoofer */
19438 { }
19439 }
19440 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019441 [ALC662_FIXUP_IDEAPAD] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019442 .type = ALC_FIXUP_PINS,
19443 .v.pins = (const struct alc_pincfg[]) {
David Henningsson6cb3b702010-09-09 08:51:44 +020019444 { 0x17, 0x99130112 }, /* subwoofer */
19445 { }
19446 }
19447 },
Todd Broch6be79482010-12-07 16:51:05 -080019448 [ALC272_FIXUP_MARIO] = {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019449 .type = ALC_FIXUP_FUNC,
19450 .v.func = alc272_fixup_mario,
Anisse Astierd2ebd472011-01-20 12:36:21 +010019451 },
19452 [ALC662_FIXUP_CZC_P10T] = {
19453 .type = ALC_FIXUP_VERBS,
19454 .v.verbs = (const struct hda_verb[]) {
19455 {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
19456 {}
19457 }
19458 },
David Henningsson6cb3b702010-09-09 08:51:44 +020019459};
19460
19461static struct snd_pci_quirk alc662_fixup_tbl[] = {
David Henningssona6c47a82011-02-10 15:39:19 +010019462 SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
Daniel T Chen2df03512010-10-10 22:39:28 -040019463 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
Daniel T Chena0e90ac2010-11-20 10:20:35 -050019464 SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
Valentine Sinitsynd4118582010-10-01 22:24:08 +060019465 SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
David Henningsson6cb3b702010-09-09 08:51:44 +020019466 SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
Anisse Astierd2ebd472011-01-20 12:36:21 +010019467 SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
David Henningsson6cb3b702010-09-09 08:51:44 +020019468 {}
19469};
19470
Todd Broch6be79482010-12-07 16:51:05 -080019471static const struct alc_model_fixup alc662_fixup_models[] = {
19472 {.id = ALC272_FIXUP_MARIO, .name = "mario"},
19473 {}
19474};
David Henningsson6cb3b702010-09-09 08:51:44 +020019475
19476
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019477static int patch_alc662(struct hda_codec *codec)
19478{
19479 struct alc_spec *spec;
19480 int err, board_config;
Kailang Yang693194f2010-10-21 08:51:48 +020019481 int coef;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019482
19483 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19484 if (!spec)
19485 return -ENOMEM;
19486
19487 codec->spec = spec;
19488
Kailang Yangda00c242010-03-19 11:23:45 +010019489 alc_auto_parse_customize_define(codec);
19490
Takashi Iwai2c3bf9a2008-06-04 12:39:38 +020019491 alc_fix_pll_init(codec, 0x20, 0x04, 15);
19492
Kailang Yang693194f2010-10-21 08:51:48 +020019493 coef = alc_read_coef_idx(codec, 0);
19494 if (coef == 0x8020 || coef == 0x8011)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019495 alc_codec_rename(codec, "ALC661");
Kailang Yang693194f2010-10-21 08:51:48 +020019496 else if (coef & (1 << 14) &&
19497 codec->bus->pci->subsystem_vendor == 0x1025 &&
19498 spec->cdefine.platform_type == 1)
Kailang Yangc027ddc2010-03-19 11:33:06 +010019499 alc_codec_rename(codec, "ALC272X");
Kailang Yang693194f2010-10-21 08:51:48 +020019500 else if (coef == 0x4011)
19501 alc_codec_rename(codec, "ALC656");
Kailang Yang274693f2009-12-03 10:07:50 +010019502
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019503 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
19504 alc662_models,
19505 alc662_cfg_tbl);
19506 if (board_config < 0) {
Takashi Iwai9a11f1a2009-07-28 16:01:20 +020019507 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
19508 codec->chip_name);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019509 board_config = ALC662_AUTO;
19510 }
19511
19512 if (board_config == ALC662_AUTO) {
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019513 alc_pick_fixup(codec, alc662_fixup_models,
19514 alc662_fixup_tbl, alc662_fixups);
19515 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019516 /* automatic parse from the BIOS config */
19517 err = alc662_parse_auto_config(codec);
19518 if (err < 0) {
19519 alc_free(codec);
19520 return err;
Takashi Iwai8c87286f2007-06-19 12:11:16 +020019521 } else if (!err) {
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019522 printk(KERN_INFO
19523 "hda_codec: Cannot set up configuration "
19524 "from BIOS. Using base mode...\n");
19525 board_config = ALC662_3ST_2ch_DIG;
19526 }
19527 }
19528
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019529 if (has_cdefine_beep(codec)) {
Takashi Iwai8af25912010-07-28 17:37:16 +020019530 err = snd_hda_attach_beep_device(codec, 0x1);
19531 if (err < 0) {
19532 alc_free(codec);
19533 return err;
19534 }
Kusanagi Kouichi680cd532009-02-05 00:00:58 +090019535 }
19536
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019537 if (board_config != ALC662_AUTO)
Takashi Iwaie9c364c2009-08-11 17:16:13 +020019538 setup_preset(codec, &alc662_presets[board_config]);
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019539
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019540 spec->stream_analog_playback = &alc662_pcm_analog_playback;
19541 spec->stream_analog_capture = &alc662_pcm_analog_capture;
19542
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019543 spec->stream_digital_playback = &alc662_pcm_digital_playback;
19544 spec->stream_digital_capture = &alc662_pcm_digital_capture;
19545
Takashi Iwaidd704692009-08-11 08:45:11 +020019546 if (!spec->adc_nids) {
19547 spec->adc_nids = alc662_adc_nids;
19548 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
19549 }
19550 if (!spec->capsrc_nids)
19551 spec->capsrc_nids = alc662_capsrc_nids;
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019552
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019553 if (!spec->cap_mixer)
Takashi Iwaib59bdf32009-08-11 09:47:30 +020019554 set_capture_mixer(codec);
Takashi Iwaif9e336f2008-10-31 16:37:07 +010019555
Takashi Iwaidc1eae22010-07-29 15:30:02 +020019556 if (has_cdefine_beep(codec)) {
Kailang Yangda00c242010-03-19 11:23:45 +010019557 switch (codec->vendor_id) {
19558 case 0x10ec0662:
19559 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
19560 break;
19561 case 0x10ec0272:
19562 case 0x10ec0663:
19563 case 0x10ec0665:
19564 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
19565 break;
19566 case 0x10ec0273:
19567 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
19568 break;
19569 }
Kailang Yangcec27c82010-02-04 14:18:18 +010019570 }
Takashi Iwai2134ea42008-01-10 16:53:55 +010019571 spec->vmaster_nid = 0x02;
19572
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019573 alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE);
19574
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019575 codec->patch_ops = alc_patch_ops;
Takashi Iwaib5bfbc62011-01-13 14:22:32 +010019576 if (board_config == ALC662_AUTO)
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019577 spec->init_hook = alc662_auto_init;
David Henningsson6cb3b702010-09-09 08:51:44 +020019578
Kailang Yangbf1b0222010-10-21 08:49:56 +020019579 alc_init_jacks(codec);
19580
Takashi Iwaicb53c622007-08-10 17:21:45 +020019581#ifdef CONFIG_SND_HDA_POWER_SAVE
19582 if (!spec->loopback.amplist)
19583 spec->loopback.amplist = alc662_loopbacks;
19584#endif
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019585
19586 return 0;
19587}
19588
Kailang Yang274693f2009-12-03 10:07:50 +010019589static int patch_alc888(struct hda_codec *codec)
19590{
19591 if ((alc_read_coef_idx(codec, 0) & 0x00f0)==0x0030){
19592 kfree(codec->chip_name);
Kailang Yang01e0f132010-11-22 10:59:36 +010019593 if (codec->vendor_id == 0x10ec0887)
19594 codec->chip_name = kstrdup("ALC887-VD", GFP_KERNEL);
19595 else
19596 codec->chip_name = kstrdup("ALC888-VD", GFP_KERNEL);
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019597 if (!codec->chip_name) {
19598 alc_free(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019599 return -ENOMEM;
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019600 }
19601 return patch_alc662(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019602 }
Takashi Iwaiac2c92e2009-12-03 10:14:10 +010019603 return patch_alc882(codec);
Kailang Yang274693f2009-12-03 10:07:50 +010019604}
19605
Kailang Yangbc9f98a2007-04-12 13:06:07 +020019606/*
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019607 * ALC680 support
19608 */
Kailang Yangc69aefa2010-08-17 10:39:22 +020019609#define ALC680_DIGIN_NID ALC880_DIGIN_NID
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019610#define ALC680_DIGOUT_NID ALC880_DIGOUT_NID
19611#define alc680_modes alc260_modes
19612
19613static hda_nid_t alc680_dac_nids[3] = {
19614 /* Lout1, Lout2, hp */
19615 0x02, 0x03, 0x04
19616};
19617
19618static hda_nid_t alc680_adc_nids[3] = {
19619 /* ADC0-2 */
19620 /* DMIC, MIC, Line-in*/
19621 0x07, 0x08, 0x09
19622};
19623
Kailang Yangc69aefa2010-08-17 10:39:22 +020019624/*
19625 * Analog capture ADC cgange
19626 */
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019627static void alc680_rec_autoswitch(struct hda_codec *codec)
19628{
19629 struct alc_spec *spec = codec->spec;
19630 struct auto_pin_cfg *cfg = &spec->autocfg;
19631 int pin_found = 0;
19632 int type_found = AUTO_PIN_LAST;
19633 hda_nid_t nid;
19634 int i;
19635
19636 for (i = 0; i < cfg->num_inputs; i++) {
19637 nid = cfg->inputs[i].pin;
19638 if (!(snd_hda_query_pin_caps(codec, nid) &
19639 AC_PINCAP_PRES_DETECT))
19640 continue;
19641 if (snd_hda_jack_detect(codec, nid)) {
19642 if (cfg->inputs[i].type < type_found) {
19643 type_found = cfg->inputs[i].type;
19644 pin_found = nid;
19645 }
19646 }
19647 }
19648
19649 nid = 0x07;
19650 if (pin_found)
19651 snd_hda_get_connections(codec, pin_found, &nid, 1);
19652
19653 if (nid != spec->cur_adc)
19654 __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1);
19655 spec->cur_adc = nid;
19656 snd_hda_codec_setup_stream(codec, nid, spec->cur_adc_stream_tag, 0,
19657 spec->cur_adc_format);
19658}
19659
Kailang Yangc69aefa2010-08-17 10:39:22 +020019660static int alc680_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
19661 struct hda_codec *codec,
19662 unsigned int stream_tag,
19663 unsigned int format,
19664 struct snd_pcm_substream *substream)
19665{
19666 struct alc_spec *spec = codec->spec;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019667
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019668 spec->cur_adc = 0x07;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019669 spec->cur_adc_stream_tag = stream_tag;
19670 spec->cur_adc_format = format;
19671
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019672 alc680_rec_autoswitch(codec);
Kailang Yangc69aefa2010-08-17 10:39:22 +020019673 return 0;
19674}
19675
19676static int alc680_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
19677 struct hda_codec *codec,
19678 struct snd_pcm_substream *substream)
19679{
19680 snd_hda_codec_cleanup_stream(codec, 0x07);
19681 snd_hda_codec_cleanup_stream(codec, 0x08);
19682 snd_hda_codec_cleanup_stream(codec, 0x09);
19683 return 0;
19684}
19685
19686static struct hda_pcm_stream alc680_pcm_analog_auto_capture = {
19687 .substreams = 1, /* can be overridden */
19688 .channels_min = 2,
19689 .channels_max = 2,
19690 /* NID is set in alc_build_pcms */
19691 .ops = {
19692 .prepare = alc680_capture_pcm_prepare,
19693 .cleanup = alc680_capture_pcm_cleanup
19694 },
19695};
19696
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019697static struct snd_kcontrol_new alc680_base_mixer[] = {
19698 /* output mixer control */
19699 HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
19700 HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
19701 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x4, 0x0, HDA_OUTPUT),
19702 HDA_CODEC_MUTE("Headphone Playback Switch", 0x16, 0x0, HDA_OUTPUT),
David Henningsson5f99f862011-01-04 15:24:24 +010019703 HDA_CODEC_VOLUME("Internal Mic Boost Volume", 0x12, 0, HDA_INPUT),
19704 HDA_CODEC_VOLUME("Mic Boost Volume", 0x18, 0, HDA_INPUT),
19705 HDA_CODEC_VOLUME("Line In Boost Volume", 0x19, 0, HDA_INPUT),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019706 { }
19707};
19708
Kailang Yangc69aefa2010-08-17 10:39:22 +020019709static struct hda_bind_ctls alc680_bind_cap_vol = {
19710 .ops = &snd_hda_bind_vol,
19711 .values = {
19712 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19713 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19714 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19715 0
19716 },
19717};
19718
19719static struct hda_bind_ctls alc680_bind_cap_switch = {
19720 .ops = &snd_hda_bind_sw,
19721 .values = {
19722 HDA_COMPOSE_AMP_VAL(0x07, 3, 0, HDA_INPUT),
19723 HDA_COMPOSE_AMP_VAL(0x08, 3, 0, HDA_INPUT),
19724 HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
19725 0
19726 },
19727};
19728
19729static struct snd_kcontrol_new alc680_master_capture_mixer[] = {
19730 HDA_BIND_VOL("Capture Volume", &alc680_bind_cap_vol),
19731 HDA_BIND_SW("Capture Switch", &alc680_bind_cap_switch),
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019732 { } /* end */
19733};
19734
19735/*
19736 * generic initialization of ADC, input mixers and output mixers
19737 */
19738static struct hda_verb alc680_init_verbs[] = {
Kailang Yangc69aefa2010-08-17 10:39:22 +020019739 {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19740 {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
19741 {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019742
Kailang Yangc69aefa2010-08-17 10:39:22 +020019743 {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
19744 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19745 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
19746 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
19747 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
19748 {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019749
19750 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19751 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19752 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19753 {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
19754 {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019755
19756 {0x16, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
19757 {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019758 {0x19, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_MIC_EVENT | AC_USRSP_EN},
Kailang Yangc69aefa2010-08-17 10:39:22 +020019759
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019760 { }
19761};
19762
Kailang Yangc69aefa2010-08-17 10:39:22 +020019763/* toggle speaker-output according to the hp-jack state */
19764static void alc680_base_setup(struct hda_codec *codec)
19765{
19766 struct alc_spec *spec = codec->spec;
19767
19768 spec->autocfg.hp_pins[0] = 0x16;
19769 spec->autocfg.speaker_pins[0] = 0x14;
19770 spec->autocfg.speaker_pins[1] = 0x15;
Takashi Iwai66ceeb62010-08-30 13:05:52 +020019771 spec->autocfg.num_inputs = 2;
19772 spec->autocfg.inputs[0].pin = 0x18;
19773 spec->autocfg.inputs[0].type = AUTO_PIN_MIC;
19774 spec->autocfg.inputs[1].pin = 0x19;
Takashi Iwai86e29592010-09-09 14:50:17 +020019775 spec->autocfg.inputs[1].type = AUTO_PIN_LINE_IN;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019776}
19777
19778static void alc680_unsol_event(struct hda_codec *codec,
19779 unsigned int res)
19780{
19781 if ((res >> 26) == ALC880_HP_EVENT)
19782 alc_automute_amp(codec);
19783 if ((res >> 26) == ALC880_MIC_EVENT)
19784 alc680_rec_autoswitch(codec);
19785}
19786
19787static void alc680_inithook(struct hda_codec *codec)
19788{
19789 alc_automute_amp(codec);
19790 alc680_rec_autoswitch(codec);
19791}
19792
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019793/* create input playback/capture controls for the given pin */
19794static int alc680_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
19795 const char *ctlname, int idx)
19796{
19797 hda_nid_t dac;
19798 int err;
19799
19800 switch (nid) {
19801 case 0x14:
19802 dac = 0x02;
19803 break;
19804 case 0x15:
19805 dac = 0x03;
19806 break;
19807 case 0x16:
19808 dac = 0x04;
19809 break;
19810 default:
19811 return 0;
19812 }
19813 if (spec->multiout.dac_nids[0] != dac &&
19814 spec->multiout.dac_nids[1] != dac) {
19815 err = add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname,
19816 HDA_COMPOSE_AMP_VAL(dac, 3, idx,
19817 HDA_OUTPUT));
19818 if (err < 0)
19819 return err;
19820
19821 err = add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname,
19822 HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
19823
19824 if (err < 0)
19825 return err;
19826 spec->multiout.dac_nids[spec->multiout.num_dacs++] = dac;
19827 }
19828
19829 return 0;
19830}
19831
19832/* add playback controls from the parsed DAC table */
19833static int alc680_auto_create_multi_out_ctls(struct alc_spec *spec,
19834 const struct auto_pin_cfg *cfg)
19835{
19836 hda_nid_t nid;
19837 int err;
19838
19839 spec->multiout.dac_nids = spec->private_dac_nids;
19840
19841 nid = cfg->line_out_pins[0];
19842 if (nid) {
19843 const char *name;
19844 if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT)
19845 name = "Speaker";
19846 else
19847 name = "Front";
19848 err = alc680_new_analog_output(spec, nid, name, 0);
19849 if (err < 0)
19850 return err;
19851 }
19852
19853 nid = cfg->speaker_pins[0];
19854 if (nid) {
19855 err = alc680_new_analog_output(spec, nid, "Speaker", 0);
19856 if (err < 0)
19857 return err;
19858 }
19859 nid = cfg->hp_pins[0];
19860 if (nid) {
19861 err = alc680_new_analog_output(spec, nid, "Headphone", 0);
19862 if (err < 0)
19863 return err;
19864 }
19865
19866 return 0;
19867}
19868
19869static void alc680_auto_set_output_and_unmute(struct hda_codec *codec,
19870 hda_nid_t nid, int pin_type)
19871{
19872 alc_set_pin_output(codec, nid, pin_type);
19873}
19874
19875static void alc680_auto_init_multi_out(struct hda_codec *codec)
19876{
19877 struct alc_spec *spec = codec->spec;
19878 hda_nid_t nid = spec->autocfg.line_out_pins[0];
19879 if (nid) {
19880 int pin_type = get_pin_type(spec->autocfg.line_out_type);
19881 alc680_auto_set_output_and_unmute(codec, nid, pin_type);
19882 }
19883}
19884
19885static void alc680_auto_init_hp_out(struct hda_codec *codec)
19886{
19887 struct alc_spec *spec = codec->spec;
19888 hda_nid_t pin;
19889
19890 pin = spec->autocfg.hp_pins[0];
19891 if (pin)
19892 alc680_auto_set_output_and_unmute(codec, pin, PIN_HP);
19893 pin = spec->autocfg.speaker_pins[0];
19894 if (pin)
19895 alc680_auto_set_output_and_unmute(codec, pin, PIN_OUT);
19896}
19897
19898/* pcm configuration: identical with ALC880 */
19899#define alc680_pcm_analog_playback alc880_pcm_analog_playback
19900#define alc680_pcm_analog_capture alc880_pcm_analog_capture
19901#define alc680_pcm_analog_alt_capture alc880_pcm_analog_alt_capture
19902#define alc680_pcm_digital_playback alc880_pcm_digital_playback
Kailang Yangc69aefa2010-08-17 10:39:22 +020019903#define alc680_pcm_digital_capture alc880_pcm_digital_capture
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019904
19905/*
19906 * BIOS auto configuration
19907 */
19908static int alc680_parse_auto_config(struct hda_codec *codec)
19909{
19910 struct alc_spec *spec = codec->spec;
19911 int err;
19912 static hda_nid_t alc680_ignore[] = { 0 };
19913
19914 err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
19915 alc680_ignore);
19916 if (err < 0)
19917 return err;
Kailang Yangc69aefa2010-08-17 10:39:22 +020019918
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019919 if (!spec->autocfg.line_outs) {
19920 if (spec->autocfg.dig_outs || spec->autocfg.dig_in_pin) {
19921 spec->multiout.max_channels = 2;
19922 spec->no_analog = 1;
19923 goto dig_only;
19924 }
19925 return 0; /* can't find valid BIOS pin config */
19926 }
19927 err = alc680_auto_create_multi_out_ctls(spec, &spec->autocfg);
19928 if (err < 0)
19929 return err;
19930
19931 spec->multiout.max_channels = 2;
19932
19933 dig_only:
19934 /* digital only support output */
Takashi Iwai757899a2010-07-30 10:48:14 +020019935 alc_auto_parse_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019936 if (spec->kctls.list)
19937 add_mixer(spec, spec->kctls.list);
19938
19939 add_verb(spec, alc680_init_verbs);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019940
19941 err = alc_auto_add_mic_boost(codec);
19942 if (err < 0)
19943 return err;
19944
19945 return 1;
19946}
19947
19948#define alc680_auto_init_analog_input alc882_auto_init_analog_input
19949
19950/* init callback for auto-configuration model -- overriding the default init */
19951static void alc680_auto_init(struct hda_codec *codec)
19952{
19953 struct alc_spec *spec = codec->spec;
19954 alc680_auto_init_multi_out(codec);
19955 alc680_auto_init_hp_out(codec);
19956 alc680_auto_init_analog_input(codec);
Takashi Iwai757899a2010-07-30 10:48:14 +020019957 alc_auto_init_digital(codec);
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019958 if (spec->unsol_event)
19959 alc_inithook(codec);
19960}
19961
19962/*
19963 * configuration and preset
19964 */
Takashi Iwaiea734962011-01-17 11:29:34 +010019965static const char * const alc680_models[ALC680_MODEL_LAST] = {
Takashi Iwaid4a86d82010-06-23 17:51:26 +020019966 [ALC680_BASE] = "base",
19967 [ALC680_AUTO] = "auto",
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019968};
19969
19970static struct snd_pci_quirk alc680_cfg_tbl[] = {
19971 SND_PCI_QUIRK(0x1043, 0x12f3, "ASUS NX90", ALC680_BASE),
19972 {}
19973};
19974
19975static struct alc_config_preset alc680_presets[] = {
19976 [ALC680_BASE] = {
19977 .mixers = { alc680_base_mixer },
Kailang Yangc69aefa2010-08-17 10:39:22 +020019978 .cap_mixer = alc680_master_capture_mixer,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019979 .init_verbs = { alc680_init_verbs },
19980 .num_dacs = ARRAY_SIZE(alc680_dac_nids),
19981 .dac_nids = alc680_dac_nids,
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019982 .dig_out_nid = ALC680_DIGOUT_NID,
19983 .num_channel_mode = ARRAY_SIZE(alc680_modes),
19984 .channel_mode = alc680_modes,
Kailang Yangc69aefa2010-08-17 10:39:22 +020019985 .unsol_event = alc680_unsol_event,
19986 .setup = alc680_base_setup,
19987 .init_hook = alc680_inithook,
19988
Kailang Yangd1eb57f2010-06-23 16:25:26 +020019989 },
19990};
19991
19992static int patch_alc680(struct hda_codec *codec)
19993{
19994 struct alc_spec *spec;
19995 int board_config;
19996 int err;
19997
19998 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
19999 if (spec == NULL)
20000 return -ENOMEM;
20001
20002 codec->spec = spec;
20003
20004 board_config = snd_hda_check_board_config(codec, ALC680_MODEL_LAST,
20005 alc680_models,
20006 alc680_cfg_tbl);
20007
20008 if (board_config < 0 || board_config >= ALC680_MODEL_LAST) {
20009 printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
20010 codec->chip_name);
20011 board_config = ALC680_AUTO;
20012 }
20013
20014 if (board_config == ALC680_AUTO) {
20015 /* automatic parse from the BIOS config */
20016 err = alc680_parse_auto_config(codec);
20017 if (err < 0) {
20018 alc_free(codec);
20019 return err;
20020 } else if (!err) {
20021 printk(KERN_INFO
20022 "hda_codec: Cannot set up configuration "
20023 "from BIOS. Using base mode...\n");
20024 board_config = ALC680_BASE;
20025 }
20026 }
20027
20028 if (board_config != ALC680_AUTO)
20029 setup_preset(codec, &alc680_presets[board_config]);
20030
20031 spec->stream_analog_playback = &alc680_pcm_analog_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020032 spec->stream_analog_capture = &alc680_pcm_analog_auto_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020033 spec->stream_digital_playback = &alc680_pcm_digital_playback;
Kailang Yangc69aefa2010-08-17 10:39:22 +020020034 spec->stream_digital_capture = &alc680_pcm_digital_capture;
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020035
20036 if (!spec->adc_nids) {
20037 spec->adc_nids = alc680_adc_nids;
20038 spec->num_adc_nids = ARRAY_SIZE(alc680_adc_nids);
20039 }
20040
20041 if (!spec->cap_mixer)
20042 set_capture_mixer(codec);
20043
20044 spec->vmaster_nid = 0x02;
20045
20046 codec->patch_ops = alc_patch_ops;
20047 if (board_config == ALC680_AUTO)
20048 spec->init_hook = alc680_auto_init;
20049
20050 return 0;
20051}
20052
20053/*
Linus Torvalds1da177e2005-04-16 15:20:36 -070020054 * patch entries
20055 */
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020056static struct hda_codec_preset snd_hda_preset_realtek[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070020057 { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020058 { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020059 { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
Kailang Yanga361d842007-06-05 12:30:55 +020020060 { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
Kailang Yangf6a92242007-12-13 16:52:54 +010020061 { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020062 { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
Kailang Yang01afd412008-10-15 11:22:09 +020020063 { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
Kailang Yangebb83ee2009-12-17 12:23:00 +010020064 { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020065 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020066 .patch = patch_alc861 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020067 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
20068 { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
20069 { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020070 { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020071 .patch = patch_alc882 },
Kailang Yangbc9f98a2007-04-12 13:06:07 +020020072 { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
20073 .patch = patch_alc662 },
Kailang Yang6dda9f42008-05-27 12:05:31 +020020074 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
Kailang Yangcec27c82010-02-04 14:18:18 +010020075 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
Kailang Yang6227cdc2010-02-25 08:36:52 +010020076 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
Kailang Yangd1eb57f2010-06-23 16:25:26 +020020077 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
Jakub Schmidtkef32610e2007-02-02 18:17:27 +010020078 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020079 { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020080 { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
Clive Messer669faba2008-09-30 15:49:13 +020020081 { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020082 .patch = patch_alc882 },
Takashi Iwaicb308f92008-04-16 14:13:29 +020020083 { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020084 .patch = patch_alc882 },
Kailang Yangdf694da2005-12-05 19:42:22 +010020085 { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
Kailang Yang01e0f132010-11-22 10:59:36 +010020086 { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc888 },
Kailang Yang44426082008-10-15 11:18:05 +020020087 { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
Takashi Iwai4953550a2009-06-30 15:28:30 +020020088 .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020089 { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc888 },
Takashi Iwai4953550a2009-06-30 15:28:30 +020020090 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
Kailang Yang274693f2009-12-03 10:07:50 +010020091 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070020092 {} /* terminator */
20093};
Takashi Iwai1289e9e2008-11-27 15:47:11 +010020094
20095MODULE_ALIAS("snd-hda-codec-id:10ec*");
20096
20097MODULE_LICENSE("GPL");
20098MODULE_DESCRIPTION("Realtek HD-audio codec");
20099
20100static struct hda_codec_preset_list realtek_list = {
20101 .preset = snd_hda_preset_realtek,
20102 .owner = THIS_MODULE,
20103};
20104
20105static int __init patch_realtek_init(void)
20106{
20107 return snd_hda_add_codec_preset(&realtek_list);
20108}
20109
20110static void __exit patch_realtek_exit(void)
20111{
20112 snd_hda_delete_codec_preset(&realtek_list);
20113}
20114
20115module_init(patch_realtek_init)
20116module_exit(patch_realtek_exit)